wrong variable value from debugger on x64

This is a discussion on wrong variable value from debugger on x64 within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone, The command dv is not print the correct value for input parameters? Here is my WinDbg debug on ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    wrong variable value from debugger on x64

    Hello everyone,


    The command dv is not print the correct value for input parameters? Here is my WinDbg debug on x64 platform and source code. Any ideas about how to retrieve the correct value?

    Code:
    0:000> bp foo
    0:000> bl
     0 e 00000001`40001020     0001 (0001)  0:**** Test64bitDebug!foo
    0:000> g
    Breakpoint 0 hit
    Test64bitDebug!foo:
    00000001`40001020 89542410        mov     dword ptr [rsp+10h],edx ss:00000000`0012fea8=cccccccc
    0:000> dv
                  a = -858993460
                  b = -858993460
    
    
    int foo (int a, int b)
    {
    	return a+b;
    }
    
    int main()
    {
    	int a1 = 100;
    	int b1 = a1 + 100;
    
    	foo (a1, b1);
    
    	return 0;
    }

    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The value -858993460 is 0xCCCCCCCC, which is the standard fill pattern for "unused memory" in Visual Studio, so you are seeing the variable before it's been set. Possibly because the debugger is confused about where the variable actually resides, as argument passing x64 is register, but it may be (looking at the disassembly shown for your breakpoint, I think it's likely) that the debug version of code stores local variables on the stack to make them more easily debuggable. If you step a few instructions into the code, does it work better?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Static Local Variable vs. Global Variable
    By arpsmack in forum C Programming
    Replies: 7
    Last Post: 08-21-2008, 03:35 AM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  3. global and static variable in a class delivered in a DLL
    By George2 in forum C++ Programming
    Replies: 16
    Last Post: 04-13-2008, 08:19 AM
  4. How to set pointer for environment variable
    By spiky1 in forum C++ Programming
    Replies: 7
    Last Post: 08-18-2006, 05:19 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21