|
|
An example of a debugging session using sdb follows. Comments (preceded by a pound sign, #) have been added to help you see what is happening.
Example of sdb Usage (Page 1 of 3)
sdb myoptim - .:../common # enter sdb command Source path: .:../common No core image *window:b # set a breakpoint at start of window 0x80802462 (window:1459+2) b *r < m.s > out.m.s # run the program Breakpoint at 0x80802462 in window:1459: window(size, func) register int size; boolean(*func)(); { *t # print stack trace window(size=2,func=w2opt) [optim.c:1459] peep() [peep.c:34] pseudo(s=.def^Imain;^I.val^I.;^I.scl^I-1;^I.endef) [local.c:483] yylex() [local.c:229] main(argc=0,argv=0xc00201bc,-1073610300) [optim.c:227]
Example of sdb Usage (Page 2 of 3)
*z # print 10 lines of source 1459: window(size, func) register int size; boolean (*func)(); { 1460: 1461: extern NODE *initw(); 1462: register NODE *pl; 1463: register int i; 1464: 1465: TRACE(window); 1466: 1467: /* find first window */ 1468: *s # step window:1459:window(size,func)registerintsize;boolean(*func)();{ *s # step window:1465: TRACE(window); *s # step window:1469: wsize = size; *s # step window:1470: if ((pl = initw(n0.forw)) == NULL) *S # step through procedure call window:1475: for (opf = pf->back; ; opf = pf->back) { *pl # show variable pl 0x80886b38 *x # print the 80386 register contents eax/ 1 ecx/ 0x402e2c edx/ 0xbffffca8 eox/ 0x17 esp/ 0xbffffc54 edp/ 0xbffffc60 esi/ 0x16 edi/ 0x15 eip/ 0x16b flag/ 0x13296 trap/ 0xe err/ 7 0x16b (main+4): lea -8(%ebp),%edi [0x7fffffff]
Example of sdb Usage (Page 3 of 3)
*pl[0] # dereference the pointer pl[0].forw/ 0x80886b6c pl[0].back/ 0x80886ac8 pl[0].ops[0]/ pushw pl[0].uniqid/ 0 pl[0].op/ 123 pl[0].nlive/ 3588 pl[0].ndead/ 4096 *pl->forw[0] # dereference the pointer pl->forw[0].forw/ 0x80886ca0 pl->forw[0].back/ 0x80886b38 pl->forw[0].ops[0]/ call pl->forw[0].uniqid/ 0 pl->forw[0].op/ 9 pl->forw[0].nlive/ 3584 pl->forw[0].ndead/ 4099 *pl!pl->forw # replace pl with pl->forw *pl # show pl 0x80886b6c *c # continue Breakpoint at 0x80802462inwindow:1459:window(size,func)registerintsize; boolean (*func)(); { *s # step window:1459:window(size,func)registerintsize;boolean(*func)();{ *s # step window:1465: TRACE(window); *size # show function argument size 3 *D # delete all breakpoints All breakpoints deleted *c # continue Process terminated *q # quit sdb $