public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* C++ names in backtrace
@ 2007-11-30 10:38 Bobo
  2007-11-30 14:46 ` Daniel Jacobowitz
  2007-11-30 14:52 ` Paul Koning
  0 siblings, 2 replies; 8+ messages in thread
From: Bobo @ 2007-11-30 10:38 UTC (permalink / raw)
  To: gdb

Hello all,

I've got a question about gdb & its backtrace command.
When i have a breakpoint hit in gdb in my C++ application i want to see the 
call stack. Using backtrace command i get something like that:
(gdb) backtrace
#0  _ZN7WSLCLAG21select_actuator_parmsEi (this=0x1bc148, parms_set_id=0) at 
WSLCLAG.cpp:151
#1  0xff063fd8 in 
_ZN9WSLCLAGSS21select_actuator_parmsE36WSPIFACSS_actuator_parms_set_id_enum 
(this=0x1bc148,
     parms_set_id=WSPIFACSS_ACTUATOR_PARMS_SET_ID_NORMAL) at 
WSLCLAGSS.cpp:137
#2  0x0004a330 in _ZN12WSLCLAGSStst18test_select_paramsEv (this=0xa0784) at 
WSLCLAGtst.hpp:123
#3  0x00049e8c in 
_ZN47TestDescription_WSLCLAGSStst_test_select_params7runTestEv 
(this=0xa07f0)
     at WSAct_unit_tester.cpp:44
#4  0x00030e14 in _ZN7CxxTest19RealTestDescription3runEv (this=0xa07f0)
     at ../../../xinc/cxxtest/RealDescriptions.cpp:96
#5  0x0003e08c in _ZN7CxxTest10TestRunner7runTestERNS_15TestDescriptionE 
(this=0xffbfe25f, td=@0xa07f0)
     at ../../../xinc/cxxtest/TestRunner.h:74
#6  0x0003df04 in _ZN7CxxTest10TestRunner8runSuiteERNS_16SuiteDescriptionE 
(this=0xffbfe25f, sd=@0xa0794)
     at ../../../xinc/cxxtest/TestRunner.h:61
#7  0x0003dc78 in _ZN7CxxTest10TestRunner8runWorldEv (this=0xffbfe25f)
     at ../../../xinc/cxxtest/TestRunner.h:46
#8  0x0003daf0 in _ZN7CxxTest10TestRunner11runAllTestsERNS_12TestListenerE 
(listener=@0xffbfe348)
     at ../../../xinc/cxxtest/TestRunner.h:23
#9  0x0003da50 in _ZN7CxxTest14ErrorFormatter3runEv (this=0xffbfe348)
     at ../../../xinc/cxxtest/ErrorFormatter.h:47
#10 0x0002ed78 in main () at WSAct_unit_tester.cpp:20

