Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Nios II Eclipse Variable Watchpoint Not Working

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.

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.