Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: jacques <jacqueslenormand@sympatico.ca>
To: gdb@sources.redhat.com
Subject: Problems outputting a string
Date: Thu, 27 Feb 2003 18:04:00 -0000	[thread overview]
Message-ID: <3E5FA468.8090008@sympatico.ca> (raw)
In-Reply-To: <3E5E3F0D.1080308@redhat.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 1354 bytes --]

Hello
I'm having problems with my program. I've always been able to see
strings with gdb, but now I can't!
Here's my source:
#include <iostream>
#include <string>
using namespace std;
string foo(){
string ret;
ret = "lal";
return ret; //<ssbreak here
}
int main(){
cout << foo();
}

Here's the output:
lal


Here's gdb:


Breakpoint 1, firstAlpha() () at /home/palomer/tetete.cpp:7
7 return ret;
(gdb) p ret
$1 = {static npos = 4294967295,
_M_dataplus = {<allocator<char>> = {<No data fields>},
_M_p = 0xbffff7a0
"l\234\004\ba"+$@?¡Ây"??\205\004\bT_\022@a"+$@?¡Ây"?d\n\023@\001"}, static
_S_empty_rep_storage = {0, 0, 0, 0}}
(gdb) p ret.c_str()

Program received signal SIGSEGV, Segmentation fault.
0x400acf3c in std::char_traits<char>::assign(char&, char const&) ()
from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/libstdc++.so.5
The program being debugged was signaled while in a function called from GDB.
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.
(gdb)

Here are my compiler flags:
-ggdb -O0 -fno-inline

g++ version:
bash-2.05b$ g++ --version
g++ (GCC) 3.2.1 20021207 (Gentoo Linux 3.2.1-20021207)


gdb version:
bash-2.05b$ gdb --version
GNU gdb 5.3



any suggestions?
--Jacques


  reply	other threads:[~2003-02-27 18:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <F84byfA34cnFqUob5MF00027426@hotmail.com>
2003-02-27 16:36 ` a question about gdb and simulator Andrew Cagney
2003-02-27 18:04   ` jacques [this message]
2003-02-27 18:14     ` Problems outputting a string jacques
2003-02-27 19:27       ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E5FA468.8090008@sympatico.ca \
    --to=jacqueslenormand@sympatico.ca \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox