iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.43k stars 3.86k forks source link

demangled output #2215

Open tthtlc opened 5 years ago

tthtlc commented 5 years ago

after running "funccount" on Mozilla firefox:

_ZN7mozilla6detail9MutexImplD2Ev         1126
_ZN7mozilla6detail9MutexImplC2ENS_12recordreplay8BehaviorE     1153
moz_xrealloc                             1305
realloc                                  1366
moz_arena_realloc                        2284
_ZN7mozilla6detail21ConditionVariableImpl8wait_forERNS0_9MutexImplERKNS_16BaseTimeDurationINS_27TimeDurationValueCalculatorEEE     3910
_ZN7mozilla6detail21ConditionVariableImpl10notify_oneEv     4848
_ZN7mozilla29BaseTimeDurationPlatformUtils21TicksFromMillisecondsEd    14664
_ZN7mozilla29BaseTimeDurationPlatformUtils9ToSecondsEl    16799
moz_arena_malloc                        25022
moz_xmalloc                             27496
_ZN7mozilla9TimeStamp8NowFuzzyENS_14TimeStamp63BitE    28645
_ZN7mozilla9TimeStamp3NowEb             28671
_ZN7mozilla9TimeStamp18GetFuzzyfoxEnabledEv    29441
malloc                                  42399
_ZN7mozilla6detail9MutexImpl4lockEv     51988
_ZN7mozilla6detail9MutexImpl6unlockEv    51990

I got the above output.

can we do better? if you do "objdump --demangle" you can easily get the demangle output from the binary. If someone can suggest how and where to modify the BCC (which I don't know) perhaps I can try combining it with:

https://github.com/whitequark/python-itanium_demangler

and submit a patch request.

palmtenor commented 5 years ago

OK, so looks like these symbols are not demangle-able with c++filt / __cxa_demangle, which BCC uses.

Fallback to Itanium Demangler is OK (but probably still try __cxa_demangle first as in practice we've found Itanium Demangler more expensive / slow), the only thing to be figured out is the additional dependency and if it's worth for BCC to have that.

yonghong-song commented 5 years ago

Could you double check, maybe with source, why __cxa_demanglee does not work?

-bash-4.4$ cat t.cc
#include <cxxabi.h>
#include <stdio.h>

int main() {
  const char *name = "_ZN7mozilla6detail21ConditionVariableImpl10notify_oneEv";
  char *dname;

  dname = abi::__cxa_demangle(name, nullptr, nullptr, nullptr);
  fprintf(stderr, "%s\n", dname);
  return 0;
}
-bash-4.4$ g++ t.cc -std=c++0x
-bash-4.4$ ./a.out
mozilla::detail::ConditionVariableImpl::notify_one()
-bash-4.4$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-
threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-lib
unwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style
=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-in
itfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-r
edhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redha
t-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64
 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
-bash-4.4$

In my environment, gcc 4.8.5 seems working fine. Maybe __cxa_demangle is not called somehow?