Skip to content

Commit 94a067a

Browse files
[LLDB] Support exception breakpoints for plugin-provided languages (#97675)
CommandObjectBreakpoint has a harcoded list of languages for which exception breakpoints can be enabled. I'm making this a bit more generic so that my Mojo plugin can get this feature. Basically, I'm adding a new overridable method `Language::SupportsExceptionBreakpoints` that can be used by language plugins to determine whether they support this feature or not. This method is used in addition to the hardcoded list and, as an example, I'm using it for the ObjC language support. Another route is simply to avoid doing the check that it's being done right now and simply try to the create the exception breakpoint for whatever language that is not in the hardcoded list. I'm happy to do that if the reviewers think it's a good idea. As a note, the other possible place for adding this `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, accessing it requires having a process, which is not always the case when invoking the `breakpoint set -E` command. The process might not be alive yet, so `Language` is a good second place for this. And as a final note, I don't want to make this `SupportsExceptionBreakpoints` complicated. I'm keeping it as simple as possible because it can easily evolve as it's not part of the public API.
1 parent b12449f commit 94a067a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lldb/include/lldb/Target/Language.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ class Language : public PluginInterface {
363363
return false;
364364
}
365365

366+
/// Returns true if this Language supports exception breakpoints via a
367+
/// corresponding LanguageRuntime plugin.
368+
virtual bool SupportsExceptionBreakpoints() const { return false; }
369+
366370
protected:
367371
// Classes that inherit from Language can see and modify these
368372

lldb/source/Commands/CommandObjectBreakpoint.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
308308
case eLanguageTypeC_plus_plus_14:
309309
m_exception_language = eLanguageTypeC_plus_plus;
310310
break;
311-
case eLanguageTypeObjC:
312-
m_exception_language = eLanguageTypeObjC;
313-
break;
314311
case eLanguageTypeObjC_plus_plus:
315312
error_context =
316313
"Set exception breakpoints separately for c++ and objective-c";
@@ -319,6 +316,12 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
319316
error_context = "Unknown language type for exception breakpoint";
320317
break;
321318
default:
319+
if (Language *languagePlugin = Language::FindPlugin(language)) {
320+
if (languagePlugin->SupportsExceptionBreakpoints()) {
321+
m_exception_language = language;
322+
break;
323+
}
324+
}
322325
error_context = "Unsupported language type for exception breakpoint";
323326
}
324327
if (!error_context.empty())

lldb/source/Plugins/Language/ObjC/ObjCLanguage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class ObjCLanguage : public Language {
194194

195195
llvm::StringRef GetInstanceVariableName() override { return "self"; }
196196

197+
bool SupportsExceptionBreakpoints() const override { return true; }
198+
197199
// PluginInterface protocol
198200
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
199201
};

0 commit comments

Comments
 (0)