How to get the timestamp (processor ticks) of the binary?

102 views
Skip to first unread message

Chiao-Ying Lin

unread,
Mar 10, 2021, 4:15:23 PM3/10/21
to DynamoRIO Users
Hello all, 

Now I want to study what instructions are exeuted  versus time. My current solution is to simply implement "time.h" in the client api, but that would be the ticks executed in drrun instead of the binary of interest. 

Best regards,
Chiao-Ying
Message has been deleted
Message has been deleted

assad.hashm...@gmail.com

unread,
Mar 11, 2021, 12:51:41 PM3/11/21
to DynamoRIO Users
Hello,

To clarify: do you want to trace instruction execution with reference to the CPU clock ticks counter?

Based on my DynamoRIO experience/knowledge, the best you can do is to timestamp the point at which an instruction is seen by the client at execution time.

It won't be a direct CPU clock-to-instruction accurate representation of when an instruction is executed but it will give you a good approximation with reference to others in the stream.

You could modify the instrace_simple.c client to timestamp each instruction in the instrace() clean call function's fprintf().
A call to instrace() is planted for each instruction at translation time so instrace() is called at execution time when each instruction is executed.

Others with more DR experience may want to correct/improve on my suggestion.

Derek Bruening

unread,
Mar 11, 2021, 1:24:31 PM3/11/21
to dynamor...@googlegroups.com
I would add that what Assad describes, the technique of including a timestamp in the header of each buffer while gathering an instruction trace, is exactly what DR's full-featured tracer drmemtrace does: see https://github.com/DynamoRIO/dynamorio/blob/master/clients/drcachesim/tracer/instru.cpp#L321 and https://github.com/DynamoRIO/dynamorio/blob/master/clients/drcachesim/tracer/instru_offline.cpp#L347.

--
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/33609263-3e06-48d1-aad8-92d2d770f79fn%40googlegroups.com.

Chiao-Ying Lin

unread,
Mar 12, 2021, 1:16:13 PM3/12/21
to DynamoRIO Users
Hello all, 

However, as this is a C code, and this timestamp function is in C++. This would trigger the error message:

<ERROR: using undefined symbol!!>

I ever tried to have the same compiled with C++, but it would lead to some more serious errors.

Best regards,
Chiao-Ying

assad.hashm...@gmail.com

unread,
Mar 15, 2021, 5:56:16 AM3/15/21
to DynamoRIO Users
The undefined symbol error usually happens when a client which linked without errors at build time can't find and load the variable(s)/function(s) at run time.
The fix is usually to link with the library or other object file which contains the missing variable(s)/function(s). 
Running drrun with -debug option should give you warnings with the name of which symbols couldn't be found.

Chiao-Ying Lin

unread,
Mar 16, 2021, 11:45:22 PM3/16/21
to DynamoRIO Users
Hello all,

at the beginning, I forgot to compile dynamorio using the arm configuration, so the debug functionality was not working as expected to show what symbols are not defined.

After the recompilation, it turns out the issue was from loading functions from "utils.h" to a cpp script.  (when functions are defined in c and used in cpp files, those symbols are not linked).  

I already have it fixed, but I wonder if it is something which needs a fix in the public repository.

Best regards

sharma...@google.com

unread,
Mar 17, 2021, 9:54:18 PM3/17/21
to DynamoRIO Users
Hi,
> However, as this is a C code, and this timestamp function is in C++

The timestamp function I found is dr_get_microseconds from instrument_api.h, defined in instrument.c (https://github.com/DynamoRIO/dynamorio/blob/8659d9512d3b5f8fdf9d4bcdd1e294afd24492b7/core/lib/instrument_api.h#L2047). Did you try using a different one? Does this work instead? 

Abhinav

Reply all
Reply to author
Forward
0 new messages