CS644 Using remote gdb with Xinu ---------------first window: download and run mon-worker.lnx using Tutor------------ blade57(1)% ls Makefile mon-worker.c mon-worker.lnx mon-worker.opc typescript blade57(2)% make clean rm -f *.opc *.lnx syms core *.o blade57(3)% ls Makefile mon-worker.c typescript blade57(4)% make U=mon-worker /groups/ulab/bin/i386-gcc -c -g -I/sources/xinu-pentium/include -Wall -Wstrict-prototypes -Wmissin g-prototypes -Wno-uninitialized -Wshadow -ansi -o mon-worker.opc mon-worker.c /groups/ulab/bin/i386-ld -N -Ttext 1000e0 -o mon-worker.lnx \ /sources/xinu-pentium/lib/startup0.opc /sources/xinu-pentium/lib/xinu_startup.opc /sources /xinu-pentium/lib/support.opc /sources/xinu-pentium/lib/initialize.opc /sources/xinu-pentium/lib/i ntr.opc /sources/xinu-pentium/lib/clkint.opc /sources/xinu-pentium/lib/ctxsw.opc /sources/xinu-pen tium/lib/cpureg.opc /sources/xinu-pentium/lib/comint.opc /sources/xinu-pentium/lib/kbmint.opc /sou rces/xinu-pentium/lib/nullnet.opc /sources/xinu-pentium/lib/lpstubs.opc mon-worker.opc \ /sources/xinu-pentium/lib/libxc.a /sources/xinu-pentium/lib/libx.a /sources/xinu-pentium/l ib/libxc.a /groups/ulab/bin/i386-nm -n mon-worker.lnx > syms blade57(5)% mtip -b 14 -f mon-worker.lnx (1) Use systems 11 - 14 for fast download For command help, type ~? For help on args, rerun without args Code starts at 0x100100 Using board # 14 Tutor> ~downloading mon-worker.lnx (2)~d for download ............................Done. Download done, setting EIP to 100100. Tutor> gdb (3)-----------> now use other window Setting gdb dev to COM1, starting gdb (CTRL-C to abort). maxaddr=3fffff (8) PC Xinu 4194304 bytes real mem clock enabled Enter cycles of work for worker to do: 10000 (12) Type <CR> for progress report, control-space or ~r to abort Worker starting (32) worker at # 1348 (37) worker at # 2080 Null char received on console, trapping to Tutor. (38) typed control-space Tutor> Tutor> Quit handler: (40) typed control-C killing process 25546 Leaving board #14 blade57(6)% exit script done on Mon Feb 22 19:56:33 2010 --------------------------Second window: remote gdb----------------------------- Script started on Mon Feb 22 19:50:24 2010 warning: could not update utmp entry blade57(1)% blade57(1)% i386-gdb mon-worker.lnx (4) GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.15.1 (sparc-sun-sunos4.1.3 --target i386-linuxaout), Copyright 1995 Free Software Foundation, Inc... (gdb) tar rem /dev/remgdb14 (5) Remote debugging using /dev/remgdb14 0x100100 in /sources/xinu-pentium/lib/startup0.opc () (gdb) b main (6) Breakpoint 1 at 0x10093b: file mon-worker.c, line 18. (gdb) c (7)----------> look in other window for bootup Continuing. Breakpoint 1, main () at mon-worker.c:18 (9) 18 printf("Enter cycles of work for worker to do: "); (gdb) n (10) 19 fgets(buf,BUFLEN,CONSOLE); (gdb) n (11)------> enter # in other window 20 sscanf(buf,"%d",&nwork); (gdb) b create (13) Breakpoint 2 at 0x1021a7: file ../sys/create.c, line 31. (gdb) c (14) Continuing. Breakpoint 2, create (procaddr=0x1009e0, ssize=1000, priority=20, name=0x100918 "worker", nargs=1, args=10000) at ../sys/create.c:31 31 disable(ps); (gdb) where (15) #0 create (procaddr=0x1009e0, ssize=1000, priority=20, name=0x100918 "worker", nargs=1, args=10000) at ../sys/create.c:31 #1 0x100996 in main () at mon-worker.c:22 #2 0x102198 in startmain () at ../sys/main.c:18 (gdb) l main (16) 9 10 void work(int ncycles); 11 void docycle(int n); 12 13 void main(void) 14 { 15 int nwork; 16 char buf[BUFLEN]; 17 18 printf("Enter cycles of work for worker to do: "); (gdb) l (17) 19 fgets(buf,BUFLEN,CONSOLE); 20 sscanf(buf,"%d",&nwork); 21 printf("Type <CR> for progress report, control-space or ~r to abort\n"); 22 resume(create(work,1000,20,"worker",1,nwork)); 23 while (1) 24 { 25 getc(CONSOLE); /* wait for <CR> from keyboard */ 26 printf("worker at # %d\n",workcount); /* report on worker */ 27 } 28 } (gdb) l (18) 29 30 /* worker top-level function: do ncycles of "work" */ 31 void work(int ncycles) 32 { 33 int i; 34 printf("Worker starting\n"); 35 for (i=1;i<=ncycles;i++) 36 { 37 docycle(i); /* do ith work cycle */ 38 workcount++; /* count it where parent can see it */ (gdb) b getc (19) Breakpoint 3 at 0x102e3f: file ../sys/getc.c, line 16. (gdb) c (20) Continuing. Breakpoint 3, getc (descrp=0) at ../sys/getc.c:16 16 if (isbaddev(descrp) ) (gdb) where (21) #0 getc (descrp=0) at ../sys/getc.c:16 #1 0x1009b3 in main () at mon-worker.c:25 #2 0x102198 in startmain () at ../sys/main.c:18 (gdb) p proctab[0] (22) $1 = {pstate = 3 '\003', pprio = 0, pesp = 4193940, psem = 0, pmsg = 0, phasmsg = 0 '\000', pbase = 4194300, pstklen = 0, plimit = 4184064, pname = "prnull\000\000\000\000\000\000\000\000\000", pargs = 0, paddr = 1048944} (gdb) p/x proctab[0] (23) $2 = {pstate = 0x3, pprio = 0x0, pesp = 0x3ffe94, psem = 0x0, pmsg = 0x0, phasmsg = 0x0, pbase = 0x3ffffc, pstklen = 0x0, plimit = 0x3fd800, pname = {0x70, 0x72, 0x6e, 0x75, 0x6c, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, pargs = 0x0, paddr = 0x100170} (gdb) p proctab[49] (24) $3 = {pstate = 1 '\001', pprio = 20, pesp = 4183836, psem = 98, pmsg = 0, phasmsg = 0 '\000', pbase = 4184056, pstklen = 20480, plimit = 4163580, pname = "main", '\000' <repeats 11 times>, pargs = 1, paddr = 1057152} (gdb) p/x proctab[49] (25) $4 = {pstate = 0x1, pprio = 0x14, pesp = 0x3fd71c, psem = 0x62, pmsg = 0x0, phasmsg = 0x0, pbase = 0x3fd7f8, pstklen = 0x5000, plimit = 0x3f87fc, pname = {0x6d, 0x61, 0x69, 0x6e, 0x0 <repeats 12 times>}, pargs = 0x1, paddr = 0x102180} (gdb) p proctab[48] (26) $5 = {pstate = 3 '\003', pprio = 20, pesp = 4163292, psem = 0, pmsg = 0, phasmsg = 0 '\000', pbase = 4163576, pstklen = 10240, plimit = 4153340, pname = "worker\000\000\000\000\000\000\000\000\000", pargs = 1, paddr = 1051104} (gdb) p/x proctab[48] (27) $6 = {pstate = 0x3, pprio = 0x14, pesp = 0x3f86dc, psem = 0x0, pmsg = 0x0, phasmsg = 0x0, pbase = 0x3f87f8, pstklen = 0x2800, plimit = 0x3f5ffc, pname = {0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, pargs = 0x1, paddr = 0x1009e0} (gdb) p currpid (28) kernel var $7 = 49 (gdb) p workcount (29) user var $8 = 237 (gdb) i loc (30) local vars devptr = (struct devsw *) 0x3f0216 (gdb) c (31) ---> enter CR in other window Continuing. Breakpoint 3, getc (descrp=0) at ../sys/getc.c:16 (33) 16 if (isbaddev(descrp) ) (gdb) i b (34) Num Type Disp Enb Address What 1 breakpoint keep y 0x0010093b in main at mon-worker.c:18 breakpoint already hit 1 time 2 breakpoint keep y 0x001021a7 in create at ../sys/create.c:31 breakpoint already hit 1 time 3 breakpoint keep y 0x00102e3f in getc at ../sys/getc.c:16 breakpoint already hit 2 times (gdb) d (35) Delete all breakpoints? (y or n) y (gdb) c (36) ----> enter CR in other window Continuing. Program received signal SIGTRAP, Trace/breakpoint trap. (38) monitor () at ../sys/evec.c:183 183 } (gdb) q (39) The program is running. Quit anyway (and kill it)? (y or n) y blade57(2)% exit script done on Mon Feb 22 19:56:26 2010