Safety-certified tools Tools for Automotive Applications C-STAT Static analysis C-RUN Runtime analysis Debugging and trace probes Build tools for Linux
In an application where some variables have the same name, it might be difficult to set a breakpoint for those variables.
Setting a breakpoint for a variable, using a C-SPY macro or in the Watch window, might fail. One possible reason for this is that C-SPY finds multiple variables with the same name. This technical note gives advice for this situation.
Use a specified reference that includes information about the location of the symbol. The syntax for a symbol location is:
Here follow five examples.
If the files main.c and test.c contain a static global (file global) variable called testvar, the syntax to use in the Watch window is:
If the file main.c contains a function called testfunc with a local variable called testvar, the syntax to add this variable to the Watch window is:
As long as function names are unique, main\ should be redundant. When debugging with extra image, debug information function names might not be unique. In such cases, it makes sense to use unique module names.
When using C-SPY macros (like __setSimBreak), the backslash ( \ ) needs to be protected with an extra backslash. For example:
__setSimBreak("main\\testvar", "R", "Do_the_testvar_Read_action()");
In the archive, there are four pictures that illustrate how C-SPY handles the situation:
When names are identical, there is a risk for a syntax error. If there are:
The reference t0\t will produce:
[syntax error, unexpected BACKSLASH, expecting COLON2]
Some alternatives (with different limitations/drawbacks) are:
By informing C-SPY about Module, Function and Symbol names, it becomes possible to reference one out of several variables using the same name.
In the Debugging guide there are more examples under the heading C-SPY EXPRESSIONS.
All product names are trademarks or registered trademarks of their respective owners.