Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12692 Discussions

Nios II Eclipse Variable Watchpoint Not Working

Altera_Forum
Honored Contributor II
1,819 Views

I have never been able to get variable watchpoints to work correctly. For example, I have a function something like 

 

int run_test() 

 

int retval = 0; 

 

if(a)  

retval = 1; 

 

if(!b) 

retval = 1; 

 

if(b && c) 

retval = 1; 

 

return retval; 

 

 

In Eclipse, if I put a watchpoint on retval and check the Write box, I expect the program to stop any time retval is written. However, I often get to the bottom of the function, retval has been written to a 1, and the program never stopped to tell me where it was happening. Has anyone else had this problem, and is there maybe some setting I'm missing? Thanks.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
532 Views

You need to be using one of the more advanced version of the Nios core.  

 

On the page where you select the level of pipelining, MMU, and other such things, I think there is a description that says which versions support variable watch points. Select that and I think it will work.
0 Kudos
Altera_Forum
Honored Contributor II
532 Views

Data watchpoints won't work on items that the compiler assigns to a register, only on writes to real memory. 

Even without the optimiser it is possible that 'retval' doesn't exist as a memory item (or at least the allocated item isn't used. 

If you move 'retval' outside the function and define it as 'volatile int retval' then the writes are required to be generated and the watchpoint should trap.
0 Kudos
Altera_Forum
Honored Contributor II
532 Views

Those are both excellent answers. Thank you, I will look into it.

0 Kudos
Reply