File: pretty_print_dump.pl

package info (click to toggle)
pcsx2 1.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 28,424 kB
  • sloc: cpp: 299,797; ansic: 23,973; lisp: 2,689; asm: 908; perl: 852; sh: 789; xml: 116; makefile: 60
file content (159 lines) | stat: -rwxr-xr-x 6,002 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/perl

use strict;
use warnings;

open(my $in, $ARGV[0]) or die "failed to get first param: $!";

my @pp_name = (
    # GPR
    "0", "0", "0", "0",
    "at", "at", "at", "at",
    "v0", "v0", "v0", "v0",
    "v1", "v1", "v1", "v1",
    "a0", "a0", "a0", "a0",
    "a1", "a1", "a1", "a1",
    "a2", "a2", "a2", "a2",
    "a3", "a3", "a3", "a3",
    "t0", "t0", "t0", "t0",
    "t1", "t1", "t1", "t1",
    "t2", "t2", "t2", "t2",
    "t3", "t3", "t3", "t3",
    "t4", "t4", "t4", "t4",
    "t5", "t5", "t5", "t5",
    "t6", "t6", "t6", "t6",
    "t7", "t7", "t7", "t7",
    "s0", "s0", "s0", "s0",
    "s1", "s1", "s1", "s1",
    "s2", "s2", "s2", "s2",
    "s3", "s3", "s3", "s3",
    "s4", "s4", "s4", "s4",
    "s5", "s5", "s5", "s5",
    "s6", "s6", "s6", "s6",
    "s7", "s7", "s7", "s7",
    "t8", "t8", "t8", "t8",
    "t9", "t9", "t9", "t9",
    "k0", "k0", "k0", "k0",
    "k1", "k1", "k1", "k1",
    "gp", "gp", "gp", "gp",
    "sp", "sp", "sp", "sp",
    "s8", "s8", "s8", "s8",
    "ra", "ra", "ra", "ra",
    "hi", "hi", "hi", "hi",
    "lo", "lo", "lo", "lo",

    # CP0
    "Index"    , "Random"    , "EntryLo0"  , "EntryLo1"  ,
    "Context"  , "PageMask"  , "Wired"     , "Reserved0" ,
    "BadVAddr" , "Count"     , "EntryHi"   , "Compare"   ,
    "Status"   , "Cause"     , "EPC"       , "PRid"      ,
    "Config"   , "LLAddr"    , "WatchLO"   , "WatchHI"   ,
    "XContext" , "Reserved1" , "Reserved2" , "Debug"     ,
    "DEPC"     , "PerfCnt"   , "ErrCtl"    , "CacheErr"  ,
    "TagLo"    , "TagHi"     , "ErrorEPC"  , "DESAVE"    ,

    "sa",
    "IsDelaySlot",
    "pc",
    "code",
    "PERF", "PERF", "PERF", "PERF",

    "eCycle0"  , "eCycle1"  , "eCycle2"  , "eCycle3"  , "eCycle4"  , "eCycle5"  , "eCycle6"  , "eCycle7"  ,
    "eCycle8"  , "eCycle9"  , "eCycle10" , "eCycle11" , "eCycle12" , "eCycle13" , "eCycle14" , "eCycle15" ,
    "eCycle16" , "eCycle17" , "eCycle18" , "eCycle19" , "eCycle20" , "eCycle21" , "eCycle22" , "eCycle23" ,
    "eCycle24" , "eCycle25" , "eCycle26" , "eCycle27" , "eCycle28" , "eCycle29" , "eCycle30" , "eCycle31" ,

    "sCycle0"  , "sCycle1"  , "sCycle2"  , "sCycle3"  , "sCycle4"  , "sCycle5"  , "sCycle6"  , "sCycle7"  ,
    "sCycle8"  , "sCycle9"  , "sCycle10" , "sCycle11" , "sCycle12" , "sCycle13" , "sCycle14" , "sCycle15" ,
    "sCycle16" , "sCycle17" , "sCycle18" , "sCycle19" , "sCycle20" , "sCycle21" , "sCycle22" , "sCycle23" ,
    "sCycle24" , "sCycle25" , "sCycle26" , "sCycle27" , "sCycle28" , "sCycle29" , "sCycle30" , "sCycle31" ,

    "cycle", "interrupt", "branch", "opmode", "tempcycles"
);

