void foo int x 5 4 int main foo return 0 If you are running
void foo() {int x = 5;} 4 int main() {foo(); return 0;} If you are running gdb on the executable of the above code, what are the two gdb commands that you need to insert in order to start running at the main function. If you had a breakpoint set at line 5 and you were on that breakpoint, what line would you be on if you entered next step
Solution
1st command is \"tbreak main\" which sets a temporary breakpoint at main function i.e at line 4, which is later removed.
2nd command \" run \" which starts the program execution under debugger from line 4.
Next - moves the control to line 6 as it skips function calls
Step - moves the control to line 2 as it forwards by one line in the program substituted code
