Tracing one function in AUTOSAR stack with Lauterbach

68 Views Asked by At

What is the difference between Lauterbach Trace Enable and Trace On/Off? How to trace only one function when using an AUTOSAR stack?

I am using a microcontroller with Arm Cortex M and Cortex R.

First approach:

&a1=sYmbol.BEGIN(FunctionName)
&a2=sYmbol.EXIT(FunctionName)

;Only generate trace messages on the addresses used for measurement
Break.Set &a1 /Program /TraceEnable 
Break.Set &a2 /Program /TraceEnable

;statistic analysis
Trace.STATistic.cycle / core 0
;Function trace
perf.lf all / core 0

Second approach:

&a1=sYmbol.BEGIN(FunctionName)
&a2=sYmbol.EXIT(FunctionName)

;Only generate trace messages on the addresses used for measurement
Break.Set &a1 /Program /TraceOn 
Break.Set &a2 /Program /TraceOff

;statistic analysis
Trace.STATistic.cycle / core 0
;Function trace
perf.lf all / core 0

Neither gave the result I was looking for. Even though I am enabling trace only for the duration of the function, it is still showing all the functions running in the function trace and trace statistics are not significantly different than when running without these breakpoints.

1

There are 1 best solutions below

0
Holger On

TraceEnable configures the onchip ETM in a way, that it only emits trace for the addresses marked with TraceEnable - and not other addresses at all.

TraceOn/TraceOff are used in pairs and configure the onchip ETM in a way, that it starts/ends emitting the trace when the CPU executes the given address.

Thus, if you want to trace only one single function you have two options:

  • Var.Break.Set FunctionName /Program /TraceEnable : That will record all instructions within the function's body - but it will not record any function called by your function. Note: Break.Set will consider FunctionName as a single address, while Var.Break.Set will consider FunctionName as an address range.
  • Var.Break.Set sYmbol.BEGIN(FunctionName) /Program /TraceOn together with Var.Break.Set sYmbol.EXIT(FunctionName) /Program /TraceOff : That will record everything which happens from the beginning to the end of the function. Tiny problem here: This will also include asynchronous interruptions caused by your AUTOSAR OS. However, the nested trace analysis (e.g. Trace.STAT.Func) should consider asynchronous interruptions (if you have loaded your ORTI file (with TAKS.ORTI))

Consider, that these filters configure onchip resources in a way, that the CPU will generate only a reduced trace. In your case it might be a more suitable approach to trace everything and filter the recorded data later (e.g. with GROUP)