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