You can debug code written and compiled outside of the IDE.
All you need is a launch configuration—you don't need to create an IDE project to store the code.
The steps shown here work for debugging code written on the same host but built outside of the IDE or even code written
(and built) on another machine. For the second case, though, you must have a copy of the source files somewhere on your host,
so GDB can display the code during debugging.
To debug non-IDE code:
-
Create a launch configuration for running the appropriate binary.
In the C/C++ Application field in the
Main tab,
you must provide the full path to the binary located outside of the workspace.
If you're debugging code that was compiled on another machine, you need to tell the IDE where to find the
source files on the host, by defining the appropriate paths in the
Source tab.
-
Click the Debug button ().
The IDE switches to the Debug perspective, which displays the source code being traced and other essential debugging
information. Then, it starts running the binary and GDB, which it attaches to the binary. If configured to do so in the
Debug settings, the debugger stops on
startup (by default, in the first line of main()).
For information on the debugging controls, see Debug perspective controls.