Eclipse C++ GDB debugger for Mac - c++

i've been trying for a whole day to use Eclipse but i failed every time.
I know that i may be wrong and i do know that there are a lot of people out there who are working hard for an open source project, but if i can't use a program, run and debug an "Hello world" file, there must be something wrong.
I'm using OSX 10.9.5 (yeah, maybe using a mac is my first error, right?).
Every time i try to debug the "Hello World.cpp" program i get the following error.
http://imgur.com/RgXCSyW
Yes, i've searched everywhere on google.
Yes, i've already seen the other replies on a similar topic and i've already tried the solutions they offered. Sadly, it didn't work.
Thanks guys for your patience, i hope to learn how to code and maybe being helpful to others one day.
Luca
p.s. writing the error so other people who are googling it can find it
"
Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Unable to find Mach task port for process-id 33383: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
Unable to find Mach task port for process-id 33383: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
"

There is another option to debug you code using LLDB debugger.
You can check this link for install the LLDB debugger integration.
It is super easy and does the work.
Btw The GDB debugger is part of GNU. Xcode does not use GNU tools (gcc, gdb) anymore. Xcode uses LLVM. LLVM's debugger is LLDB.
Some info about it:
apple developers,
The LLDB Debugger
Probably your problem has been solved, but sharing another solution to others cant be bad :)
This is relevant to macOS Sierra also.

This is a relatively well known "issue" on OS X (which btw is a pain-in-the-neck-to-develop-c++ on). You first need to install g++ and GDB debugger (since LLVM clang++ in combination with LLVM debugger are not yet supported by Eclipse on OS X). The easiest way is via macports. First install macports via the native installer, then, from a terminal, install g++ and gdb (debugger)
sudo port install gcc5 # or gcc49
and
sudo port install gdb
After this, you need to codesign it, see this link. The name of the debugger will be ggdb (not gdb), and macoprts will install it in /opt/local/bin/ggdb.

Related

Debugging a Qt application on Windows

my Qt (QML/C++) application crashes and I can not find the reason why. I tried to output a lot of information but some signal/slot connection probably causes a crash. I spent many hours trying to find the reason but I failed.
The only good point is that I can reproduce the crash whenever I want.
Unfortunately I don't know hot to use the included GDB debugger. This is the output I got:
How do I find from this what happened and where? I need to find at least the function, in which my application crashed.
Or what else could I try? Unfortunately I can not disable the signal/slot connections or the associated functions, because then I can not get to the point, where it crashes.
Qt has detailed documentation on how to install a debugger found here: QtCreator Debugger
MingW does have a GDB that can be used to debug the application better. You can also use CDB to debug, just depends on your preference.
Once that is installed, you'll be able to set breakpoints and check variable information to see where your program is crashing using the Debugger view in QtCreator.
Tools->Options->Build & Run
If you have Qt version kit like this you need to check debuggers.
https://i.stack.imgur.com/LaY1p.png
https://i.stack.imgur.com/8kTG6.png
You need to install MinGW and after install you will be have debugger. After install press F5 to start debuging.

"Program File does not exist" while trying to debug with Eclipse/OpenOCD

I recently got a nrf51 bluetooth module and I am trying to debug it with Eclipse Mars. I installed the required toolchain as well as OpenOCD (I am using STLink v2 to debug the board).
While running openOCD and arm-none-eabi-gdb in console, everything works fine. The OpenOCD server starts up and I am able to connect with the gdb tool.
However, when trying to start a debug session with Eclipse, it throws the error "Exception occurred during launch. Reason: Program file does not exist". The build process finishes normally. It's the first time I used Eclipse for C/C++ development and the first time after years I used Eclipse at all so I don't even have an idea what could be wrong.
I tried messing around with the project settings without luck. Can anyone give me a hint?
I should mention, I used an already existing Makefile since I tried compiling one of the nordic SDK examples. I Changed it so the resulting files are ready for debugging.
In past I've used Segger's Jlink programmer and the JlinkExe (A pre-built binary) for Linux platform to program Nordic Bluetooth module such as NRF51 and it worked seamlessly. There are some very good documentation on using GNU toolchain with NRF51 series SOC and in case you get your hands on Segger's Jlink, I would recommend you to use that for programming. Meanwhile, this thread in the Nordic's developer zone seem to be very much similar to your problem. Maybe you'll be find some clues there.

run valgrind/other memory-checks through eclipse luna in Windows-8 64bit

