# Usage: objdump -d a.out | awk -f distill.awk | ./test_get_len # Distills the disassembly as follows: # - Removes all lines except the disassembled instructions. # - For instructions that exceed 1 line (7 bytes), crams all the hex bytes # into a single line. BEGIN { prev_addr = "" prev_hex = "" prev_mnemonic = "" } /^ *[0-9a-f]+:/ { if (split($0, field, "\t") < 3) { # This is a continuation of the same insn. prev_hex = prev_hex field[2] } else { if (prev_addr != "") printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic prev_addr = field[1] prev_hex = field[2] prev_mnemonic = field[3] } } END { if (prev_addr != "") printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic }