Author Topic: Code::Blocks 12.11 GDB Segfault On Breakpoint  (Read 7452 times)

Offline Dark Fire

  • Single posting newcomer
  • *
  • Posts: 2
Code::Blocks 12.11 GDB Segfault On Breakpoint
« on: March 20, 2013, 03:03:55 am »
Okay, I've been battling this problem for a few days. I installed Code::Blocks 12.11 and discovered it segfaulted on breakpoint when debugging. A rudimentary google search linked me here to a thread that indicated the problem was due to GCC optimizing out strings and whatever. Can't find any arguments to pass to GCC to cease this behaviour, so I went with the thread and set out to install Pretty Printers using the guide on the C::B wiki.

After extracting MinGW-Builds over the CodeBlocks MinGW, it started complaining about the target not being compatible with x86-64 or whatever, so I set it to build with the i686 target. It then compiled, and it ran with the debugger! Yay! But then when I put in breakpoints, the debugger seems to effectively crash on the breakpoint. It comes with this output:

Quote
[debug]Command-line: C:\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/Users/Hayley/Documents/CodeBlocks/StringTest/bin/Debug/StringTest.exe
[debug]Working dir : C:\Users\Hayley\Documents\CodeBlocks\StringTest

Starting debugger: C:\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/Users/Hayley/Documents/CodeBlocks/StringTest/bin/Debug/StringTest.exe
done

[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!

Setting breakpoints

[debug]Reading symbols from C:\Users\Hayley\Documents\CodeBlocks\StringTest\bin\Debug\StringTest.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.5.1
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]For bug reporting instructions, please see:
[debug].
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.5.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Users/Hayley/Documents/CodeBlocks/StringTest/
[debug]Source directories searched: C:/Users/Hayley/Documents/CodeBlocks/StringTest;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Users/Hayley/Documents/CodeBlocks/StringTest/main.cpp:20"
[debug]Breakpoint 1 at 0x40139b: file C:\Users\Hayley\Documents\CodeBlocks\StringTest\main.cpp, line 20.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Users\Hayley\Documents\CodeBlocks\StringTest\bin\Debug\StringTest.exe

Child process PID: 10720

[debug][New Thread 10720.0x2818]
[debug]Do you need "set solib-search-path" or "set sysroot"?
[debug]Do you need "set solib-search-path" or "set sysroot"?
[debug]Do you need "set solib-search-path" or "set sysroot"?
[debug]Do you need "set solib-search-path" or "set sysroot"?
[debug]Program received signal ?, Unknown signal.
[debug]0x0008de08 in ?? ()
[debug]>>>>>>cb_gdb:

What's going on?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code::Blocks 12.11 GDB Segfault On Breakpoint
« Reply #1 on: March 20, 2013, 03:42:51 am »
Code
This GDB was configured as "x86_64-w64-mingw32".
It looks like you are using a 64bit version of GDB, right?
What's your compiler log?
Did you build a 64bit exe?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Dark Fire

  • Single posting newcomer
  • *
  • Posts: 2
Re: Code::Blocks 12.11 GDB Segfault On Breakpoint
« Reply #2 on: March 20, 2013, 03:59:18 am »
Yeah, I presume MinGW-Builds is 64-bit, so it would make sense that the GDB is also 64-bit.

Compiler log:
Quote
mingw32-g++.exe -Wall -fexceptions  -g    -I"C:\Program Files (x86)\CodeBlocks\DevPaks\include" -IC:\MinGW\include  -c C:\Users\Hayley\Documents\CodeBlocks\StringTest\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LC:\MinGW\lib\boost -LC:\MinGW\lib\sdl  -o bin\Debug\StringTest.exe obj\Debug\main.o   
Output size is 956.11 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings (0 minutes, 1 seconds)
Presume that's 32-bit. Sending "show archi" to GDB returns (Currently i386), though, so is that really an issue?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code::Blocks 12.11 GDB Segfault On Breakpoint
« Reply #3 on: March 20, 2013, 04:29:58 am »
Yeah, I presume MinGW-Builds is 64-bit, so it would make sense that the GDB is also 64-bit.
MinGW-Builds sites supply both 32bit and 64bit compiler suites.

Quote
Presume that's 32-bit. Sending "show archi" to GDB returns (Currently i386), though, so is that really an issue?
I'm not sure whether a 64bit GDB can debug a 32bit app, I suggest you run the same steps in the Command line. If it also crash there, then you can report the bug to GDB or MinGW-Builds, as it is not related to C::B.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Grad

  • Single posting newcomer
  • *
  • Posts: 9