[Linux-ia64] Script for decoding PSR in oopses

From: Peter Chubb <peter_at_chubb.wattle.id.au>
Date: 2003-01-31 12:46:00
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.


#!/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)) }
'
Received on Thu Jan 30 17:46:39 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:11 EST