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