In the project I am working on, I use gdb to debug - I would like to be able to call make from gdb - but I can't because that would mean the working directory would be incorrect. Here is my directory layout and the two options I have tried:
Project
├─bin
│ ┗━Option 1
├─build
│ ├─debug.sh
│ ┟─makefile
│ ┗━Option 2
├─include
└─src
Here is the contents of debug.sh using option 1
#!/bin/bash
gdb --cd=../bin ../bin/ProjectBinary -ex run
Option1:
When I invoke ./debug, the program runs correctly - the working directory is correctly set to Project/bin. But I cannot call make from gdb because the makefile isn't in the current directory.
Option2 (debug.sh not shown):
When I invoke ./debug, the program fails because the working directory is set incorrectly - but I can successfully call make from gdb.
How do I get the best of both worlds and allow it so I can call make from gdb, as well as the working directory to be correct for the executable - ie how I have 2 working directories, one for the program being debugged, and one for gdb itsself?