Author Topic: GDB Pause  (Read 6594 times)

Offline oZZ

  • Multiple posting newcomer
  • *
  • Posts: 30
GDB Pause
« on: February 11, 2007, 12:32:07 am »
Is there a way in C::B to pause an application running inside gdb to get the stack trace?

I can't even do it from the command line since control-C doesn't get passed from gdb to the application (in cmd.exe).  In other shells (rxvt/sh and bash) ctrl-c halts gdb itself.

I can get a stacktrace via procexp (XP version), but the symbols don't load correctly, so it's not exactly relevant.

I've seen posts on here of people who have gotten stacktraces of hanging (not crashed) apps, so I know there's a way.

Thanks
-Shawn.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2769
Re: GDB Pause
« Reply #1 on: February 11, 2007, 02:40:25 am »
Is there a way in C::B to pause an application running inside gdb to get the stack trace?

I can't even do it from the command line since control-C doesn't get passed from gdb to the application (in cmd.exe).  In other shells (rxvt/sh and bash) ctrl-c halts gdb itself.

I can get a stacktrace via procexp (XP version), but the symbols don't load correctly, so it's not exactly relevant.

I've seen posts on here of people who have gotten stacktraces of hanging (not crashed) apps, so I know there's a way.

Thanks
-Shawn.

Put an asm("int3"); statement in the program at the point you want to see the backtrace.
Run it under GDB or the CB debugger. You'll get a trap (sigint) at that instruction.

You can also make it conditional, eg, if (i<0) asm("int3");

From the point of the sigint, you can backtrace, step, continue, etc.

Be sure to remove it for release. A lot of us forget to take 'em out, and they cause real grief.
« Last Edit: February 11, 2007, 02:47:36 am by Pecan »

Offline oZZ

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: GDB Pause
« Reply #2 on: February 11, 2007, 03:35:28 am »
The problem is I don't know when I want to see the backtrace.  It's going into an infinite loop somewhere and I want to break when its in the loop.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2769
Re: GDB Pause
« Reply #3 on: February 11, 2007, 04:11:06 am »
The problem is I don't know when I want to see the backtrace.  It's going into an infinite loop somewhere and I want to break when its in the loop.

That is not possible under windows AFAIK.

Offline oZZ

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: GDB Pause
« Reply #4 on: February 11, 2007, 04:28:39 am »
Wow.. windows sucks ;)

Thanks for the help though!