* [Linux-ia64] Script for decoding PSR in oopses
@ 2003-01-31 1:46 Peter Chubb
2003-01-31 2:10 ` Keith Owens
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Peter Chubb @ 2003-01-31 1:46 UTC (permalink / raw)
To: linux-ia64
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 204 bytes --]
hi,
I find trying to work out what the PSR is after an oops to be
a bit of a pain, so here's an awk script to do it for you.
Usage is
decode_psr hex_number
if you save the script as decode_psr.
[-- Attachment #2: decode_psr --]
[-- Type: text/plain, Size: 2821 bytes --]
#!/bin/sh
echo $1 | awk '
function readhex(hexval, i, digits, value, ndigit) {
tolower(hexval);
ndigit = gsub("[a-f0-9]", " &", hexval);
split(hexval, digits, " ");
value = 0;
for ( i = 1; i <= ndigit; i++) {
value *= 16;
value += values[digits[i]];
}
return value;
}
function decode_psr(psr, decoded, cpl) {
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = "be "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "up "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "ac "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "mfl "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "mfh "
psr = int(psr / 256);
if (psr % 2)
decoded = decoded "ic "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "i "
psr = int(psr / 2);
if (psr % 2 == 1)
decoded = decoded "pk "
psr = int(psr / 4)
if (psr % 2 == 1)
decoded = decoded "dt "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "dfl "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "dfh "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "sp "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "pp "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "di "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "si "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "db "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "lb "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "tb "
psr = int(psr / 2)
if (psr % 2 == 1)
decoded = decoded "rt "
psr = int(psr / 16)
cpl = psr % 4;
decoded = decoded "cpl=" cpl " "
psr = int(psr/4)
if (psr % 2)
decoded = decoded "IA32 "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "mc "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "it "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "id "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "da "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "dd "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "ss "
psr = int(psr / 2)
cpl = psr %4
decoded= decoded "ri=" cpl " "
psr = int(psr / 4)
if (psr % 2)
decoded = decoded "ed "
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "bn"
psr = int(psr / 2)
if (psr % 2)
decoded = decoded "ia"
psr = int(psr / 2)
if (psr)
decoded = decoded "Reserved = " psr
return decoded
}
BEGIN {
for (i = 0; i < 10; i++)
values[i ""] = i;
values["a"] = 10;
values["b"] = 11;
values["c"] = 12;
values["d"] = 13;
values["e"] = 14;
values["f"] = 15;
}
{ print $1, decode_psr(readhex($1)) }
'
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb @ 2003-01-31 2:10 ` Keith Owens 2003-01-31 2:31 ` David Mosberger ` (6 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: Keith Owens @ 2003-01-31 2:10 UTC (permalink / raw) To: linux-ia64 On Fri, 31 Jan 2003 12:46:00 +1100, Peter Chubb <peter@chubb.wattle.id.au> wrote: > I find trying to work out what the PSR is after an oops to be >a bit of a pain, so here's an awk script to do it for you. > >Usage is > decode_psr hex_number >if you save the script as decode_psr. Below are Perl ia64_psr and ia64_isr. Run as echo hex_number | ia64_[pi]sr == ia64_psr = #!/usr/bin/perl -w use strict; use integer; my @fields = ( [ 0, 6, "User mask" ], [ 0, 1, "rv" ], [ 1, 1, "be" ], [ 2, 1, "up" ], [ 3, 1, "ac" ], [ 4, 1, "mfl" ], [ 5, 1, "mfh" ], [ 0, 24, "System mask" ], [ 6, 6, "rv" ], [ 13, 1, "ic" ], [ 14, 1, "i" ], [ 15, 1, "pk" ], [ 16, 1, "rv" ], [ 17, 1, "dt" ], [ 18, 1, "dfl" ], [ 19, 1, "dfh" ], [ 20, 1, "sp" ], [ 21, 1, "pp" ], [ 22, 1, "di" ], [ 23, 1, "si" ], [ 24, 1, "db" ], [ 25, 1, "lp" ], [ 26, 1, "tb" ], [ 27, 1, "rt" ], [ 28, 4, "rv" ], [ 32, 2, "cpl" ], [ 34, 1, "is" ], [ 35, 1, "mc" ], [ 36, 1, "it" ], [ 37, 1, "id" ], [ 38, 1, "da" ], [ 39, 1, "dd" ], [ 40, 1, "ss" ], [ 41, 2, "ri" ], [ 43, 1, "ed" ], [ 44, 1, "bn" ], [ 45, 1, "ia" ], [ 46, 18, "rv" ] ); while (defined($_ = <STDIN>)) { chomp(); my $w0 = hex(substr($_, 0, -8)); my $w1 = hex(substr($_, -8)); printf("psr %s\n", $_); &ia64_psr($w1, 0, 32); &ia64_psr($w0, 32, 64); } sub ia64_psr() { my ($w, $s, $e) = @_; my $v; foreach (@fields) { next if ($_->[0] >= $e); next if ($_->[0] < $s); # use integer implies signed shift, I want unsigned no integer; $v = ($w >> ($_->[0] - $s)) & (~0 >> (32 - $_->[1])); printf("%2d %2d %12s %x\n", $_->[0], $_->[1], $_->[2], $v); } } == ia64_isr = #!/usr/bin/perl -w use strict; use integer; my @fields = ( [ 0, 16, "Code" ], [ 16, 8, "Vector" ], [ 24, 8, "rv" ], [ 32, 1, "x" ], [ 33, 1, "w" ], [ 34, 1, "r" ], [ 35, 1, "na" ], [ 36, 1, "sp" ], [ 37, 1, "rs" ], [ 39, 1, "ni" ], [ 40, 1, "so" ], [ 41, 2, "ei" ], [ 43, 1, "ed" ], [ 44, 20, "rv" ], ); while (defined($_ = <STDIN>)) { chomp(); my $w0 = hex(substr($_, 0, -8)); my $w1 = hex(substr($_, -8)); printf("isr %s\n", $_); &ia64_isr($w1, 0, 32); &ia64_isr($w0, 32, 64); } sub ia64_isr() { my ($w, $s, $e) = @_; my $v; foreach (@fields) { next if ($_->[0] >= $e); next if ($_->[0] < $s); # use integer implies signed shift, I want unsigned no integer; $v = ($w >> ($_->[0] - $s)) & (~0 >> (32 - $_->[1])); printf("%2d %2d %12s %x\n", $_->[0], $_->[1], $_->[2], $v); } } ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb 2003-01-31 2:10 ` Keith Owens @ 2003-01-31 2:31 ` David Mosberger 2003-01-31 3:31 ` Peter Chubb ` (5 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: David Mosberger @ 2003-01-31 2:31 UTC (permalink / raw) To: linux-ia64 >>>>> On Fri, 31 Jan 2003 13:10:58 +1100, Keith Owens <kaos@ocs.com.au> said: Keith> On Fri, 31 Jan 2003 12:46:00 +1100, Peter Chubb Keith> <peter@chubb.wattle.id.au> wrote: >> I find trying to work out what the PSR is after an oops to be a >> bit of a pain, so here's an awk script to do it for you. >> Usage is decode_psr hex_number if you save the script as >> decode_psr. Keith> Below are Perl ia64_psr and ia64_isr. Run as echo hex_number Keith> | ia64_[pi]sr OK, now where is the Python version?? ;-)) --david ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb 2003-01-31 2:10 ` Keith Owens 2003-01-31 2:31 ` David Mosberger @ 2003-01-31 3:31 ` Peter Chubb 2003-01-31 4:41 ` Wichmann, Mats D ` (4 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: Peter Chubb @ 2003-01-31 3:31 UTC (permalink / raw) To: linux-ia64 >>>>> "David" = David Mosberger <davidm@napali.hpl.hp.com> writes: >>>>> On Fri, 31 Jan 2003 13:10:58 +1100, Keith Owens <kaos@ocs.com.au> said: Keith> On Fri, 31 Jan 2003 12:46:00 +1100, Peter Chubb Keith> <peter@chubb.wattle.id.au> wrote: >>> I find trying to work out what the PSR is after an oops to be a >>> bit of a pain, so here's an awk script to do it for you. >>> Usage is decode_psr hex_number if you save the script as >>> decode_psr. Keith> Below are Perl ia64_psr and ia64_isr. Run as echo hex_number | Keith> ia64_[pi]sr David> OK, now where is the Python version?? ;-)) Who cares? Once you've got a script you can use it. BTW, there's a bug in the AWK script: --- decode_psr-old 2003-01-31 13:33:51.000000000 +1100 +++ decode_psr 2003-01-31 13:11:13.000000000 +1100 @@ -77,7 +77,7 @@ psr = int(psr / 2) if (psr % 2 = 1) decoded = decoded "rt " - psr = int(psr / 16) + psr = int(psr / 32) cpl = psr % 4; decoded = decoded "cpl=" cpl " " ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb ` (2 preceding siblings ...) 2003-01-31 3:31 ` Peter Chubb @ 2003-01-31 4:41 ` Wichmann, Mats D 2003-01-31 4:56 ` Keith Owens ` (3 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: Wichmann, Mats D @ 2003-01-31 4:41 UTC (permalink / raw) To: linux-ia64 > Keith> Below are Perl ia64_psr and ia64_isr. Run as echo hex_number > Keith> | ia64_[pi]sr > > OK, now where is the Python version?? ;-)) For once :-) the Perl isn't obtuse enough to make it necessary. (grin) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb ` (3 preceding siblings ...) 2003-01-31 4:41 ` Wichmann, Mats D @ 2003-01-31 4:56 ` Keith Owens 2003-01-31 5:08 ` David Mosberger ` (2 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: Keith Owens @ 2003-01-31 4:56 UTC (permalink / raw) To: linux-ia64 On Thu, 30 Jan 2003 20:41:19 -0800, "Wichmann, Mats D" <mats.d.wichmann@intel.com> wrote: >david mosberger wrote >> OK, now where is the Python version?? ;-)) > >For once :-) the Perl isn't obtuse enough to >make it necessary. (grin) Damn! Now I have to return my "Perl Obfuscator" badge. OTOH, this bit from a Perl decoder for ia64 unwind data should reinstate my rating. <ducks and runs> my @decode_type; sub set_decode_type() { my ($i, $mask, $type, $start, $end); for ($i = 0; $i < 256; ++$i) { $decode_type[0][$i] = '?'; $decode_type[1][$i] = '?'; } foreach ( # prologue body [ 0, '00-- ----', 'R1' ], [ 1, '00-- ----', 'R1' ], [ 0, '0100 0---', 'R2' ], [ 1, '0100 0---', 'R2' ], [ 0, '0110 00--', 'R3' ], [ 1, '0110 00--', 'R3' ], [ 0, '100- ----', 'P1' ], [ 0, '1010 ----', 'P2' ], [ 0, '1011 0---', 'P3' ], [ 0, '1011 1000', 'P4' ], [ 0, '1011 1001', 'P5' ], [ 0, '110- ----', 'P6' ], [ 0, '1110 ----', 'P7' ], [ 0, '1111 0000', 'P8' ], [ 0, '1111 0001', 'P9' ], [ 0, '1111 1001', 'X1' ], [ 0, '1111 1010', 'X2' ], [ 0, '1111 1011', 'X3' ], [ 0, '1111 1100', 'X4' ], [ 0, '1111 1111', 'P10' ], [ 1, '10-- ----', 'B1' ], [ 1, '110- ----', 'B2' ], [ 1, '1110 0000', 'B3' ], # manual only lists this form for B3 ... [ 1, '1110 1010', 'ea' ], # ... but this one is used as well :( [ 1, '1111 0000', 'B4' ], [ 1, '1111 1000', 'B4' ], [ 1, '1111 1001', 'X1' ], [ 1, '1111 1010', 'X2' ], [ 1, '1111 1011', 'X3' ], [ 1, '1111 1100', 'X4' ], ) { $mask = '0b' . $_->[1]; $mask =~ s/ //g; $start = $end = $mask; $start =~ s/-/0/g; $end =~ s/-/1/g; for ($i = oct($start); $i <= oct($end); ++$i) { if ($decode_type[$_->[0]][$i] ne '?') { die("$0 decode_type[$_->[0]][$i] already set to $decode_type[$_->[0]][$i], ignoring $_->[2]\n"); } $decode_type[$_->[0]][$i] = $_->[2]; } } } ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb ` (4 preceding siblings ...) 2003-01-31 4:56 ` Keith Owens @ 2003-01-31 5:08 ` David Mosberger 2003-01-31 20:10 ` Jim Hull 2003-02-10 5:12 ` Matt Chapman 7 siblings, 0 replies; 9+ messages in thread From: David Mosberger @ 2003-01-31 5:08 UTC (permalink / raw) To: linux-ia64 >>>>> On Fri, 31 Jan 2003 14:31:43 +1100, Peter Chubb <peter@chubb.wattle.id.au> said: >>>> Usage is decode_psr hex_number if you save the script as >>>> decode_psr. Keith> Below are Perl ia64_psr and ia64_isr. Run as echo hex_number Keith> ia64_[pi]sr David> OK, now where is the Python version?? ;-)) Peter> Who cares? Once you've got a script you can use it. Oh, man, are you one of those heathens who think that _any_ language will do?? --david PS: Sorry if my jokes aren't funny. Just couldn't resist... ;-) ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb ` (5 preceding siblings ...) 2003-01-31 5:08 ` David Mosberger @ 2003-01-31 20:10 ` Jim Hull 2003-02-10 5:12 ` Matt Chapman 7 siblings, 0 replies; 9+ messages in thread From: Jim Hull @ 2003-01-31 20:10 UTC (permalink / raw) To: linux-ia64 Peter wrote: > BTW, there's a bug in the AWK script: There's also a bug in perl version of ia64_psr: --- ia64_psr_orig Fri Jan 31 11:49:35 2003 +++ ia64_psr Fri Jan 31 11:49:35 2003 @@ -11,7 +11,7 @@ [ 4, 1, "mfl" ], [ 5, 1, "mfh" ], [ 0, 24, "System mask" ], - [ 6, 6, "rv" ], + [ 6, 7, "rv" ], [ 13, 1, "ic" ], [ 14, 1, "i" ], [ 15, 1, "pk" ], -- Jim ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] Script for decoding PSR in oopses 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb ` (6 preceding siblings ...) 2003-01-31 20:10 ` Jim Hull @ 2003-02-10 5:12 ` Matt Chapman 7 siblings, 0 replies; 9+ messages in thread From: Matt Chapman @ 2003-02-10 5:12 UTC (permalink / raw) To: linux-ia64 On Fri, Jan 31, 2003 at 12:10:29PM -0800, Jim Hull wrote: > Peter wrote: > > > BTW, there's a bug in the AWK script: > > There's also a bug in perl version of ia64_psr: And ia64_isr is missing ir: --- ia64_isr.orig Mon Feb 10 16:03:42 2003 +++ ia64_isr Mon Feb 10 16:08:28 2003 @@ -12,6 +12,7 @@ [ 35, 1, "na" ], [ 36, 1, "sp" ], [ 37, 1, "rs" ], + [ 38, 1, "ir" ], [ 39, 1, "ni" ], [ 40, 1, "so" ], [ 41, 2, "ei" ], Matt ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-02-10 5:12 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-01-31 1:46 [Linux-ia64] Script for decoding PSR in oopses Peter Chubb 2003-01-31 2:10 ` Keith Owens 2003-01-31 2:31 ` David Mosberger 2003-01-31 3:31 ` Peter Chubb 2003-01-31 4:41 ` Wichmann, Mats D 2003-01-31 4:56 ` Keith Owens 2003-01-31 5:08 ` David Mosberger 2003-01-31 20:10 ` Jim Hull 2003-02-10 5:12 ` Matt Chapman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox