Check with these questions that you understand how the debugger works.
After create an executable file, ./program
,
and invoke the debugger with gdb program
,
you want to execute the program through the debugger.
Which is the correct command?
Once you have started to execute the program through the debugger, you want to introduce a breakpoint in line 36 of your code. Which is the correct command?
Having the following piece of code from the program
calculate_square.c
:
5 int calculate_square(int n) 6 { 7 /* Function to print the square of a number */ 8 int square = 0; 9 if (n<=250) 10 { 11 square = n * n; 12 printf(''The square of %d is %d \n", n, square); 13 } 14 return square; 15 } 16 int main(int argc, char **argv) 17 { 18 calculate_square(5); 19 calculate_square(251); 20 return 0; 21 }
You invoke the debugger, introduce a breakpoint in
the function call in line 19 and start the execution of the program through
the debugger. The program stops in line 19, and you want to get inside the
calculate_square
function to see how that function
behaves with the argument number 251, so: