Demangling C++ symbol names


Like quite a few of my colleagues I ordered the the two volume update of Solaris Internals pretty much as soon as they came out, and one of the most useful tips I have come across in reading of Solaris Performance and Tools is a program bundled with the Sun Studio Compilers, c++filt.

c++filt demangles C++ symbol names, (for postmortem debugging mdb has the ::dem dcmd [1]), and is mentioned with reference to java in several sections of the the book. Anyway an example will save you listening to me ramble on, so as an example lets look at an abbreviated pstack(1) of a java process on my desktop.

tiresias /home/fintanr $ ptree `pgrep java`
2287  /usr/bin/java -jar /usr/lib/patch/swupna.jar -wait
28414 /usr/jdk/instances/jdk1.5.0/jre/bin/java -client -Xbootclasspath/a:/usr/jdk/ins

tiresias /home/fintanr $ pstack 28414
... snip....
-----------------  lwp# 38 / thread# 38  --------------------
 fef38c27 lwp_cond_wait (830a4a8, 830a490, 0, 0)
 feab748c __1cCosHSolarisFEventEpark6M_v_ (830a468) + 4c
 feab6b36 __1cNObjectMonitorEwait6MxipnGThread__v_ (814c774, 0, 0, 1, 8652e80) + 346
 feab64b0 __1cSObjectSynchronizerEwait6FnGHandle_xpnGThread__v_ (82e55cc, 0, 0, 8652e80) + 70
 feab6204 JVM_MonitorWait (8652f40, ee37bbb0, 0, 0, ee37bb7c, 0) + 234
 f9207fcd ???????? (0, f9206269, 0, 0, ef8fe738, ee37bbb4)
 f9202a7b ???????? (ef8fe738, 3, ef8fe738, ee37bbdc, f35a9d08, ee37bc20)
 f9202a7b ???????? (0, 0, 0, ef8fe738, 0, efa090d0)
 f9202d81 ???????? (efa090d0, ee37bc68, fedb2000, 8652e80, 1, ee37bcfc)
 f9200152 ???????? (ee37bca8, ee37be4c, a, f342b5b0, f92072d0, ee37bda8)
 feaa86d7 __1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v_ 
 (ee37be48, ee37bd40, ee37bda4, 8652e80, ee37bd34, feaa8528) + 187
 feaa8544 __1cCosUos_exception_wrapper6FpFpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread_
     _v2468_v_ (feaa8550, ee37be48, ee37bd40, ee37bda4, 8652e80) + 14
 feaa8528 __1cJJavaCallsEcall6FpnJJavaValue_nMmethodHandle_pnRJavaCallArguments_pnGThread__v_
    (ee37be48, 82e55c8, ee37bda4, 8652e80) + 28
 feab5ede __1cJJavaCallsMcall_virtual6FpnJJavaValue_nLKlassHandle_nMsymbolHandle_4pnRJavaCallArguments
    _pnGThread__v_ (ee37be48, 82e55bc, fedd4e58, fedd4f28, ee37bda4, 8652e80) + be
 feab5e0d __1cJJavaCallsMcall_virtual6FpnJJavaValue_nGHandle_nLKlassHandle_nMsymbolHandle_5pnGThread__v
   _ (ee37be48, 82e55b8, 82e55bc, fedd4e58, fedd4f28, 8652e80) + 6d
 feab5d80 __1cMthread_entry6FpnKJavaThread_pnGThread__v_ (8652e80, 8652e80) + d0
 feab5c81 __1cKJavaThreadRthread_main_inner6M_v_ (8652e80) + 51
 feab5c25 __1cKJavaThreadDrun6M_v_ (8652e80) + 105
 fecc05e2 __1cG_start6Fpv_0_ (8652e80) + d2
 fef37bdd _thr_setup (fbe66000) + 51
 fef37e30 _lwp_start (fbe66000, 0, 0, 0, fbe66000, ee37bff8)

tiresias /home/fintanr $ pstack 28414 | ./c++filt
.... snip.....
----------------  lwp# 38 / thread# 38  --------------------
 fef38c27 lwp_cond_wait (830a4a8, 830a490, 0, 0)
 feab748c void os::Solaris::Event::park() (830a468) + 4c
 feab6b36 void ObjectMonitor::wait(long long,int,Thread\*) (814c774, 0, 0, 1, 8652e80) + 346
 feab64b0 void ObjectSynchronizer::wait(Handle,long long,Thread\*) (82e55cc, 0, 0, 8652e80) + 70
 feab6204 JVM_MonitorWait (8652f40, ee37bbb0, 0, 0, ee37bb7c, 0) + 234
 f9207fcd ???????? (0, f9206269, 0, 0, ef8fe738, ee37bbb4)
 f9202a7b ???????? (ef8fe738, 3, ef8fe738, ee37bbdc, f35a9d08, ee37bc20)
 f9202a7b ???????? (0, 0, 0, ef8fe738, 0, efa090d0)
 f9202d81 ???????? (efa090d0, ee37bc68, fedb2000, 8652e80, 1, ee37bcfc)
 f9200152 ???????? (ee37bca8, ee37be4c, a, f342b5b0, f92072d0, ee37bda8)
 feaa86d7 void JavaCalls::call_helper(JavaValue\*,methodHandle\*,JavaCallArguments\*,Thread\*) 
   (ee37be48, ee37bd40, ee37bda4, 8652e80, ee37bd34, feaa8528) + 187
 feaa8544 void os::os_exception_wrapper(void(\*)(JavaValue\*,methodHandle\*,JavaCallArguments\*,Thread\*),
    JavaValue\*,methodHandle\*,JavaCallArguments\*,Thread\*) (feaa8550, ee37be48, ee37bd40, ee37bda4,
    8652e80) + 14
 feaa8528 void JavaCalls::call(JavaValue\*,methodHandle,JavaCallArguments\*,Thread\*) (ee37be48,
    82e55c8, ee37bda4, 8652e80) + 28
 feab5ede void JavaCalls::call_virtual(JavaValue\*,KlassHandle,symbolHandle,symbolHandle,JavaCallArguments\*,
   Thread\*) (ee37be48, 82e55bc, fedd4e58, fedd4f28, ee37bda4, 8652e80) + be
 feab5e0d void JavaCalls::call_virtual(JavaValue\*,Handle,KlassHandle,symbolHandle,symbolHandle,Thread\*) 
    (ee37be48, 82e55b8, 82e55bc, fedd4e58, fedd4f28, 8652e80) + 6d
 feab5d80 void thread_entry(JavaThread\*,Thread\*) (8652e80, 8652e80) + d0
 feab5c81 void JavaThread::thread_main_inner() (8652e80) + 51
 feab5c25 void JavaThread::run() (8652e80) + 105
 fecc05e2 void\*_start(void\*) (8652e80) + d2
 fef37bdd _thr_setup (fbe66000) + 51
 fef37e30 _lwp_start (fbe66000, 0, 0, 0, fbe66000, ee37bff8)

Very handy if I do say so.

[1] mdb ::dem help
> ::help dem

NAME
  dem - demangle C++ symbol names

SYNOPSIS
  ::dem name ...

ATTRIBUTES

  Target: kvm
  Module: mdb
  Interface Stability: Evolving
Comments:

Post a Comment:
Comments are closed for this entry.
About

fintanr

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today