Friday, August 1, 2014

Not able to debug C++ with remote Eclipse CDT on Windows

I had an interesting idea that I may be able to debug Raspberry Pi C++ program from Eclipse running on MS-Windows remotely. It turned out that this is not easy task at all. The complexity is remote debugging plus cross platform plus different type of OS plus Eclipse debugging; none of them are simple nor easy. lol

Although I ended up having no result at all, I like to summarize what I have found and share what difficulty I found.


Difficulty 1. Remote debugging with gdb/gdbserver.
Normally remote debugging wit gdb and gdbserver consists of two parts. On "target" platform, which runs the program, gdbserver launch the program that we want to debug. Then gdb with all debugging information such as symbols and binaries runs remotely and it access gdbserver via network. This is actually doable if both platforms are same although I haven't done.

Difficulty 2. Cross platform remote debugging.
gdb/gdbserver supports cross-platform remote debugging so this is still doable step. If one side computer is using Intel chip and another side is using ARM, the binary that should be used on both platforms is for the "target" platform. In my situation, I should have used ARM binary on both Raspberry Pi side and MS-Windows side, which happens to be running on Intel chip.

Difficulty 3. Cross platform remote debugging on MS-Windows.
This step is where it gets complicated, because on MS-Windows there isn't much choice of cross-compiler. Choices I found are MingW and Cygwin. I cannot use MS-VisualStudio compiler because it doesn't do cross-compile for ARM chips; I don't think it will work with gdb either. Moreover, none of MingW or Cygin has pre-packaged cross-compiler for ARM. I need to get source code of GCC and other libraries. Then I need to compile the compiler by myself. From my experience, this kind of Frankenstein compilation easily goes off the rail, because they will need specific versions of dependent libraries and it is not easy to satisfy the dependencies of the dependencies of the dependencies.

Difficulty 4. Setting up MS-Windows Eclipse for gdb remote debugging.
This step itself may be doable but it seems that the gdb feature in Eclipse is mainly for Linux/Unix environment not for MS-Windows with MingW or Cygwin. So I am not sure if this step actually work out if I walked through the previous step. Alternatively there is a GUI version of gdb called "ddd". But I don't think there is one for MingW or Cygwin.

An alternative was to use Eclipse on Raspberry Pi and display it on MS-Windows via X11-forwarding. But it turned out that it is super slow.

Another alternative is to utilize unit-testing instead of using debugger at all. But this is not always possible and unit-test cannot eliminate the need of debugger.

These leaves me the last and only choice; I will need to use text version of gdb via SSH terminal, which isn't a preferred way of debugging these days.

1 comment:

  1. Try this video:

    https://www.youtube.com/watch?v=Al6OZ2kF_qA&index=4&list=WL

    ...plus make sure in the "Debug Configurations > Main" under "Connection" also set the "Properties..." to the same path as "Remote Absolute File Path..."

    ReplyDelete

About Me

My photo
Tomorrow may not come, so I want to do my best now.