This is an archive of the discontinued LLVM Phabricator instance.

Support for generating DWARF .debug_aranges sections.
ClosedPublic

Authored by richard.mitton on Sep 11 2013, 1:30 PM.

Details

Reviewers
echristo
Summary

This patch enables LLVM to generate a DWARF .debug_aranges section.

Previously LLVM would simply not generate any data for this (or would rely on a tool like dsymutil to do it instead). This patch allows debuggers to use this data to accelerate file loading.

I really have no idea what I'm doing with regards to LLVM's internals, so someone more knowledgeable should definitely review this.

Diff Detail

Event Timeline

Adding myself as a reviewer.

A first pass through clang-format and other LLVM style issues (dropping
braces on single-statement blocks, etc) might be nice.

richard.mitton updated this revision to Unknown Object (????).Sep 11 2013, 5:15 PM

Ran though clang-format to bring in line with LLVM code style.

Another comment is that it needs testcases, I'd also like a testcase that has multiple CUs to make sure we can handle that.

I'm looking more at the patch as well.

Yes you're right, I'll write up a test case for it.

I'm not entirely sure what situation actually generates multiple CUs at
once (although the code as-written should handle it fine). Can anyone
point me in the right direction for testing this?

Eric Christopher wrote:

Another comment is that it needs testcases, I'd also like a testcase that has multiple CUs to make sure we can handle that.

I'm looking more at the patch as well.

http://llvm-reviews.chandlerc.com/D1649

Easiest way to do that is to take two compile units and merge them together using llvm-link and then generate code for that. I'd suggest making them not share any types at the moment other than basic types, that work isn't quite done.

For example:

a.c:

int add(int a, int b) { return a+b; }

b.c:
extern int add(int a, int b);
int foo(int a, int b) { return add(a, b); }

compile them both to bitcode, link them together, and generate code. You could also take a look at the stmt-list-multiple-compile-units.ll testcase to get an idea of what it'll look like.

If you need any help send me email, I'm very interested in seeing this get in. I've got a few more comments that I'll make tonight or tomorrow.

Might even be able to just reuse that testcase, I've not looked at it particularly closely, but it might work.

In general looks OK, needs testcases as I mentioned and could use some comments in a few places. Thanks for the work.

include/llvm/MC/MCStreamer.h
89

Needs a comment to say what this is used for.

include/llvm/Support/Dwarf.h
62

Make sure to explicitly test for this in the testcase.

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1096

Might be nice to pull in the end of text and data into this.

2760

Period at the end of a sentence.

lib/CodeGen/AsmPrinter/DwarfDebug.h
303

Needs commentary.

lib/MC/MCStreamer.cpp
200

Magic numbers are magic. What's with the +1? :)

richard.mitton updated this revision to Unknown Object (????).Sep 17 2013, 8:58 PM

Improved comments.
Added test cases.
Fixed output order to be stable under different runs.

This patch currently fails the test suite on two tests, due to common symbols being undefined. I'll keep looking into this.

richard.mitton updated this revision to Unknown Object (????).Sep 19 2013, 2:07 PM

This patch fixes handling of common symbols and now passes all the regression tests.

I think it should be good to go now? I hope? :)

echristo accepted this revision.Sep 19 2013, 2:18 PM

Instead of, or perhaps in addition to, testing the assembly output can you test using the output of llvm-dwarfdump as well? It makes it much easier to look at the output and verify correctness if something changes. Also some comments in the tests about what aspect you're testing at each spot would be nice.

LGTM with that change.

Thanks so much, let me know if you need someone to commit for you.

I was actually planning to do that, but it turns out the raw arange data
on it's own doesn't actually give much useful information to test
against (it's just two numbers with no context). I found it basically
impossible to write a useful test against the dwarfdump output.

Richard Mitton
richard@codersnotes.com

That's pretty much why I said in addition rather than replacing. Also it can be done as a follow up if you'd rather discuss this after.