Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When calling a function in debug mode, GDB is crashed

I'm trying to make a c++ program on Windows using MinGW.

The built program runs fine, Nevertheless, the problem occurs while debugging.

When debugging, If I try to inspect a execution result of function or method, like screenshots below, GDB is forced terminated.

I've ran GDB as a command line, the result has been the same though.

I also changed MinGW to different version, but to no avail.

GDB on WSL is working fine without any problems by the same configurations.

It's not working only on native Windows.

I would appreciate if you let me know why.


Just before watching "add(2, 3)".

ERROR: GDB exited unexpectedly. Debugging will now abort.


The same result of GDB command line.
"p v[1]", "p v.at(1)", "p v.empty()", "p v.size()", ... were failed,
"p add(2, 3)", "p my_obj.func()", ... were crashed.


G++ version is 8.1.0
gdb version is 8.1

like image 942
ias Avatar asked Jan 10 '20 08:01

ias


Video Answer


1 Answers

It seems to be a bug with GDB bug info and seems to be reproduceable with:

  • set up 64-bit MinGW environment
  • compile and link a simple hello world c++ console application with gcc (also versioned 8.1.0)
  • start debugging EXE file with gdb
  • set breakpoint for instance on the main function (b main)
  • run info registers command (i r)
  • Debugger now unexpectedly quits and returns you to the command line.

If the website shows the correct information it seems like no one is currently working on it, but changing GDB version from 32-bit to 64-bit might resolve it.

like image 74
darclander Avatar answered Oct 02 '22 15:10

darclander