aboutsummaryrefslogtreecommitdiff
path: root/find
blob: dda3fc3f86e8bb06722ba0fb9d6f6bf40cb31b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
function usage() {
  echo >&2 "Usage: $0 name address [name address ...]"
  exit 2
}

function find_single() {
  name=$1
  address=$2
  addr_last12=`echo -n "$address" | tail -c 3`
  grep -r --include=\*.symbols -i -e "^$name .*$addr_last12$" db/ \
    | 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 "db/${id}.so"
done