Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 478
glebd Avatar asked Sep 03 '09 00:09

glebd


5 Answers

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.

like image 169
Clay Bridges Avatar answered Nov 16 '22 05:11

Clay Bridges


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.

like image 25
cdespinosa Avatar answered Nov 16 '22 06:11

cdespinosa


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.

like image 33
dodgio Avatar answered Nov 16 '22 05:11

dodgio


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.

like image 1
Employed Russian Avatar answered Nov 16 '22 06:11

Employed Russian


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.

like image 1
BenjaminSelby Avatar answered Nov 16 '22 05:11

BenjaminSelby