Question
1.) gdb Consider the following program: // lab6.cpp #include using namespace std; void setArray ( int numbers[][3] ) { int i, j; for ( i
1.) gdb
Consider the following program:
// lab6.cpp #includeusing namespace std; void setArray ( int numbers[][3] ) { int i, j; for ( i = 0; i < 2; i++ ) // break point 2 for ( j = 0; j < 3; j++ ) numbers[i][j] = 3 * i + j; // break point 3 } int main() { int a[2][3]; cout << a << endl; int b = 9; // break point 1 setArray ( a ); }
Compile and load the program using gdb as discussed in class. Inside gdb to do the following: Set the breakpoints as shown in the program. Run the program to the breakpoints. Then use the command s (step) or c (continue) to continue. At each breakpoint examine the stack (you may use bt) and examine 10 memory locations starting from the address of the array ( you may use x/10 ...). (If you want to study more of the stack, execute info frame which shows the information of the current frame, and then execute x/20x $sp-0x10 where sp is the stack pointer. You should able to see that the values of local variables i, j in the function setArray are saved in the stack.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started