Commit 11df65c3c6f7fdc837a5be8787d31011e8bb93c1
Committed by
Sam Ravnborg
1 parent
c19ef7fd8e
Exists in
master
and in
20 other branches
scripts: add x86 64 bit support to the markup_oops.pl script
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Showing 1 changed file with 55 additions and 4 deletions Side-by-side Diff
scripts/markup_oops.pl
1 | -#!/usr/bin/perl -w | |
1 | +#!/usr/bin/perl | |
2 | 2 | |
3 | 3 | use File::Basename; |
4 | 4 | |
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | my $target = "0"; |
30 | 30 | my $function; |
31 | 31 | my $module = ""; |
32 | -my $func_offset; | |
32 | +my $func_offset = 0; | |
33 | 33 | my $vmaoffset = 0; |
34 | 34 | |
35 | 35 | my %regs; |
36 | 36 | |
... | ... | @@ -49,8 +49,41 @@ |
49 | 49 | $regs{"%edi"} = $2; |
50 | 50 | $regs{"%esp"} = $4; |
51 | 51 | } |
52 | + if ($line =~ /RAX: ([0-9a-f]+) RBX: ([0-9a-f]+) RCX: ([0-9a-f]+)/) { | |
53 | + $regs{"%eax"} = $1; | |
54 | + $regs{"%ebx"} = $2; | |
55 | + $regs{"%ecx"} = $3; | |
56 | + } | |
57 | + if ($line =~ /RDX: ([0-9a-f]+) RSI: ([0-9a-f]+) RDI: ([0-9a-f]+)/) { | |
58 | + $regs{"%edx"} = $1; | |
59 | + $regs{"%esi"} = $2; | |
60 | + $regs{"%edi"} = $3; | |
61 | + } | |
62 | + if ($line =~ /RBP: ([0-9a-f]+) R08: ([0-9a-f]+) R09: ([0-9a-f]+)/) { | |
63 | + $regs{"%r08"} = $2; | |
64 | + $regs{"%r09"} = $3; | |
65 | + } | |
66 | + if ($line =~ /R10: ([0-9a-f]+) R11: ([0-9a-f]+) R12: ([0-9a-f]+)/) { | |
67 | + $regs{"%r10"} = $1; | |
68 | + $regs{"%r11"} = $2; | |
69 | + $regs{"%r12"} = $3; | |
70 | + } | |
71 | + if ($line =~ /R13: ([0-9a-f]+) R14: ([0-9a-f]+) R15: ([0-9a-f]+)/) { | |
72 | + $regs{"%r13"} = $1; | |
73 | + $regs{"%r14"} = $2; | |
74 | + $regs{"%r15"} = $3; | |
75 | + } | |
52 | 76 | } |
53 | 77 | |
78 | +sub reg_name | |
79 | +{ | |
80 | + my ($reg) = @_; | |
81 | + $reg =~ s/r(.)x/e\1x/; | |
82 | + $reg =~ s/r(.)i/e\1i/; | |
83 | + $reg =~ s/r(.)p/e\1p/; | |
84 | + return $reg; | |
85 | +} | |
86 | + | |
54 | 87 | sub process_x86_regs |
55 | 88 | { |
56 | 89 | my ($line, $cntr) = @_; |
57 | 90 | |
58 | 91 | |
... | ... | @@ -83,10 +116,18 @@ |
83 | 116 | } |
84 | 117 | |
85 | 118 | foreach $reg (keys(%regs)) { |
119 | + my $clobberprime = reg_name($clobber); | |
120 | + my $lastwordprime = reg_name($lastword); | |
86 | 121 | my $val = $regs{$reg}; |
122 | + if ($val =~ /^[0]+$/) { | |
123 | + $val = "0"; | |
124 | + } else { | |
125 | + $val =~ s/^0*//; | |
126 | + } | |
127 | + | |
87 | 128 | # first check if we're clobbering this register; if we do |
88 | 129 | # we print it with a =>, and then delete its value |
89 | - if ($clobber =~ /$reg/) { | |
130 | + if ($clobber =~ /$reg/ || $clobberprime =~ /$reg/) { | |
90 | 131 | if (length($val) > 0) { |
91 | 132 | $str = $str . " $reg => $val "; |
92 | 133 | } |
... | ... | @@ -94,7 +135,7 @@ |
94 | 135 | $val = ""; |
95 | 136 | } |
96 | 137 | # now check if we're reading this register |
97 | - if ($lastword =~ /$reg/) { | |
138 | + if ($lastword =~ /$reg/ || $lastwordprime =~ /$reg/) { | |
98 | 139 | if (length($val) > 0) { |
99 | 140 | $str = $str . " $reg = $val "; |
100 | 141 | } |
101 | 142 | |
102 | 143 | |
... | ... | @@ -109,13 +150,23 @@ |
109 | 150 | if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { |
110 | 151 | $target = $1; |
111 | 152 | } |
153 | + if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) { | |
154 | + $target = $1; | |
155 | + } | |
112 | 156 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { |
113 | 157 | $function = $1; |
114 | 158 | $func_offset = $2; |
115 | 159 | } |
160 | + if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { | |
161 | + $function = $1; | |
162 | + $func_offset = $2; | |
163 | + } | |
116 | 164 | |
117 | 165 | # check if it's a module |
118 | 166 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) { |
167 | + $module = $3; | |
168 | + } | |
169 | + if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) { | |
119 | 170 | $module = $3; |
120 | 171 | } |
121 | 172 | parse_x86_regs($line); |