User forums > Help
Watching std::string in debugger causes segfault?!?
MortenMacFly:
--- Quote from: ascholer on March 03, 2013, 12:49:53 am ---May just have to downgrade GCC version I provide.
--- End quote ---
Or look what GCC switch turn off such optimisations.
Jenna:
The funny thing is, that it does not crash (with watch scripts) on fedora 64-bit with gcc 4.7.2.
I don't know if it is gcc 4.7.2 or fedora/linux specific.
And on windows it also works fine with ollydbg's gdb with pretty printer enabled and TDM's gcc 4.7.1 shipped with C::B 12.11.
Folco:
I use gcc 4.7.2 too, from Linux Mint (from Ubuntu). It seems to work, if I did correctly the test case :
ollydbg:
--- Quote from: jens on March 03, 2013, 12:49:25 pm ---And on windows it also works fine with ollydbg's gdb with pretty printer enabled and TDM's gcc 4.7.1 shipped with C::B 12.11.
--- End quote ---
Well, I have different result. Today, I tried with my GDB and tdm's gcc 4.7.1sjlj. But I receive the segfault like:
--- Code: ---Selecting target:
Debug
Adding source dir: E:\code\cb\test_code\mortenr2012-01-15\
Adding source dir: E:\code\cb\test_code\mortenr2012-01-15\
Adding file: E:\code\cb\test_code\mortenr2012-01-15\bin\Debug\mortenr2012-01-15.exe
Changing directory to: E:/code/cb/test_code/mortenr2012-01-15/.
Set variable: PATH=.;E:\code\gcc\tdm471sjlj\bin;E:\code\gcc\tdm471sjlj;E:\code\gcc\PCXMinGW463\bin;E:\code\gcc\PCXMinGW463;E:\code\common_bin;D:\Program Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin;E:\code\opencv\2.4.3\mingw\bin
[debug]Command-line: E:\code\gcc\PCXMinGW463\bin\gdb.exe -nx -fullname -quiet -args E:/code/cb/test_code/mortenr2012-01-15/bin/Debug/mortenr2012-01-15.exe
[debug]Working dir : E:\code\cb\test_code\mortenr2012-01-15
Starting debugger: E:\code\gcc\PCXMinGW463\bin\gdb.exe -nx -fullname -quiet -args E:/code/cb/test_code/mortenr2012-01-15/bin/Debug/mortenr2012-01-15.exe
done
[debug]> set prompt >>>>>>cb_gdb:
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
[debug]Reading symbols from E:\code\cb\test_code\mortenr2012-01-15\bin\Debug\mortenr2012-01-15.exe...
[debug]done.
[debug](gdb)
[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.5.50.20130204-cvs
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[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 "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (GDB) 7.5.50.20130204-cvs
[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]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source E:\code\cb\CodeBlocksUnofficial\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> source E:\code\gcc\PCXMinGW463\bin\my.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory E:/code/cb/test_code/mortenr2012-01-15/
[debug]Source directories searched: E:/code/cb/test_code/mortenr2012-01-15;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/mortenr2012-01-15/main.cpp:10"
[debug]Breakpoint 2 at 0x4013af: file E:\code\cb\test_code\mortenr2012-01-15\main.cpp, line 10.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: E:\code\cb\test_code\mortenr2012-01-15\bin\Debug\mortenr2012-01-15.exe
Child process PID: 1964
[debug][New Thread 1964.0x94c]
[debug]Breakpoint 2, main () at E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10
[debug]E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10:111:beg:0x4013af
[debug]>>>>>>cb_gdb:
At E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10
[debug]> whatis s
[debug]type = std::string
[debug]>>>>>>cb_gdb:
[debug]> output s.c_str()[0]@s.size()
[debug]The program being debugged was signaled while in a function called from GDB.
[debug]GDB has restored the context to what it was before the call.
[debug]To change this behavior use "set unwindonsignal off".
[debug]Evaluation of the expression containing the function
[debug](std::string::size() const) will be abandoned.
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x004228da in std::string::size() const ()
[debug]>>>>>>cb_gdb:
[debug]> bt 30
Program received signal SIGSEGV, Segmentation fault.
In std::string::size() const () ()
[debug]> bt 30
[debug]#0 main () at E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10
[debug]>>>>>>cb_gdb:#0 main () at E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10
[debug]> whatis s
[debug]>>>>>>cb_gdb:
[debug]> output s
[debug]type = std::string
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]"asdfasdf">>>>>>cb_gdb:#0 main () at E:\code\cb\test_code\mortenr2012-01-15\main.cpp:10
[debug]>>>>>>cb_gdb:
.
--- End code ---
I try another newer build on GDB CVS 2013-03-02, but same segfault.
Jenna:
--- Quote from: ollydbg on March 04, 2013, 04:06:08 pm ---
--- Quote from: jens on March 03, 2013, 12:49:25 pm ---And on windows it also works fine with ollydbg's gdb with pretty printer enabled and TDM's gcc 4.7.1 shipped with C::B 12.11.
--- End quote ---
--- End quote ---
What I meant, was that I have used the pretty printer (watch-scripts disabled).
With the watch-scripts I get the segfault also.
With gdb from TDM and watch-scripts disabled I don't get the segfault, and the value is visible, but hidden in the deep of the string-structure.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version