I'm using the Ubuntu packages to develop against the LLVM libraries. Here are the packages I have installed:
libllvm3.1
llvm-3.1
llvm-3.1-dev
llvm-3.1-runtime
llvm-3.1-source
'llvm-3.1-source' contains the source code, but as far as I can tell, none of them contain the debug symbols. So when I get a segfault deep inside some LLVM code, I can't tell at what line of source code it occurs.
How do I get the debug symbols?
LLVM is quick-and-easy to build from source. Download the source packages from http://llvm.org/releases/download.html#3.2 and follow the instructions to build in debug mode. Then you can have full debugging capability into LLVM itself.
Related
I use the MSYS2 mingw-w64-x86_64-toolchain group to build my code and stack traces would be more useful if I had debug symbols for the standard library libgcc.
I have searched on the package manager and Google, but can't work out how to get debugging symbols for the standard library. I would expect a mingw-w64-x86_64-gcc-devel or mingw-w64-x86_64-gcc-dbgsym package.
Would I have to compile gcc from source?
Yes you need build GCC yourself with debug enabled. MSYS2 provide only release builds
I have built clang 3.6 from source and followed the rather straightforward instruction on the page and installed ninja, which I confirmed can build clang-format.
My question is quite simply how to pass some flags so I can get debug symbols because I do not want to do my work (modifying clang-format) using disassembly throughout.
This can be through the standard build (which uses CMake) or ninja.
I've faced similar issue recently (I wanted to debug clang's code itself). Turned out that you need to explicitly specify -DCMAKE_BUILD_TYPE=Debug when you run CMake to generate Ninja or standard makefiles.
BTW, be careful: with this Debug option ld "ate" about 4G of my RAM to link clang binary...
I'm developing some C/C++/Objective C static analysis utility which works with llvm bytecode files. Its basic idea is quite simple:
1. Utility executes clang/clang++ with arguments "-c -emit-llvm -femit-all-decls -g" to generate llvm bytecode file for tested source file.
2. If file was created it's being read by LLVM C bindings and checked. Problems related to some specific code points are reported with source references since there are debug metadata with source references.
I've had a prototype of my utility which worked fine, but recently I've updated Xcode to 6.1 and source references became missing.
To fix this I've tried to rebuild my tool and llvm static libraries with updated compiler, but it didn't solved my problem.
I've tried to receive any hints from llvm, and the only thing I finally got is:
➜ bin ./llvm-dis test.bc
warning: ignoring debug info with an invalid version (600054001) in test.bc
So llvm-dis has shown me above warning and produced test.ll file which was stripped of any debug metadata attributes.
This is my simple test source file which I'm playing with:
int returnFive() {
return 5;
}
and some info which may be helpful:
➜ bin clang --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
➜ bin ./llvm-config --version
3.5.0
➜ bin ./llvm-config --host-target
x86_64-apple-darwin14.0.0
For me this seems very compatible, but it isn't so maybe someone can give me any suggestions on how to resolve this?
While I'm still not comfortable with the solution, I've hacked LLVM code and removed the call to llvm::UpgradeDebugInfo method from BitcodeReader::MaterializeModule code. Of course I may be punished for this if some truly incompatible LLVM compiler is used, but for now it works, furthermore not only clang from XCode can be used, but as well I can use Clang from LLVM release page which also produces "debug info with invalid version (0)".
When I tried to build the LLVM source with a user defined module(which invoke add_llvm_loadable_module from CmakeLists.txt) I am getting following error -
LlvmDisassembler ignored -- Loadable modules not supported on this
platform.
I am building from the latest trunk and using MingW to build LLVM. Is there any way to build dll for LLVM modules in Windows ?
As the error indicates, build dynamical loadable module is not supported. It can be built as a static library and link to the main executable.
I have CGAL compiled manually and installed in ~/Library/CGAL/CGAL-4.0.2/. Boost (boost #1.50.0_0+debug+no_single+no_static) as well as cmake (2.8.8_1) are installed using macports. For compilation purposes of the provided examples things work nicely. My problem is when I try to debug an example. In particular, for instance, I ran cmake -DCMAKE_BUILD_TYPE=Debug . in the directory containing the Arrangements_on_surfaces_2 and then make. The generated binary functions as expected, but when running gdb foo in order to debug foo, I get the following warnings:
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/boost/work/boost_1_50_0/bin.v2/libs/thread/build/darwin-4.2.1/debug/address-model-64/architecture-x86/threading-multi/pthread/thread.o" - no debug information available for "libs/thread/src/pthread/thread.cpp".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/boost/work/boost_1_50_0/bin.v2/libs/thread/build/darwin-4.2.1/debug/address-model-64/architecture-x86/threading-multi/pthread/once.o" - no debug information available for "libs/thread/src/pthread/once.cpp".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/boost/work/boost_1_50_0/bin.v2/libs/thread/build/darwin-4.2.1/debug/address-model-64/architecture-x86/threading-multi/future.o" - no debug information available for "libs/thread/src/future.cpp".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/boost/work/boost_1_50_0/bin.v2/libs/system/build/darwin-4.2.1/debug/address-model-64/architecture-x86/threading-multi/error_code.o" - no debug information available for "libs/system/src/error_code.cpp".
I don't really know what to do. I tried downloading, compiling and installing boost manually and then recompile CGAL. However, once I tried to compile an example I got run time complain about missing boost libraries.
On the other hand, when trying to debug an XCode project (after creating it using the -G Xcode option for cmake) I could debug an example.
Any assistance will be helpful!
I also had problems with Boost when I tried installing CGAL with macports. Then I tried the same with homebrew, and it worked like a charm.