Note: don't worry if you can't finish the entire lab exercise. Use turnin (see step 8) to turn in as much as you've completed before you leave the lab. Make sure you finish the rest of the lab on your own time.
0 < n <= 20The program then reads in n integers and saves them in an array. You may assume that the number of elements in the array will not exceed 20. Name your program lab3.c.
help help
list display ten more lines
list <line number> display ten lines centered around
<line number>
list - display ten lines previous to the lines
just printed
print <variable name> print the value of a variable
break <function name> set a breakpoint at the start of a function
break <line number> set a breakpoint at the specified line
cont continue execution after a breakpoint
clear <function name> remove all breakpoints from function
run run program with optional arguments
step resume execution for just a single statement
quit exit the debugger
backtrace shows layers of functions you are into
A breakpoint is just what the name implies - a point
at which you break out of the currently-executing program and are brought
into the debugger. You can then check out the state of various
variables to make sure they contain the values they
should contain at that point. If you reach a breakpoint and you find
something amiss, you know that there is a bug in your program in one of
the instructions that executed prior to the breakpoint. If, on the other
hand, everything looks OK, you can narrow down your search for bugs in the
instructions that execute after the breakpoint. Loops are
usually good places to put breakpoints; start by placing a breakpoint
immediately before a loop and immediately after. If it looks like there
may be a problem inside a loop,
placing a breakpoint
within the loop allows you to stop after
each iteration and make sure the loop control
variables and other variables contain the correct values.
(gdb)
list (to get the line numbers), break <linenumber> (to set a breakpoint), run (to start the program),
print <variable name> (to check the current
value of a variable), cont (to run up to the next breakpoint).
/cs/bin/turnin submit cs2301 lab3 lab3.c
See you next week!