[LLVMdev] Writing unit tests for DWARF?

Renato Golin rengolin at systemcall.org
Fri Mar 18 02:25:08 PDT 2011


On 17 March 2011 21:54, Devang Patel <dpatel at apple.com> wrote:
> I did not mean comparing dwarfdump output. It is never going to work. Sorry for the confusion. I meant letting dwarfdump verify the structure of dwarf info.

Yes, using dwarfdump to verify is fine, but producing correct Dwarf is
not the same as producing THE correct Dwarf you need. You still need
some way of grepping for the symbols you want to have generated, or
the test is not testing for the right thing.

You could have regressions and not break the dwarf, but break what the
dwarf represents.


> Instead, isn't it easier and straight forward to do a FileCheck on debugger output in the first place ?

Oh, but that is only one level of testing, and it doesn't guarantee
your generating correct Dwarf, just "gdb compatible" Dwarf.

I'm doing all three levels (IR, Dwarf and gdb) and it's much easier to
see it fail in the IR level, or even Dwarf than to debug problems
using gdb output.

But I need some better validation for both IR and Dwarf.

One way of testing without comparing IR and Dwarf would be to have
several tests, ALL of them validating with dwarfdump AND stepping
through with gdb and testing every single detail in them. That way,
you assure that the Dwarf generated is gdb compatible and avoid
regressions in that area. If all you care is gdb compatibility, then
you're safe. But when you have a regression, you'll have two major
problems:

1. You won't know where the regression started. There could have been
multiple regressions and only the last one caused validation/gdb to
fail, and the last one could even be an unrelated commit that changes
ELF sections layout, for instance.

2. Even if there was only one regression, finding the bug would be
tiresome. You won't have a "good version" of the IR or the Dwarf to
compare and see what went wrong. Someone not used to Dwarf would take
a long time to figure out what went wrong and how to fix it.

Depends on the level of compatibility you want...

-- 
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