1 /* $Id: emdmp.c,v 1.3 1994/06/24 10:03:31 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
8 /* Author: E.G. Keizer */
10 /* Print a readable version of the data in the post mortem dump */
11 /* dmpc [-s] [-dn,m] [file] */
24 long ignmask,uerrorproc,cause;
25 long pc,sp,lb,hp,pd,pb;
46 "Illegal instruction",
47 "Illegal size parameter",
52 "Bad argument of LAE",
55 "GTO descriptor error"
72 main(argc,argv) char **argv;
78 scanargs(argc,argv); fcore=fopen(core,"r") ;
79 if ( fcore==NULL ) fatal("Can't open %s",core) ;
81 if ( read2()!=010255 ) fatal("not a post mortem dump");
82 if ( read2()!=VERSION ) fatal("wrong version dump file");
83 wsize=read2(); asize=read2();
84 if ( wsize>4 ) fatal("cannot handle word size %d",wsize) ;
85 if ( asize>4 ) fatal("cannot handle pointer size %d",asize) ;
86 tsize=readaddr(); dsize=readaddr();
87 ignmask=readaddr(); uerrorproc=readaddr(); cause=readaddr();
88 pc=readaddr(); sp=readaddr(); lb=readaddr(); hp=readaddr();
89 pd=readaddr(); pb=readaddr();
94 for ( i=0 ; i<40 ; i++ ) {
95 tok=getbyte(fileaddr++) ;
96 if ( !isprint(tok) ) break ;
102 printf("line %ld",line) ;
104 if ( fileaddr || line ) printf(", ");
108 printn("cause",cause) ;
110 prints("cause",cstr[(int)cause]);
112 printn("pc",pc);printn("sp",sp);printn("lb",lb);
114 if ( pd ) printn("pd",pd) ;
115 if ( pb ) printn("pb",pb) ;
116 printn("errproc",uerrorproc) ;
117 printn("ignmask",ignmask) ;
118 if ( tsize ) printn("Text size",tsize) ;
119 if ( dsize ) printn("Data size",dsize) ;
121 if ( dflag==0 ) exit(0);
122 fatal("d-flag not implemeted (yet)");
126 scanargs(argc,argv) char **argv ; {
128 while ( argv++, argc-- > 1 ) {
129 switch( argv[0][0] ) {
130 case '-': switch( argv[0][1] ) {
131 case 's': sflag++ ; break ;
132 case 'l': dflag++ ; break ;
133 default : fatal(": [-s] [-ln.m] [file]") ;
136 default :core=argv[0] ;
141 prints(s1,s2) char *s1,*s2; {
142 printf("%-15s %s\n",s1,s2);
145 printn(s1,d) char *s1; long d; {
146 printf("%-15s %15ld\n",s1,d);
150 fatal(s1,p1,p2,p3,p4,p5) char *s1 ; {
151 fprintf(stderr,"%s: ",pname);
152 fprintf(stderr,s1,p1,p2,p3,p4,p5) ;
153 fprintf(stderr,"\n") ;
160 if ( i==EOF ) fatal("Premature EOF");
166 i=getb() ; return getb()*256 + i ;
174 for (i=0 ; i<asize ; i++ ) res |= getb()<<(8*i) ;
183 for (i=0 ; i<wsize ; i++ ) res |= getb()<<(8*i) ;
187 unsigned getbyte(a) long a ; {
188 fseek(fcore,a+512,0) ;
192 long getword(a) long a ; {
193 fseek(fcore,a+512,0) ;
197 long getaddr(a) long a ; {
198 fseek(fcore,a+512,0) ;