Question

This sounds really simple but I just can't get it to work. I installed the Windows SDK 7.1 and opened the Windows SDK 7.1 Command Prompt.

I have a code, test.c, as follows:

#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);
}

And now I want to debug it. I first compiled it using:

cl test.c /Z7

And then, opened:

mdbg test.exe

What happened next is:

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

It just directly ran to the end, without stopping at all. I don't even have a chance to set the breakpoints...

What should I do?

Thank you all so much.

Was it helpful?

Solution

You are using a wrong tool for this purpose. Mdbg (as its name suggests) is a managed debugger so it works with .NET assemblies and you are trying to debug a native application. I would recommend using windbg or cdb (if you prefer command line debuggers). Both tools are available for free in Windows SDK - just install Debugging Tools for Windows. They also have good documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top