The C++ names (classes & methods) are not really readable in this output 
(well i can derive them from the characters shown in gdb, but it takes me 
some mental effort and it's also error prone). I understand that the names i 
see are C++ mangled names.
However if i type in gdb l MyClass::my_function i get the correct names 
displayed. Also if i put a breakpoint in this function it gets hit. So gdb 
has some way to translate "human readable" C++ names into mangled onces.

My question:
- is there any way to let gdb display the real C++ names iso the mangled 
ones in commands like backtrace?

I'm using gdb >6.7.1 on SUN Solaris, i build my applications with gcc 3.x.
     



-----------
IRR.BY ('Èç ðóê â ðóêè – Îíëàéí') – êðóïíåéøèé â Áåëàðóñè 
ñàéò ÷àñòíûõ îáúÿâëåíèé. http://irr.by

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
  2007-11-30 10:38 C++ names in backtrace Bobo
@ 2007-11-30 14:46 ` Daniel Jacobowitz
  2007-11-30 14:52 ` Paul Koning
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-11-30 14:46 UTC (permalink / raw)
  To: Bobo; +Cc: gdb

On Fri, Nov 30, 2007 at 12:38:25PM +0200, Bobo wrote:
> - is there any way to let gdb display the real C++ names iso the mangled ones 
> in commands like backtrace?

It should happen automatically.  Did you use "set language c" maybe?

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
  2007-11-30 10:38 C++ names in backtrace Bobo
  2007-11-30 14:46 ` Daniel Jacobowitz
@ 2007-11-30 14:52 ` Paul Koning
  2007-11-30 15:03   ` Dima S
  1 sibling, 1 reply; 8+ messages in thread
From: Paul Koning @ 2007-11-30 14:52 UTC (permalink / raw)
  To: spiridenok; +Cc: gdb

>>>>> "Bobo" == Bobo  <spiridenok@tut.by> writes:

 Bobo> ...My question: - is there any way to let gdb display the real C++
 Bobo> names iso the mangled ones in commands like backtrace?

Try "set print demangle".

    paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
  2007-11-30 14:52 ` Paul Koning
@ 2007-11-30 15:03   ` Dima S
  2007-11-30 18:45     ` Stan Shebs
       [not found]     ` <18256.10018.785226.339384@pkoning-laptop.equallogic.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Dima S @ 2007-11-30 15:03 UTC (permalink / raw)
  To: Paul Koning; +Cc: gdb

Thanks for tips! I've tried both of them (print demangle + set language), 
none of them works :(

$>gdb <my_cpp_application>
GNU gdb 6.7.50.20071104
Copyright (C) 2007 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 "sparc-sun-solaris2.8"...
(gdb) set print demangle
(gdb) set language c++
(gdb) b WSLCLAG.cpp:120
No source file named WSLCLAG.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (WSLCLAG.cpp:120) pending.
(gdb) run
Starting program: <my_cpp_application>
warning: Temporarily disabling breakpoints for unloaded shared library 
"/usr/lib/ld.so.1"
warning: Lowest section in /usr/lib/libdl.so.1 is .dynamic at 00000094
Running 17 tests
Breakpoint 1, _ZN7WSLCLAG7destroyEv (this=0x14fcd0) at WSLCLAG.cpp:120
120         int   actuator_i = 0;
(gdb) backtrace
#0  _ZN7WSLCLAG7destroyEv (this=0x14fcd0) at WSLCLAG.cpp:120
#1  0x0002c5c8 in _ZN12WSLCLAGSStst21test_init_and_destroyEv (this=0x4b62c) 
at WSLCLAGtst.hpp:97
#2  0x0002c270 in 
_ZN50TestDescription_WSLCLAGSStst_test_init_and_destroy7runTestEv 
(this=0x4b660)
     at WSLCLAGtst.cpp:32
#3  0x0001df00 in _ZN7CxxTest19RealTestDescription3runEv (this=0x4b660)
     at ../../../xinc/cxxtest/RealDescriptions.cpp:96
#4  0x00026f04 in _ZN7CxxTest10TestRunner7runTestERNS_15TestDescriptionE 
(this=0xffbfe26f, td=@0x4b660)
     at ../../../xinc/cxxtest/TestRunner.h:74
#5  0x00026d7c in _ZN7CxxTest10TestRunner8runSuiteERNS_16SuiteDescriptionE 
(this=0xffbfe26f, sd=@0x4b63c)
     at ../../../xinc/cxxtest/TestRunner.h:61
#6  0x00026af0 in _ZN7CxxTest10TestRunner8runWorldEv (this=0xffbfe26f)
     at ../../../xinc/cxxtest/TestRunner.h:46
#7  0x00026968 in _ZN7CxxTest10TestRunner11runAllTestsERNS_12TestListenerE 
(listener=@0xffbfe358)
     at ../../../xinc/cxxtest/TestRunner.h:23
#8  0x000268c8 in _ZN7CxxTest14ErrorFormatter3runEv (this=0xffbfe358)
     at ../../../xinc/cxxtest/ErrorFormatter.h:47
#9  0x0001be64 in main () at WSLCLAGtst.cpp:20


Fri, 30 Nov 2007 09:51:35 -0500, Paul Koning <pkoning@equallogic.com>

> 
> Bobo> ...My question: - is there any way to let gdb display the real C++
> Bobo> names iso the mangled ones in commands like backtrace?
> 
> Try "set print demangle".
> 
>    paul
> 
     



-----------
IRR.BY ('Èç ðóê â ðóêè – Îíëàéí') – êðóïíåéøèé â Áåëàðóñè 
ñàéò ÷àñòíûõ îáúÿâëåíèé. http://irr.by

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
  2007-11-30 15:03   ` Dima S
@ 2007-11-30 18:45     ` Stan Shebs
  2007-12-05 12:49       ` Dima S
       [not found]     ` <18256.10018.785226.339384@pkoning-laptop.equallogic.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Stan Shebs @ 2007-11-30 18:45 UTC (permalink / raw)
  To: Dima S; +Cc: Paul Koning, gdb

Dima S wrote:
> Thanks for tips! I've tried both of them (print demangle + set 
> language), none of them works :(
I find it suspicious that the mangled names are only preceded by one 
underscore. Try feeding mangled names with different numbers of 
underscores to c++filt, see which one demangles correctly. (On Darwin, 
it's two underscores.)

Stan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
       [not found]     ` <18256.10018.785226.339384@pkoning-laptop.equallogic.com>
@ 2007-12-05 12:47       ` Dima S
  0 siblings, 0 replies; 8+ messages in thread
From: Dima S @ 2007-12-05 12:47 UTC (permalink / raw)
  To: Paul Koning; +Cc: gdb

I set both print demangle and asm-demangle on, but i see no difference.
The names a still not "human-readable"...

Fri, 30 Nov 2007 10:07:14 -0500, Paul Koning <pkoning@equallogic.com>:

> 
> Dima> Thanks for tips! I've tried both of them (print demangle + set
> Dima> language), none of them works :(
> 
> I should have been more explicit, "set print demangle on".
> 
> You might also try "set print asm-demangle on" but I wouldn't expect
> that one to be what you need.  That command controls demangling in
> assembly language output -- things like the "disassemble" command and
> "x/i" displays.
> 
>      paul
        



-----------
IRR.BY ('Èç ðóê â ðóêè – Îíëàéí') – êðóïíåéøèé â Áåëàðóñè 
ñàéò ÷àñòíûõ îáúÿâëåíèé. http://irr.by

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
  2007-11-30 18:45     ` Stan Shebs
@ 2007-12-05 12:49       ` Dima S
       [not found]         ` <18262.48200.586110.349260@pkoning-laptop.equallogic.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Dima S @ 2007-12-05 12:49 UTC (permalink / raw)
  To: Stan Shebs; +Cc: Paul Koning, gdb

Sorry but i'm not familiar with "c++filt"...
What is it and how can i feed my mangled names to it?


> Dima S wrote:
>> Thanks for tips! I've tried both of them (print demangle + set 
>> language), none of them works :(
> I find it suspicious that the mangled names are only preceded by one 
> underscore. Try feeding mangled names with different numbers of 
>underscores to c++filt, see which one demangles correctly. (On Darwin, it's 
>two underscores.)
> 
> Stan
> 

        



-----------
IRR.BY ('Èç ðóê â ðóêè – Îíëàéí') – êðóïíåéøèé â Áåëàðóñè 
ñàéò ÷àñòíûõ îáúÿâëåíèé. http://irr.by

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: C++ names in backtrace
       [not found]         ` <18262.48200.586110.349260@pkoning-laptop.equallogic.com>
@ 2007-12-07  8:29           ` Dima S
  0 siblings, 0 replies; 8+ messages in thread
From: Dima S @ 2007-12-07  8:29 UTC (permalink / raw)
  To: Paul Koning; +Cc: gdb

I've downloaded & built a version of c++filt (version GNU c++filt (GNU 
Binutils)2.18 to be more precise).

