This is an archive of the discontinued LLVM Phabricator instance.

Create a trivial lldb-test program
ClosedPublic

Authored by zturner on Nov 29 2017, 9:57 PM.

Details

Summary

This is basically a proof-of-concept and starting point for having a testing-centric tool in LLDB. I'm sure this leaves a lot of room to be desired, but this at least allows us to have something to build on.

Right now there is only one command, the modules command, and I created this command not because it was particularly special, but because it addressed an immediate use case and was extremely simple.

Run the tool as lldb-test module <path-to-object>.

Getting the linker stuff working was tricky, but hopefully I did this right.

Feel free to add testing related stuff to your heart's content after this goes in. Implementing the commands themselves takes some work, but once they're there they can be reused without writing any code and result in very easy to use and maintain tests.

Note that due to some oddities in llvm's command line library, if you type -help you'll see a bunch of junk. I plan to investigate and hopefully fix all that in the coming <insert-time-period-here>

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Nov 29 2017, 9:57 PM
labath edited edge metadata.Nov 30 2017, 2:31 AM

I feel this is reimplementing llvm-readobj, but maybe that's appropriate as we are reimplementing object file readers as well (my original patch wouldn't be necessary if we were using the llvm object library). Minor comments below, but I actually quite like this approach. It's also much less code than I expected this will need.

lldb/tools/lldb-test/CMakeLists.txt
3 ↗(On Diff #124873)

This is only scary if you link against liblldb, which you're not doing here. You also don't need to add lldbHost here, as it's already added in the list below. So this whole blob can just be deleted.

lldb/tools/lldb-test/lldb-test.cpp
55 ↗(On Diff #124873)

My test case is probably the only place where this will actually be a real C string. I think we should go with something more generic like hex-encoding the data.

zturner updated this revision to Diff 124960.Nov 30 2017, 9:56 AM

Updated based on labath@'s suggestions. Also added a new class LinePrinter, shamelessly ripped and stripped down from a copy used in one of LLVM's dumpers, but that makes it possible to do some nice formatting easily.

davide accepted this revision.Nov 30 2017, 4:28 PM

This LGTM. I think we can iterate in tree from what we have.

This revision is now accepted and ready to land.Nov 30 2017, 4:28 PM
This revision was automatically updated to reflect the committed changes.