------- Comment #11 from dick_guertin at yahoo dot com 2006-01-18 03:10 ------- I think I've found the 'smoking gun'. Here is a listing of NSCAN
void NSCAN() { unsigned char *token; long token_length; long r[16]; r[3] = htonl(R2); r[4] = htonl(R3); r[5] = htonl(R4); r[6] = htonl(R5); r[7] = htonl(R6); R15 = nscan((NSCNCB *) R1, &token, &token_length, r); R0 = token_length; R1 = (long) token; R2 = ntohl(r[3]); R3 = ntohl(r[4]); R4 = ntohl(r[5]); R5 = ntohl(r[6]); R6 = ntohl(r[7]); I_LTR(R15,R15); } Later, I've included a 'disassem' of this code compiled with -O2. Here is what happened when the program was executed: This GDB was configured as "sparc-sun-solaris2.8"... (gdb) break comm.c:3651 Breakpoint 1 at 0x269ec: file comm.c, line 3651. (gdb) run Starting program: /afs/ir.stanford.edu/users/g/u/guertin/wylsrc/wylbur.ge Breakpoint 1, EDTBASE () at comm.c:3651 3651 NSCAN (); (gdb) x/4bx &r1 0x2d6a0c <r1>: 0x00 0x31 0x17 0x80 (gdb) break nscan Breakpoint 2 at 0x1eb3e8: file scan.c, line 1122. (gdb) cont Continuing. Breakpoint 2, nscan (scancb=0x0, token=0xffbef3dc, token_length=0xffbef3d8, stack_pointer=0xffbef3e0) at scan.c:1122 1122 if (scancb->skip == NULL) (gdb) where #0 nscan (scancb=0x0, token=0xffbef3dc, token_length=0xffbef3d8, stack_pointer=0xffbef3e0) at scan.c:1122 #1 0x001eeb44 in NSCAN () at scanstub.c:304 #2 0x000269f4 in EDTBASE () at comm.c:3651 #3 0x00027428 in EDTCOM () at comm.c:3464 #4 0x001ef540 in signon (edit_file=0xffbef890 "") at sign.c:477 #5 0x000e82fc in main (argc=1, argv=0xffbefa0c) at main.c:110 (gdb) x/4bx &scancb Address requested for identifier "scancb" which is in register $l0 (gdb) disas NSCAN Dump of assembler code for function NSCAN: 0x001eeaec <NSCAN+0>: save %sp, -184, %sp 0x001eeaf0 <NSCAN+4>: sethi %hi(0x2d6800), %l1 0x001eeaf4 <NSCAN+8>: ld [ %l1 + 0x1fc ], %o2 ! 0x2d69fc <r2> 0x001eeaf8 <NSCAN+12>: sethi %hi(0x2d6800), %l2 0x001eeafc <NSCAN+16>: ld [ %l2 + 0x1d4 ], %o3 ! 0x2d69d4 <r3> 0x001eeb00 <NSCAN+20>: sethi %hi(0x2d6800), %l3 0x001eeb04 <NSCAN+24>: ld [ %l3 + 0x1e4 ], %o4 ! 0x2d69e4 <r4> 0x001eeb08 <NSCAN+28>: sethi %hi(0x2d6800), %l4 0x001eeb0c <NSCAN+32>: ld [ %l4 + 0x208 ], %o5 ! 0x2d6a08 <r5> 0x001eeb10 <NSCAN+36>: sethi %hi(0x2d6800), %l5 0x001eeb14 <NSCAN+40>: ld [ %l5 + 0x1e0 ], %g1 ! 0x2d69e0 <r6> 0x001eeb18 <NSCAN+44>: sethi %hi(0x2d6800), %l0 0x001eeb1c <NSCAN+48>: st %o2, [ %fp + -68 ] 0x001eeb20 <NSCAN+52>: st %o3, [ %fp + -64 ] 0x001eeb24 <NSCAN+56>: st %o4, [ %fp + -60 ] 0x001eeb28 <NSCAN+60>: st %o5, [ %fp + -56 ] 0x001eeb2c <NSCAN+64>: st %g1, [ %fp + -52 ] 0x001eeb30 <NSCAN+68>: add %fp, -80, %o3 0x001eeb34 <NSCAN+72>: ld [ %l0 + 0x20c ], %o0 0x001eeb38 <NSCAN+76>: add %fp, -84, %o1 0x001eeb3c <NSCAN+80>: call 0x1eb3e4 <nscan> 0x001eeb40 <NSCAN+84>: add %fp, -88, %o2 0x001eeb44 <NSCAN+88>: sethi %hi(0x2d6800), %o3 0x001eeb48 <NSCAN+92>: st %o0, [ %o3 + 0x204 ] ! 0x2d6a04 <r15> 0x001eeb4c <NSCAN+96>: ld [ %fp + -88 ], %o4 0x001eeb50 <NSCAN+100>: sethi %hi(0x2d6800), %g1 0x001eeb54 <NSCAN+104>: st %o4, [ %g1 + 0x1e8 ] ! 0x2d69e8 <r0> 0x001eeb58 <NSCAN+108>: ld [ %fp + -84 ], %o5 0x001eeb5c <NSCAN+112>: st %o5, [ %l0 + 0x20c ] 0x001eeb60 <NSCAN+116>: ld [ %fp + -68 ], %g1 0x001eeb64 <NSCAN+120>: st %g1, [ %l1 + 0x1fc ] 0x001eeb68 <NSCAN+124>: ld [ %fp + -64 ], %o5 0x001eeb6c <NSCAN+128>: st %o5, [ %l2 + 0x1d4 ] 0x001eeb70 <NSCAN+132>: ld [ %fp + -60 ], %g1 0x001eeb74 <NSCAN+136>: st %g1, [ %l3 + 0x1e4 ] 0x001eeb78 <NSCAN+140>: ld [ %fp + -56 ], %o5 0x001eeb7c <NSCAN+144>: st %o5, [ %l4 + 0x208 ] 0x001eeb80 <NSCAN+148>: ld [ %fp + -52 ], %g1 0x001eeb84 <NSCAN+152>: st %g1, [ %l5 + 0x1e0 ] 0x001eeb88 <NSCAN+156>: ld [ %o3 + 0x204 ], %o5 0x001eeb8c <NSCAN+160>: st %o5, [ %o3 + 0x204 ] 0x001eeb90 <NSCAN+164>: ld [ %o3 + 0x204 ], %o4 0x001eeb94 <NSCAN+168>: sethi %hi(0x2d0400), %g1 0x001eeb98 <NSCAN+172>: sethi %hi(0x2d0400), %o5 0x001eeb9c <NSCAN+176>: st %o4, [ %g1 + 0x354 ] 0x001eeba0 <NSCAN+180>: clr [ %o5 + 0x350 ] 0x001eeba4 <NSCAN+184>: ret 0x001eeba8 <NSCAN+188>: restore End of assembler dump. (gdb) print &r1 $1 = (volatile long unsigned int *) 0x2d6a0c (gdb) print &r2 $2 = (volatile long unsigned int *) 0x2d69fc (gdb) maintenance print raw-registers Name Nr Rel Offset Size Type Raw value g0 0 0 0 4 int32_t 0x00000000 g1 1 1 4 4 int32_t 0x00000000 g2 2 2 8 4 int32_t 0x00000000 g3 3 3 12 4 int32_t 0x00000000 g4 4 4 16 4 int32_t 0x00000000 g5 5 5 20 4 int32_t 0x00000000 g6 6 6 24 4 int32_t 0x00000000 g7 7 7 28 4 int32_t 0x00000000 o0 8 8 32 4 int32_t 0x00000000 o1 9 9 36 4 int32_t 0x00000000 o2 10 10 40 4 int32_t 0x00000000 o3 11 11 44 4 int32_t 0x00000000 o4 12 12 48 4 int32_t 0x00000000 o5 13 13 52 4 int32_t 0x00000000 sp 14 14 56 4 *1 0xffbef300 o7 15 15 60 4 int32_t 0x00000000 l0 16 16 64 4 int32_t 0x00000000 l1 17 17 68 4 int32_t 0x00000000 l2 18 18 72 4 int32_t 0x00000000 l3 19 19 76 4 int32_t 0x00000000 l4 20 20 80 4 int32_t 0x00000000 l5 21 21 84 4 int32_t 0x00000000 l6 22 22 88 4 int32_t 0x00000000 l7 23 23 92 4 int32_t 0x00000000 i0 24 24 96 4 int32_t 0x00311780 i1 25 25 100 4 int32_t 0xffbef3dc i2 26 26 104 4 int32_t 0xffbef3d8 i3 27 27 108 4 int32_t 0xffbef3e0 i4 28 28 112 4 int32_t 0x00000066 i5 29 29 116 4 int32_t 0x00311932 fp 30 30 120 4 *1 0xffbef378 i7 31 31 124 4 int32_t 0x001eeb3c y 64 64 256 4 int32_t 0x00000000 psr 65 65 260 4 int32_t 0xfe401002 pc 68 68 272 4 *1 0x001eb3e8 npc 69 69 276 4 *1 0x001eb3ec *1: Register type's name NULL. (gdb) disas nscan Dump of assembler code for function nscan: 0x001eb3e4 <nscan+0>: save %sp, -120, %sp 0x001eb3e8 <nscan+4>: ld [ %i0 + 0x24 ], %g1 0x001eb3ec <nscan+8>: cmp %g1, 0 0x001eb3f0 <nscan+12>: bne 0x1eb404 <nscan+32> 0x001eb3f4 <nscan+16>: mov %i0, %l0 0x001eb3f8 <nscan+20>: sethi %hi(0x2c2800), %g1 0x001eb3fc <nscan+24>: or %g1, 0x138, %g1 ! 0x2c2938 <tblwskip> 0x001eb400 <nscan+28>: st %g1, [ %i0 + 0x24 ] 0x001eb404 <nscan+32>: ld [ %l0 + 0x20 ], %g1 0x001eb408 <nscan+36>: cmp %g1, 0 0x001eb40c <nscan+40>: bne,a 0x1eb424 <nscan+64> 0x001eb410 <nscan+44>: ld [ %l0 + 0x28 ], %g1 0x001eb414 <nscan+48>: sethi %hi(0x2c2800), %g1 0x001eb418 <nscan+52>: or %g1, 0x38, %g1 ! 0x2c2838 <tblwmark> 0x001eb41c <nscan+56>: st %g1, [ %l0 + 0x20 ] 0x001eb420 <nscan+60>: ld [ %l0 + 0x28 ], %g1 0x001eb424 <nscan+64>: cmp %g1, 0 0x001eb428 <nscan+68>: be 0x1eb564 <nscan+384> 0x001eb42c <nscan+72>: clr [ %l0 + 0x5c ] 0x001eb430 <nscan+76>: clr [ %fp + -20 ] 0x001eb434 <nscan+80>: b 0x1eb448 <nscan+100> 0x001eb438 <nscan+84>: mov 1, %l2 0x001eb43c <nscan+88>: cmp %i0, 0 0x001eb440 <nscan+92>: bne,a 0x1eb598 <nscan+436> 0x001eb444 <nscan+96>: ld [ %l0 + 0x10 ], %o2 0x001eb448 <nscan+100>: call 0x1eae64 <scntoken> 0x001eb44c <nscan+104>: mov %l0, %o0 0x001eb450 <nscan+108>: mov %o0, %o1 0x001eb454 <nscan+112>: st %o0, [ %fp + -20 ] 0x001eb458 <nscan+116>: call 0x1ea4e0 <set_token> 0x001eb45c <nscan+120>: mov %l0, %o0 0x001eb460 <nscan+124>: mov %o0, %o1 0x001eb464 <nscan+128>: st %o0, [ %fp + -20 ] 0x001eb468 <nscan+132>: call 0x1ea5a0 <set_type> 0x001eb46c <nscan+136>: mov %l0, %o0 0x001eb470 <nscan+140>: ld [ %l0 + 0x10 ], %o2 0x001eb474 <nscan+144>: mov %o0, %i0 0x001eb478 <nscan+148>: st %o0, [ %fp + -20 ] ---Type <return> to continue, or q <return> to quit--- Notice that 'nscan' expects 'scancb' in %l0, but it is ZERO. It does NOT contain the value in R1 (aka: r1). (gdb) x/4bx &r1 0x2d6a0c <r1>: 0x00 0x31 0x17 0x80 Notice the assembly code in NSCAN just before the 'call nscan' at NSCAN+80. r1 never gets loaded into %l0. Therefore, it is NOT passed to 'nscan' properly. This is the point of failure. A portion of 'nscan' code matching the disassemb above is: long nscan(NSCNCB *scancb, unsigned char **token, long *token_length, long stack_pointer[]) { long result; /* Set scan defaults if needed */ if (scancb->skip == NULL) scancb->skip = (unsigned char *) htonl((long) tblwskip); if (scancb->stop == NULL) scancb->stop = (unsigned char *) htonl((long) tblwmark); scancb->msgl = 0; etc. R1 is defined as an alias of r1, and r1 is a global value, like this: define.vars.h:#define R1 r1 define.vars.h:volatile unsigned long r1; Can you dispute my findings? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25791