3

I am trying to debug C++ code using Eclipse Galileo on my MacBook Pro running Mac OS X v10.5 (Leopard). It's my first time trying this. I have a complicated C++ program I'd like to debug, but to test things out, I just tried to debug and step through the following:

#include <iostream>
using namespace std;

int main()
{
  int x = 0;
  cout << x << endl;

  x = 54;
  cout << x << endl;

  return 0;
}

I clicked the debug icon, told it to use GDB (DSF) Create Process Launcher and started to step through the code. I wanted to be able to monitor the value of x, so I opened up the Variables window and watched. Initially, it was 4096 - presumably some garbage value. As soon as I hit the next line, where it had shown the value, it now shows the following error:

Failed to execute MI command:
-var-update 1 var1
Error message from debugger back end:
Variable object not found

I can't seem to figure this out or get around it. And a few Google searches turned up bone dry without even the hint of a lead.


Solution: As drhirsch pointed out below, use the Standard Create Process Launcher instead of the GDB Create Process Launcher. (This is actually a workaround and not a true solution, but it worked for at least two of us.)

Community
  • 1
  • 1
Eben Geer
  • 3,696
  • 3
  • 31
  • 34
  • hi, i am getting the same error how do you get on screen the error output "Failed to execute .."? I do not even any info .... – Open the way Dec 20 '09 at 22:10
  • Ok, at the moment, using /opt/local/bin/fsf-gdb which is version 7.1, seems to do the trick! I did not test it extensively, but I can use breakpoints in very different functions, and the program stops there while debugging – Open the way Mar 04 '11 at 15:35
  • Did you compile with debug information and not strip the executable? – steve Aug 13 '09 at 07:09
  • I'm building in Debug and don't see anything like that in the project settings, so I'm pretty sure that's not it. Plus, it actually does edit and continue just fine during debug. Thanks for the idea, though. – Eben Geer Aug 13 '09 at 08:10

8 Answers8

5

In my experience the gdb/dsf launcher is still quite unusable. I can't get it to show variables too, it seems still very buggy.

Did you try the Standard Create Process Launcher? For me this works fine.

Gunther Piez
  • 29,760
  • 6
  • 71
  • 103
  • You know, I honestly tried switching to that and got an entirely different sort of application error. However, on your suggestion, I tried again and whaddaya know...it works! Thanks! – Eben Geer Aug 13 '09 at 08:11
  • I may have restarted Eclipse since then. That could be why. – Eben Geer Aug 13 '09 at 08:12
2

This appears to still be a problem without a reliably good answer, other than using an IDE other than Eclipse.

I tried both the DSF Create Process Launcher and the Standard Create Process Launcher variations, but neither results in a successful debugging experience. The GDB debugger launches either way, but breakpoints are not handled properly (unresolved in some cases) and almost no variable values can be inspected/tracked.

Here's what software I'm using:

  • Eclipse 3.5.2 (Galileo), 64-bit Cocoa version
  • Eclipse C/C++ development tools 6.0.2.2
  • Mac OS X 10.6.3 (Snow Leopard)
  • GDB 6.3.5 (Apple's version that ships with Xcode)

I've also tried building GDB 7.1 from source since as of 7.0 it is supposed to have native x86/x86_64 Darwin support. It builds fine and launches OK from the command-line, but it has various problems when I try launching it from Eclipse. These appear to be related to changes that Apple made recently to how the taskgated mechanism works for allowing debuggers to connect to processes. The following error is typical of these:

Target request failed: Unable to find Mach task port for process-id 88283:
(os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8)).

Various sources on the web indicate that Apple uses their own special patches in GDB 6.3.5 to support Mac OS X, however this is a really old code base (2004). Conversely, other web sources indicate that the Eclipse DSF debugger framework requires GDB commands that only appear starting in GDB 6.6 (circa 2006?).

I've been all over the Eclipse-related forums but have found no signs of a solution to this problem. It appears that almost no one on the Eclipse CDT development team uses Mac OS X, so they rarely bother to test their changes on this platform.

EDIT UPDATE: In addition to the above, I've retried all of the prior described testing (GDB versions 6.3.5 and 7.1) with a developer build, Eclipse Helios 3.6 RC3 (IDE for C/C++ developers), which includes CDT 7.0. Encountered all of the same reported problems. Eclipse CDT debugging on Mac OS X Snow Leopard is still non-functional.

Does anyone know something different and/or a reliable Eclipse-based solution to the scenario I've reported above?

Joel Hoff
  • 1,993
  • 20
  • 22
  • Joel, you may want to post this as your own question. For my purposes, drhirsch's recommendation to simply use the Standard launcher worked just fine for me. Two upvotes indicate it may have helped others as well, but based on the feedback on this page, it doesn't seem to be helping everyone. Perhaps this topic deserves another question from someone such as yourself who is still experiencing the issue. – Eben Geer Jun 28 '10 at 16:52
  • @speedmetal - Thanks for the suggestion; I may do that yet as the problem still exists for me--I've been using XCode instead. I'll probably try posting on one of the Eclipse forums first, though. – Joel Hoff Jun 29 '10 at 18:09
  • I am having the same problem, did you find a new solution? – Open the way Mar 03 '11 at 08:52
  • I am thinking about the following workaround; install linux ubuntu or similar in a virtual machine and then activate remote debugging so your program is debugged there. it should work, although not a very elegant solution – Open the way Mar 03 '11 at 08:53
  • I still have not found a solution. Looked again about 1-2 months ago, but I found nothing that works. I'm still stuck working with Xcode on Mac OSX. – Joel Hoff Mar 19 '11 at 01:14
1

I've had similar problems with multiple versions of Eclipse on Ubuntu. One solution that has often worked for me is to use GDB version 6.6 rather than the latest versions.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user710464
  • 11
  • 1
0

In the future, you could also try using Xcode (just to debug) - drag all the files in to import them into a new project, but don't compile. Instead, open the debugger window and attach to your running process.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
0

You can follow the instructions of page GDB on OS X Mavericks and Xcode 5.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mahbubcsedu
  • 158
  • 6
0

The same problem, but I might have found a way. In Eclipse, under the project properties, in Run/Debug settings, I deleted the launch configurations and ran the debugger again.

At that point everything worked correctly, although it takes at least 10 seconds to launch the debugger if I modify. I think it has to do with a combination of both the debugging properties and the launcher configuration.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Update to the released version of Eclipse 3.6 (Helios) and use the DSF/GDB Create Launcher. There was a lot of work done to bring the feature parity of the DSF/GDB framework up to usable levels for Eclipse 3.6 (Helios). Debugging now works just fine on OS X 10.5 and 10.6 using Eclipse CDT 3.6 Helios.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

OK, at the moment, using /opt/local/bin/fsf-gdb which is version 7.1, seems to do the trick! I did not test it extensively, but I can use breakpoints in very different functions, and the program stops there while debugging.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Open the way
  • 26,225
  • 51
  • 142
  • 196