summaryrefslogtreecommitdiff
path: root/lldb/test
diff options
context:
space:
mode:
authorAlex Langford <alangford@apple.com>2023-04-24 16:58:18 -0700
committerAlex Langford <alangford@apple.com>2023-04-26 10:24:28 -0700
commitc997acb97a9b15468d991116c28bb003afecb07c (patch)
treed0faf35ccac2a8d700519ee13954a58cf3c16925 /lldb/test
parent3ce3ee6169828060d3671be1de6a67c21efcc668 (diff)
downloadllvm-c997acb97a9b15468d991116c28bb003afecb07c.tar.gz
[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
Diffstat (limited to 'lldb/test')
-rw-r--r--lldb/test/Shell/Watchpoint/ExpressionLanguage.test19
-rw-r--r--lldb/test/Shell/Watchpoint/Inputs/languages.cpp12
2 files changed, 31 insertions, 0 deletions
diff --git a/lldb/test/Shell/Watchpoint/ExpressionLanguage.test b/lldb/test/Shell/Watchpoint/ExpressionLanguage.test
new file mode 100644
index 000000000000..be4dca8f64a4
--- /dev/null
+++ b/lldb/test/Shell/Watchpoint/ExpressionLanguage.test
@@ -0,0 +1,19 @@
+# RUN: %clangxx_host %p/Inputs/languages.cpp -g -o %t.out
+# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %s %t.out 2>&1 | FileCheck %s
+
+settings show interpreter.stop-command-source-on-error
+# CHECK: interpreter.stop-command-source-on-error (boolean) = false
+
+b main
+run
+# CHECK: stopped
+# CHECK-NEXT: stop reason = breakpoint
+
+watchpoint set expression -- &g_foo
+# CHECK: Watchpoint created:
+
+watchpoint set expression -l c++ -- &g_bar
+# CHECK: Watchpoint created:
+
+watchpoint set expression -l fake -- &g_baz
+# CHECK: Unknown language type: 'fake' for expression. List of supported languages:
diff --git a/lldb/test/Shell/Watchpoint/Inputs/languages.cpp b/lldb/test/Shell/Watchpoint/Inputs/languages.cpp
new file mode 100644
index 000000000000..98b653f3d404
--- /dev/null
+++ b/lldb/test/Shell/Watchpoint/Inputs/languages.cpp
@@ -0,0 +1,12 @@
+#include <cstdint>
+#include <iostream>
+
+uint64_t g_foo = 5;
+uint64_t g_bar = 6;
+uint64_t g_baz = 7;
+
+int main() {
+ int val = 8;
+ printf("Hello world! %d\n", val);
+ return 0;
+}