Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/objdump-func: Support multiple functions

Allow specifying multiple functions on the cmdline. Note this removes
the secret EXTRA_ARGS feature.

While at it, spread out the awk to make it more readable.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/0bf5f4f5978660985037b24c6db49b114374eb4d.1681325924.git.jpoimboe@kernel.org

authored by

Josh Poimboeuf and committed by
Peter Zijlstra
27d000d6 e8deb00c

+24 -8
+24 -8
scripts/objdump-func
··· 3 3 # 4 4 # Disassemble a single function. 5 5 # 6 - # usage: objdump-func <file> <func> 6 + # usage: objdump-func <file> <func> [<func> ...] 7 7 8 8 set -o errexit 9 9 set -o nounset ··· 13 13 command -v gawk >/dev/null 2>&1 || die "gawk isn't installed" 14 14 15 15 usage() { 16 - echo "usage: objdump-func <file> <func>" >&2 16 + echo "usage: objdump-func <file> <func> [<func> ...]" >&2 17 17 exit 1 18 18 } 19 19 20 20 [[ $# -lt 2 ]] && usage 21 21 22 22 OBJ=$1; shift 23 - FUNC=$1; shift 23 + FUNCS=("$@") 24 24 25 - # Secret feature to allow adding extra objdump args at the end 26 - EXTRA_ARGS=$@ 27 - 28 - # Note this also matches compiler-added suffixes like ".cold", etc 29 - ${OBJDUMP} -wdr $EXTRA_ARGS $OBJ | gawk -M -v f=$FUNC '/^$/ { P=0; } $0 ~ "<" f "(\\..*)?>:" { P=1; O=strtonum("0x" $1); } { if (P) { o=strtonum("0x" $1); printf("%04x ", o-O); print $0; } }' 25 + ${OBJDUMP} -wdr $OBJ | gawk -M -v _funcs="${FUNCS[*]}" ' 26 + BEGIN { split(_funcs, funcs); } 27 + /^$/ { func_match=0; } 28 + /<.*>:/ { 29 + f = gensub(/.*<(.*)>:/, "\\1", 1); 30 + for (i in funcs) { 31 + # match compiler-added suffixes like ".cold", etc 32 + if (f ~ "^" funcs[i] "(\\..*)?") { 33 + func_match = 1; 34 + base = strtonum("0x" $1); 35 + break; 36 + } 37 + } 38 + } 39 + { 40 + if (func_match) { 41 + addr = strtonum("0x" $1); 42 + printf("%04x ", addr - base); 43 + print; 44 + } 45 + }'