Last active
June 1, 2018 20:22
-
-
Save cls/1677af8f05df1cee445042a8942b060a to your computer and use it in GitHub Desktop.
Script to grep objects' symbol tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pattern="$1" | |
shift | |
if [ $# -gt 1 ] | |
then | |
GREP_OPTIONS="$GREP_OPTIONS --with-filename" | |
export GREP_OPTIONS | |
fi | |
for file in "$@" | |
do | |
nm -P "$file" | awk '{print $2,$1}' | c++filt | grep --label="$file" --regexp="$pattern" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires GNU grep, and an optional C++ demangler, but is otherwise POSIX compatible.
The GNU dependency can be removed by doing something like the following.