I am trying to run a c++ project in eclipse with valgrind leak check.
I can't see the output of valgrind in eclipse console, therefore I can't know if I have leaks or not.
I added in run configurations --> arguments the following:
valgrind --leak-check=yes
Do I need to add anything? Is there a different reason that might cause this?
Thank you
EDIT:
The problem is with Valgrind not running on Windows. I used to work in Linux environment and didn't know Windows doesn't work with Valgrind in the same way.
So rephrasing my question:
I am using Eclipse Luna on Windows 8 64bit.
I have looked through some other posts but so far nothing has been working:
1. I tried to get the Visual Leak Detector, but I couldn't debug because of gdb problems (I installed it using apt-get command).
I tried to:
A. set the location of my gdb, like here Eclipse CDT cannot debug using gdb on Mac but couldn't understand it's location in windows (find . -name returned no interesting results).
B. Also I tried to set the Source Lookup Path as mentioned here How to get gdb working with Eclipse CDT under windows (fails to find source code) , but it did not work as well.
C. Also I tried to reinstall cygwin and select the gdb package, but it was N/A (or I at least couldn't understand how to select it).
2. I tried this from Free Application to check Memory Leaks in Windows x64?
#define _CRTDBG_MAP_ALLOC
#include
#include
Add the following right before the program's exit point(s):
_CrtDumpMemoryLeaks();
It doesn't work as well.
I will try and get the other tools in other posts when I have the time, but if anyone has a solution for why what I have tried so far didn't work - I'll be happy to know.
Have you tried installing the plugin?
Try out this link: http://wiki.eclipse.org/Linux_Tools_Project/PluginInstallHelp

How do I get the .gdbinit command file needed by Eclipse for debugging?

My knowledge and experience in programming is still very fresh and basic, so please bear with me.
I want to be able to use C++ on my MacBook (OS 10.9.5 Mavericks) via Eclipse, which I have already been using for Java previously.
So I followed the instructions in Eclipse GDB MacOSX Mavericks
to get GDB, but now I still need the GDB command file (.gdbinit), which I can't find anywhere (I tried which .gdbinit on Terminal to no avail).
Please help me.
.gdbinit is a configuration file. You won't have one unless you've downloaded one or written one separately. It goes in your home directory and just contains a list of commands to run on startup. You don't necessarily need one. See this answer: .gdbinit file missing
However, if you are fairly new to programming, I'd suggest starting with Xcode, Clang and LLDB on the Mac for C++ rather than Eclipse, GCC and GDB. It's far easier to get setup, and well documented.
See:
How do I set up a C++ project in Xcode 4?

How to do remote debugging with Eclipse CDT without gdbserver?

We're using the Eclipse CDT 5 C++ IDE on Windows to develop a C++ application on a remote AIX host.
Eclipse CDT has the ability to perform remote debugging using gdbserver. Unfortunately, gdbserver is not supported on AIX.
Is anyone familiar with a way to debug remotely using Eclipse CDT without gdbserver? Perhaps using an SSH shell connection to gdb?
finally I got gdb run remotly anyhow now. At the Bug-symbol on the taskbar I took Debug Configurations - GDB Hardware Debugging.
In Main C/C++ Applications I set the full path on the Samba share of the executable (X:\abin\vlmi9506). I also set a linked folder on X:\abin in the project. Then I modified my batch-script in GDB Setup. It's not directly calling gdb in the plink-session but a unix-shell-script, which opens gdb. By this I have the possibility to set some unix environment-variables for the program before doing debug. The call in my batch:
plink.exe prevoax1 -l suttera -pw XXXXX -i /proj/user/dev/suttera/vl/9506/test/vlmi9506ddd.run 20155 dev o m
In the unix script I started gdb with the command line params from eclipse, that I found in my former tryals. The call in the shell command looks like this:
gdb -nw -i mi -cd=$LVarPathExec $LVarPathExec/vlmi9506
Then IBM just gives gdb 6.0 for AIX. I found version 6.8 in the net at http://www.perzl.org/aix/index.php?n=Main.Gdb. Our Admin installed it.
I can now step through the program and watch variables. I even can write gdb-commands directly in the console-view. yabadabadooooooo
Hope that helps to others as well. Can not tell, what was really the winner-action.
But each answer gives more new questions. Now I got 3 of them.
When I start the debug config I have to click restart in the toolbar to come really in the main procedure. Is it possible to come directly in main without restarting?
On AIX our programs are first preprocessed for embedded sql. The preprocessed c-source is put in another directory. When I duble-click the line to set a breakpoint, I get the warning "unresolved breakpoint" and in the gdb-console I see, that the break is set to the preprocessed source which is wrong. Is it possible to set the breakpoints on the right source?
We are using CICS on AIX. With the xldb-Debugger and the CDCN-command of CICS we manage that debugging is started, when we come in our programs. Is it possible to get that remotely (in plink) with gdb-eclipse as well?
I wouldn't normally take a shot in the dark on a question I can't really test the answer to, but since this one has sat around for a day, I'll give it a shot. It seems from looking at:
http://wiki.eclipse.org/TM_and_RSE_FAQ#How_can_I_do_Remote_Debugging_with_CDT.3F
...that even if the CDT has changed since that wiki page was made, you should still be able to change the debug command to:
ssh remotehost gdb
instead of using TM which uses gdbserver. This will probably be slightly slower than the TM remote debugging since that actually uses a local gdb, but on the other hand this way you won't have to NFS or SMB mount your source code to make it available to the local debugger (and if you're on a LAN it probably won't matter anyhow).
There's also a reference TCF implementation for linux, which you may or may not have any luck recompiling for AIX, but it allows for remote debugging if gdbserver is otherwise not available:
http://wiki.eclipse.org/DSDP/TM/TCF_FAQ
tried also to remotly debug an aix-appl with windows eclipse-cdt-gdb.
Got blocked at the end with unix/windows path-problems. Maybe my result can help u a little further - maybe you already got it work. I'm interested in your comment. asked on eclipse news portal- following the answer of martin oberhuber (thanks again) tried dsp dd (also blocked with path problem) and set an request in eclipse bugzilla.
here the link to news:
http://www.eclipse.org/newsportal/article.php?id=406&group=eclipse.dsdp.tm
Here my bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252758
At the moment we still debug localy with xldb but I am trying ddd-gdb at the moment. At least locally gdb is running.