gdb: SIGTRAP on std::string::c_str() call

Posted by sheepsimulator on Stack Overflow See other posts from Stack Overflow or by sheepsimulator
Published on 2010-05-15T16:08:38Z Indexed on 2010/05/15 16:14 UTC
Read the original article Hit count: 301

Filed under:
|
|
|

So I've been trying to use gdb to return the value of a string I have by calling

> print <member variable name>.c_str()

But everytime I do so, I get this:

Program received signal SIGTRAP, Trace/breakpoint trap.
<some address> in std::string::c_str() from /usr/lib/libstdc++.so.6
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (std::string::c_str() const) will be abandoned.

Two questions:

  1. Why/how is the standard library throwing SIGTRAP? I checked basic_string.h and c_str() is defined as:

    const _CharT* c_str() const { return _M_data(); }

I don't see any SIGTRAP-throwing here... is there a way to get around this SIGTRAP?

  1. How can I read the text value of the std::string out (without getting some crazy extension library) in gdb?

© Stack Overflow or respective owner

Related posts about gdb

Related posts about c++