[LLVMdev] Writing unit tests for DWARF?

Renato Golin rengolin at systemcall.org
Thu Mar 17 14:00:24 PDT 2011


On 17 March 2011 18:45, Devang Patel <dpatel at apple.com> wrote:
> Yes, It'd be good to have a setup to build SingleSource and MultiSource tests with debug info and run dwarfdump --verify on them.

I tried some dwarfdump on a few examples I had and the comparison with
codesourcery's gcc is impossible, the resulting Dwarf is very
different.

For instance, GCC declares the types at the beginning of the tree
while LLVM only does when needed (metadata-style). The relocation
sections in GCC are huge and they also use debug_loc in many more
cases than LLVM, for instance extern functions, global variables and
the cases I mentioned in my example before. Of course, Dwarf produced
by Armcc is also different (though, closer to what GCC does, for
obvious reasons).

One way we could do this, slowly and painfully, but surely, is to
generate Dwarf, use the debugger to make sure that Dwarf actually
produces what GDB is expecting (you probably have many cases already)
and take a snapshot of that Dwarf. Once we understand how that Dwarf
works and what are the required tags, we create a dwarfdump test that
will FileCheck on those.

This is more or less how I'm doing my local IR/Dwarf/GDB tests. It
takes a while, but have saved me from some regressions already... ;)


-- 
cheers,
--renato

http://systemcall.org/

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm



More information about the llvm-dev mailing list