LLDB mainline
TargetAPIMutex.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Target/Target.h"
11#include "lldb/Utility/Policy.h"
12
13using namespace lldb_private;
14
16 if (m_target_sp) {
17 Policy policy = PolicyStack::Get().Current();
18 std::recursive_mutex &real_mutex = policy.view == Policy::View::Private
19 ? m_target_sp->m_private_mutex
20 : m_target_sp->m_mutex;
21 m_mutex = std::shared_ptr<std::recursive_mutex>(m_target_sp, &real_mutex);
22 }
23 if (m_mutex)
24 m_mutex->lock();
25}
26
28 if (m_target_sp) {
29 Policy policy = PolicyStack::Get().Current();
30 std::recursive_mutex &real_mutex = policy.view == Policy::View::Private
31 ? m_target_sp->m_private_mutex
32 : m_target_sp->m_mutex;
33 m_mutex = std::shared_ptr<std::recursive_mutex>(m_target_sp, &real_mutex);
34 }
35 return m_mutex ? m_mutex->try_lock() : true;
36}
static PolicyStack & Get()
Definition Policy.cpp:21
Policy Current() const
Definition Policy.cpp:26
std::shared_ptr< std::recursive_mutex > m_mutex
An aliasing shared_ptr into m_target_sp's own mutex, resolved fresh on every lock()/try_lock() call.
A class that represents a running process on the host machine.
Describes what view of the process a thread should see and what operations it is allowed to perform.
Definition Policy.h:33
@ Private
Parent (unwinder) frames, private state, private run lock.
Definition Policy.h:37