![]() |
![]() |
Debugging CPU Faults
The “gdis” disassembler is a powerful debugging aide that can help you turn a cryptic crash dump (i.e the text that is printed in your gload window when your program takes an exception) into useful debugging information.
For example, you can disassemble the section named “code” (as specified in the spec file) in the “chrome” example application executable as follows:
% gdis -S -t .code.text letters
Here is a portion of the output ...
[ 144] 0x80200050: 27 bd ff 90 addiu sp,sp,-112
[ 144] 0x80200054: af bf 00 1c sw ra,28(sp)
145: int i, *pr;
146: char *ap;
147: u32 *argp;
148: u32 argbuf[16];
149:
150: /* notice that you can’t call rmonPrintf() until you set
151: * up the rmon thread.
152: */
153:
154: osInitialize();
[ 154] 0x80200058: 0c 08 04 c4 jal osInitialize
[ 154] 0x8020005c: 00 00 00 00 nop
155:
156: argp = (u32 *)RAMROM_APP_WRITE_ADDR;
[ 156] 0x80200060: 3c 0e 00 ff lui t6,0xff
[ 156] 0x80200064: 35 ce b0 00 ori t6,t6,0xb000
[ 156] 0x80200068: af ae 00 60 sw t6,96(sp)
157: for (i=0; i<sizeof(argbuf)/4; i++, argp++) {
[ 157] 0x8020006c: af a0 00 6c sw zero,108(sp)
158: osPiRawReadIo((u32)argp, &argbuf[i]); /* Assume no DMA */
[ 158] 0x80200070: 8f af 00 6c lw t7,108(sp)
[ 158] 0x80200074: 8f a4 00 60 lw a0,96(sp)
[ 158] 0x80200078: 27 b9 00 20 addiu t9,sp,32
[ 158] 0x8020007c: 00 0f c0 80 sll t8,t7,2
[ 158] 0x80200080: 0c 08 05 4c jal osPiRawReadIo
[ 158] 0x80200084: 03 19 28 21 addu a1,t8,t9
[ 157] 0x80200088: 8f a8 00 6c lw t0,108(sp)
[ 157] 0x8020008c: 8f aa 00 60 lw t2,96(sp)
[ 157] 0x80200090: 25 09 00 01 addiu t1,t0,1
[ 157] 0x80200094: 2d 21 00 10 sltiu at,t1,16
[ 157] 0x80200098: 25 4b 00 04 addiu t3,t2,4
[ 157] 0x8020009c: af ab 00 60 sw t3,96(sp)
[ 157] 0x802000a0: 14 20 ff f3 bne at,zero,0x80200070
[ 157] 0x802000a4: af a9 00 6c sw t1,108(sp)
159: }
...
Notice that the C source is interleaved with the disassembled code, and that the PC is given in the second column.
When your program crashes, you can look up the error PC listed in the crash dump (it is identified as “epc”) to determine where the program crashed and find the corresponding line in the source/disassembly listing.
Copyright © 1999 Nintendo of America Inc. All Rights Reserved Nintendo and N64 are registered trademarks of Nintendo Last Updated January, 1999 |