gdb doesn't find source files compiled by clang++

When compiling my project with clang++, the path to the source files is apparently not included in the object code. This means that gdb is unable to find source files to display code with. For specific instances, I can use gdb's directory command to add a directory, but my project has a lot of source directories and this gets annoying very quickly.

When I switch my configuration to use g++, gdb simply finds all my source files.

This functionality worked clang++ 2.9 on Snow Leopard, but doesn't work with clang++ 3.1 on Lion. I have XCode 4.3.2.

Is there a clang option that forces full paths to be used in object files? Might something else be wrong with my configuration?


I discovered this: the issue happens, when building projects with hierarchical makefiles. If a subdirectory has been built from a parent directory (in my makefile: make -w -C sub-dir) then gdb can not open the source file. When changing into the sub-dir and calling make just for this directory then gdb finds the source. You can verify this by searching the build-path in the generated object files. I used strings object-file | grep $HOME.

I noticed also: this was not happen for one object file: this file has not been compiled with CC. This file has been compiled with esql. At the end, esql calls CC.

That's why I tried this workaround: don't call clang directly from make. Call clang from a shell script.

$ cat ~/bin/mycc

/usr/bin/cc "$@"

$ export CC=mycc
$ make 

Hurray! gdb opens the source files!

BTW: replacing make -w -C sub-dir by (cd sub-dir;make -w) is another workaround.

Need Your Help

Where to find JDK 8 for ARM

java oracle arm java-8

I went to the Oracle site to download the release JDK 8 for ARM and the version labeled as JDK 8 is actually JDK 7 update 40. Does anyone know where to find the JDK 8 for ARM or how to let Oracle k...