Skip to content

Commit adcf33f

Browse files
Revert "Reapply PR/87550 (#94625)"
This reverts commit 35fa2de. It broke the LLDB bots on green dragon
1 parent cce10cc commit adcf33f

File tree

7 files changed

+13
-77
lines changed

7 files changed

+13
-77
lines changed

lldb/include/lldb/API/SBDebugger.h

-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ class LLDB_API SBDebugger {
5757

5858
static const char *GetBroadcasterClass();
5959

60-
static bool SupportsLanguage(lldb::LanguageType language);
61-
6260
lldb::SBBroadcaster GetBroadcaster();
6361

6462
/// Get progress data from a SBEvent whose type is eBroadcastBitProgress.

lldb/include/lldb/Symbol/TypeSystem.h

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ class TypeSystem : public PluginInterface,
209209
// TypeSystems can support more than one language
210210
virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
211211

212-
static bool SupportsLanguageStatic(lldb::LanguageType language);
213212
// Type Completion
214213

215214
virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;

lldb/source/API/SBDebugger.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,3 @@ bool SBDebugger::InterruptRequested() {
17421742
return m_opaque_sp->InterruptRequested();
17431743
return false;
17441744
}
1745-
1746-
bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
1747-
return TypeSystem::SupportsLanguageStatic(language);
1748-
}

lldb/source/Symbol/TypeSystem.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,3 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
335335
}
336336
return GetTypeSystemForLanguage(language);
337337
}
338-
339-
bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
340-
if (language == eLanguageTypeUnknown)
341-
return false;
342-
343-
LanguageSet languages =
344-
PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
345-
if (languages.Empty())
346-
return false;
347-
return languages[language];
348-
}

lldb/tools/lldb-dap/DAP.cpp

+10-51
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ namespace lldb_dap {
3232
DAP g_dap;
3333

3434
DAP::DAP()
35-
: broadcaster("lldb-dap"), exception_breakpoints(),
35+
: broadcaster("lldb-dap"),
36+
exception_breakpoints(
37+
{{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
38+
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
39+
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
40+
{"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
41+
{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
42+
{"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
3643
focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false),
3744
enable_auto_variable_summaries(false),
3845
enable_synthetic_child_debugging(false),
@@ -58,64 +65,16 @@ DAP::DAP()
5865

5966
DAP::~DAP() = default;
6067

61-
void DAP::PopulateExceptionBreakpoints() {
62-
llvm::call_once(initExceptionBreakpoints, [this]() {
63-
exception_breakpoints = {};
64-
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
65-
exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
66-
lldb::eLanguageTypeC_plus_plus);
67-
exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
68-
lldb::eLanguageTypeC_plus_plus);
69-
}
70-
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
71-
exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
72-
lldb::eLanguageTypeObjC);
73-
exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
74-
lldb::eLanguageTypeObjC);
75-
}
76-
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
77-
exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
78-
lldb::eLanguageTypeSwift);
79-
exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
80-
lldb::eLanguageTypeSwift);
81-
}
82-
});
83-
}
84-
8568
ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) {
86-
// PopulateExceptionBreakpoints() is called after g_dap.debugger is created
87-
// in a request-initialize.
88-
//
89-
// But this GetExceptionBreakpoint() method may be called before attaching, in
90-
// which case, we may not have populated the filter yet.
91-
//
92-
// We also cannot call PopulateExceptionBreakpoints() in DAP::DAP() because
93-
// we need SBDebugger::Initialize() to have been called before this.
94-
//
95-
// So just calling PopulateExceptionBreakoints(),which does lazy-populating
96-
// seems easiest. Two other options include:
97-
// + call g_dap.PopulateExceptionBreakpoints() in lldb-dap.cpp::main()
98-
// right after the call to SBDebugger::Initialize()
99-
// + Just call PopulateExceptionBreakpoints() to get a fresh list everytime
100-
// we query (a bit overkill since it's not likely to change?)
101-
PopulateExceptionBreakpoints();
102-
assert(exception_breakpoints.has_value() &&
103-
"exception_breakpoints must have been populated");
104-
105-
for (auto &bp : *exception_breakpoints) {
69+
for (auto &bp : exception_breakpoints) {
10670
if (bp.filter == filter)
10771
return &bp;
10872
}
10973
return nullptr;
11074
}
11175

11276
ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const lldb::break_id_t bp_id) {
113-
// See comment in the other GetExceptionBreakpoint().
114-
PopulateExceptionBreakpoints();
115-
assert(exception_breakpoints.has_value() &&
116-
"exception_breakpoints must have been populated");
117-
118-
for (auto &bp : *exception_breakpoints) {
77+
for (auto &bp : exception_breakpoints) {
11978
if (bp.bp.GetID() == bp_id)
12079
return &bp;
12180
}

lldb/tools/lldb-dap/DAP.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ struct DAP {
156156
std::unique_ptr<std::ofstream> log;
157157
llvm::StringMap<SourceBreakpointMap> source_breakpoints;
158158
FunctionBreakpointMap function_breakpoints;
159-
std::optional<std::vector<ExceptionBreakpoint>> exception_breakpoints;
160-
llvm::once_flag initExceptionBreakpoints;
159+
std::vector<ExceptionBreakpoint> exception_breakpoints;
161160
std::vector<std::string> init_commands;
162161
std::vector<std::string> pre_run_commands;
163162
std::vector<std::string> post_run_commands;
@@ -229,8 +228,6 @@ struct DAP {
229228

230229
llvm::json::Value CreateTopLevelScopes();
231230

232-
void PopulateExceptionBreakpoints();
233-
234231
/// \return
235232
/// Attempt to determine if an expression is a variable expression or
236233
/// lldb command using a hueristic based on the first term of the

lldb/tools/lldb-dap/lldb-dap.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <cstdio>
1717
#include <cstdlib>
1818
#include <cstring>
19-
#include <optional>
2019
#include <sys/stat.h>
2120
#include <sys/types.h>
2221
#if defined(_WIN32)
@@ -1587,7 +1586,6 @@ void request_initialize(const llvm::json::Object &request) {
15871586
bool source_init_file = GetBoolean(arguments, "sourceInitFile", true);
15881587

15891588
g_dap.debugger = lldb::SBDebugger::Create(source_init_file, log_cb, nullptr);
1590-
g_dap.PopulateExceptionBreakpoints();
15911589
auto cmd = g_dap.debugger.GetCommandInterpreter().AddMultiwordCommand(
15921590
"lldb-dap", "Commands for managing lldb-dap.");
15931591
if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
@@ -1623,7 +1621,7 @@ void request_initialize(const llvm::json::Object &request) {
16231621
body.try_emplace("supportsEvaluateForHovers", true);
16241622
// Available filters or options for the setExceptionBreakpoints request.
16251623
llvm::json::Array filters;
1626-
for (const auto &exc_bp : *g_dap.exception_breakpoints) {
1624+
for (const auto &exc_bp : g_dap.exception_breakpoints) {
16271625
filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp));
16281626
}
16291627
body.try_emplace("exceptionBreakpointFilters", std::move(filters));
@@ -2478,7 +2476,7 @@ void request_setExceptionBreakpoints(const llvm::json::Object &request) {
24782476
// Keep a list of any exception breakpoint filter names that weren't set
24792477
// so we can clear any exception breakpoints if needed.
24802478
std::set<std::string> unset_filters;
2481-
for (const auto &bp : *g_dap.exception_breakpoints)
2479+
for (const auto &bp : g_dap.exception_breakpoints)
24822480
unset_filters.insert(bp.filter);
24832481

24842482
for (const auto &value : *filters) {

0 commit comments

Comments
 (0)