0

这听起来很简单,但我就是无法让它工作。我安装了 Windows SDK 7.1 并打开了 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

就直接跑到了尽头,根本没有停下来。我什至没有机会设置断点...

我应该怎么办?

非常感谢大家。

4

1 回答 1

2

您为此目的使用了错误的工具。Mdbg(顾名思义)是一个托管调试器,因此它适用于 .NET 程序集,并且您正在尝试调试本机应用程序。我建议使用windbgcdb(如果您更喜欢命令行调试器)。这两种工具都可以在 Windows SDK 中免费使用 - 只需安装适用于 Windows 的调试工具。他们也有很好的文档。

于 2014-02-12T05:34:02.857 回答