64-bit fixes. [rsc] --rw-rw-r-- M 451989 glenda sys 5885 Nov 6 11:07 sys/src/cmd/ktrace.c /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:4,13 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:4,13 #include #include - static int rtrace(ulong, ulong, ulong); - static int ctrace(ulong, ulong, ulong); - static int i386trace(ulong, ulong, ulong); - static ulong getval(ulong); + static int rtrace(uvlong, uvlong, uvlong); + static int ctrace(uvlong, uvlong, uvlong); + static int i386trace(uvlong, uvlong, uvlong); + static uvlong getval(uvlong); static void inithdr(int); static void fatal(char*, ...); static void readstack(void); /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:25,31 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:25,31 } static void - printaddr(char *addr, ulong pc) + printaddr(char *addr, uvlong pc) { int i; char *p; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:42,48 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:42,48 if(!isxdigit(addr[i])) break; if(i == 8){ - print("src(0x%.8lux); // 0x%s\n", pc, addr); + print("src(0x%.8llux); // 0x%s\n", pc, addr); return; } } /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:49,66 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:49,66 if(p=strchr(addr, '+')){ *p++ = 0; - print("src(0x%.8lux); // %s+0x%s\n", pc, addr, p); + print("src(0x%.8llux); // %s+0x%s\n", pc, addr, p); }else - print("src(0x%.8lux); // %s\n", pc, addr); + print("src(0x%.8llux); // %s\n", pc, addr); } - static void (*fmt)(char*, ulong) = printaddr; + static void (*fmt)(char*, uvlong) = printaddr; void main(int argc, char *argv[]) { - int (*t)(ulong, ulong, ulong); - ulong pc, sp, link; + int (*t)(uvlong, uvlong, uvlong); + uvlong pc, sp, link; int fd; ARGBEGIN{ /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:76,82 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:76,82 switch(argc){ case 4: t = rtrace; - link = strtoul(argv[3], 0, 16); + link = strtoull(argv[3], 0, 16); break; case 3: break; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:83,90 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:83,90 default: usage(); } - pc = strtoul(argv[1], 0, 16); - sp = strtoul(argv[2], 0, 16); + pc = strtoull(argv[1], 0, 16); + sp = strtoull(argv[2], 0, 16); if(!interactive) readstack(); /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:135,145 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:135,145 } static int - rtrace(ulong pc, ulong sp, ulong link) + rtrace(uvlong pc, uvlong sp, uvlong link) { Symbol s, f; char buf[128]; - ulong oldpc; + uvlong oldpc; int i; i = 0; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:175,187 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:175,187 } static int - ctrace(ulong pc, ulong sp, ulong link) + ctrace(uvlong pc, uvlong sp, uvlong link) { Symbol s; char buf[128]; int found; - ulong opc; - long moved, j; + uvlong opc, moved; + long j; USED(link); j = 0; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:188,195 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:188,195 opc = 0; while(pc && opc != pc) { moved = pc2sp(pc); - if (moved == -1){ - print("pc2sp(%.8lux) = -1 %r\n", pc); + if (moved == ~0){ + print("pc2sp(%.8llux) = -1 %r\n", pc); break; } found = findsym(pc, CTEXT, &s); /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:213,222 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:213,222 } static int - i386trace(ulong pc, ulong sp, ulong link) + i386trace(uvlong pc, uvlong sp, uvlong link) { int i; - ulong osp; + uvlong osp; Symbol s, f; char buf[128]; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:228,256 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:228,261 symoff(buf, sizeof buf, pc, CANY); fmt(buf, pc); + //XXX s.value &= ~(uintptr)0; if(pc != s.value) { /* not at first instruction */ if(findlocal(&s, FRAMENAME, &f) == 0) break; sp += f.value-mach->szaddr; }else if(strcmp(s.name, "forkret") == 0){ - print("//passing interrupt frame; last pc found at sp=%lux\n", osp); + //XXX + print("//passing interrupt frame; last pc found at sp=%llux\n", osp); + sp += 15 * mach->szaddr; /* pop interrupt frame */ } pc = getval(sp); + //XXX if(pc == 0 && strcmp(s.name, "forkret") == 0){ sp += 3 * mach->szaddr; /* pop iret eip, cs, eflags */ - print("//guessing call through invalid pointer, try again at sp=%lux\n", sp); + print("//guessing call through invalid pointer, try again at sp=%llux\n", sp); s.name = ""; pc = getval(sp); } if(pc == 0) { - print("//didn't find pc at sp=%lux, last pc found at sp=%lux\n", sp, osp); + print("//didn't find pc at sp=%llux, last pc found at sp=%llux\n", sp, osp); break; } osp = sp; sp += mach->szaddr; + //XXX if(strcmp(s.name, "forkret") == 0) sp += 2 * mach->szaddr; /* pop iret cs, eflags */ /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:261,271 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:266,276 } int naddr; - ulong addr[1024]; - ulong val[1024]; + uvlong addr[1024]; + uvlong val[1024]; static void - putval(ulong a, ulong v) + putval(uvlong a, uvlong v) { if(naddr < nelem(addr)){ addr[naddr] = a; /n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:289,313 - /n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:294,318 for(i=0; i