This is an archive of the discontinued LLVM Phabricator instance.

[NFC][trace] simplify the instruction dumper
ClosedPublic

Authored by wallace on Apr 19 2022, 10:00 PM.

Details

Summary

TraceInstructionDumper::DumpInstructions was becoming too big, so I'm
refactoring it into smaller functions. I also made some static methods proper
instance methods to simplify calls. Other minor improvements are also done.

Diff Detail

Event Timeline

wallace created this revision.Apr 19 2022, 10:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 10:00 PM
wallace requested review of this revision.Apr 19 2022, 10:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 10:00 PM
jj10306 accepted this revision.Apr 20 2022, 4:23 AM

two very minor comments, but looks good - I'm sure you already have, but be sure to run the dumper unittest test to ensure the output didn't change unexpectedly as a result some minor formatting mistake in this diff 🙂

lldb/include/lldb/Target/TraceInstructionDumper.h
26

It shouldn't be an issue now because this struct is never stored any where, but in the future we should be aware that if this struct is ever stored "long term" (ie in another class), we should instead use ExececutionContextRef
From the documentation in ExecutionContext.h

/// exist during a function that requires the objects. ExecutionContext
/// objects should NOT be used for long term storage since they will keep
/// objects alive with extra shared pointer references to these  objects
lldb/source/Target/TraceInstructionDumper.cpp
199

should this be a static function?

This revision is now accepted and ready to land.Apr 20 2022, 4:23 AM
wallace added inline comments.Apr 25 2022, 8:01 PM
lldb/include/lldb/Target/TraceInstructionDumper.h
26

Yes, you are right :)

lldb/source/Target/TraceInstructionDumper.cpp
199

goot catch

wallace updated this revision to Diff 425109.Apr 25 2022, 8:02 PM

address comments

This revision was landed with ongoing or failed builds.Apr 25 2022, 8:03 PM
This revision was automatically updated to reflect the committed changes.