Question: Write a GDB script to do the following to the program `debuggingPractice.c`. 1. Break at the assignment of the loop in main and print the

Write a GDB script to do the following to the program `debuggingPractice.c`.

1. Break at the assignment of the loop in main and print the value of the general purpose registers.

2. Print "OVER " in GDB when the variable `i` is greater than 5. Do note that we expect a newline at the end of the print statement.

3. Set the variable `i` to `0xCAFE` when `i` reaches the value 10.

// compile with gcc -g debuggingPractice.c -o debuggingPractice.out

#include

#include

void foo()

{

printf("In foo ");

}

void bar()

{

printf("In bar ");

exit(0);

}

int main()

{

int i = 0;

while(i < 20) {

printf("i is %#X ", i);

i++;

}

foo();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!