Debugging Status on x86?

Hi everyone,

I was under the impression that debugging support on llvm-gcc-4.2.1 + llvm-2.7 was pretty complete (at least on x86 linux), but ran into a glitch.

First off, are there any docs that discuss the current state, in so far as DWARF support is concerned?

The behavior I am seeing is the following:

llvm-gcc -g hello.c -o hello

produces a working executable with apparently complete debugging support. (stepping

However,

llvm-gcc -g -c -emit-llvm hello.c -o hello.bc
llc hello.bc -o hello.s
llvm-gcc -g hello.s -o hello

seem to produce an executable that gdb7 has some issues with, such as inability to examine variables… (but stepping/nexting seem to be okay, and line numbers show up properly

So is this an llvm-gcc issue? or is this an issue with llvm itself?

I’m willing to help out on this, so someone please point me in the right direction.

The most specific doc that talks about debugging was the http://www.llvm.org/docs/DebuggingJITedCode.html
It seems to indicate that debugging support was at least partial.

Thanks.

-jason

Using -g at both levels leads to issues... gcc is trying to add
debugging info to assembly with debugging info.

-Eli

Hi Eli, thanks for your response.

AFAIK, Removing -g from the second call to gcc does not seem to do anything. The generated executable shows the same behavior under gdb.

-jason

Does adding -O0 to the llc command-line help? (I didn't spot that before.)

-Eli

I'm willing to help out on this, so someone please point me in the right
direction.

The main class, which has all Dwarf information is:

llvm/Support/Dwarf.h

The classe that deals with debug info in LLVM (metadata) is:

llvm/Analysis/DebugInfo.h

In Clang, the class that builds the debug information is:

llvm/tools/clang/lib/CodeGen/CGDebugInfo.h

to serve as a template. I'm not sure how complete the debug info is in
Clang, but it's supposed to be complete. I haven't tested the results.

The most specific doc that talks about debugging was
the http://www.llvm.org/docs/DebuggingJITedCode.html
It seems to indicate that debugging support was at least partial.

There's a post on this in the blog:

As Eli mentioned, add -O0 on llc command line. Otherwise llc by
default runs code gen optimizations and transformations to improve
code, which are disabled when you run llvm-gcc without any
optimization flag.

The issue is at llvm code gen phase. The optimization phases are
removing variable's info in your case because probably it is
interfering with the optimization. If you've a small test case then
please file bugzilla report. Supporting debugging of optimized code is
a challenging task.