Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i place a break point with logical condition in Trace 32

I want to set a break point, which stops my application when two variables contain a certain value. E.g. Stop execution when both x==10 and y==11.

How can I achieve that in Lauterbach TRACE32?

like image 342
Yeswanth Prabhat Kumar Avatar asked Jun 29 '17 05:06

Yeswanth Prabhat Kumar


1 Answers

The command Var.Break.Set has an option \VarCONDition, which allows you to specify a condition under which the CPUs stays stopped once it hits the corresponding breakpoint. (In the dialog for setting breakpoints you'll find also the field "Condition" for that, when you click on "advanced".)

So for you scenario the required two commands would be:

Var.Break.Set x /Write /VarCONDition (x==10 && y==11) 
Var.Break.Set y /Write /VarCONDition (x==10 && y==11) 

As a result the CPU is stopped on every write to x or y, but gets immediately restarted when condition "x==11 && y==11" is not met.

Of course x and y must be located in memory. It won't work if the variable is implemented in a CPU register (unless you have one of these rarer CPU, that supports read/write breakpoints on core registers.)

In case you are using a Cortex-A or Cortex-R CPU you must also add the option "/AfterStep" since these processors have a break-before-make behavior also for address-write-breakpoints.

If your CPU supports data value breakpoints (e.g. Cortex-M4) you can set the breakpoints also like this

Var.Break.Set x /Write /DATA 10. /VarCONDition y==11 
Var.Break.Set y /Write /DATA 11. /VarCONDition x==10. 

This is much better since it only stops the CPU when the correct value is written to x or y and stays stopped if also the other variable has the correct value.

like image 74
Holger Avatar answered Oct 04 '22 23:10

Holger