I\'m a Visual Studio user and am used to breakpoints for debugging. I\'m now working in a linux environment and am using Eclipse as an IDE. I\'m a newbie in linux and eclips
The following instructions are for Eclipse 3.5 (Galileo). For 3.6 (Helios), they are similar except for the link in step 2.
You should now be able to set breakpoints and inspect values of variables in Eclipse.
An alternative is to install DDD (an GUI frontend for GDB).
First download Eclipse CDT ensure that you can import a project into Eclipse as shown at: How to create a project from existing source in Eclipse and then find it?
You could try to test things out with this simple test directory: https://github.com/cirosantilli/ide-test-projects/tree/e93924d4e2ce8cd64b00a7ce67d10d62b497fda1/cpp
git clone https://github.com/cirosantilli/ide-test-projects
cd ide-test-projects/cpp
make
./main.out
Once Eclipse imported the project, and e.g. you seem to be able to jump to definitions, etc., let's setup a GDB step debug.
First you have to go under:
and set it to:
main.out
Now eclipse knows how to run your program. We can confirm that by doing a test run:
and the terminal on the bottom show the output of the program:
Finally, we can put a breakpoint on any point, e.g. main
by double clicking on the sidebar to the left of the code, which creates a blue circle (shown on image above).
Now we can debug via:
and as expected we are left at main
:
The light blue line over (void)argv;
indicates that this is the current line being executed under the debugger.
From there on it is just a matter of learning the debugging interface, e.g.:
You can then switch back to the normal code view (non-debug) with Ctrl + F8
once you are done debugging: How to change back the perspective after terminating the debugged process in Eclipse?
Tested on Eclipse 2020-03 (4.15.0).