Skip to content

Commit

Permalink
Test case for LLD stack dump issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanAlbert committed Jun 19, 2020
0 parents commit 2bcc2e2
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/bin/
/build-bfd/
/build-lld/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Failing LLD crash dump test case

Test case for https://github.com/android/ndk/issues/1196
9 changes: 9 additions & 0 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.10)

project(application)
if(ANDROID_LD STREQUAL lld)
set(SUFFIX -lld)
else()
set(SUFFIX "")
endif()
add_executable("application${SUFFIX}" application.cpp)
6 changes: 6 additions & 0 deletions application/application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <cstdlib>

int main(void)
{
abort();
}
81 changes: 81 additions & 0 deletions build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

set -e

HERE=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

ANDROID_ABI=arm64-v8a
ANDROID_NATIVE_API_LEVEL=29

if [ -z "$ANDROID_NDK" ]; then
>&2 echo "Must set ANDROID_NDK"
exit 1
fi

function compile()
{
printf '\nConfigure & Compile test applications ...\n\n'

rm -rf $HERE/build-bfd
mkdir "$HERE/build-bfd"

cd "$HERE/build-bfd"

cmake \
-G Ninja \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ANDROID_ABI \
-DANDROID_PLATFORM=android-$ANDROID_NATIVE_API_LEVEL \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$HERE/bin \
-DANDROID_LD=deprecated \
"$HERE/application"

cmake --build . -- -j1 -v

rm -rf $HERE/build-lld
mkdir "$HERE/build-lld"

cd "$HERE/build-lld"

cmake \
-G Ninja \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ANDROID_ABI \
-DANDROID_PLATFORM=android-$ANDROID_NATIVE_API_LEVEL \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$HERE/bin \
-DANDROID_LD=lld \
"$HERE/application"

cmake --build . -- -j1 -v

printf '\nConfigure & Compile test applications DONE\n\n'
}

function run()
{
printf '\nRun with & without LLD\n'

adb logcat -c

adb push $HERE/bin/application /data/local/tmp/
adb push $HERE/bin/application-lld /data/local/tmp/

set +e

adb shell /data/local/tmp/application
adb shell /data/local/tmp/application-lld

set -e
}

function crash_dump()
{
printf '\nCrash dumps:\n\n'
adb logcat -d | $ANDROID_NDK/ndk-stack -sym $HERE/bin
}

compile
run
crash_dump

0 comments on commit 2bcc2e2

Please sign in to comment.