This is an archive of the discontinued LLVM Phabricator instance.

[NativeProcessLinux] Remove double thread state accounting
ClosedPublic

Authored by labath on May 7 2015, 7:50 AM.

Details

Summary

Now that all thread events are processed synchronously, there is no need to have separate records
of whether a thread is running. This changes the (ever-dwindling) remains of the TSC to use
NativeThreadLinux as the authoritative source of the state of threads. The rest of the
ThreadContext we need has been moved to a member of NTL.

Diff Detail

Event Timeline

labath updated this revision to Diff 25184.May 7 2015, 7:50 AM
labath retitled this revision from to [NativeProcessLinux] Remove double thread state accounting.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: chaoren, ovyalov.
labath added a subscriber: Unknown Object (MLST).
chaoren added inline comments.May 7 2015, 10:58 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
4495

s/Stopped/Running/?

source/Plugins/Process/Linux/NativeThreadLinux.h
101

Why did you get rid of the m_ prefix?

ovyalov edited edge metadata.May 7 2015, 12:34 PM

Please see my comments.

source/Plugins/Process/Linux/NativeProcessLinux.cpp
2450

Could you add check for thread_sp != nullptr?

4414

Potentially, we may add NativeThreadProtocol::RequestStop() to implement this logic as a part of NativeThreadLinux.

4495

Previous version of code requested stop if thread's running (state == ThreadState::Running) - s/StateIsStoppedState/StateIsRunningState ?

4587

Do we still need this lock?

labath added inline comments.May 8 2015, 2:55 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
2450

I added a break two lines above. The fact that thread_sp is null is logged at the start if the function.

4414

I would add this signature to the base class only if/when we have a need to call it from the base NativeProcessProtocol. Right now this looks to me like a detail of this specific implementation of Native(Process/Thread)Protocol. A different implementation of these may wish to (or will need to) do this completely differently.

How about I put this to NTL::RequestStop? At some point I would like to get rid of all these NTL casts (perhaps by reimplementing NPL::GetThreadByID to cast in a single place), so this will become cleaner as well.

4495

You are right of course. I am puzzled at how this wasn't caught by the test suite though...

4587

No, but I'm saving that for another change. I will submit that shortly.

source/Plugins/Process/Linux/NativeThreadLinux.h
101

I was under the impression m_ is used for private members, or at least members of real classes (not just structs). I can put it back if you wish.

labath updated this revision to Diff 25297.May 8 2015, 2:55 AM
labath edited edge metadata.

Address review comments

ovyalov accepted this revision.May 8 2015, 5:28 PM
ovyalov edited edge metadata.

Looks good.

This revision is now accepted and ready to land.May 8 2015, 5:28 PM
This revision was automatically updated to reflect the committed changes.