Unable to attach GDB to process from Eclipse CDT - c

I'm building a plugin on Mac OS X using Eclipse CDT, which streams some data via libwebsockets to a browser websocket connection. The compilation process works fine, and I'm able to run my plugin in X-Plane and see data coming in on Google Chrome as expected.
I want to setup debugging with GDB, but I've been pulling my hair for about a week now without any success. I've created a launch configuration in Eclipse CDT to Attach to Application, but every time the debug session is supposed to start, I just get the following in the Eclipse debug perspective:
When starting the Debug, Eclipse shows me a popup list of running processes, and I select X-Plane, but when starting, it simply shows that the thread is suspended.
I've set up the launch configuration as follows:
As an alternative, I tried setting up a project using a makefile, which can be seen here:
https://gist.github.com/josefvanniekerk/690ad22160789c724490
The gcc and linker invocations from Eclipse CDT look as follows:
Building file: ../src/XPWebSocket.c
Invoking: GCC C Compiler
gcc -DAPL=1 -DIBM=0 -DLIN=0 -DXPLM210 -I../lib/xpsdk_v213/CHeaders/XPLM -I../lib/libwebsockets/lib -O3 -g3 -Wall -c -fmessage-length=0 -fvisibility=hidden -MMD -MP -MF"src/XPWebSocket.d" -MT"src/XPWebSocket.d" -o "src/XPWebSocket.o" "../src/XPWebSocket.c"
Finished building: ../src/XPWebSocket.c
Building target: xpwebsocket.xpl
Invoking: MacOS X C Linker
gcc -L../lib/libwebsockets/build/lib -F/{...omitted...}/Projects/xplane/XPWebSocketLib/lib/xpsdk_v213/Libraries/Mac -framework XPLM -shared -o "xpwebsocket.xpl" ./src/XPWebSocket.o -lwebsockets
Finished building target: xpwebsocket.xpl
I've made double sure that I've passed the -g option to enable debugging, but I just can't get this working.
I've tried pointing the C/C++ Application to /Applications/X-Plane/X-Plane.app/Contents/MacOS/X-Plane, changed it to Debug/xpwebsocket.xpl, tried pointing it to the .xpl file inside the X-Plane Resources/Plugins folder, quite frankly, I have no idea what I'm supposed to do to get debugging to work with X-Plane + GDB.
I've started reading up on trying to establish a GDB debug session from the command line, maybe if I understand that process, I can get around to get Eclipse to work. But who knows how many days of reading up that's going to involve.
Can anyone please offer some advice?
More info just in, GDB trace in Eclipse CDT is showing the following (just the error bits):
033,165 &".gdbinit: No such file or directory.\n"
033,165 13^error,msg=".gdbinit: No such file or directory."
037,222 19-target-attach --thread-group i1 197&
037,223 19^error,msg="Asynchronous execution not supported on this target."
After turning off: "Non-stop mode" in CDT, getting the following:
527,581 18^error,msg="Unable to find Mach task port for process-id 197: (os/kern) failure (0x5).\n (\
please check gdb is codesigned - see taskgated(8))"
Guessing I need to codesign X-Plane executable.

I managed to sort this out by signing gdb using the following guide:
http://ntraft.com/installing-gdb-on-os-x-mavericks/
However, fixing the above only reveals that there's possibly a LOT wrong with GDB on Yosemite.

Related

process_begin: CreateProcess(NULL, g++ Hello.C -o Hello, ...) failed. make (e=2): The system cannot find the file specified

