Skip to content

Commit acb6a6e

Browse files
committed
Address code review feedback
1 parent 5ea2ad6 commit acb6a6e

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

lldb/include/lldb/API/SBLock.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ class LLDB_API SBLock {
2828
bool IsValid() const;
2929

3030
private:
31-
friend class SBTarget;
32-
3331
SBLock() = default;
34-
SBLock(std::recursive_mutex &mutex);
32+
33+
// Private constructor used by SBTarget to create the Target API lock.
34+
// Requires a friend declaration.
3535
SBLock(std::recursive_mutex &mutex, lldb::TargetSP target_sp);
36+
friend class SBTarget;
37+
3638
SBLock(const SBLock &rhs) = delete;
3739
const SBLock &operator=(const SBLock &rhs) = delete;
3840

lldb/include/lldb/API/SBTarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ class LLDB_API SBTarget {
947947
lldb::SBTrace CreateTrace(SBError &error);
948948

949949
#ifndef SWIG
950-
lldb::SBLock GetAPILock() const;
950+
lldb::SBLock AcquireAPILock() const;
951951
#endif
952952

953953
protected:

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ class Target : public std::enable_shared_from_this<Target>,
16951695
/// The private implementation backing SBLock.
16961696
struct APILock {
16971697
APILock(std::recursive_mutex &mutex) : lock(mutex) {}
1698+
virtual ~APILock() = default;
16981699
std::lock_guard<std::recursive_mutex> lock;
16991700
};
17001701

@@ -1703,6 +1704,7 @@ struct APILock {
17031704
struct TargetAPILock : public APILock {
17041705
TargetAPILock(std::recursive_mutex &mutex, lldb::TargetSP target_sp)
17051706
: APILock(mutex), target_sp(target_sp) {}
1707+
~TargetAPILock() override = default;
17061708
lldb::TargetSP target_sp;
17071709
};
17081710

lldb/source/API/SBLock.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ using namespace lldb_private;
1919

2020
#ifndef SWIG
2121

22-
SBLock::SBLock(std::recursive_mutex &mutex)
23-
: m_opaque_up(std::make_unique<APILock>(mutex)) {
24-
LLDB_INSTRUMENT_VA(this);
25-
}
26-
2722
SBLock::SBLock(std::recursive_mutex &mutex, lldb::TargetSP target_sp)
2823
: m_opaque_up(std::make_unique<TargetAPILock>(mutex, target_sp)) {
2924
LLDB_INSTRUMENT_VA(this);

lldb/source/API/SBTarget.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "lldb/API/SBTarget.h"
10-
#include "lldb/API/SBLock.h"
11-
#include "lldb/Utility/Instrumentation.h"
12-
#include "lldb/Utility/LLDBLog.h"
13-
#include "lldb/lldb-public.h"
14-
1510
#include "lldb/API/SBBreakpoint.h"
1611
#include "lldb/API/SBDebugger.h"
1712
#include "lldb/API/SBEnvironment.h"
@@ -60,11 +55,14 @@
6055
#include "lldb/Utility/ArchSpec.h"
6156
#include "lldb/Utility/Args.h"
6257
#include "lldb/Utility/FileSpec.h"
58+
#include "lldb/Utility/Instrumentation.h"
59+
#include "lldb/Utility/LLDBLog.h"
6360
#include "lldb/Utility/ProcessInfo.h"
6461
#include "lldb/Utility/RegularExpression.h"
6562
#include "lldb/ValueObject/ValueObjectConstResult.h"
6663
#include "lldb/ValueObject/ValueObjectList.h"
6764
#include "lldb/ValueObject/ValueObjectVariable.h"
65+
#include "lldb/lldb-public.h"
6866

6967
#include "Commands/CommandObjectBreakpoint.h"
7068
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -2437,7 +2435,7 @@ lldb::SBTrace SBTarget::CreateTrace(lldb::SBError &error) {
24372435
}
24382436

24392437
#ifndef SWIG
2440-
lldb::SBLock SBTarget::GetAPILock() const {
2438+
lldb::SBLock SBTarget::AcquireAPILock() const {
24412439
LLDB_INSTRUMENT_VA(this);
24422440

24432441
if (TargetSP target_sp = GetSP())

lldb/unittests/API/SBLockTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(SBLockTest, LockTest) {
4040

4141
// Take the API lock.
4242
{
43-
lldb::SBLock lock = target.GetAPILock();
43+
lldb::SBLock lock = target.AcquireAPILock();
4444
ASSERT_FALSE(locked.exchange(true));
4545

4646
// Wake up the test thread.

0 commit comments

Comments
 (0)