When i run the c++filt program with my mangles names i get correct demangled 
names on the output:
Examples (the mandgled names used here can be found in my previous posts):

./binutils/cxxfilt _ZN7WSLCLAG21select_actuator_parmsEi
WSLCLAG::select_actuator_parms(int)

./binutils/cxxfilt _ZN7CxxTest14ErrorFormatter3runEv
CxxTest::ErrorFormatter::run()

./binutils/cxxfilt _ZN7WSLCLAG7destroyEv
WSLCLAG::destroy()

So it seems that i can demangle the names from gdb backtrace using c++filt.
Does it mean/say anything to anybody?
How can i get demangled names in gdb?

Thanks in advance!


Wed, 5 Dec 2007 09:57:12 -0500, Paul Koning <pkoning@equallogic.com>:

> 
>>>>>> "Dima" == Dima S <spiridenok@tut.by> writes:
> 
> Dima> Sorry but i'm not familiar with "c++filt"...  What is it and
> Dima> how can i feed my mangled names to it?
> 
> It's one of the GNU tools, like gcc.  You'll find it in the same
> place.
> 
>Feed it the names you want to demangle to its stdin, and they will
> come out to stdout.
> 
>     paul
> 

          



-----------
WWW.PIZZA.BY - Äîñòàâêà íà äîì èëè â îôèñ ïèööû, ñóøè, øàøëûêà, 
íàïèòêîâ êðóãëîñóòî÷íî. http://pizza.by 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-12-07  8:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-30 10:38 C++ names in backtrace Bobo
2007-11-30 14:46 ` Daniel Jacobowitz
2007-11-30 14:52 ` Paul Koning
2007-11-30 15:03   ` Dima S
2007-11-30 18:45     ` Stan Shebs
2007-12-05 12:49       ` Dima S
     [not found]         ` <18262.48200.586110.349260@pkoning-laptop.equallogic.com>
2007-12-07  8:29           ` Dima S
     [not found]     ` <18256.10018.785226.339384@pkoning-laptop.equallogic.com>
2007-12-05 12:47       ` Dima S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).