0

I compile C++ code with MinGW GCC on Windows. I'm currently dealing with a SIGSEGV that occasionally pops up in a multithreaded program, so I can't really step through the program with GDB like I normally would. I've read through program logs but they only gave me an idea as to where the problem happened.

Can I get a stack trace of where the problem occurred? I saw a similar thread here but since I don't have execinfo.h I cannot use it.

Community
  • 1
  • 1
Pieter
  • 31,619
  • 76
  • 167
  • 242

1 Answers1

1

You can run the program with gdb (command r). Where ever it crashes, you will get back to gdb and you can look at the stack trace and variables.

You may want to look at this also, or search for "gdb multithreaded".

Shahbaz
  • 46,337
  • 19
  • 116
  • 182
  • Is this equivalent to entering the `backtrace` command after a program caused a SIGSEGV? Cuz I just see some [vague unhelpful](http://pastebin.com/Bt3FGywD) stuff when I do that. – Pieter Jul 31 '12 at 17:24
  • Yes (`bt` for short). What you saw is due to stack corruption. You have written out of boundaries of some array, destroying function stack frames, so gdb is not able to recover the calling functions. Have you tried running it with `valgrind`? – Shahbaz Jul 31 '12 at 20:06
  • Is there a Windows version of `valgrind` now? Are there any Windows alternatives you can recommend? – Pieter Aug 01 '12 at 07:08
  • I'll try out some of the alternatives mentioned there. Thanks! – Pieter Aug 01 '12 at 11:33