debug (619B)
1 #!/bin/sh 2 # This script is quite good at scraping 3 # source out of debug binaries, but not 4 # data (it gets mangled pretty bad). 5 6 [ -z "$1" ] || [ -n "$2" ] && printf "usage: %s <debug binary>\n" "$(basename "$0")" && exit 2 7 8 objdump -St "$1" 2>&1 | awk ' 9 /SYMBOL TABLE/ {st = 1} 10 /^[[:space:]]*$/ { 11 st = 0 12 if (!sp) { 13 print 14 sp = 1 15 } 16 } 17 $1 !~ ":$" && $2 !~ "<[^>]*>:$" && !st && !/Disassembly.*:/ && /[^[:space:]]/ { 18 # avoid double printing for loops 19 if ($1 ~ "^for") { 20 if (forseen[$0] == 1) { 21 forseen[$0] = 0 22 } else { 23 print 24 forseen[$0] = 1 25 } 26 } else { 27 print 28 sp = 0 29 } 30 } 31 '