S OME USEFUL D EBUG C OMMANDS FOR C LEAR -S PEED S OFTWARE D EVELOPMENT K IT -- COMMANDS FROM CHAP.7 By: Pallav Laskar
cscn –o mandelbrot.csx –g mandelbrotcp.cn --to compile program with debug support. csgdb mandelbrot.csx -- to Start debugging A message is displayed along with the current location of the program counter. List To view the program source. -> list -> set listsize 10
break 22 --to set a new break point -> break main -- to set a break around a function -> break info --to get info around all break points that have been set -> tbreak Gets deleted once hit by execution
run -- start running the program till the break point is reached. print (mono or poly) To view the state of all variables when the break point is reached. -> print /d --to print integer value of the variable -->set print elements Where Find the current location of the program counter while debugging. Whatis gives the data type of the variable name used delete
Next -- take the program counter to the next line of execution continue Run till the end of the program is reached. Step Differs from next because it steps into function call rather than stepping over.
Print &x print the address of variable x If address is $8p4 then print/f $8p4 Will give the value of x print/f $8p4[5] If x is poly then the above content will print the content of the 5 th register.
(gdb)step calcres (x=-1.5, y= {-1.25, , , , , , , , , , , , ……….},res=64) at mandelbrot.cn:52 52 xcal=x; Stop at the first valid line of code for the function calcres which is line number 52.
To limit the number of display of PE’s (gdb) set print elements 4 (gdb) where #0 calcres (x=-1.5, y={-1.25, , , }, res=64) at mandelbrot.cn:52 #1 0x800155a0 in main () at mandelbrot.cn:113
regs and peregs: The whole mono and poly register set can be viewed using the two above commands. Step: progress the debugger to the function up: To move up the call stack and back to main use the up command.
print/x $pc Print the program counter (PC) at the current location down Move back down the call stack into function using the down command p/x $enable To view the enable state of the poly array
Viewing the poly enable state Print the value of the enable register in the debugger: (gdb) p/x $enable $2 = {0xff } (gdb)p/t $enable Print the value of the enable state in binary }. This show that all 96 of the PEs are currently enabled at every level. --{ }.PEs are currently disabled:
Attaching a command to a breakpoint commands 4 Attaching a command to a breakpoint (gdb) commands 4 Type commands for when breakpoint 4 is hit, one per line. End with a line saying just "end". >print/t $enable >end (gdb) commands 5 Type commands for when breakpoint 5 is hit, one per line. End with a line saying just "end". >print/t $enable >end
(gdb) info break Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at mandelbrot.cn:96 breakpoint already hit 1 time 4 breakpoint keep y 0x800150ec in terminate at mandelbrot.cn:34 breakpoint already hit 1 time print/t $enable 5 breakpoint keep y 0x in terminate at mandelbrot.cn:36 breakpoint already hit 1 time print/t $enable
Finish debugger can return from a function by using the finish command ignore 6 20 Will ignore next 20 crossings of breakpoint 6.
Viewing memory List 2 integers at the current PC location in mono memory using the x command: (gdb) x/2x $pc 0x800155f0 : 0x x (gdb) The argument “2” determines the number of values to print and the “x” specifies that the output is hexadecimal. pex/2x 0x0 pex/2x 0x pex/4x &buffer
Enter the same pex command again but add the argument to the end. (gdb) pex/2x 0x (PE 0) 0x0 : 0xdead2222 0x (PE 1) 0x0 : 0xdead2222 0x (PE 2) 0x0 : 0xdead2222 0x (PE 3) 0x0 : 0xdead2222 0x (PE 4) 0x0 : 0xdead2222 0x (PE 5) 0x0 : 0xdead2222 0x (PE 6) 0x0 : 0xdead2222 0x (PE 7) 0x0 : 0xdead2222 0x (PE 8) 0x0 : 0xdead2222 0x (PE 9) 0x0 : 0xdead2222 0x (PE 10) 0x0 : 0xdead2222 0x (gdb) You can now see 2 integer values for each of the first 11 processing elements.