2014-02-11 74 views
0

這聽起來很簡單,但我不能得到它的工作。我安裝了Windows SDK 7.1並打開了Windows SDK 7.1命令提示符。使用mdbg調試簡單的C代碼與Windows SDK 7.1

我有一個代碼,test.c的,如下:

#include <stdio.h> 
#include <math.h> 

void main() 
{ 
    int i; 
    for(i=1; i<10; i++) 
     printf("Hello world! This is line %d \n", i); 
} 

,現在我想調試它。我第一次使用它編譯:

cl test.c /Z7 

,然後打開:

mdbg test.exe 

接下來發生了什麼是:

MDbg (Managed debugger) v4.0.30319.1 (RTMRel.030319-0100) started. 
Copyright (C) Microsoft Corporation. All rights reserved. 

For information about commands type "help"; 
to exit program type "quit". 
run test.exe 
Hello world! This is line 1 
Hello world! This is line 2 
Hello world! This is line 3 
Hello world! This is line 4 
Hello world! This is line 5 
Hello world! This is line 6 
Hello world! This is line 7 
Hello world! This is line 8 
Hello world! This is line 9 
STOP: Process Exited 

它只是直接跑到終點,沒有停止在所有。我甚至沒有機會設置斷點...

我該怎麼辦?

非常感謝大家。

回答

2

您正在爲此使用錯誤的工具。 Mdbg(顧名思義)是管理的調試器,所以它可以與.NET程序集一起使用,並且您正在嘗試調試本機應用程序。我會推薦使用windbgcdb(如果你更喜歡命令行調試器)。這兩個工具都可以在Windows SDK中免費獲得 - 只需安裝Debugging Tools for Windows即可。他們也有很好的文檔。