I have seemingly successfully built the cross-compiled android version of DynamoRIO on a VM that is running Ubuntu. Additionally, I am doing my testing on a Nexus 6 which has ARM cores. I began by following the installation and build steps outlined in the repo (https://github.com/DynamoRIO/dynamorio/wiki/How-To-Build and https://github.com/DynamoRIO/dynamorio/wiki/Test-Suite), specifically:
$ git clone https://github.com/DynamoRIO/dynamorio.git
$ mkdir build_android
$ cd build_android
$ cmake -DCMAKE_TOOLCHAIN_FILE=../dynamorio/make/toolchain-android.cmake -DANDROID_TOOLCHAIN=/mytooldir/android-ndk-21 -DBUILD_TESTS=ON -DDR_COPY_TO_DEVICE=ON ../dynamorio
make -j6
make test
My understanding is that the “make test” command is meant to build and run a series of provided example tests with the help of adb shell and drrun (the DynamoRIO run executable). All but the first of theses tests fail. I then created a “hello world” ARM binary (hello) and successfully ran it using adb shell as a sanity test which worked.
My next step was to adb shell into the phone and work interactively from there. I tried running the phone-local drrun executable. It seemed to run and correctly accept arguments; however, when I run something like drrun -- ls or drrun -- hello a segmentation fault results. The main questions I have right now are:
1. How can run a provided instrumentation tool (for example the inscount tool for instruction counting) on my hello binary?
2. How can I write my own instrumentation tool to inject assembly instructions of my choosing.
Thanks for any help!
My understanding is that the “make test” command is meant to build and run a series of provided example tests with the help of adb shell and drrun (the DynamoRIO run executable). All but the first of theses tests fail.
My next step was to adb shell into the phone and work interactively from there. I tried running the phone-local drrun executable. It seemed to run and correctly accept arguments; however, when I run something like drrun -- ls or drrun -- hello a segmentation fault results.
1. How can run a provided instrumentation tool (for example the inscount tool for instruction counting) on my hello binary?
2. How can I write my own instrumentation tool to inject assembly instructions of my choosing.
--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To post to this group, send email to dynamor...@googlegroups.com.
Visit this group at https://groups.google.com/group/dynamorio-users.
For more options, visit https://groups.google.com/d/optout.
On Tue, Apr 19, 2016 at 12:48 AM, Caroline Trippel <carolin...@gmail.com> wrote:My understanding is that the “make test” command is meant to build and run a series of provided example tests with the help of adb shell and drrun (the DynamoRIO run executable). All but the first of theses tests fail.
We expect the tests to pass, and they do pass on our devices. However, we are not able to test every version of Android on every device, and need the community's help to diagnose issues that are hit in other environments. See below for debugging information.My next step was to adb shell into the phone and work interactively from there. I tried running the phone-local drrun executable. It seemed to run and correctly accept arguments; however, when I run something like drrun -- ls or drrun -- hello a segmentation fault results.
We expect this to work. Please debug following https://github.com/DynamoRIO/dynamorio/wiki/Debugging: using debug build, run under gdb (for Android, use the gdb server) and load the symbols to see where the fault is. If the fault is in the code cache, use -loglevel 4 to see the mangled version of the block that faulted. Sharing the fault callstack and the last block here may enable us to diagnose the issue remotely.
Thanks for the help. When I run in debug mode, I am seeing the following:ctrippel@ctrippel-VirtualBox:/usr/local/tools/build_android$ adb shell /data/local/tmp/build_android/bin32/drrun -debug -- /data/local/tmp/hello<Application /data/local/tmp/build_android/lib32/debug/libdynamorio.so (5744). Internal Error: DynamoRIO debug check failure: failed to find envp @/usr/local/tools/dynamorio/core/unix/os.c:720 envp != NULL(Error occurred @-1 frags)version 6.1.16905, custom build0xb6cf9808 0x000000000xb6ce7144 0x68636769>
Elf file type is DYN (Shared object file)
Entry point 0xd285c
There are 7 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00000034 0x00000034 0x000e0 0x000e0 R 0x4
INTERP 0x000114 0x00000114 0x00000114 0x00013 0x00013 R 0x1
[Requesting program interpreter: /system/bin/linker]
LOAD 0x000000 0x00000000 0x00000000 0xfb700 0xfb700 R E 0x1000
LOAD 0x0fc52c 0x000fd52c 0x000fd52c 0x51b04 0x73a22 RW 0x1000
DYNAMIC 0x139bd4 0x0013abd4 0x0013abd4 0x000a8 0x000a8 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0
GNU_RELRO 0x0fc52c 0x000fd52c 0x000fd52c 0x3dad4 0x3dad4 RW 0x4
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .dynsym .dynstr .hash .rel.dyn .text .rodata
03 .data.rel.ro.local .data.rel.ro .dynamic .got .data .fspdata .cspdata .nspdata .bss
04 .dynamic
05
06 .data.rel.ro.local .data.rel.ro .dynamic .got
Also, what is the output from:% /mytooldir/android-ndk-21/bin/arm-linux-androideabi-ld --version
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-21/bin/arm-linux-androideabi-ld --version
GNU ld (binutils-2.25-48ba864) 2.25.51.20141117
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
root@ctrippel-VirtualBox:/usr/local/tools# ls -l ./android-ndk-21/bin/arm-linux-androideabi-ld
lrwxrwxrwx 1 ctrippel ctrippel 28 Apr 19 21:20 ./android-ndk-21/bin/arm-linux-androideabi-ld -> arm-linux-androideabi-ld.bfd
Another question:
I was able to run the test provided in samples/bin32 of the DynamoRIO-ARM-Android-EABI-6.1.1-3 release on my Android device successfully. However, I'm having a bit of trouble using cmake to compile my own instrumentation library. I found these instructions:
mkdir build cd build CFLAGS=-m32 CXXFLAGS=-m32 cmake -DDynamoRIO_DIR=$DYNAMORIO_HOME/cmake $DYNAMORIO_HOME/samples make instrcalls
However, I'm wondering how to specify that I'm building for Android. This make command is giving me some issues.
Thanks!
cmake -DCMAKE_TOOLCHAIN_FILE=/mytools/dynamorio/make/toolchain-android.cmake -DANDROID_TOOLCHAIN=/mytools/android-ndk-21 samples/
--
I filed https://github.com/DynamoRIO/dynamorio/issues/1927 on the ld.bfd issue.If you'd like to send a patch adding Android information to the samples.dox documentation we would welcome the contribution (see https://github.com/DynamoRIO/dynamorio/wiki/Contributing).
Hi Derek -- I'm working on getting something running for a deadline next week and then I'll get a more detailed documentation patch up. I'm having another issue. I've successfully been able to write an instrumentation tool; however, when I try to run any instrumentation tool (including the ones provided, i.e., libinscount.so) on a multi-threaded program, I get an internal crash/program aborted. Is there something special I should be doing to instrument, say, a 2-thread program?
255|root@shamu:/data/local/tmp # ./build_android/bin32/drrun -verbose -c libl>
INFO: client 0 path: /data/local/tmp/libllfence.so
INFO: targeting application: "/data/local/tmp/a.out"
INFO: app cmdline: "./a.out"
INFO: configuration directory is "/data/local/tmp/.dynamorio"
INFO: will exec /data/local/tmp/a.out
INFO: registering client with id=0 path=|/data/local/tmp/libllfence.so| ops=||
<Application /data/local/tmp/a.out (5459). DynamoRIO Sample Client 'llfence' internal crash at PC 0xb6f29960. Please report this at http://dynamorio.org/issues. Program aborted.
Received SIGSEGV at pc 0xb6f29960 in thread 5459
Base: 0xb6e57000
Registers: r0 =0x00000000 r1 =0xb6dcdca6 r2 =0x00000004 r3 =0x00000011
r4 =0x00000000 r5 =0x5397ef48 r6 =0x00000000 r7 =0x00000000
r8 =0
version 6.1.1, build 3
-no_dynamic_options -client_lib '/data/local/tmp/libllfence.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
Am I missing something when it comes to inserting instructions into a multi-threaded program?
Thanks!
It may have nothing to do with threads: probably the 2-thread binary simply contains additional opcode sequences not present in the smaller binary. For example, DMB has no 16-bit Thumb encoding, so perhaps you're trying to insert it inside an IT block, though that should result in an encoding message.
Use debug DR with logging. For small apps, run with "-loglevel 3" and you can see precisely which block it last instrumented. Attach gdb at the crash and get a callstack. Using logging and the debugger will be indispensable steps in diagnosing any issue with these types of low-level tools.
--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To post to this group, send email to dynamor...@googlegroups.com.
Visit this group at https://groups.google.com/group/dynamorio-users.
For more options, visit https://groups.google.com/d/optout.
I just posted a reply, but it appears to have been deleted. After some more debugging, it seems I was not setting the translation field. I'm still having issues with crashing, so I wanted to see if what I'm doing makes sense. I do; however, know that the proper dmb instructions are being inserted, as several basic blocks are instrumented before failure.
On each basic block, I do the following:
static dr_emit_flags_t
event_basic_block(void *drcontext, void *tag, instrlist_t *bb,
bool for_trace, bool translating)
{
instr_t *instr, *next_instr;
dr_printf("in dynamorio_basic_block(tag="PFX")\n", tag);
instrlist_disassemble(drcontext, tag, bb, STDOUT);
for (instr = instrlist_first_app(bb); instr != NULL; instr = next_instr) {
/* grab next now so we don't go over instructions we insert */
next_instr = instr_get_next_app(instr);
if (instr_reads_memory(instr)) {
instr_t* dmb = INSTR_CREATE_dmb(drcontext, opnd_create_immed_uint(15, OPSZ_4b));
instrlist_preinsert(bb, instr, instr_set_translation(dmb, instr_get_app_pc_instr(instr));; // is this correct for the app_pc field?
}
}
dr_printf("Finished instrumenting dynamorio_basic_block(tag="PFX")\n", tag);
instrlist_disassemble(drcontext, tag, bb, STDOUT);
return DR_EMIT_STORE_TRANSLATIONS; // is this correct for the return statement?
//return DR_EMIT_DEFAULT;
}
I added a couple comments/questions in the code segment; however this still crashes. When I run this with debug, I'm getting:
<Application /system/bin/toolbox (19575). Internal Error: DynamoRIO debug check failure: /dynamorio_package/core/translate.c:1455 app != NULL || instr_is_meta(inst)
(Error occurred @3 frags)
version 6.1.1, build 3
This is the last basic block that is instrumented:
in dynamorio_basic_block(tag=0xb6c29008)
TAG 0xb6c29008
+0 L3 b510 stmdb %r4 %lr %sp -> -0x08(%sp)[8byte] %sp
+2 L3 4c15 ldr +0x54(%pc)[4byte] -> %r4
+4 L3 447c add %r4 %pc -> %r4
+6 L3 7823 ldrb (%r4)[1byte] -> %r3
+8 L3 bb03 cbnz $0xb6c29054 %r3
END 0xb6c29008
Finished instrumenting dynamorio_basic_block(tag=0xb6c29008)
TAG 0xb6c29008
+0 L3 b510 stmdb %r4 %lr %sp -> -0x08(%sp)[8byte] %sp
+2 L4 @0x52f866a0 f3bf 8f5f dmb $0x0f
+6 L3 4c15 ldr +0x54(%pc)[4byte] -> %r4
+8 L3 447c add %r4 %pc -> %r4
+10 L4 @0x52f86278 f3bf 8f5f dmb $0x0f
+14 L3 7823 ldrb (%r4)[1byte] -> %r3
+16 L3 bb03 cbnz $0xb6c29054 %r3
END 0xb6c29008
Do you have any suggestions? Also, is there any way to omit library code from instrumentation?
You received this message because you are subscribed to a topic in the Google Groups "DynamoRIO Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dynamorio-users/eL1__o7m4AQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dynamorio-use...@googlegroups.com.
I just posted a reply, but it appears to have been deleted.
After some more debugging, it seems I was not setting the translation field. I'm still having issues with crashing, so I wanted to see if what I'm doing makes sense. I do; however, know that the proper dmb instructions are being inserted, as several basic blocks are instrumented before failure.
if (instr_reads_memory(instr)) {
instr_t* dmb = INSTR_CREATE_dmb(drcontext, opnd_create_immed_uint(15, OPSZ_4b));
instrlist_preinsert(bb, instr, instr_set_translation(dmb, instr_get_app_pc_instr(instr));; // is this correct for the app_pc field?
return DR_EMIT_STORE_TRANSLATIONS; // is this correct for the return statement?
//return DR_EMIT_DEFAULT;
I added a couple comments/questions in the code segment; however this still crashes. When I run this with debug, I'm getting:
<Application /system/bin/toolbox (19575). Internal Error: DynamoRIO debug check failure: /dynamorio_package/core/translate.c:1455 app != NULL || instr_is_meta(inst)
So, I think I have my tool figured out. I'm printing the BB assembly both before and after instrumentation and it appears to be inserting instructions in the correct places. And if my understanding is correct, this should be dynamically inserting these new instructions into the actual app instruction stream. Is this right?
Anyways, I am able to run my tool on a simple single-threaded hello world app, the Android-ARM ls binary and another 2-thread (one main thread and one child thread) app. However, if I try to run my library (or any library for that matter) or just drrun with no client on an app that has 3 threads (main + 2 children), I get a segmentation fault. This happens with even the very simple .cpp program that I've also attached here. Is DR only able to handle 2 threads? Are there some compiler flags I'm missing? This happens with both dynamic and static linking.
139|root@shamu:/data/local/tmp # ./build_android/bin32/drrun -debug -stderr_mask 15 -c samples/bin32/libopcodes.so -- ./cppthread>
<Starting application /data/local/tmp/cppthread (2852)>
<Paste into GDB to debug DynamoRIO clients:
set confirm off
add-symbol-file '/data/local/tmp/samples/bin32/libopcodes.so' 0xb6c23700
add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrx.so' 0xb6c111a4
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrreg.so' 0xb6bfe9b8
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrmgr.so' 0xb6bebd64
add-symbol-file '/system/lib/libc.so' 0xb6b84ef0
add-symbol-file '/system/lib/libdl.so' 0xb6b6f56c
>
<Initial options = -no_dynamic_options -client_lib '/data/local/tmp/samples/bin32/libopcodes.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
Client opcodes is running
<get_memory_info mismatch! (can happen if os combines entries in /proc/pid/maps)
os says: 0xb6602000-0xb6700000 prot=0x00000003
cache says: 0xb6602000-0xb6900000 prot=0x00000003
>
Hi from thread1
Hello from main
Greetings from thread2
<Stopping application /data/local/tmp/cppthread (2852)>
Top 15 opcode execution counts in 32-bit ARM mode:
4518 : uxtb
4757 : ldrb
4778 : bic
5218 : lsr
5358 : bx
5868 : rev
5987 : orr
6309 : ands
6762 : tst
7848 : ldrd
9181 : subs
9726 : mov
11117 : add
12060 : pld
17260 : ldr
22457 : cmp
43383 : b
Top 15 opcode execution counts in 32-bit Thumb mode:
7144 : stmdb
8061 : bl
8449 : cbnz
8729 : sub
9068 : movs
14557 : adds
15959 : and
16104 : b
21787 : ldrb
22752 : eor
26512 : cbz
33856 : str
54397 : mov
71868 : add
74465 : cmp
106325 : b
158566 : ldr
root@shamu:/data/local/tmp # ./build_android/bin32/drrun -debug -stderr_mask 15 -c samples/bin32/libopcodes.so -- ./cppthread>
<Starting application /data/local/tmp/cppthread (2858)>
<Paste into GDB to debug DynamoRIO clients:
set confirm off
add-symbol-file '/data/local/tmp/samples/bin32/libopcodes.so' 0xb6c39700
add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrx.so' 0xb6c271a4
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrreg.so' 0xb6c149b8
add-symbol-file '/data/local/tmp/build_android/ext/lib32/debug/libdrmgr.so' 0xb6c01d64
add-symbol-file '/system/lib/libc.so' 0xb6b9aef0
add-symbol-file '/system/lib/libdl.so' 0xb6b8556c
>
<Initial options = -no_dynamic_options -client_lib '/data/local/tmp/samples/bin32/libopcodes.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
Client opcodes is running
<get_memory_info mismatch! (can happen if os combines entries in /proc/pid/maps)
os says: 0xb6602000-0xb6700000 prot=0x00000003
cache says: 0xb6602000-0xb6900000 prot=0x00000003
>
Segmentation fault
139|root@shamu:/data/local/tmp #
Right now gdb is not even letting me step through instructions as it says it cannot find the bounds of the function. Also, it appears to seg fault as soon as the third thread is created.
ctrippel$ ~/android-ndk-r11c/prebuilt/darwin-x86_64/bin/gdb
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin14.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote :1234
Remote debugging using :1234
warning: Architecture rejected target-supplied description
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun...Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun.debug...done.
done.
0xb6ff0a18 in ?? ()
(gdb) s
Cannot find bounds of current function
(gdb) continue
Continuing.
Program received signal SIGINT, Interrupt.
0xb6ff0a18 in ?? ()
(gdb) continue
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) cont
Continuing.
[New Thread 3910]
[New Thread 3909]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3910]
0x2a21118e in ?? ()
(gdb)
(gdb) cont
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) n
Cannot find bounds of current function
(gdb) cont
Continuing.
[New Thread 4190]
[New Thread 4188]
[New Thread 4189]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4190]
0x2a21118e in ?? ()
<Initial options = -no_dynamic_options -client_lib '/data/local/tmp/samples/bin32/libopcodes.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
Client opcodes is running
<get_memory_info mismatch! (can happen if os combines entries in /proc/pid/maps)
os says: 0xb6602000-0xb6700000 prot=0x00000003
cache says: 0xb6602000-0xb6900000 prot=0x00000003
>
--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To post to this group, send email to dynamor...@googlegroups.com.
Visit this group at https://groups.google.com/group/dynamorio-users.
For more options, visit https://groups.google.com/d/optout.
(gdb) s
Cannot find bounds of current function
(gdb) continue
Continuing.
Program received signal SIGINT, Interrupt.
0xb6ff0a18 in ?? ()
(gdb) continue
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) cont
Continuing.
[New Thread 3910]
[New Thread 3909]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3910]
0x2a21118e in ?? ()
(gdb)
--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To post to this group, send email to dynamor...@googlegroups.com.
Visit this group at https://groups.google.com/group/dynamorio-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To post to this group, send email to dynamor...@googlegroups.com.
Visit this group at https://groups.google.com/group/dynamorio-users.
For more options, visit https://groups.google.com/d/optout.
***The size limits are preventing me from attaching log.1.*.html
--
I'm attaching 3 files
I don's even see this address in the log files: 0x2a21118e
Where do I look to see the code cache?
—————————————————————————————————————————————————————————————————————————
How I built NDK:
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-r11c/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-21 --install-dir=./android-ndk-21
HOST_OS=linux
HOST_EXE=
HOST_ARCH=x86_64
HOST_TAG=linux-x86_64
HOST_NUM_CPUS=1
BUILD_NUM_CPUS=2
Auto-config: --toolchain=arm-linux-androideabi-4.9
Copying prebuilt binaries...
Copying sysroot headers and libraries...
Copying c++ runtime headers and libraries...
Copying files to: ./android-ndk-21
Cleaning up...
Done.
—————————————————————————————————————————————————————————————————————————
****************************************See simple.cpp file****************************************
—————————————————————————————————————————————————————————————————————————
How I compiled simple.cpp to cppthread and pushed to phone
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-21/bin/arm-linux-androideabi-g++ -std=c++11 -g -fpie -pie -o cppthread simple.cpp
root@ctrippel-VirtualBox:/usr/local/tools# adb push cppthread /data/local/tmp/apps
344 KB/s (4207476 bytes in 11.921s)
Phone specs: Nexus 6, Quad-core, running Android 5.0
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Running uninstrumented app on phone
root@shamu:/data/local/tmp # ./apps/cppthread
Hello from main
Greetings from thread2
Hi from thread1
root@shamu:/data/local/tmp #
root@shamu:/data/local/tmp # ./apps/cppthread
Hello from main
Hi from thread1
Greetings from thread2
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Phone file hierarchy:
/data/local/tmp/
——> build_android/
————> lib32 // from DynamoRIO-ARM-Android-EABI-6.1.1-3/lib32
————> bin32 // from DynamoRIO-ARM-Android-EABI-6.1.1-3/bin32
————> ext // from DynamoRIO-ARM-Android-EABI-6.1.1-3/ext
——> apps/
————> cppthread
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Running drrun with no client on cppthread
root@shamu:/data/local/tmp # ./build_android/bin32/drrun -- ./apps/cppthread
Hello from main
Segmentation fault
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Now running with -debug -loglevel 4
Runs fine the first time…
root@shamu:/data/local/tmp # ./build_android/bin32/drrun -debug -loglevel 4 ->
<log dir=/data/local/tmp/build_android/bin32/../logs/cppthread.9278.00000000>
<Starting application /data/local/tmp/apps/cppthread (9278)>
<Paste into GDB to debug DynamoRIO clients:
set confirm off
add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
>
<Initial options = -no_dynamic_options -loglevel 4 -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
<get_memory_info mismatch! (can happen if os combines entries in /proc/pid/maps)
os says: 0xb6802000-0xb6900000 prot=0x00000003
cache says: 0xb6802000-0xb6b00000 prot=0x00000003
>
HiGreetingsHello from thread2
from main
from thread1
<Stopping application /data/local/tmp/apps/cppthread (9278)>
****************************************See cppthread.9278.00000000/ directory***************************************
Segmentation fault the second time…
/bin32/drrun -debug -loglevel 4 -- ./apps/cppthread <
<log dir=/data/local/tmp/build_android/bin32/../logs/cppthread.9286.00000000>
<Starting application /data/local/tmp/apps/cppthread (9286)>
<Paste into GDB to debug DynamoRIO clients:
set confirm off
add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
>
<Initial options = -no_dynamic_options -loglevel 4 -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >
<get_memory_info mismatch! (can happen if os combines entries in /proc/pid/maps)
os says: 0xb6802000-0xb6900000 prot=0x00000003
cache says: 0xb6802000-0xb6b00000 prot=0x00000003
>
Segmentation fault
****************************************See cppthread.9286.00000000/ directory***************************************
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Now running with -debug -loglevel 4 and gdb/gdbserver (This time does not create logs)
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) set solib-search-path ~/android/:~/android/system_lib:~/android/vendor_lib:~/android/vendor_lib/egl/:/usr/local/tools/DynamoRIO-ARM-Android-EABI-6.1.1-3/lib32/debug/
(gdb) add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
add symbol table from file "/data/local/tmp/build_android/lib32/debug/libdynamorio.so" at
.text_addr = 0x21508
(y or n) y
Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so...Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so.debug...done.
done.
(gdb) target remote :1234
Remote debugging using :1234
warning: Architecture rejected target-supplied description
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun...Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun.debug"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun.debug...done.
done.
Reading /system/bin/linker from remote target...
Reading /system/bin/linker from remote target...
Reading symbols from target:/system/bin/linker...Reading /system/bin/.debug/linker from remote target...
(no debugging symbols found)...done.
0xb6ff0a18 in __dl__start () from target:/system/bin/linker
(gdb) break main
Breakpoint 1 at 0x2a01aa60: file /dynamorio_package/tools/drdeploy.c, line 976.
(gdb) cont
Continuing.
Breakpoint 1, main (argc=6, argv=0xbefff9e4) at /dynamorio_package/tools/drdeploy.c:976
976 /dynamorio_package/tools/drdeploy.c: No such file or directory.
(gdb) x/100i 0x2a01aa60
=> 0x2a01aa60 <main>: stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}
…
0x2a01ab72 <main+274>: str r1, [sp, #16]
(gdb)
(gdb) break *0x2a01ab72
Breakpoint 2 at 0x2a01ab72: file /dynamorio_package/tools/drdeploy.c, line 1088.
(gdb) cont
Continuing.
Breakpoint 2, 0x2a01ab72 in main (argc=6, argv=0xbefff9e4) at /dynamorio_package/tools/drdeploy.c:1088
1088 in /dynamorio_package/tools/drdeploy.c
(gdb) x/100i 0x2a01aa60
0x2a01aa60 <main>: stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}
…
=> 0x2a01ab72 <main+274>: str r1, [sp, #16]
(gdb)
(gdb) break *0x2a01ab70
Breakpoint 3 at 0x2a01ab70: file /dynamorio_package/tools/drdeploy.c, line 1088.
(gdb) cont
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) ni
0x2a20f5fc in ?? ()
(gdb) x/100i 0x2a01ab70
0x2a01ab70 <main+272>: add r1, pc
…
0x2a01ac36 <main+470>: movs r0, r0
(gdb) break *0x2a01ac36
Breakpoint 4 at 0x2a01ac36: file /dynamorio_package/tools/drdeploy.c, line 344.
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x2a232d06 in ?? ()
(gdb) Quit
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Running again with -debug -loglevel 4 and gdb… (This time does not create logs and fails at the same place as the previous)
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
add symbol table from file "/data/local/tmp/build_android/lib32/debug/libdynamorio.so" at
.text_addr = 0x21508
(y or n) y
Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so...Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so.debug...done.
done.
(gdb) set solib-search-path ~/android/:~/android/system_lib:~/android/vendor_lib:~/android/vendor_lib/egl/:/usr/local/tools/DynamoRIO-ARM-Android-EABI-6.1.1-3/lib32/debug/
(gdb) target remote :1234
Remote debugging using :1234
warning: Architecture rejected target-supplied description
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun...Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun.debug"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun.debug...done.
done.
Reading /system/bin/linker from remote target...
Reading /system/bin/linker from remote target...
Reading symbols from target:/system/bin/linker...Reading /system/bin/.debug/linker from remote target...
(no debugging symbols found)...done.
0xb6ff0a18 in __dl__start () from target:/system/bin/linker
(gdb) break main
Breakpoint 1 at 0x2a01aa60: file /dynamorio_package/tools/drdeploy.c, line 976.
(gdb) cont
Continuing.
Breakpoint 1, main (argc=6, argv=0xbefff9e4) at /dynamorio_package/tools/drdeploy.c:976
976 /dynamorio_package/tools/drdeploy.c: No such file or directory.
(gdb) cont
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x2a232d06 in ?? ()
(gdb) Quit
—————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————
Running again with -debug -loglevel 4 and gdb… (This time fails elsewhere and create logs)
root@ctrippel-VirtualBox:/usr/local/tools# ./android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file '/data/local/tmp/build_android/lib32/debug/libdynamorio.so' 0x00021508
add symbol table from file "/data/local/tmp/build_android/lib32/debug/libdynamorio.so" at
.text_addr = 0x21508
(y or n) y
Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so...Reading symbols from /data/local/tmp/build_android/lib32/debug/libdynamorio.so.debug...done.
done.
(gdb) set solib-search-path ~/android/:~/android/system_lib:~/android/vendor_lib:~/android/vendor_lib/egl/:/usr/local/tools/DynamoRIO-ARM-Android-EABI-6.1.1-3/lib32/debug/
(gdb) cont
The program is not being run.
(gdb) target remote :1234
Remote debugging using :1234
warning: Architecture rejected target-supplied description
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /data/local/tmp/build_android/bin32/drrun from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun...Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Reading /data/local/tmp/build_android/bin32/drrun.debug from remote target...
Load new symbol table from "target:/data/local/tmp/build_android/bin32/drrun.debug"? (y or n) y
Reading symbols from target:/data/local/tmp/build_android/bin32/drrun.debug...done.
done.
Reading /system/bin/linker from remote target...
Reading /system/bin/linker from remote target...
Reading symbols from target:/system/bin/linker...Reading /system/bin/.debug/linker from remote target...
(no debugging symbols found)...done.
0xb6ff0a18 in __dl__start () from target:/system/bin/linker
(gdb) cont
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2a20f5f8 in ?? ()
(gdb) cont
Continuing.
[New Thread 9372]
[New Thread 9371]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 9372]
0x2a21118e in ?? ()
(gdb) disassemble main
Dump of assembler code for function main:
0x2a01aa60 <+0>: str r3, [sp, #352] ; 0x160
…
0x2a01aabc <+92>: movs r7, r2
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) info line *0x2a232d06
No line number information available for address 0x2a232d06
(gdb) info line *0x2a21118e
No line number information available for address 0x2a21118e
(gdb) disas 0x2a232d06,0x2a232d06
Dump of assembler code from 0x2a232d06 to 0x2a232d06:
End of assembler dump.
(gdb) Quit
****************************************See cppthread.9361.00000000/ directory***************************************
—————————————————————————————————————————————————————————————————————————