Capturing the instruction trace from the ARM ETM

According to the ARM documentation for the CPU models available in Apple Silicon, the CoreSight implementation includes an Embedded Trace Macrocell which can perform a complete "Instruction Trace" (https://developer.arm.com/documentation/102119/0200/What-is-trace-). Although other operating systems such as Linux make this easy, we have not been able to find any tools or even a system-level API for accessing this feature of the ETM.

In the "Instruments" window of Xcode 16+, there is a "Processor Trace" instrument, but this performs sampling and is totally unrelated to the Instruction Trace we need for debugging and analysis purposes. Because it produces a complete, contiguous sequence of branch instructions, the Instruction Trace is essential for identifying precise execution behaviors that are otherwise invisible to the developer. On other platforms, an alternative is debugger scripting, but we have found far too many bugs and reliability issues with the macOS implementation of lldb.

Any suggestions would be greatly appreciated!

Hi there,

Processor Trace in Instruments does indeed instruction tracing (to be precise, tracing every branch taken by the program).

In Instruments, this data is currently presented only at the function level granularity, so all the branches taken and their costs are pulled into the function cost, so the information gets "lost" during processing by Instruments.

What kind of information would you like to extract from the traces? Are you looking for a programmatic access, visualization in Instruments or both?

Kacper

Capturing the instruction trace from the ARM ETM
 
 
Q