This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

why so


Hello gdb list,

I am stuck with debugging C++ application that uses STL.
So, i have a simple code:

#include <iostream>

static int
test(std::string s)
{
    std::cout << s << std::endl;
    return 0;
}

int main(int argc, char **argv)
{
    std::string a = "hello";
	
    test(a);
    return 0;
}

while debugging *test* function, i try to print s variable and
i see following stauff, thought i expect to see "hello":

    (gdb) print s.c_str()
    $2 = 0xbf9486d8 "\024pR\b"

gdb version is:

    demon >>> gdb -v
    GNU gdb 6.8-debian
    Copyright (C) 2008 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "i486-linux-gnu".
    demon >>>

thanks in advance.

--
Uladzislau Rezki


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]