Hot!Debugger displays wrong values for variables...

Author
roujesky
Junior Member
  • Total Posts : 116
  • Reward points : 0
  • Joined: 2008/08/12 13:04:59
  • Location: 0
  • Status: offline
2018/02/03 21:36:50 (permalink)
0

Debugger displays wrong values for variables...

Debugging a pic32MX795 chip using MPLAB X 4.05. Language is C hosted on Windows 10 pro with terabytes of free disk space and 32gb ram.
It seems that when I hover over variables , the debugger displays the wrong value. Sometime a really big number or really big negative value (around -2 billion or 2 billion), yet, I am sure the values are really correct because the variables make the program behave correctly.  For instance,
if(x==3)
   dothis();
else
   dothat();
 
when I hover over x, the value shows huge, yet the debugger will step and execute dothis().   Basically, the debugger seems to be lying to me...
 
Any ideas on what I have set up wrong?
 
thanks!
 
 
 
 
 
#1

13 Replies Related Threads

    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/03 22:09:57 (permalink)
    0
    You need to show all your code.
    Chances are the code has been optimised, and the variable doesn't really exist.
    You can force it to exist by adding the "volatile" qualifier to the variables definition, but that can also make your code slower and clunkier.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #2
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/04 07:02:33 (permalink)
    0
    Hi,
    I also have sen this on occasions.
    I always relies on the Watch window and if I still have a doubt I use the Memory display of the RAM area.
    Hovering may have an issue with "interpretation" of the variable type...
    Regards
     
    #3
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/05 08:08:46 (permalink)
    0
    It is kind of weird.  I am running MplabXIDE 4.05, 4.01 and 3.30.  I am using c32.   I strongly suspect it is a configuration/properties thing.  I have an older win7 machine that it works perfectly on.  But 2 different windows 10 pro machines it does not.   It really does rock my world because I don't trust anything I see.   Can it be a file permissions thing since it works on win7 home, but windows 10 pro it does not?  
    I really hope someone can give me the silver bullet...  :(
     
    thanks!
    #4
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/10 12:46:52 (permalink)
    0
    Sorry late getting back, been distracted with other projects...
    I am actually using XC32 1.31 not c32.  Optimization is set to 0.
    The application is rather extensive , so here is a bit of the code:
     
      int nStatus ;
       for (;;)
        {

            startTime = xTaskGetTickCount();
            //printf(".");
            SetLEDStatusGreen();
            nDistance = ReWindRunningAVG(GetDistance(REWIND_MOTOR, &nStatus));
            if(nStatus != 0)
            {
                //not communicating with Gesture re-init
                stopREWINDMotor(REWIND_MOTOR);
                nSampleCount = 0 ;            
                initREWINDGesture();
                vTaskDelay(10 / portTICK_RATE_MS);

                //after initializing, read it again to get a good value
                nDistance = ReWindRunningAVG(GetDistance(REWIND_MOTOR, &nStatus));
                
            }
            SetLEDStatusGreen();

    I have attached a picture of my screen which shows the hover values.
    Take a look at nStatus variable.  it checks for 0.  If it is not 0 it executes the code in the parenthesis.  You can see it displays 1A0F.  Yet, stepping it skips all the code in parenthesis.  For the record, nStatus  REALLY is 0.  I step thru the call and it does return 0...
    Hmmmm...   Looking at this again, the address and nStatus are SUSPICIOUSLY similar....Also, this happens everywhere in this application!  floats display bizarre values, but when printed to a console (DBPrintf), they are appropriate.
    I just downloaded MPLabX 4.10 and behavior is the same. :(
    Anybody have any ideas??
     
    thanks!
     
     
     
     

    Attachment(s)

    Attachments are not available: Download requirements not met
    #5
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/10 14:28:36 (permalink)
    0
    Hi,
    did you try to put this variable in the watch window ?
    Have you tried to declare a pointer to nStatus ?
    Regards
     
     
    #6
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/10 14:50:43 (permalink)
    0
    I forgot to mention that it displays incorrectly in the watch window.
    also, I have an even simpler picture.  I broke at wasRunning = false.  you can see as the red line.  stepped to the current line, green.  Looking at the hover, it is COMPLETELY unitialized!  UGH!!!
    I never had these problems in MPLab8.
     
    thanks!!

    Attachment(s)

    Attachments are not available: Download requirements not met
    #7
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/11 10:07:17 (permalink)
    0
    Hi,
    Remember that the green line shows the line of code which will be executed when you restart.
    than line is not yet executed.
    Regards
    #8
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/11 11:03:45 (permalink)
    0
    Hi RISC:
    Understood, but you can see that the variable is not set, even though it was explicitly set to false....  :(
    #9
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/11 11:10:23 (permalink)
    0
    Hi,
    Did you define false in your project ?
    Regards
     
    #10
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/11 11:46:49 (permalink)
    0
    yes
     #define FALSE  ((BOOLEAN)0)
     
    the key is that it is ALL variables display as junk.  I have the optimization set to '0'.  I don't understand.  Not sure what happened, it works fine on my old windows 7 home, but I moved the project to my neat new windows 10 pro with gobs of diskspace and RAM and this happens.
    Is there a specific scratch file or something that has wrong permissions?  
    I am at a loss.  HELP!
     
    thanks!
    #11
    D.Balazs
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/03/12 05:56:20
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/13 00:11:44 (permalink)
    +1 (1)
    Hello all,
    I have the same issue with MPLAB X 4.10, XC8 1.45 and ICD4. First I though that ICD4 is the fault, it's not reading out correctly the memory of the PIC, but afterwards I realized that the PC has Win10 PRO and might be the same issue. Global variables are shown ok, but when entering a function the stack local variables have dummy data, or at least this is what is shown in the variables/watches window. Tried declaring volatile, even static but still didn't get any improvements. I've taken out the optimization and still it's bad. Could be the windows 10 pro issue or is it the MPLAB X or ICD4.
    Thanks.
    #12
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/13 15:55:46 (permalink)
    0
    D.Balazs, I am really glad you chimed in on this!  I was feeling like I am the lone ranger with this problem.  I agree that it may be a windows 10 pro thing.   So, I am spinning up a win 7 VM to see.   I will let you know what I discover....
     
    #13
    roujesky
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2008/08/12 13:04:59
    • Location: 0
    • Status: offline
    Re: Debugger displays wrong values for variables... 2018/02/13 20:50:59 (permalink)
    0
    Well, i spun up a windows 7 VM to run on my win 10 pro laptop and it still displayed garbage in the hover :(
    I am out of ideas....
     
    #14
    Jump to:
    © 2018 APG vNext Commercial Version 4.5