Annotation of hatari/tools/debugger/devpac3-symbols-convert.sh, revision 1.1.1.2

1.1       root        1: #!/bin/sh
                      2: #
                      3: # script to convert Devpac v3 symbol table for Hatari debugger.
                      4: #
                      5: # 2013 (C) Eero Tamminen, licenced under GPL v2+
                      6: 
                      7: usage ()
                      8: {
                      9:        name=${0##*/}
                     10:        echo
                     11:        echo "Usage: $name <symbol file>"
                     12:        echo
                     13:        echo "Convert Devpac v3 symbol table listing (enabled"
                     14:        echo "in Listings options) to format understood by"
                     15:        echo "the Hatari debugger 'symbols' command."
                     16:        echo
                     17:        echo "For example:"
                     18:        echo "  $name FOOBAR.SYM > foobar.syms"
                     19:        echo
                     20:        echo "ERROR: $1!"
                     21:        echo
                     22:        exit 1
                     23: }
                     24: if [ $# -ne 1 ]; then
                     25:        usage "incorrect number of arguments"
                     26: fi
                     27: 
                     28: if [ \! -f $1 ]; then
                     29:        usage "given '$1' symbol file not found"
                     30: fi
                     31: 
                     32: # parse symbol information at the end of the file
                     33: awk '
                     34: /^[0-9A-F]+  [BDT]  R  / { print $1, $2, $4; next }
                     35: /^[0-9A-F]+  F[DEF].R  / {
                     36:        if ($2 == "FD.R") type = "D";
                     37:        else if ($2 == "FE.R") type = "B";
                     38:        else if ($2 == "FF.R") type = "T";
                     39:        print $1, type, $3;
                     40:        next
                     41: }
                     42: ' $1 | sort
                     43: 
                     44: # parse code listing
                     45: # - has problem that in Devpac output the offsets in
                     46: #   the code listing part don't take includes into
                     47: #   account i.e. they seem wrong
1.1.1.2 ! root       48: #
1.1       root       49: # works by:
                     50: # - removing columns that confuse rest command line
                     51: # - removing macro etc symbols at zero address
                     52: # - removing (optional) ':' from symbol end
                     53: # - matching addresses & symbol names and print
                     54: #   them in 'nm' order
                     55: #
                     56: #cut -b 7,9-17,39- $1 | grep -v 'T 00000000 ' | tr -d : |\
                     57: #  awk '/^[TBD] [0-9A-F]+ [._a-zA-Z0-9]/ {print $2,$1,$3}'

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.