This is an archive of the discontinued LLVM Phabricator instance.

[trace][intelpt] Support system-wide tracing [7] - Create a base IntelPTProcessTrace class
ClosedPublic

Authored by wallace on May 12 2022, 2:28 PM.

Details

Summary

We have two different "process trace" implementations: per thread and per core. As a way to simplify the collector who uses both, I'm creating a base abstract class that is used by these implementations. This effectively simplify a good chunk of code.

Diff Detail

Event Timeline

wallace created this revision.May 12 2022, 2:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 2:28 PM
wallace requested review of this revision.May 12 2022, 2:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 2:28 PM
wallace added inline comments.May 12 2022, 2:34 PM
lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
70

this shouldn't have been here since the beginning

lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
320 ↗(On Diff #429077)

I've just found this bug. I'll try to create a unit test later.

jj10306 requested changes to this revision.May 19 2022, 8:08 AM
jj10306 added inline comments.
lldb/source/Plugins/Process/Linux/IntelPTCollector.h
73

Could this be moved to be a part of the new IntelPTProcessTrace abstract class or is this also needed for handling thread trace?

lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
36–38

If this now returns IntelPTProcessTraceUP instead of an instance of itself, then we are basically forcing any uses of this class to be done using dynamic polymorphism (behind the indirection of a pointer to the super class). Should this instead return an instance of itself and then leave it up to the caller to decide if they want to use the object directly or behind a pointer?
I know that currently the only use of this is behind the IntelPTProcessTraceUP (stored on the collector), but maybe in the future we would want to use it directly.
wdyt?

119–125

In TracesThread you check that the tid is a thread of m_process but in TraceStart you return success for all threads without checking if it's a part of the process.
I don't think it particularly matters if we do the check or not, but I do think that the behavior should be consistent between these functions.

lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
58

same comment here as above on the other subclasss

lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h
20
This revision now requires changes to proceed.May 19 2022, 8:08 AM
wallace added inline comments.Jun 9 2022, 12:00 PM
lldb/source/Plugins/Process/Linux/IntelPTCollector.h
73

i can't because you the reason you mention: thread trace

lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
36–38

good call

119–125

ahh you are right

lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
58

+1

lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h
20

+1

wallace requested review of this revision.Jun 15 2022, 9:29 AM
jj10306 accepted this revision.Jun 15 2022, 9:33 AM
This revision is now accepted and ready to land.Jun 15 2022, 9:33 AM