mac-nm 812 B

12345678910111213141516171819
  1. #!/bin/sh
  2. # This script is a wrapper for OS X nm(1) tool. nm(1) perform C++ function
  3. # names demangling, so we're piping its output to c++filt(1) tool which does it.
  4. # But c++filt(1) comes with XCode (as a part of GNU binutils), so it doesn't
  5. # guaranteed to exist on a system.
  6. #
  7. # An alternative approach is to perform demangling in tick processor, but
  8. # for GNU C++ ABI this is a complex process (see cp-demangle.c sources), and
  9. # can't be done partially, because term boundaries are plain text symbols, such
  10. # as 'N', 'E', so one can't just do a search through a function name, it really
  11. # needs to be parsed, which requires a lot of knowledge to be coded in.
  12. if [ "`which c++filt`" == "" ]; then
  13. nm "$@"
  14. else
  15. nm "$@" | sed -n "s/\([0-9a-fA-F]\{8,16\}\) [iItT] \(.*\)/\\1 \\2/p"\
  16. | c++filt -p -i
  17. fi