Search code examples
armtrace32lauterbach

Using registers in break point conditions with Trace32


Trying to set break point at a specific location and set trigger condition that is based on the value of one of the registers e.g. R1 (Cortex-R family CPU).

Is there a way to do it in trace32? What is the syntax for condition?


Solution

  • You can also check register values in the condition of a breakpoint.

    However, please be aware that conditional breakpoints are always intrusive to the run-time behavior of your chip. That means that your target CPU will always stop at the breakpoint location, then the debuggers evaluates the condition and then restart the CPU, if the condition was not met. (Note, that "conditional breakpoints" are not the same than "data-breakpoints" (certain value written to certain location). Data-breakpoints are non-intrusive on a lot of chips (like your Cortex-R)).

    The basic trick is to use the PRACTICE function Register() to access a core-register.

    To set a program breakpoint, to stop on a certain program location and stay stopped, if a core-register contains a certain value, use one of the following commands:

    • Break.Set <prog.addr|symbol> /Program /CONDition Register(<reg.>)==<reg.value>
    • Break.Set <prog.addr|symbol> /Program /VarCONDition \Register(<reg.>)==<value>

    E.g.:

    • Break.Set P:0x1000 /Program /CONDition Register(R0)==0x42
    • Break.Set P:0x1000 /Program /VarCONDition \Register(R0)==0x42

    The difference between the two commands? The first one uses TRACE32 expressions, where symbols stand for their address (like the linker sees symbols). The second one uses so-called HLL expressions, where symbols stand for variables like in the C/C++ language. (HLL expr. == C-style expr.)

    Usually it is easier to write conditions in HLL expressions (especially when they deal with variables), while using PRACTICE functions is usually easier in TRACE32 expressions.

    You can also set the condition in the Break.Set dialog: Click on the button "advanced" and then your condition in the field "CONDition". The HLL checkbox on the right of the field "CONDition" defines if your using a HLL expression or not.