Help getting function name with drsyms

109 views
Skip to first unread message

JK

unread,
Feb 13, 2022, 12:35:51 PM2/13/22
to DynamoRIO Users
I am basically brand new to DynamoRIO and looking for some tips on the following. My basic goal is to print out the execution trace of my program including the function name of each instruction.

I noticed that the instrcalls sample client instruments call instructions and prints out the function name. So I tried to modify the event_app_instruction() function there to instrument every instruction (not just call instructions). However I seem to still only be printing calls.

Actually first, I had tried modifying the instrace example client to include the function name while printing, in addition to the program counter + instruction. This seemed more straightforward to me, but I actually had even less success here - can I get the function name from the program counter?

Preferably I would also print the file name and line number, too.

sharma...@google.com

unread,
Feb 15, 2022, 2:30:06 AM2/15/22
to DynamoRIO Users
Hi,
> So I tried to modify the event_app_instruction() function there to instrument every instruction (not just call instructions). However I seem to still only be printing calls.

Can you provide more details of the modifications you made? Did you extend this (https://github.com/DynamoRIO/dynamorio/blob/b7b47716d1c4ad52fee4651c4b9afa9e60ea2bdf/api/samples/instrcalls.c#L254) if-else-if ladder to add a clean call for all other instructions using dr_insert_clean_call (https://dynamorio.org/dr__ir__utils_8h.html#a1df44dbe3d8dbf82e63e96741f167c64)?

> can I get the function name from the program counter?

To get the function name from a pc, try using drsym_lookup_address (https://dynamorio.org/group__drsyms.html#ga201e8a9bf6746cbfd232bc4e4a243d2b). See this sample (https://github.com/DynamoRIO/dynamorio/blob/9f8d170fa8eef5f00ea14cdf87384e01e5f8545a/suite/tests/client-interface/drcallstack-test.dll.c#L43). The drsym_info_t returned by this routine (https://dynamorio.org/struct__drsym__info__t.html) contains the file and line number too.

Hope this helps.

Abhinav

JK

unread,
Feb 16, 2022, 11:30:13 AM2/16/22
to DynamoRIO Users
Abhinav,

With your advice, I was able to modify the instrace_simple client to do what I want now. Thank you, I really appreciate it.
Reply all
Reply to author
Forward
0 new messages