Search code examples
functiontimetrace32lauterbach

How many time a function is called in Trace32?


I have only debugger power-pro from Lauterbach. I can't do trace with it, is it normal ?

And if it's normal, I need to know how can I know how many time a function is called ? I set a breakpoint on my function but it doesn't show the same number when I use trace.statistic during the same time (the count is not the same).


Solution

  • If Trace.METHOD ONCHIP ist selected, your chip actually supports some trace functionality. The program flow is stored in a dedicated memory on the chip and read from there via JTAG. (The methods Analyser or CAnalyzer apply to Lauterbach hardware, which can store the program flow when it is send from the chip via a dedicated physical interface.)

    The on-chip trace buffer is probably not very big. So when it overflows it will either stop recording or overwrite the oldest data. So your on-chip buffer can only record a certain amount of executed instructions. So watch in the Window Trace.state how your trace buffer fills up.

    If you are only interested how much one single function is called, I recommend to record only the call of this function. Therefor program a trace-filter in your chip. You can do this with the command Break.Set <your function's name> /TraceEnable. Although the command sounds like "setting a breakpoint", it is instead programming a trace filter thanks to the option "/TraceEnable"

    Next, clear your trace buffer with Trace.Init, run your code until it hits your breakpoint and open Trace.STATistic.sYmbol Count /CountALL, which shows you how often your function was called. Ensure that (even with the active filter) your trace buffer does not overflow while your application is running.


    If you can't use the on-chip trace you could create a variable e.g. with Var.NEWGLOBAL int \count=0 and set a breakpoint on your function's entry which increments the counting variable every time the breakpoint gets hit. E.g. like this: Break.set myFuncName /CMD "Var.ASSIGN \count++" /RESUME . Watch the counting variable with Var.View %e \count.