dynamorio icon indicating copy to clipboard operation
dynamorio copied to clipboard

Implement dr_insert_cbr_instrumentation on ARM & AArch64

Open fhahn opened this issue 8 years ago • 5 comments

dr_insert_cbr_instrumentation and dr_insert_cbr_instrumentation_ex are not yet implemented on ARM & AArch64.

fhahn avatar Mar 16 '17 12:03 fhahn

xref #1569

fhahn avatar Mar 16 '17 12:03 fhahn

Hello @derekbruening @fhahn @egrimley I have a requirement to get api/samples/cbrtrace.c working for AArch64.

My approach to implementing dr_insert_cbr_instrumentation_help() is to figure out the X86 version and port to AArch64. Do you think this is the best way of tackling the issue?

There may (probably will?) be differences in the way the clean call is used by dr_insert_cbr_instrumentation_help() on AArch64 AIUI the layouts differ.

AssadHashmi avatar May 09 '18 18:05 AssadHashmi

The x86 version is so complex b/c it's trying to take advantage of the clean call state save to avoid spilling anything extra, yet not affect the stored state, while not changing the clean call insertion code and instead examining it afterward: rather messy. One could imagine ways to make it simpler and less fragile, but at a performance cost with extra loads and stores; or even simpler, with a layered callee who computes the branch direction from the dr_mcontex_t, but again at a performance cost.

One thing you won't have to deal with on AArch64 is the flags being clobbered (by POPF on x86 to clear the direction flag for the ABI).

derekbruening avatar May 09 '18 18:05 derekbruening

Ah ok! Thanks Derek.

AssadHashmi avatar May 09 '18 18:05 AssadHashmi

AARCH64 cbr instrumentation done in pr https://github.com/DynamoRIO/dynamorio/pull/7005. Please test and report issues if any. I am re-opening this issue since ARM cbr instrumentation is not implemented yet.

jiegec avatar May 19 '25 17:05 jiegec