glebd
glebd

Reputation: 339

Xcode 3.2 + LLVM = no local symbols when debugging

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?

Upvotes: 10

Views: 5792

Answers (5)

BenjaminSelby
BenjaminSelby

Reputation: 61

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.

Upvotes: 1

Clay Bridges
Clay Bridges

Reputation: 11860

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.

Upvotes: 10

cdespinosa
cdespinosa

Reputation: 20799

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.

Upvotes: 6

dodgio
dodgio

Reputation: 2329

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.

Upvotes: 5

Employed Russian
Employed Russian

Reputation: 213375

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.

Upvotes: 1

Related Questions