1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 17:53:23 -07:00
rc/sh/disf
2021-07-29 00:37:35 -07:00

14 lines
510 B
Bash
Executable File

#!/usr/bin/env bash
# disassembles a function given its symbolic name.
# YES_ZSH
function disf() {
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
local exe="${1:?first argument should be an unstripped executable}"
local symbol="${2:?second argument should be a function name}"
# note: relies on GNU sed: https://unix.stackexchange.com/a/78485
objdump -d -C --no-show-raw-insn "$exe" | sed '/<'"$symbol"'>:/,/^$/!d;//d'
}
[ "${SOURCING:-0}" -gt 0 ] || disf "$@"