my @pp_iop_name = (
    # GPR
    "0"  , "at" , "v0" , "v1" ,
    "a0" , "a1" , "a2" , "a3" ,
    "t0" , "t1" , "t2" , "t3" ,
    "t4" , "t5" , "t6" , "t7" ,
    "s0" , "s1" , "s2" , "s3" ,
    "s4" , "s5" , "s6" , "s7" ,
    "t8" , "t9" , "k0" , "k1" ,
    "gp" , "sp" , "s8" , "ra" ,
    "hi" , "lo" ,

    # CP0
    "Index"    , "Random"    , "EntryLo0"  , "EntryLo1"  ,
    "Context"  , "PageMask"  , "Wired"     , "Reserved0" ,
    "BadVAddr" , "Count"     , "EntryHi"   , "Compare"   ,
    "Status"   , "Cause"     , "EPC"       , "PRid"      ,
    "Config"   , "LLAddr"    , "WatchLO"   , "WatchHI"   ,
    "XContext" , "Reserved1" , "Reserved2" , "Debug"     ,
    "DEPC"     , "PerfCnt"   , "ErrCtl"    , "CacheErr"  ,
    "TagLo"    , "TagHi"     , "ErrorEPC"  , "DESAVE"    ,

    # CP2D
    "CP2D1"  , "CP2D2"  , "CP2D3"  , "CP2D4"  , "CP2D5"  , "CP2D6"  , "CP2D7"  , "CP2D8"  ,
    "CP2D9"  , "CP2D10" , "CP2D11" , "CP2D12" , "CP2D13" , "CP2D14" , "CP2D15" , "CP2D16" ,
    "CP2D17" , "CP2D18" , "CP2D19" , "CP2D20" , "CP2D21" , "CP2D22" , "CP2D23" , "CP2D24" ,
    "CP2D25" , "CP2D26" , "CP2D27" , "CP2D28" , "CP2D29" , "CP2D30" , "CP2D31" , "CP2D32" ,

    # CP2H
    "CP2H1"  , "CP2H2"  , "CP2H3"  , "CP2H4"  , "CP2H5"  , "CP2H6"  , "CP2H7"  , "CP2H8"  ,
    "CP2H9"  , "CP2H10" , "CP2H11" , "CP2H12" , "CP2H13" , "CP2H14" , "CP2H15" , "CP2H16" ,
    "CP2H17" , "CP2H18" , "CP2H19" , "CP2H20" , "CP2H21" , "CP2H22" , "CP2H23" , "CP2H24" ,
    "CP2H25" , "CP2H26" , "CP2H27" , "CP2H28" , "CP2H29" , "CP2H30" , "CP2H31" , "CP2H32" ,

    "pc",
    "code",
    "cycle",
    "int",

    "eCycle0"  , "eCycle1"  , "eCycle2"  , "eCycle3"  , "eCycle4"  , "eCycle5"  , "eCycle6"  , "eCycle7"  ,
    "eCycle8"  , "eCycle9"  , "eCycle10" , "eCycle11" , "eCycle12" , "eCycle13" , "eCycle14" , "eCycle15" ,
    "eCycle16" , "eCycle17" , "eCycle18" , "eCycle19" , "eCycle20" , "eCycle21" , "eCycle22" , "eCycle23" ,
    "eCycle24" , "eCycle25" , "eCycle26" , "eCycle27" , "eCycle28" , "eCycle29" , "eCycle30" , "eCycle31" ,

    "sCycle0"  , "sCycle1"  , "sCycle2"  , "sCycle3"  , "sCycle4"  , "sCycle5"  , "sCycle6"  , "sCycle7"  ,
    "sCycle8"  , "sCycle9"  , "sCycle10" , "sCycle11" , "sCycle12" , "sCycle13" , "sCycle14" , "sCycle15" ,
    "sCycle16" , "sCycle17" , "sCycle18" , "sCycle19" , "sCycle20" , "sCycle21" , "sCycle22" , "sCycle23" ,
    "sCycle24" , "sCycle25" , "sCycle26" , "sCycle27" , "sCycle28" , "sCycle29" , "sCycle30" , "sCycle31" ,
);

my $line;
my $cpu;
my $iop = 0;
while($line = <$in>) {
    if ($line =~ /Dump register data: (0x[0-9a-f]+)/) {
        $cpu = hex($1);
    }
    if ($line =~ /Dump PSX register data: (0x[0-9a-f]+)/) {
        $cpu = hex($1);
        $iop = 1;
    }
    if ($line =~ /ds:(0x[0-9a-f]+)/) {
        my $mem = hex($1);
        my $offset = $mem - $cpu;
        my $pretty;
        # keep only the cpuRegisters structure
        next unless ($offset >= 0 && $offset < 980);

        if ($iop) {
            my $byte = $offset % 4;
            my $dw   = $offset / 4;

            $pretty = "&$pp_iop_name[$dw]_B$byte";
        } else {
            my $byte = ($offset >= 544) ? $offset % 4 : $offset % 16;
            my $dw   = $offset / 4;

            # FIXME B doesn't work for duplicated register
            $pretty = "&$pp_name[$dw]_B$byte";
        }

        #print "AH $pretty\n";
        $line =~ s/ds:0x[0-9a-f]+/$pretty/;
    }
    print $line;
}