Is there a way to get the C ++ source code in binary so that gdb can see it?

Let's say I have a build machine and a test machine, and the source code is only on the build machine. (Linux)

I have an executable for a C / C ++ debug build and I want to run it using gdb on a test machine.

In the debugger running on the test machine, it still looks for actual source files that are not there.

Is there a way for g ++ to actually include the source in the executable itself with different debugging information so the files are not needed?

+3


source to share


2 answers


It is not possible for the source to be compiled into binary to allow gdb to debug this way.

Probably the best mechanism in this case is to use gdbserver - which allows you to remotely launch an application and debug it on the build machine.



If you cannot use remote debugging, then an alternative is to set the directory containing the source on the test machine and then use set substitute-path

to map to the directory the test machine has against the build.

+4


source


No, but the good news is not necessarily. You must set the original path . It must accept the network path.



+2


source







All Articles