I’m working on a big app (ns2) and somewhere someone put an exit(1) in there without any debug or print statements and it is being executed. I don’t want to have to manually check every file that calls exit to figure out why the program is exiting. Is is possible to determine where the program exited? This is running on Linux and coded in C++. Is it possible to do something like this in gdb?
Share
Sure. Put a breakpoint at the start of exit(3). When it breaks, look at the stack.
Second choice, run it under truss(1) (I’m pretty sure there’s a Linux version of truss.)
Or strace(1).
Update
In fact, I ran across another method in another question: here’s a link.