#!/bin/sh # # $0 filters the output of objdump to just emit the disassembly of # a specific function. # # usage: $0 FUNCTION [FILE] # FUNCTION is the function to filter for (it may be regular expression too) # if FILE is ommited it's assumed to be a.out # if [ $# -lt 1 ]; then echo "usage: $0 FUNCTION [FILE] [OBJDUMP_FLAGS..]" exit 1 fi FUNC="$1"; shift [ $# -ge 1 -a "$1:0:1" != "-" ] && { FILE="$1"; shift; } || FILE="a.out" export FUNC objdump -d "$FILE" "$@" \ | perl -e 'undef $/; $_=<>; /(^.*<$ENV{FUNC}>:\n(^[ \t].+\n)*)/m && print "$1"'