Debug Info Documentation State

Hi,

I wanted to add debug info to my language (compiler written in Scala, outputs .ll files), but I found it really hard to do based on the documentation provided at http://llvm.org/docs/SourceLevelDebugging.html (I looked at the specific doc for LLVM 3.0 though)

With LLVM 3.0, DI version 8 (which is documented there) seemed to work, except DW_TAG_auto_variable for which I used version tag 11 and imitated what clang was doing.

Got that working for simple programs, but now I switched to LLVM 3.2 and that debug info doesn’t work any more. My best bet seems to be looking at how Clang/LLVM does it internally.

PS. For anyone else looking for this, lib/VMCore/DIBuilder.cpp seems to be the best place to look what the structures should look like.

My question is, any plans to updating the documentation? Documenting different versions of the debug info is probably too much, but the docs should at least be of a working version (of course it’s possible that Version 8 works fine and I was just doing something wrong).

Hi,

I wanted to add debug info to my language (compiler written in Scala,
outputs .ll files), but I found it really hard to do based on the
documentation provided at http://llvm.org/docs/SourceLevelDebugging.html(I looked at the specific doc for LLVM 3.0 though)

With LLVM 3.0, DI version 8 (which is documented there) seemed to work,
except DW_TAG_auto_variable for which I used version tag 11 and imitated
what clang was doing.

Got that working for simple programs, but now I switched to LLVM 3.2 and
that debug info doesn't work any more. My best bet seems to be looking at
how Clang/LLVM does it internally.

PS. For anyone else looking for this, lib/VMCore/DIBuilder.cpp seems to be
the best place to look what the structures should look like.

Yes. You should use DIBuilder if at all possible or construct something
that does the same thing if you need bindings. But I'd probably just do
bindings, producing the text is the least portable way.

My question is, any plans to updating the documentation? Documenting
different versions of the debug info is probably too much, but the docs
should at least be of a working version (of course it's possible that
Version 8 works fine and I was just doing something wrong).

We've removed the versioning on debug info recently and it will continue to
be an unstable format for the foreseeable future. Updating the
documentation is definitely possible, and should be happening as we move
around fields and change things. It's possible it hasn't happened of late
and so that should probably be fixed. A good chunk of the layout still
looks correct - but will be incorrect against any released version even if
it was updated. It should reflect top of tree.

That said, looking at how clang emits debug information is guaranteed to be
the current correct way to emit it so that what you emit is understood by
the backend and if you've got any specific questions the mailing list
should work well.

-eric

Thanks for the quick reply! I will keep the DIBuilder and Clang’s CGDebugInfo as my reference for now.

At the moment I want to stick with generating .ll – it’s somewhat easier for me to debug the output of my compiler that way, and I haven’t programmed much in C/C++ for years – mostly been a JVM guy. But at one point I may want to look into bindings or even creating a bootstrapped compiler.

Understood. Getting some bindings for your language might be an easier way of keeping up to date. The C API is reliable, C++/IR format not so much. Quite a bit has already changed since 3.2.

-eric