Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions