This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uVision3/ARM watch window bug...?

The uVision3 IDE watch window shows the value of pString incorrectly (when stopped on a breakpoint in the "bug" function), unless pString is actually referenced in the function (by, for example, uncommenting the line "pString[0] = 0"). This is true even if the code optimizations are set to the lowest level possible.

#include <string.h>

int bug(int *nState,char *pString)
{
    *nState = 0;
//    pString[0] = 0;
    return(0);
}

void main(void)
{
    int foo = 0;
    char *bar;
    char s[] = "KEIL uVision3 for ARM\r";
    bar = s;
    bug(&foo,bar);
    while(1);
}

Please spare me from comments about not passing parameters to functions if you're not going to reference them, etc. I discovered this bug while testing some code I was prototyping, before the code actually used the parameter passed to it. I'm just trying to give some feedback to the KEIL folks so that they know about this bug.

Parents
  • I've seen this as well. It looks to me as though the variables in the watch window are linked to the register where the value is/will be stored. I've seen that when the variable is actually used that the compiler will copy the value to another register. This register is the one that the watch window references when displaying the value.

    In the case of your example, the *nState pointer's value it probably passed in as register 0, and the *pString pointer is probably passed in as register 1. Since *nState is used, a copy is put in another register (register 3 or 4 maybe). After this local copy is made, the value of *nState can be seen in the watch window. Since *pString is not used, a local copy is not made and the watch window has not register to use to display the value.

    You can however still look as the register used to passed in the variable to determine if the correct value is passed.

Reply
  • I've seen this as well. It looks to me as though the variables in the watch window are linked to the register where the value is/will be stored. I've seen that when the variable is actually used that the compiler will copy the value to another register. This register is the one that the watch window references when displaying the value.

    In the case of your example, the *nState pointer's value it probably passed in as register 0, and the *pString pointer is probably passed in as register 1. Since *nState is used, a copy is put in another register (register 3 or 4 maybe). After this local copy is made, the value of *nState can be seen in the watch window. Since *pString is not used, a local copy is not made and the watch window has not register to use to display the value.

    You can however still look as the register used to passed in the variable to determine if the correct value is passed.

Children
No data