1

I am trying to figure out why a program I am using is hanging.

I initially thought the problem was "solved" by running it through GDB but I am getting the exact same symptoms as before - is there any way I can send a signal or something to GDB to print off the stack trace so I can try to see what is happening?

I am using FreeBSD-9.0.

javanix
  • 1,270
  • 3
  • 24
  • 40
  • You can attach `gdb` to a running process with `gdb program pid` . D you try that? – Basile Starynkevitch Jul 23 '12 at 16:15
  • I've already attached it - I ran my program with the command "gdb myprogram" and it is hanging while running "within" gdb. I'm looking for some sort of interactive gdb command to just spit out line numbers/stack/etc. – javanix Jul 23 '12 at 16:16
  • Or use `gcore(1)` http://www.freebsd.org/cgi/man.cgi?query=gcore&sektion=1 – Nikolai Fetissov Jul 23 '12 at 16:16
  • Of course, the program doesn't hang at all if I run it through [truss](http://www.unix.com/man-page/FreeBSD/1/truss/). – javanix Jul 23 '12 at 17:55

2 Answers2

2

You can interrupt a running process within GDB by simply pressing Control-C.

You can then get a backtrace with the backtrace command.

ams
  • 24,923
  • 4
  • 54
  • 75
1

I ended up getting a backtrace by creating a coredump using gcore(1) and then starting myprogram with the coredump created in GDB.

javanix
  • 1,270
  • 3
  • 24
  • 40