I am trying to use gdb with MySQL source code which is written in C/C++. In mysql-test/t, I create a custom test case file, say, example.test and then debug it by using the following line of code
/mysql-test-run --gdb example
Now I want to see the flow of execution as it changes from one function in a file to another in some different file. I am not sure of how the execution changes, so I can’t pre define the break points. Any solution to how I can get to see the flow with multiple files of source code?
You can use the
nextdirective to take line-by-line steps through the source. When appropriate, you can use thestepdirective to take steps “into” the function(s) being called on the current line.A reasonable method would be to do
nextuntil you think you only just pass the externally visible behavior you’re looking for. Then start over, stopping at the line right before you saw the behavior last time. Thenstepthis time. Repeat as necessary until you find the code you’re looking for. If you believe that it’s encountering some sort of deadlock, it’s significantly easier — just interrupt (Ctrl-C) the program when you think it’s stuck and it should stop right in the interesting spot.In general, walking through the source you’ll build up some places you think are interesting. You can note the source file and line number and/or function names as appropriate and set those breakpoints directly in the future to avoid tedious
next/next/nextbusiness.