Where in the source code should I debug a program as it exits?

  • Follow


MSVS 2005, Version 8
C/C++

I have a couple of programs that behave properly except at the end,
when they exit. One of them makes the failure sound and the debugger
displays exit code 0x3.

I come from the Unix world where it is very easy to determine where
the program begins (in main()) and where it ends. It is very confusing
in Windows.

I figured out that a way to debug a Windows program as it begins is
simply pressing F10.

TIA,

-Ramon

0
Reply ramon (1465) 8/22/2010 3:05:00 PM

It's impossible to guess but...

On Sun, 22 Aug 2010 08:05:00 -0700 (PDT), Ramon F Herrera
<ramon@conexus.net> wrote:

>
>MSVS 2005, Version 8
>C/C++
>
>I have a couple of programs that behave properly except at the end,
>when they exit. One of them makes the failure sound and the debugger
>displays exit code 0x3.

Are these console programs or win32 projects? If console, then main is
the start, and exit(n) or return 0 are the exits from main. 

If Win32 then your exit control points are the WM_DESTROY or IDM_EXIT
cases in the WndProc function both of them post messages to the main
message loop which will process the messages and finally exit the
program at the end of the WinMain or _tWinMain function with:

return (int) msg.wParam;

Set a breakpoint there and examine the call stack.

>
>I come from the Unix world where it is very easy to determine where
>the program begins (in main()) and where it ends. It is very confusing
>in Windows.
>
>I figured out that a way to debug a Windows program as it begins is
>simply pressing F10.

Set a breakpoint at your suspect exit points and see where the program
stops when you close it, then trace (f10) from there. 

Remember, Windows programs process messages, a clean exit from a
Windows program is to call PostQuitMessage(0), do not exit() or
ExitProcess().
0
Reply Geoff 8/22/2010 5:57:46 PM


On Aug 22, 12:57=A0pm, Geoff <ge...@invalid.invalid> wrote:

 > Are these console programs or win32 projects?

Win32. More specifically, MFC.

Thanks for your tips...

-Ramon

0
Reply Ramon 8/22/2010 6:25:05 PM

Are you trying to access files ? If I remember exit 3 has to do
with the pathname or something to that effect.
If so step thru that area.
0
Reply RB 8/28/2010 4:42:36 PM

3 Replies
196 Views

(page loaded in 0.159 seconds)

Similiar Articles:













7/16/2012 9:28:43 AM


Reply: