This is an archive of the discontinued LLVM Phabricator instance.

Introduce a ProcessStatus monitor abstraction.
AbandonedPublic

Authored by zturner on Oct 30 2014, 1:09 PM.

Details

Reviewers
clayborg
jingham
Summary

Note: This patch is optional, and was something I arrived at as an intermediate step while trying to implement debugging on Windows in such a way that ProcessWindows::DoLaunch() could reuse Host::LaunchProcess. While I ultimately ended up needing to circumvent the entire Host::LaunchProcess codepath entirely for techncial reasons, making this patch not strictly necessary for my subsequent patch, the abstraction still seems generally useful for creating reusable code, so I'm posting it here anyway.

This is a very general abstraction useful for local debugging as well as remote debugging, that allows implementors to customize the way in which processes are monitored for changes in status after being launched.

Additionally, a Windows implementation is provided that waits for a process to exit and notifies listeners, and Host::LaunchProcess uses this implementation.

This change is intended to provide no functional change, and consists mostly of new code, not altered code. The altered code that does exist only offers a fallback path so that if someone does not specify a ProcessStatusMonitor, it simply falls back to the old code path so that everything behaves as before.

Diff Detail

Event Timeline

zturner updated this revision to Diff 15575.Oct 30 2014, 1:09 PM
zturner retitled this revision from to Introduce a ProcessStatus monitor abstraction..
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added reviewers: clayborg, jingham.
zturner updated this object.
zturner added a subscriber: Unknown Object (MLST).
clayborg requested changes to this revision.Oct 30 2014, 1:21 PM
clayborg edited edge metadata.

In include/lldb/Host/MonitoringProcessLauncher.h: please include lldb-forward.h and don't forward declare anything manually

In explicit MonitoringProcessLauncher(lldb::ProcessStatusMonitorSP monitor, lldb::ProcessLauncherUP delegate_launcher); I would change each arg to be a const reference to avoid copies and reference counts being bumped.

Change ProcessStatusMonitorCallbackEntry to not use std::pair and declare a small structure instead. Seeing "a.first" and "a.second" really doesn't help the readability of the code, so please make a struct with good member names ("callback" and "baton").

In lldb-forward.h the spacing of the new stuff you added seems to be using tabs as it isn't indented the same as the others. Please make sure to use spaces instead of tabs.

This revision now requires changes to proceed.Oct 30 2014, 1:21 PM

Gah, thanks for noticing the lldb-forward.h problem. It's clang-format
doing that, it's not smart enough to align variables in cases where you've
chosen to not use standard 1-space separation between type and variable
names.

zturner updated this revision to Diff 15626.Oct 31 2014, 9:34 AM
zturner edited edge metadata.

Fixed issues suggested by Greg.

clayborg accepted this revision.Oct 31 2014, 10:12 AM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Oct 31 2014, 10:12 AM
zturner abandoned this revision.Nov 3 2014, 3:55 PM

I'm going to abandon this revision for now. After the discussion on-list about the high level concept of monitoring processes, and the realization that this makes no sense for windows and is different conceptually from monitoring for debug events, I think a different abstraction is needed, so this doesn't improve anything.