Files
clang-p2996/lldb/source/Host/common/HostProcess.cpp
Pavel Labath 998bdc5b75 Generalize child process monitoring functions
Summary:
This replaces the C-style "void *" baton of the child process monitoring functions with a more
C++-like API taking a std::function. The motivation for this was that it was very difficult to
handle the ownership of the object passed into the callback function -- each caller ended up
implementing his own way of doing it, some doing it better than others. With the new API, one can
just pass a smart pointer into the callback and all of the lifetime management will be handled
automatically.

This has enabled me to simplify the rather complicated handshake in Host::RunShellCommand. I have
left handling of MonitorDebugServerProcess (my original motivation for this change) to a separate
commit to reduce the scope of this change.

Reviewers: clayborg, zturner, emaste, krytarowski

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D20106

llvm-svn: 269205
2016-05-11 16:59:04 +00:00

66 lines
1.5 KiB
C++

//===-- HostProcess.cpp -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostNativeProcess.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/HostThread.h"
using namespace lldb;
using namespace lldb_private;
HostProcess::HostProcess()
: m_native_process(new HostNativeProcess)
{
}
HostProcess::HostProcess(lldb::process_t process)
: m_native_process(new HostNativeProcess(process))
{
}
HostProcess::~HostProcess()
{
}
Error HostProcess::Terminate()
{
return m_native_process->Terminate();
}
Error HostProcess::GetMainModule(FileSpec &file_spec) const
{
return m_native_process->GetMainModule(file_spec);
}
lldb::pid_t HostProcess::GetProcessId() const
{
return m_native_process->GetProcessId();
}
bool HostProcess::IsRunning() const
{
return m_native_process->IsRunning();
}
HostThread
HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals)
{
return m_native_process->StartMonitoring(callback, monitor_signals);
}
HostNativeProcessBase &HostProcess::GetNativeProcess()
{
return *m_native_process;
}
const HostNativeProcessBase &HostProcess::GetNativeProcess() const
{
return *m_native_process;
}