diff options
author | Niklas Baumstark <niklas.baumstark@gmail.com> | 2016-05-31 20:28:21 +0200 |
---|---|---|
committer | Niklas Baumstark <niklas.baumstark@gmail.com> | 2016-05-31 20:28:36 +0200 |
commit | 8cc223890b985a0e9bc7da7210568b5efb60c303 (patch) | |
tree | 19d5e561062ee0006db78bf4de0512e821b9bfa9 /find | |
parent | 0b811b2df37c471e3ff89bf371f5c4c1277ca720 (diff) | |
download | libc-database-8cc223890b985a0e9bc7da7210568b5efb60c303.tar.gz libc-database-8cc223890b985a0e9bc7da7210568b5efb60c303.zip |
allow multiple function/address pairs for find
Diffstat (limited to 'find')
-rwxr-xr-x | find | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -1,12 +1,31 @@ #!/bin/bash -if [[ $# != 2 ]]; then - echo >&2 "Usage: $0 name address" +function usage() { + echo >&2 "Usage: $0 name address [name address ...]" exit 2 -fi -name=$1 -address=$2 -addr_last12=`echo -n "$address" | tail -c 3` -for id in `grep -e "^$name .*$addr_last12" db/*.symbols \ - | perl -n -e '/db\/(.*)\.symbols/ && print "$1\n"'`; do +} + +function find_single() { + name=$1 + address=$2 + addr_last12=`echo -n "$address" | tail -c 3 | tr '[:upper:]' '[:lower:]'` + grep -e "^$name .*$addr_last12$" db/*.symbols \ + | perl -n -e '/db\/(.*)\.symbols/ && print "$1\n"' \ + | sort +} + +function find() { + [[ $# < 2 ]] && usage + name=$1; shift + address=$1; shift + if [[ $# == 0 ]]; then + find_single $name $address + else + comm -12 \ + <(find_single $name $address) \ + <(find "$@") + fi +} + +for id in `find "$@"`; do echo "`cat db/${id}.info` (id $id)" done |