public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [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

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