Enabling breakpoints in goclipse - eclipse

I'm trying to get debugging of go programs working in eclipse Luna with goclipse v0.11.0 on OS-X 10.9.5. I am using GNU gdb (GDB) 7.9.1 from brew, and go1.4.2.
I successfully installed and code-signed gdb using instructions here:
http://ntraft.com/installing-gdb-on-os-x-mavericks/
I am building my go program with -gcflags "-N -l" and I can successfully debug it at the command line, including setting breakpoints at go functions and stepping through them with the gdb command line, with source appearing as it should.
However, in goclipse I cannot set a breakpoint at all, because the 'toggle breakpoint' item on the menu is greyed out, and the 'Breakpoint Types' list says 'none available'.
If I select 'Stop on Startup at' 'main', then I can step through assembler, which is unhelpful, but proves gdb is being used.
If I keep the above option set, wait until the program hits the main breakpoint, and type (at the gdb console within eclipse) break main.foo, then cont, then a breakpoint is set in the right place, and I can step through things in the Eclipse IDE. Thus it appears the only issue is setting the breakpoints in the IDE.
The go program concerned is a single file and it works under command line gdb, and I have deleted the binary and started afresh, so this is not a 'need a rebuild' issue.
Related question: How to debug Go programs using GoClipse? however the two answers there are 'disable Stop on Startup' (which makes no difference here), and ensuring -gcflags "-N -l" is given (which makes no difference).
Screenshot:
Any ideas?

Related

Should debugger be launched always in VScode when only running a file (not debugging) using code-runner?

In a VScode C/C++ programming setup on Windows 10 system, the "C/C++ Extension Pack", "Code Runner", "WSL" extensions are installed, which use Alpine Linux target on WSL on this PC. Alpine Linux WSL instance has the gcc dev environment, build-tools, gdb etc. installed, apart from the necessary VScode extensions needed inside WSL.
In this environment I am able to write C/C++ programs, build them, execute them, interact with them through the built-in terminal. I use the "Code Runner" "Run C/C++ file" shortcut button to build(if necessary) and run individual C/C++ program files (there is no Makefile and these are simple programs all thrown in a single folder, not in a project structure).
Recently however, I noticed that whenever I try to "Run C/C++ file", debugger is also launched and I get a screen like this (notice the 2 yellow/orange arrows indicating what I am trying to draw attention to):
I do not remember this being the case earlier, but I think this started after I tried to debug a program by setting a breakpoint, which I later cleared. I've also ensured that "Run > Remove All Breakpoints" is done, to make sure that there are absolutely no breakpoints. Therefore wondering if:
it is normal for debugger to get launched in this manner ?
if not, what exactly might have caused it ?
finally, what can I do to make sure that the debugger is not launched, when all I want to do is "Run" ?
In "Code Runner" settings file, I did not find anything that might control this behaviour, but then I am quite new to VScode so not sure if I am missing anything obvious.

Gdb stops when viewing variables in Eclipse

When debugging a c++ app, and hitting a breakpoint, gdb terminates the debug session when I click on a variable to expand its content in the Variables panel.
The displayed message is: <terminated, exit value: 0>gdb (10.1.90.20210103)
Printing the variable from the Debugger Console works correctly.
Debugging was working OK some weeks ago. The major changes that happen recently was a debian upgrade from 10 to 11 (bullseye), and an upgrade of the Eclipse version.
Activating gdb traces following where can I find GDB traces, I could see the commands sent to GDB, but no particular error before GDB stopped.
Any idea of what could cause this issue?
Eclipse Version: 2021-12 (4.22.0), Build id: 20211202-1639 running on linux debian bullseye.
I answer my own question.
After checking related answers, I suspect that the problem is linked to stl pretty printing in Eclipse (which was working fine before). I tried different version of Eclipse and gdb, and finally managed to fix the issue by using a previous version of gdb (8.3 instead of 10.1).
Here is the procedure that I followed (I'm not sure all steps are mandatory).
Reinstalled eclipse from scratch
Deleted the .metadata directory and recreated the eclipse workspace
Downloaded version 8.3 of gdb sources, and compiled it with python support ('./configure --with-python'). Note that libgmp-dev and python2.7-dev debian packages must be installed.
Copied gdb-8.3 somewhere under /usr/local/
Updated eclipse preference settings : C-C++/Debug/GDB and change GDB Debugger to the pach where gdb 8.3 executable was located under /usr/local/.
Checked in Debugger Console that the right gdb version is displayed. If this is not the case, you may have to set gdb using Debug As.../Debug Configurations/Debugger/GDB Debugger

Eclipse + GDB: Cannot find bounds of current function

I have problems debugging a program in Eclipse 2019-03 using GDB on Windows 10 with MinGW.
Whenever I stop in the program, I get the error message ERROR: Unexpected GDB output from command "-exec-step 1". Cannot find bounds of current function.
I got this also when debugging a new C/C++ project with just printing a line to the console, so it seems unrelated to the actual program that was executing.
Both programs could be debugged fine when running gdb manually on the command line.
Answering my own question: the problem was caused by a number of watch expressions that I had configured in Eclipse. I discovered this when I enabled GDB traces in Eclipse to see the MI commands between Eclipse and GDB.
Removing all watch expressions in Eclipse solved the problem for me.

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.

C++ Eclipse: Debugging with optirun/primusrun on Linux

How can I debug my Program with optirun or primusrun? When simply running it, I can use the workaround of running primusrun with my program as parameter, but this does not work for debugging. I tried replacing "gdb" with "primusrun gdb" and starting eclipse with primusrun but it does not do anything.
You can start Eclipse under primusrun. gdb and the debbugged process will "inherit" this, thus running themselves on the discrete card.
Unfortunately, this means that Eclipse itself is also holding the card active, thereby increasing the power consumption.
Instead of having to start Eclipse using optirun, you can change the command used to launch GDB as follows:
Click on "Debug configurations..." on the Run menu.
Click on the launch configuration for your application.
Go to the Debugger tab.
Change the "GDB debugger" field to optirun gdb.
On my system (eclipse neon, Debian stretch), you have to put a absolute path to make this working (/usr/bin/optirun gdb).
For Run Configurations another solution is to set optirun (absolute path) as "C/C++ Application" and the name of your Application (e.g. "Debug/appName") as an Argument ("Arguments" Tab, "Program arguments").