aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectBreakpoint.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-07-10 15:24:27 -0700
committerGitHub <noreply@github.com>2025-07-10 15:24:27 -0700
commitf28a497a06c2d9202638d753e1cd2e247814d180 (patch)
tree5599ddef580f55fbf72b8f47f2ad8a516a2cf319 /lldb/source/Commands/CommandObjectBreakpoint.cpp
parent4859b92b7f4e0365517acd464cec29721f469461 (diff)
downloadllvm-f28a497a06c2d9202638d753e1cd2e247814d180.zip
llvm-f28a497a06c2d9202638d753e1cd2e247814d180.tar.gz
llvm-f28a497a06c2d9202638d753e1cd2e247814d180.tar.bz2
[lldb] Support specifying a language for breakpoint conditions (#147603)
LLDB breakpoint conditions take an expression that's evaluated using the language of the code where the breakpoint is located. Users have asked to have an option to tell it to evaluate the expression in a specific language. This is feature is especially helpful for Swift, for example for a condition based on the value in memory at an offset from a register. Such a condition is pretty difficult to write in Swift, but easy in C. This PR adds a new argument (-Y) to specify the language of the condition expression. We can't reuse the current -L option, since you might want to break on only Swift symbols, but run a C expression there as per the example above. rdar://146119507
Diffstat (limited to 'lldb/source/Commands/CommandObjectBreakpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 2440a7e..38ec375 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -72,7 +72,7 @@ public:
case 'c':
// Normally an empty breakpoint condition marks is as unset. But we need
// to say it was passed in.
- m_bp_opts.SetCondition(option_arg.str().c_str());
+ m_bp_opts.GetCondition().SetText(option_arg.str());
m_bp_opts.m_set_flags.Set(BreakpointOptions::eCondition);
break;
case 'C':
@@ -154,6 +154,21 @@ public:
m_bp_opts.GetThreadSpec()->SetIndex(thread_index);
}
} break;
+ case 'Y': {
+ LanguageType language = Language::GetLanguageTypeFromString(option_arg);
+
+ LanguageSet languages_for_expressions =
+ Language::GetLanguagesSupportingTypeSystemsForExpressions();
+ if (language == eLanguageTypeUnknown)
+ error = Status::FromError(CreateOptionParsingError(
+ option_arg, short_option, long_option, "invalid language"));
+ else if (!languages_for_expressions[language])
+ error = Status::FromError(
+ CreateOptionParsingError(option_arg, short_option, long_option,
+ "no expression support for language"));
+ else
+ m_bp_opts.GetCondition().SetLanguage(language);
+ } break;
default:
llvm_unreachable("Unimplemented option");
}