Access GDB Directly In Eclipse Luna

This isn’t a new feature, but it’s really useful when you’re debugging in eclipse, especially if you’re using the more advance or obscure features in GDB.

Basically, when you are debugging any program, there is a way to talk directly to GDB without using the point-and-click interface of Eclipse.

It’s called the GDB console.

It’s also really easy to find. When you are next running a debug session, just click on the console icon that is displayed in the console tab. The console usually shows your program output, but there is more than just one console!

gdb-console-eclipse

The one highlighted is the one you can use to talk directly to GDB. You’ll see there is also a GDB traces console, which is also pretty handy to know about.

This provides the output of the “conversation” between Eclipse and GDB, so it can be a great tool to understand what’s going on if you’re trying to debug in Eclipse, but the debugger doesn’t seem to be responding correctly.

The GDB traces buffer is set to a default of 500,000 characters.
If for some reason that isn’t enough for you, you can change it under Window -> Preferences -> C/C++ -> Debug -> GDB.

Once you’ve opened the GDB console, you can type your normal GDB commands in and GDB will respond in the window.

I’ve got a screenshot here of a request I made to GDB for info on all local variables (there are none – this is a Hello World program), and then I’ve requested a breakpoint on line 14.

My commands are printed in green:

gdb-console-eclipse2

Happy debugging!