summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Windows/DebugMonitorMessages.cpp
blob: 86904a604f2803ff50a4dec52bd2c7abdb105057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//===-- DebugMonitorMessages.cpp --------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "DebugMonitorMessages.h"
#include "DebugMonitorMessageResults.h"

#include "lldb/Core/Error.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Target/ProcessLaunchInfo.h"

using namespace lldb;
using namespace lldb_private;

DebugMonitorMessage::DebugMonitorMessage(MonitorMessageType message_type)
    : m_message_type(message_type)
{
    Retain();
    m_completion_predicate.SetValue(nullptr, eBroadcastNever);
}

DebugMonitorMessage::~DebugMonitorMessage()
{
    const DebugMonitorMessageResult *result = m_completion_predicate.GetValue();
    if (result)
        result->Release();
    m_completion_predicate.SetValue(nullptr, eBroadcastNever);
}

const DebugMonitorMessageResult *
DebugMonitorMessage::WaitForCompletion()
{
    const DebugMonitorMessageResult *result = nullptr;
    m_completion_predicate.WaitForValueNotEqualTo(nullptr, result);
    return result;
}

void
DebugMonitorMessage::CompleteMessage(const DebugMonitorMessageResult *result)
{
    if (result)
        result->Retain();
    m_completion_predicate.SetValue(result, eBroadcastAlways);
}

LaunchProcessMessage::LaunchProcessMessage(const ProcessLaunchInfo &launch_info, lldb::ProcessSP process_plugin)
    : DebugMonitorMessage(MonitorMessageType::eLaunchProcess)
    , m_launch_info(launch_info)
    , m_process_plugin(process_plugin)
{
}

LaunchProcessMessage *
LaunchProcessMessage::Create(const ProcessLaunchInfo &launch_info, lldb::ProcessSP process_plugin)
{
    return new LaunchProcessMessage(launch_info, process_plugin);
}
OpenPOWER on IntegriCloud