From c997acb97a9b15468d991116c28bb003afecb07c Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Mon, 24 Apr 2023 16:58:18 -0700 Subject: [lldb] Add support for specifying language when setting watchpoint by expression This is useful in contexts where you have multiple languages in play: You may be stopped in a frame for language A, but want to set a watchpoint with an expression using language B. The current way to do this is to use the setting `target.language` while setting the watchpoint and unset it after the watchpoint is set, but that's kind of clunky and somewhat error-prone. This should add a better way to do this. rdar://108202559 Differential Revision: https://reviews.llvm.org/D149111 --- lldb/source/Commands/CommandObjectWatchpoint.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp') diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 8b8c196..14180f9 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -835,8 +835,7 @@ corresponding to the byte size of the data type."); m_arguments.push_back(arg); // Absorb the '-w' and '-s' options into our option group. - m_option_group.Append(&m_option_watchpoint, LLDB_OPT_SET_ALL, - LLDB_OPT_SET_1); + m_option_group.Append(&m_option_watchpoint, LLDB_OPT_SET_1, LLDB_OPT_SET_1); m_option_group.Finalize(); } @@ -990,6 +989,7 @@ public: : CommandObjectRaw( interpreter, "watchpoint set expression", "Set a watchpoint on an address by supplying an expression. " + "Use the '-l' option to specify the language of the expression. " "Use the '-w' option to specify the type of watchpoint and " "the '-s' option to specify the byte size to watch for. " "If no '-w' option is specified, it defaults to write. " @@ -1083,6 +1083,8 @@ protected: options.SetKeepInMemory(false); options.SetTryAllThreads(true); options.SetTimeout(std::nullopt); + if (m_option_watchpoint.language_type != eLanguageTypeUnknown) + options.SetLanguage(m_option_watchpoint.language_type); ExpressionResults expr_result = target->EvaluateExpression(expr, frame, valobj_sp, options); -- cgit v1.1