Problem 3: Assembly-Level Debugging
Thus far, we've mostly been taking advantage of the fact that gdb
understands your program at the source level: it knows about
strings, source lines, call chains, and even complicated C++ data
structures. But sometimes it's necessary to dive into the assembly
code.
-
If you get to this point before we've done the lecture on “flow control”, it might be a good time to take a break and work on some other class.
-
When you are working with assembly code, it can be very helpful to issue the
gdbcommandset disassemble-next-line on. That will tellgdbthat whenever the program stops, it should disassemble and display the next instruction that is to be executed. We suggest that you issue this command whenever you start GDB.
To be sure we're all on the same page, let's quit gdb and bring it up
on problem2 again, still using the result of compiling with -Og -g.
Run the program with arguments of 1 42 2 47 3.
That's it—you're done!
(When logged in, completion status appears here.)