1

視窗7 64位,Visual Studio 2010中,控制檯C++應用程序,Win 32調試配置:不正確的調試

 
#include "stdafx.h" 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    char* p = NULL; 
    *p = 1; 
    return 0; 
} 

開始調試。很顯然,我得到這個錯誤messsge:

 
Unhandled exception at 0x77d915de in test.exe: 0xC0000005: Access violation writing location 0x00000000. 

我選擇調試,看看下面的堆棧:

 
ntdll.dll!77d915de()  
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
ntdll.dll!77d915de()  
ntdll.dll!77d8014e()  
msvcr100d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 504 + 0xc bytes C++ 
>ffffffff() 

中斷調試在dbgheap.c __finally線。堆棧已損壞,堆棧中缺少*p = 1行。輸出窗口:

 
'test.exe': Loaded 'C:\tmp\test\Debug\test.exe', Symbols loaded. 
'test.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file 
'test.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file 
'test.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file 
'test.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded. 
First-chance exception at 0x010f13a8 in test.exe: 0xC0000005: Access violation writing location 0x00000000. 
Unhandled exception at 0x77d915de in test.exe: 0xC0000005: Access violation writing location 0x00000000. 

現在,如果我在64 Debug配置運行同一程序,一切都OK了 - 上線*p = 1中斷調試。我怎樣才能得到正確的調試Win32程序?

回答

3

調試 - >者除外>的win32 Exception-> 0000005蜱在TEST2 0x00041378在「拋出該異常」欄或整個爲Win32異常的「拋出該異常」列http://msdn.microsoft.com/en-us/library/038tzxdw(v=vs.100).aspx

*p = 1; 
00041375 mov eax,dword ptr [p] 
00041378 mov byte ptr [eax],1 

第一次機會異常的框.exe:0xC0000005:訪問衝突寫入位置0x00000000

+0

謝謝,這個伎倆。有趣的是,爲什麼它沒有對x64進行這種更改? –

+0

可能通過設計,Visual Studio Debugger Team必須知道,[Connect for Site for Visual Studio](http://connect.microsoft.com/VisualStudio) – sergmat