annotate scripts/list2crc.pl @ 2955:a0b770fab355

Add scripts/os9.gdb and list2crc.pl for gdb debugging Some gdb commands to facilitate debugging with gdb (on XRoar). Uses GVIM as external code viewer. Example: mkdir lst make PORTS=coco1 LISTDIR=$PWD/lst cd lst for f in *.lst; do ../scripts/list2crc.pl $f; done m6809-gdb (gdb) source ../scripts/os9.gdb (gdb) tar rem :65520 (gdb) os9_mwhere (print current module, update source viewer) (gdb) os9_mdir (list all registered modules and their entry points) (gdb) hbreak *0xa243 (set breakpoint on entry of SHELL) (gdb) cont (gdb) b9 0x56 (set a breakpoint at offset 0x56 in SHELL) (gdb) cont
author Tormod Volden <debian.tormod@gmail.com>
date Sun, 09 Feb 2014 21:44:25 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2955
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
1 #!/usr/bin/perl
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
2
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
3 # Copyright 2014 Tormod Volden
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
4 #
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
5 # Digests assembly listings generated by lwasm, and stores the
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
6 # module body listing in a file named by the module CRC.
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
7 # Example: for f in *.lst; do ../scripts/list2crc.pl $f; done
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
8
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
9 open(CRCFILE, ">", "crc.tmp") or die "cannot create crc.tmp: $!";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
10
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
11 while (<>) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
12 ($hoffset, $opbytes, $filepath, $lineno, $label, $opcode, $operand, $comment) =
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
13 ( $_ =~ /^(\w+) (\w+)\s+\((.*)\):(\d+) (\S+)?\s+(\w+)\s*(\S+)?\s*(.*)?/ );
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
14
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
15 # print $hoffset, "\t", $opcode, "\t", $comment, "\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
16 if (lc($opcode) eq "mod") {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
17 $in_module = 1;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
18 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
19
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
20 if (lc($opcode) eq "emod") {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
21 die "double emod" if $found_emod;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
22 $found_emod = 1;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
23 $crc = $opbytes;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
24 $in_module = 0;
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
25 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
26
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
27 # if ($in_module && $hoffset) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
28 # $offset = hex($hoffset);
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
29 # print CRCFILE "$offset\t$filepath\t$lineno\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
30 # }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
31 if ($in_module) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
32 print CRCFILE $_
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
33 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
34 }
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
35 close(CRCFILE);
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
36 if ($crc) {
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
37 print "writing $crc.crc\n";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
38 rename "crc.tmp", $crc . ".crc";
a0b770fab355 Add scripts/os9.gdb and list2crc.pl for gdb debugging
Tormod Volden <debian.tormod@gmail.com>
parents:
diff changeset
39 }