This is an archive of the discontinued LLVM Phabricator instance.

First pass at HostThreads refactor
ClosedPublic

Authored by zturner on Sep 4 2014, 2:04 PM.

Details

Summary

This patch is a first attempt at creating a HostThread abstraction. This is based on previous discussion on the list. There are a few issues that still need to be worked out, but this is being posted preliminarily to deal with any high-level issues.

Key summary of changes:

  • Threads inside the LLDB process are managed by the HostThread class.
  • HostThread is a typedef for one of: {HostThreadWindows, HostThreadMacOSX, HostThreadFreeBSD}, all of which inherit from HostThreadBase which defines a common interface and set of utility functions.
  • Create a new thread by calling ThreadRunner::LaunchThread()
  • A new class named ThisThread is introduced which allows manipulation and inspection of the currently running thread. Current functionality only allows querying and setting the name.

One of the remaining issues is some deadlocks in ProcessPOSIX and ProcessLinux. I'm still not sure what's causing this, but am looking into it. Would appreciate some help from a Linux guru, although I will keep at it in the meantime.

I also plan to add more comments on the member functions in some of the header files for newly introduced classes.

This patch should apply cleanly on top of git revision a45429b9052517c6a2cb319a07f6b1d2c956ea3a, but due to the size of the patch it may not apply cleanly on top of other revisions. I tried to separate up the patch, but it was fairly difficult and I was unable to make it work cleanly.

Diff Detail

Event Timeline

zturner updated this revision to Diff 13284.Sep 4 2014, 2:04 PM
zturner retitled this revision from to First pass at HostThreads refactor.
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added a reviewer: tfiala.
zturner added a subscriber: Unknown Object (MLST).
zturner updated this revision to Diff 13285.Sep 4 2014, 2:19 PM

Fixed all the deadlocks in ProcessLinux. Sometimes just looking at a diff is the easiest way to find a bug :)

All tests currently pass on Linux and MacOSX. Remaining work will be some cleanup, adding comments, clang-formatting the patch, etc.

zturner updated this revision to Diff 13290.Sep 4 2014, 4:13 PM

clang-formatted patch, added a bunch of comments, fixed a minor bug.

zturner updated this revision to Diff 13349.Sep 5 2014, 3:28 PM

Fixed issues suggested by Jim Ingham. HostThread is now a standalone class that uses a facade pattern to hide the platform-specific details of the different thread implementations. Various other style and naming issues have also been addressed.

zturner closed this revision.Sep 9 2014, 2:05 PM
zturner updated this revision to Diff 13495.

Closed by commit rL217460 (authored by @zturner).