views:

1308

answers:

5

I have a project for Mac OS X 10.5 that I'm building on 10.6 using Xcode 3.2. When I use GCC 4.2 for Debug build and hit a breakpoint, Xcode debugger displays local variable information normally. If I choose LLVM GCC 4.2 or Clang LLVM, when I hit breakpoint, local symbols are not available, and GDB says No symbol 'self' in current context if I try to print self or any other local symbol. In all cases Generate debug info option is set. The Debug configuration is set to $(NATIVE_ARCH) and 10.5 SDK, Build active architecture only option is set. When GDB starts, I can see it is being configured as x86_64-apple-darwin. I must be missing something obvious. How do I make GDB show local symbols when using a LLVM compiler?

A: 

GDB from FSF only added support for JIT code very recently.

I don't know whether Apple-supplied GDB has support for it at all (do you get reasonable stack traces?). If it does, this support is (apparently) incomplete.

Employed Russian
What makes you think this has anything to do with JIT, or that Apple would ship a gdb that doesn't fully work with the compiler they wrote?
Stack looks correct, shows all my functions. It's local vars that are missing.
glebd
But llvm can generate native code, not bytecode.
osgx
+3  A: 

This may help. Try turning off "Link-Time Optimization" in the project's build options. That fixed a problem I had with missing debug symbols.

In fact, that fixed a bunch of weird problems I was having with Clang. I'd say that feature is just too bleeding edge to use yet.

dodgio
+4  A: 

Make sure you're building with Dwarf symbols and no optimization. llvm is a new back-end, and not all of its optimized codegen is hooked up to debug symbol generation yet.

cdespinosa
+5  A: 

For those not familiar, a little more detail to cdespinosa's answer, which worked for me, and which I voted up.

  1. From the Xcode menu, select Project > Edit Project Settings...
  2. Choose the Build tab
  3. In the search box type "Optimization Level", choose that field, and select None.
  4. Next search for "Debug Information Format", choose that field, and select "DWARF" or "DWARF with dSYM".

Would have put this in comments to his post if I had the privs. ;)

This cost me some serious time, and was frankly kind of sloppy on Apple's part, but in general I can't complain.

Clay Bridges
A: 

I was having this problem and solved it by putting a tick next to the menu item: "Project > Set Active Build Configuration > Debug". Previously, the "Release" option was selected. Locals started showing up in the debugger for my project from then on.

SpaceMonkey