Skip to content

Commit fef5e1f

Browse files
committed
Add static convenience method for FindDAP + lint
1 parent 3a2ae1f commit fef5e1f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,7 @@ void DAP::EventThread() {
13751375
if (lldb::SBProcess::EventIsProcessEvent(event)) {
13761376
lldb::SBProcess process = lldb::SBProcess::GetProcessFromEvent(event);
13771377
// Find the DAP instance that owns this process's target
1378-
DAP *dap_instance = DAPSessionManager::GetInstance().FindDAPForTarget(
1379-
process.GetTarget());
1378+
DAP *dap_instance = DAPSessionManager::FindDAP(process.GetTarget());
13801379
if (!dap_instance)
13811380
continue;
13821381

@@ -1441,8 +1440,7 @@ void DAP::EventThread() {
14411440
lldb::SBTarget event_target =
14421441
lldb::SBTarget::GetTargetFromEvent(event);
14431442
// Find the DAP instance that owns this target
1444-
DAP *dap_instance =
1445-
DAPSessionManager::GetInstance().FindDAPForTarget(event_target);
1443+
DAP *dap_instance = DAPSessionManager::FindDAP(event_target);
14461444
if (!dap_instance)
14471445
continue;
14481446

@@ -1528,8 +1526,7 @@ void DAP::EventThread() {
15281526
lldb::SBTarget event_target = bp.GetTarget();
15291527

15301528
// Find the DAP instance that owns this target
1531-
DAP *dap_instance =
1532-
DAPSessionManager::GetInstance().FindDAPForTarget(event_target);
1529+
DAP *dap_instance = DAPSessionManager::FindDAP(event_target);
15331530
if (!dap_instance)
15341531
continue;
15351532

lldb/tools/lldb-dap/DAPSessionManager.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ DAPSessionManager &DAPSessionManager::GetInstance() {
3232
// Use std::call_once for thread-safe initialization
3333
static std::once_flag initialized;
3434
static DAPSessionManager *instance = nullptr;
35-
36-
std::call_once(initialized, []() {
37-
instance = new DAPSessionManager();
38-
});
39-
35+
36+
std::call_once(initialized, []() { instance = new DAPSessionManager(); });
37+
4038
return *instance;
4139
}
4240

@@ -95,7 +93,7 @@ DAPSessionManager::GetEventThreadForDebugger(lldb::SBDebugger debugger,
9593
// Try to use shared event thread, if it exists
9694
if (auto it = m_debugger_event_threads.find(debugger_id);
9795
it != m_debugger_event_threads.end()) {
98-
if (auto thread_sp = it->second.lock()) {
96+
if (auto thread_sp = it->second.lock()) {
9997
return thread_sp;
10098
}
10199
// Our weak pointer has expired

lldb/tools/lldb-dap/DAPSessionManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class DAPSessionManager {
7575
/// Find the DAP instance that owns the given target
7676
DAP *FindDAPForTarget(lldb::SBTarget target);
7777

78+
/// Static convenience method for FindDAPForTarget
79+
static DAP *FindDAP(lldb::SBTarget target) {
80+
return GetInstance().FindDAPForTarget(target);
81+
}
82+
7883
/// Clean up shared resources when the last session exits
7984
void CleanupSharedResources();
8085

0 commit comments

Comments
 (0)