So when I’m debugging with GDB I’d like to see the source code and maybe interact with it. But even when I have the source file it doesn’t seem to read it and get loaded.

What happens is GDB is being lazy and doesn’t look for the source file in the executables directory . It only looks for $cdir and $cwd. So we have to add it .Run these commands.
Set directories <the source files directory> – to add the source directory
show directories – to see the current directories
file <executable name> – to reload the GDB core. And that’s it. You should now see the source code.

And its done.
One thought on “Read source files inside GDB-TUI”