This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Allow dumping the state of all scratch TypeSystems
ClosedPublic

Authored by teemperor on Oct 16 2021, 4:08 AM.

Details

Summary

This adds the target dump typesystem'command which dumps the TypeSystem of the
target itself (aka the 'scratch TypeSystem'). This is similar to target modules dump ast
which dumps the AST of lldb::Modules associated with a selected target.

Unlike target modules dump ast, the new command is not a subcommand of
target modules dump as it's not touching the modules of a target at all. Also unlike
target modules dump ast I tried to keep the implementation language-neutral, so
this patch moves our Clang Dump to the TypeSystem interface so it will also dump
the state of any future/downstream scratch TypeSystems (e.g., Swift). That's also
why the command just refers to a 'typesystem' instead of an 'ast' (which is only how
Clang is necessarily modelling the internal TypeSystem state).

The main motivation for this patch is that I need to write some tests that check
for duplicates in the ScratchTypeSystemClang of a target. There is currently no way
to check for this at the moment (beside measuring memory consumption of course).
It's probably also useful for debugging LLDB itself.

Diff Detail

Event Timeline

teemperor created this revision.Oct 16 2021, 4:08 AM
teemperor requested review of this revision.Oct 16 2021, 4:08 AM

Does it make sense to make target modules dump ast use the new DumpState method?

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
9751

use static instead of anonymous namesapce

teemperor updated this revision to Diff 380410.Oct 18 2021, 8:26 AM
  • Repurpose existing Dump method.

Does it make sense to make target modules dump ast use the new DumpState method?

Makes sense, I repurposed the existing non-virtual Dump so both should use the same backend.

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
9751

whops, thanks!

teemperor edited the summary of this revision. (Show Details)Oct 18 2021, 8:27 AM
labath accepted this revision.Oct 18 2021, 8:31 AM
This revision is now accepted and ready to land.Oct 18 2021, 8:31 AM