* Re: a question about gdb and simulator [not found] <F84byfA34cnFqUob5MF00027426@hotmail.com> @ 2003-02-27 16:36 ` Andrew Cagney 2003-02-27 18:04 ` Problems outputting a string jacques 0 siblings, 1 reply; 4+ messages in thread From: Andrew Cagney @ 2003-02-27 16:36 UTC (permalink / raw) To: liu lijuan; +Cc: gdb >> >>Assuming you have the GDB sources in front of you, look at the file >>"src/include/gdb/remote-sim.h". It defines the GDB-SIM interfaces that >>GDB currently uses. >> >>Also, I'd not dismiss the "remote" method. Some simulators use that >>interface as well. > >> >Andrew > Thank you very much! It is very important to us. But I have some questions > on remote debugging. Does it include the debugging of built-in cpu simulator > by inputting "target sim" and the debugging using remote serial protocol to > communicate by inputting "target remote xxxx"? If the simulator is not built-in, you would any of: (gdb) target remote host:port (gdb) target remote |simulator (gdb) target extended-remote <same-choices> The option `|simulator' is probably the most useful. It talks remote protocol on stdin/stdout. Andrew ^ permalink raw reply [flat|nested] 4+ messages in thread
* Problems outputting a string 2003-02-27 16:36 ` a question about gdb and simulator Andrew Cagney @ 2003-02-27 18:04 ` jacques 2003-02-27 18:14 ` jacques 0 siblings, 1 reply; 4+ messages in thread From: jacques @ 2003-02-27 18:04 UTC (permalink / raw) To: gdb [-- 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problems outputting a string 2003-02-27 18:04 ` Problems outputting a string jacques @ 2003-02-27 18:14 ` jacques 2003-02-27 19:27 ` Daniel Jacobowitz 0 siblings, 1 reply; 4+ messages in thread From: jacques @ 2003-02-27 18:14 UTC (permalink / raw) To: gdb; +Cc: gdb [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=GB2312, Size: 1425 bytes --] woops, had the gdb output paste wrong, here it is(everything else was correct): bash-2.05b$ gdb tetete.o GNU gdb 5.3 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... (gdb) b 7 Breakpoint 1 at 0x80486ad: file /home/palomer/tetete.cpp, line 7. (gdb) r Starting program: /home/palomer/tetete.o Breakpoint 1, foo() () 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 "T\233\004\ba"+$@?¡Ây"?\035\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) --Jacques ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problems outputting a string 2003-02-27 18:14 ` jacques @ 2003-02-27 19:27 ` Daniel Jacobowitz 0 siblings, 0 replies; 4+ messages in thread From: Daniel Jacobowitz @ 2003-02-27 19:27 UTC (permalink / raw) To: jacques; +Cc: gdb On Fri, Feb 28, 2003 at 01:13:19PM -0500, jacques wrote: > woops, had the gdb output paste wrong, here it is(everything else was > correct): > > > bash-2.05b$ gdb tetete.o > GNU gdb 5.3 > Copyright 2002 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and you are > welcome to change it and/or distribute copies of it under certain > conditions. > Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for details. > This GDB was configured as "i686-pc-linux-gnu"... > (gdb) b 7 > Breakpoint 1 at 0x80486ad: file /home/palomer/tetete.cpp, line 7. > (gdb) r > Starting program: /home/palomer/tetete.o > > Breakpoint 1, foo() () 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 > "T\233\004\ba"+$@?÷y"?\035\205\004\bT_\022@a"+$@?÷y"?d\n\023@\ > 001"}, static _S_empty_rep_storage = {0, 0, 0, 0}} The short version: If you get a CVS snapshot of GDB (see http://sources.redhat.com/gdb/ for how to get one) this will be fixed. The long version, for the curious: The debug info for ret says: <2><bdba>: Abbrev Number: 107 (DW_TAG_variable) DW_AT_name : ret DW_AT_decl_file : 1 DW_AT_decl_line : 5 DW_AT_type : <7759> DW_AT_location : 3 byte block: 91 8 6 (DW_OP_fbreg: 8; DW_OP_deref; ) Note the DW_OP_deref at the end. decode_locdesc et al. support arguments which are frame-base relative and passed by reference, but not variables which are stored by reference. Oops. However, LOC_COMPUTED handles this perfectly gracefully. It would make a great test-case; I'll add it later. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-02-27 19:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <F84byfA34cnFqUob5MF00027426@hotmail.com>
2003-02-27 16:36 ` a question about gdb and simulator Andrew Cagney
2003-02-27 18:04 ` Problems outputting a string jacques
2003-02-27 18:14 ` jacques
2003-02-27 19:27 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox