Search code examples
cdebugginggdbeclipse-cdt

Unable to attach GDB to process from Eclipse CDT


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:

Debug perspective thread view

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:

enter image description here

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.


Solution

  • 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.