2009年11月18日

Visual Studio C Command Line Debugging

Visual Studio Express Editions
Install Debugging Tools for Windows 32-bit Version
//-- src/hello.c --
#include
void main(void){
printf("hello world\r\n");
}

//-- makefile --
debugPath=Debug

all:
cl /Zi src\hello.c /Fo$(debugPath)\hello.obj /Fe$(debugPath)\hello.exe

clean:
del $(debugPath)\hello.* *.pdb

debugging:
cdb -lines -y .;$(debugPath) -c "~*kb;t;t;p;g;q" $(debugPath)\hello.exe

Start Menu->programs->Microsoft Visual C++ 2008 Express Edition->
Visual Studio Tools->Visual Studio 2008 Command Prompt
set PATH=%PATH%;C:\Program Files\Debugging Tools for Windows (x86)
nmake all
nmake debugging
nmake clean


>nmake all

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

cl /Zi src\hello.c /FoDebug\hello.obj /FeDebug\hello.exe
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

hello.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

/debug
/out:Debug\hello.exe
Debug\hello.obj

>nmake debugging

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

cdb -lines -y .;Debug -c "~*kb;t;t;p;g;q" Debug\hello.exe

Microsoft (R) Windows Debugger Version 6.11.0001.404 X86
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: Debug\hello.exe
Symbol search path is: .;Debug
Executable search path is:
ModLoad: 00400000 00426000 hello.exe
ModLoad: 7c920000 7c9b7000 ntdll.dll
ModLoad: 7c800000 7c91f000 C:\WINDOWS\system32\kernel32.dll
(1010.a60): Break instruction exception - code 80000003 (first chance)
eax=00241eb4 ebx=7ffdf000 ecx=00000001 edx=00000002 esi=00241f48 edi=00241eb4
eip=7c92120e esp=0012fb20 ebp=0012fc94 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202
*** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll -
ntdll!DbgBreakPoint:
7c92120e cc int 3
0:000> cdb: Reading initial command '~*kb;t;t;p;g;q'

. 0 Id: 1010.a60 Suspend: 1 Teb: 7ffde000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
0012fc94 7c9410af 0012fd30 7c920000 0012fce0 ntdll!DbgBreakPoint
0012fd1c 7c92e457 0012fd30 7c920000 00000000 ntdll!RtlLookupElementGenericTable+0x80
00000000 00000000 00000000 00000000 00000000 ntdll!KiUserApcDispatcher+0x7
hello world
quit:

>nmake clean

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

del Debug\hello.* *.pdb

沒有留言:

網誌存檔