I'm trying to make a file into a program on VScode with the Bash terminal, but it reports the above error. I'm relatively new to programming as a whole and trying to follow along with the CS50 course uploaded online; please forgive any incompetence.
below is the entire problem
$ make Hello CC=gcc
g++ Hello.C -o Hello
process_begin: CreateProcess(NULL, g++ Hello.C -o Hello, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [<builtin>: Hello] Error 2
I installed Git and then downloaded chocolatey because I was missing the "make" cmd and I was then able to use the cmd but thats as far as I got before the aforementioned error showed up.
I've already made sure the file directory is correct in VScode via the explorer (Folder -> Hello.C)
I've been attempting this for a couple hours now and genuinely have no idea how to proceed; any advice is appreciated.
I am under the assumption you are using Windows.
Which is very likely your problem.
Under Windows, C Compilers aren't preinstalled, and the compiler you are trying to use (GCC/G++) is a Linux exclusive. MinGW is the Windows equivalent.
From personal experience, programming C under Windows is a hassle, so I can recommend you use WSL (Windows Linux Subsystem) and the corresponding VSCode extension, wich allows you to code in VSCode under Windows with the Terminal, Code and Filesystem running in Linux.
If you were watching this Video, the Prof is using Github codespaces an online cloud service his code runs on (also Linux).

GNOME Builder: "A suitable debugger can't be found" error

I am trying to debug a sample program in Gnome Builder IDE that is written in C, but there is a pop up each time I am pressing the "Debug" button, that says "Failed to initialize debugger: a suitable debugger could not be found".
I am using Manjaro Linux XFCE, the project is make-based, so no meson.
Here is a part of my makefile:
all: koala
WARNINGS = -Wall
DEBUG = -fno-omit-frame-pointer -g
OPTIMIZE = -O2
koala: Makefile koala.c
gcc -o $# $(WARNINGS) $(DEBUG) $(OPTIMIZE) koala.c -lm
UPD: Tried debugging on some sample project with Meson - it works. Now I want to figure out how to use it with make projects.
Same issue here: have a C++ project I am building with make on gnome-builder 3.38 and no chance to spawn gdb from the UI.
By searching the Gnome forums, it appears that at the time I am writing this answer Builder doesn't know how to execute the final executable/environment through make. Hence it cannot launch GDB.
Meson is the only option to graphically debug in Builder for now and since Builder is very much targeting Gnome applications develoment, hence Meson, I have not seen a clear roadmap to support GDB via make.

Eclipse CDT Debug not in executable format: File format not recognized after strawberry installation

Maybe I'm missing something obvious since I searched the internet for quite a while but could not find a solution for the following problem:
I'm using Eclipse Kepler SP2 (Build id: 20140224-0627) with CDT and MinGW as compiler backend. Debugging C code with gdb worked great up until today (at least I noticed the problem today).
Now I get the following error message when i want to start a progam in the debugger:
Error in final launch sequence
Failed to execute MI command:
-file-exec-and-symbols C:/[...]/Debug/test.exe
Error message from debugger back end:
"C:\[...]\Debug\test.exe": not in executable format: File format not recognized
The program runs nicely and so I thought I might have screwed up some settings. But when I tried to debug an old program, everything worked until I recomplied the old program -> same problem. If I ask the C-wizard to create a new "Hello World" ANSI C application with MinGW, the same problem occurs.
The compile commands which were used are
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\test.o" "..\\src\\test.c"
gcc -o test.exe "src\\test.o"
I did not update my MinGW in between, but updated Eclipse.
Do you have any pointers on where to look for the problem?
Edit: I just checked the binary type: My old projects are all [x86/le], the newly compiled ones are [amd64/le]. This should be a trace.... Will update posting according to progress.
Edit2: argh I installed strawberry perl a few days ago, and the installer has changed the environment variable MINGW_HOME in origin BUILD SYSTEM to c:\strawberry\c and this screwed up my builds. Resetting it to my c:\MinGW solved the issue.
I'll post this as answer, too. Heading and tags have been updated to point to this issue more directly.
I installed strawberry perl a few days ago, and the installer has changed the environment variable MINGW_HOME in origin BUILD SYSTEM to c:\strawberry\c and this screwed up my builds. Resetting it to my c:\MinGW solved the issue.
BTW: This happened, because strawberry added c:\strawberry\c to the PATH in front of my custom c:\MinGW and eclipse adds those to the BUILD SYSTEM variables.
It should be a parser problem, what is your binary parser under Project/Properties/Build/Settings ?
Check Project->Properties ->C/C++ Build ->environment and path for MINGW_HOME
make sure you have right gdb version (by checking under debug Configuration ->environment).

Configuring C/C++ on eclipse on Fedora

I installed Eclipse in fedora and then installed the CDT plugin for developping C/C++ applications . All the installation are done !
So now i can create a C/C++ project but when it comes to running it i got this message
launch failed , Binary not found
and
unable to find full path to gcc.
gcc -O2 -g -Wall -c -fmessage-length=0 -o Rad1.o ../Rad1.c
Internal Builder: Cannot run program "gcc": Unknown reason
Error: Program "gcc" is not found in PATH
Is there any more configuration i must do so C/C++ runs?
Thanks.
Executing c/c++ program with eclipse+unix base plate-forme, it requied object file of the program to execute/run it. So first of all you need to build your program by just pressing Ctr+b to buid it. This will create an object file that was required. Now you enabled to run/execute your programe. Good luck :)

Compiling an MPI program with mingw and MPICH2 in eclipse juno

Ive been trying to setup mpich2 to compile some programs using MPI on windows 7. The problem that I encounter is that it wont create the binary files when I build a project.
I use the stadard mpi program to test (hello world) and I get this message after building it:
13:33:29 ** Rebuild of configuration Debug for project mpitest **
Info: Internal Builder is used for build mpiCC "-IC:\MPICH2\include"
-O0 -g3 -Wall -c -fmessage-length=0 -o "src\mpitest.o" "..\src\mpitest.c"
The Open MPI wrapper compiler was unable to find the specified
compiler cl.exe in your PATH.
Note that this compiler was either specified at configure time or in one of several
possible environment variables.
13:33:29 Build Finished (took 78ms)
I tried to search for cl.exe but it doesn't exist. I have to say that I also installed openMPI but I didn't use it cause the cluster that I am gonna target run the program is using MPICH2. I have already installed 32bit minGW, 32bit MPICH2 and 32bit openMPI.
Is it normal to not create binaries since i run the .c file in the cluster? If its normal how am i going to check if the program is ok even for 1 process?
Thanks in advance! Cheers!
I found the answer by luck... In the project preferences, select C/C++ build-> Tool Chain editor-> choose cygwin and its done. For some reason i had mingw in that option and wouldnt create binaries, i suppose it needs some other tools that can be found only in the cygwin and not mingw... Still trying to set it and run on the cluster... so many options :/

Resources