ARM-software / CSAL

Coresight Access Library
Other
107 stars 42 forks source link

Storing ETM trace in persistent buffer. #18

Closed HokageM closed 3 months ago

HokageM commented 3 months ago

I want to keep track of the last N instructions of the ETM and save them in a persistent buffer. This should be done during execution.

I found the do_fetch_trace function, which saves the traced data in a file. Is there also a way to save the traced data into another buffer? How do I need to configure the ETM for that purpose?

HokageM commented 3 months ago

I guess this function should do what I ask for: int cs_get_trace_data(cs_device_t dev, void *buf, unsigned int size)

algrant-arm commented 3 months ago

I believe so. Note that the device here is the trace buffer (ETB) not the ETM. In the most general case, multiple trace sources (ETMs etc.) will funnel into a trace sink, and the data is collected from the sink, and it then needs to be demultiplexed to get each trace stream.

It can be set it up so that there's only one active trace source, and in that case you can even turn off the multiplex formatting in the ETB, but it's still the ETB where the trace ends up being collected from.

Alternatively if there's an ETR (trace router) on the trace path, it can write directly to a memory buffer.

HokageM commented 3 months ago

Thank you! I will try it.