2014-02-11 47 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即可。他们也有很好的文档。