How to get the dynamic instruction trace on AArch64 Android

197 views
Skip to first unread message

fish-man

unread,
Mar 25, 2022, 10:51:31 AM3/25/22
to DynamoRIO Users
Hello,
I am going to get the instruction trace on Android aarch64, I got it successfully on 32 bits drrun, I tried to make Android 64bits drrun, like https://github.com/DynamoRIO/dynamorio/issues/2154, but failed. Could someone give me some advice on how to make Android 64bits drrun? At the same time I want to ask if it is possible to get the trace of 64 bits application?

Thanks

Derek Bruening

unread,
Mar 25, 2022, 12:52:50 PM3/25/22
to fish-man, DynamoRIO Users
On Fri, Mar 25, 2022 at 10:51 AM fish-man <lhx...@gmail.com> wrote:
Hello,
I am going to get the instruction trace on Android aarch64, I got it successfully on 32 bits drrun, I tried to make Android 64bits drrun, like https://github.com/DynamoRIO/dynamorio/issues/2154, but failed. Could someone give me some advice on how to make Android 64bits drrun?

I know there has been Android interest: hopefully anyone working on it will reply here and contribute any local fixes they have upstream.

 At the same time I want to ask if it is possible to get the trace of 64 bits application?

64-bit in general?  Certainly that is well-supported for x86-64 Linux and AArch64 Linux: we use it on a regular basis.
 

Thanks

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/fe2168da-e325-43a8-bfd9-ade8305c6358n%40googlegroups.com.

fish-man

unread,
Mar 31, 2022, 9:36:47 AM3/31/22
to DynamoRIO Users
Hello!
I successfully got the trace on AARCH64 Android 11 by compiling Dynamorio v8.0. I'm using instrace_simple.c to get the trace. But there are two problems here, can you give me some advice?

The first question is about instruction recognition:
There are some instructions that don't seem to be recognized, fprintf 'xx',
Snipaste_2022-03-31_21-28-24.png
And one instruction is different from the result of my own disassembly.
$ rasm2 -a arm -b 64 -d 910003e0 -e
mov x0, sp


second question:
I commented out the fprintf code in the instrace_simple.c file, printed the num_refs variable at event_exit, and showed that 7322338 instructions were executed. But the number of lines in the instrace.toybox.log file generated after uncommenting was far more than this number(7322338). The file was too large, and when it exceeded 3GB, I terminated the program prematurely. Is there something wrong?
Snipaste_2022-03-31_20-55-33.png

Can you give me some advice?
Thanks!

Derek Bruening

unread,
Mar 31, 2022, 9:59:22 AM3/31/22
to fish-man, DynamoRIO Users
On Thu, Mar 31, 2022 at 9:36 AM fish-man <lhx...@gmail.com> wrote:
Hello!
I successfully got the trace on AARCH64 Android 11 by compiling Dynamorio v8.0. I'm using instrace_simple.c to get the trace. But there are two problems here, can you give me some advice?

Wow, that is good news that it worked: we thought there were issues with the private loader on Android 10+ (https://github.com/DynamoRIO/dynamorio/issues/3683).


The first question is about instruction recognition:
There are some instructions that don't seem to be recognized, fprintf 'xx',

Instructions that are not yet fully decoded by DR's decoder are given the opcode 'xx'.  If you used v8.0 that's from 2 years ago; since then the decoder has been expanded to cover most opcodes, so more recent DR code would eliminate most the 'xx' I would expect.
 
Snipaste_2022-03-31_21-28-24.png
And one instruction is different from the result of my own disassembly.
$ rasm2 -a arm -b 64 -d 910003e0 -e
mov x0, sp

Many AArch64 instructions are known by multiple names: they have an alias but underneath are implemented as something else that is semantically equivalent.  The DR decoder may not use the preferred assembly alias in all cases.
 


second question:
I commented out the fprintf code in the instrace_simple.c file, printed the num_refs variable at event_exit, and showed that 7322338 instructions were executed. But the number of lines in the instrace.toybox.log file generated after uncommenting was far more than this number(7322338). The file was too large, and when it exceeded 3GB, I terminated the program prematurely. Is there something wrong?

What printf code did you use to print it out?  If it was for a 32-bit value that would explain printing the wrong number.
 
Snipaste_2022-03-31_20-55-33.png

Can you give me some advice?
Thanks!
在2022年3月25日星期五 UTC-5 11:52:50<Derek Bruening> 写道:
On Fri, Mar 25, 2022 at 10:51 AM fish-man <lhx...@gmail.com> wrote:
Hello,
I am going to get the instruction trace on Android aarch64, I got it successfully on 32 bits drrun, I tried to make Android 64bits drrun, like https://github.com/DynamoRIO/dynamorio/issues/2154, but failed. Could someone give me some advice on how to make Android 64bits drrun?

I know there has been Android interest: hopefully anyone working on it will reply here and contribute any local fixes they have upstream.

 At the same time I want to ask if it is possible to get the trace of 64 bits application?

64-bit in general?  Certainly that is well-supported for x86-64 Linux and AArch64 Linux: we use it on a regular basis.
 

Thanks

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/fe2168da-e325-43a8-bfd9-ade8305c6358n%40googlegroups.com.

--
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.

fish-man

unread,
Mar 31, 2022, 11:27:52 PM3/31/22
to DynamoRIO Users
This is the definition of the num_refs variable in instrace_simple.c
Snipaste_2022-04-01_10-44-30.png
Here is the printf I added, They are compiled under 64bit
Snipaste_2022-04-01_11-17-36.png
It looks like it's all 64bit.

I can only get num_refs after commenting fprintf, otherwise, the generated instrace.toybox.log file is too large
Snipaste_2022-04-01_11-16-57.png

Derek Bruening

unread,
Apr 5, 2022, 3:09:40 PM4/5/22
to fish-man, DynamoRIO Users
Not sure.  I would try dr_printf to rule out anything weird with the libc copy.

Alex Hunter

unread,
Mar 9, 2024, 9:30:11 PMMar 9
to DynamoRIO Users
Hi, Could you please elaborate the steps to build dynamoRIO for aarch64 android? I want to run it for android arm64.

Regards
Gagan

Derek Bruening

unread,
Mar 12, 2024, 10:30:40 AMMar 12
to Alex Hunter, fish-man, DynamoRIO Users
It looks like the various folks (including on this thread) who have made progress have either not (yet?) contributed the improvements to the central repository or have not finished merging pull requests (e.g. https://github.com/DynamoRIO/dynamorio/pull/3547)  Hopefully there will be future community contributions to get things working, or if you yourself are able to make progress please consider sending pull requests to help the community.  See also the issue tracker for this: https://github.com/DynamoRIO/dynamorio/issues/2154

Reply all
Reply to author
Forward
0 new messages