How to use the GDB console in Eclipse CDT? - eclipse

Is there a way how I can access gdb's console in Eclipse? I would like to just be able to set breakpoints with the mouse and then use the console for debugging.

You must click here
Next select one with *gdb
Now you can write GDB commands in console example:

First of all, you need to install CDT plugin. Then, you can debug C++ application like Java application in Eclipse.
If you want gdb console, push 'Display Selected Console' in Console view in Debug perspective.
You can choose '[Your App name][C/C++ Application]gdb' entry, and then you can type gdb instruction(i.e. print this) in Console View.

It is possible to write in the console window and gdb answers. (You have to choose the right console window from the chooser in the top right edge of the console view).
Unfortunately the console is quite limited: gdb answers to command, but important features like tab-completion do not work.

Window > Show view > "Debugger Console" is the right way as of Eclipse CDT 4.7.0.
You can then type certain commands like print on the console and they will be evaluated.
Other more "active" commands like continue have no effect however.
Mentioned on this comment.

Related

How to inspect variables form interactive console in PyDev

How can I run code in the Interactive Console in PyDev and see the created variables in the Variables view?
I am looking for the same functionality available in Spyder. If I am interactively running a script or just testing pieces, I would like o be able to see all the available shell variables and their respective values in the variables view.
I have already checked "Connect console to Debug Session" in Preferences > Pydev > Interactive console.
But when I run, say, a=1, the "Variables" view will be in italic for a moment and nothing appears there.
ANSWER
Following Fabio's advice: I updated Pydev from v5.4 to 5.8. That did it.
Not sure what's happening there.
For me, after checking Connect console to Debug Session in Preferences > PyDev > Interactive console, I do see created variables in the variables view.
Are you actually using the interactive console (i.e.: started with Ctrl+Alt+Enter)?
Can you show a screenshot with Eclipse on that situation?
Which PyDev version are you using?

Force return with a specific value while debugging in Eclipse CDT

I'm debugging some C++ code in Eclipse configured with a MinGW gdb configuration.
When running gdb directly in a shell, I can return from a function immediately, and tell it what value the function should return, with for example return 3.
How do I do that while debugging in Eclipse rather than running gdb outside of Eclipse in a shell window?
Eclipse CDT does not provide that feature in the UI with a button or similar. Feel free to enter a feature request, or even better a patch.
However, you can of type return 3 in the GDB input console in CDT without having to leave the Eclipse environment. Here are some instructions I wrote for a related (but not duplicate) question that shows you how to use the console.
Console
The console view allows you to enter GDB commands in standard GDB syntax.
To use the Console:
Select the gdb item in the Debug View
The Console view will now display the interface to GDB:
Type commands to GDB, e.g. print i + j or p i - j (p is short for print):
Other Hints when using the Console
You can "pin" the console so that it stays the selected console top with this button on the toolbar:
You can switch console with this drop-down:
You can open a second console, e.g. one for GDB interaction and one for output of your program with this button:

Can't find GDB option in Eclipse on mac

I'm new to Macs but I don't think this is a problem that comes from that. I've been attempting to set up GDB as a debugger for programming in golang on Eclipse. I know how to do it for the most part, but at some point one of the steps is to open up your debug preferences in the C/C++ configuration and fill in the path of where the debugger is located. Unfortunately, the option doesn't even show up for me:
Why doesn't the "GDB" option show up under Preferences >> C/C++ >> Debug? If i'm not mistaken, it should be a part of the CDT package correct? Am I just using the wrong version? It should be giving me this option:
At least it does for Neil Craft, the author of this tutorial
For anyone coming here looking for an answer:
https://www.ics.uci.edu/~pattis/common/handouts/macmingweclipse/allexperimental/mac-gdb-install.html#eclipse
If there is no GDB section in the C/C++Debug subtree, close the preferences window, and try to first start a debugging session for any project that you can already run without problems. You can do it by either clicking the Debug button on the toolbar, or selecting RunDebug from the main menu. This attempt will, of course, fail with an error message about the gdb command, but it will force the said C/C++DebugGDB settings to appear in the preferences.

Enter pydev interactive console immediately on F11?

I would like to F11 a python file in Eclipse and when I hit a breakpoint automatically enter the Python Interactive Console (not the default pydev debug console).
I understand that I could upon entering debug mode open a new interactive python console (I have turned on the connection between the interactive console and the debug console) and work from there. But not only is that an extra step but it is frustrating because everytime I interact with such an interactive console it shoves me back to the debug console! Then I have to go review the interactive console. I also understand that I could do a 'runfile' from within the interactive console, but I really want to use the convenient F11 capacity of eclipse to just be in an editor, hit F11 and when I break enter the interactive console.
Basically I would like the Interactive Console to be my debug console. Possible?
If the F11 approach is not possible, is there another approach? My goal is to get my history of command typing available to me with arrow keys. Not possible in the default python debug console from what I can tell. Perhaps if I made the pydev debug console ipython?
Thanks, I have searched a lot on this but can't come up with a solution.
from PyDev 3.9.2 onwards, a console prompt with history, code-completion, etc. will appear automatically.
See: http://pydev.blogspot.com.br/2015/02/pydev-392-released.html for details.

Ipython in pydev interactive debugging console(eclipse)

I have ipython working in pydev when using the normal interactive console, however when entering debug mode the console reverts to the standard pydev console. If I close this console and re-open it, ipython returns and I can use it as normal. Am I missing something, or is this a bug?
-Eric
Actually since PyDev version 3.0 you can attache a IPython console to a debug-session:
http://pydev.org/manual_adv_interactive_console.html#full-debug-support-in-interactive-console
To enable that feature, go to window > preferences > PyDev > Interactive Console and check 'Connect console to Debug Session?'.
Then only hassle is that you have to re-open a new IPython-console every time you re-launch the program in debug-mode.
Actually, Eclipse itself can have multiple consoles open at the same time... if you want, you can create multiple console views and pin a different console to each view (if you don't pin the console, one console will be shown on top of the other and you'll have to do the switching from one to the other manually).
As it is now, the debug console is not the same as the interactive console (it's a simpler version because of issues with the eclipse integration, although there are plans to be able to attach an interactive console to a debug session).
So, what you described is what should really happen (not really a bug).