Mick
Mick

Reputation: 7937

Program ends abruptly even in debugger - how did that happen?

I am trying to debug a program that unexpectedly shuts down. When I say "shuts down, I mean one moment I am seeing all the windows being displayed, each of which is showing all the right data,then suddenly all the windows disappear. The is no messagebox reporting anything wrong. So I tried running the program in the debugger hoping that it would somehow trap whatever was causing the program to abort, but even within the debugger the program simply ends abruptly. The last line in the debugger is:

The program '[5500] test.exe: Native' has exited with code 0 (0x0).

My program, which is extremely large and extremely old, has a lot of self diagnostics. My suspicion is that perhaps a self test has failed and maybe I just called "exit()", forgetting to pop up a dialog explaining why.

My question now is, how can I find out from which point in the code, my program quit?

Upvotes: 8

Views: 2464

Answers (2)

Potatoswatter
Potatoswatter

Reputation: 137810

Marcelo's answer is great. If for some reason you can't break on exit, install a function (takes no arguments, returns void) with atexit and break inside that.

Upvotes: 4

Marcelo Cantos
Marcelo Cantos

Reputation: 185852

Set a breakpoint on exit() and terminate() (maybe one calls the other, but I'm not sure).

Upvotes: 6

Related Questions