[Lldb-commits] [lldb] 2bab173 - [lldb] Make TestFormatters.py not rely on working constructor calls
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 19 01:21:56 PST 2020
Author: Raphael Isemann
Date: 2020-02-19T10:21:36+01:00
New Revision: 2bab1738f39606324f7bd4c71de1354288c63285
URL: https://github.com/llvm/llvm-project/commit/2bab1738f39606324f7bd4c71de1354288c63285
DIFF: https://github.com/llvm/llvm-project/commit/2bab1738f39606324f7bd4c71de1354288c63285.diff
LOG: [lldb] Make TestFormatters.py not rely on working constructor calls
All calls to operator new in this test fail for me with:
```
expression --show-types -- *(new foo(47))`
Error output:
error: Execution was interrupted, reason: internal c++ exception breakpoint(-6)..
The process has been returned to the state before expression evaluation.
```
As calling operator new isn't the idea of this test, this patch moves that
logic to the binary with some new_* utility functions and explicitly tests
this logic in the constructor test (where we can isolate the failures and
skip them on Linux).
Added:
Modified:
lldb/test/API/commands/expression/formatters/TestFormatters.py
lldb/test/API/commands/expression/formatters/main.cpp
lldb/test/API/lang/cpp/constructors/TestCppConstructors.py
Removed:
################################################################################
diff --git a/lldb/test/API/commands/expression/formatters/TestFormatters.py b/lldb/test/API/commands/expression/formatters/TestFormatters.py
index 98872dffca35..1fbc1ef82986 100644
--- a/lldb/test/API/commands/expression/formatters/TestFormatters.py
+++ b/lldb/test/API/commands/expression/formatters/TestFormatters.py
@@ -57,7 +57,7 @@ def cleanup():
self.runCmd("frame variable foo1.b --show-types")
self.runCmd("frame variable foo1.b.b_ref --show-types")
- self.filecheck("expression --show-types -- *(new foo(47))", __file__,
+ self.filecheck("expression --show-types -- *(new_foo(47))", __file__,
'-check-prefix=EXPR-TYPES-NEW-FOO')
# EXPR-TYPES-NEW-FOO: (foo) ${{.*}} = {
# EXPR-TYPES-NEW-FOO-NEXT: (int) a = 47
@@ -90,13 +90,13 @@ def cleanup():
self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
- self.expect("expression new int(12)",
+ self.expect("expression new_int(12)",
substrs=['(int *) $', ' = 0x'])
self.runCmd(
"type summary add -s \"${var%pointer} -> ${*var%decimal}\" \"int *\"")
- self.expect("expression new int(12)",
+ self.expect("expression new_int(12)",
substrs=['(int *) $', '= 0x', ' -> 12'])
self.expect("expression foo1.a_ptr",
@@ -112,7 +112,7 @@ def cleanup():
# EXPR-FOO1-SAME: h = 27
# EXPR-FOO1-SAME: k = 29
- self.filecheck("expression --ptr-depth=1 -- new foo(47)", __file__,
+ self.filecheck("expression --ptr-depth=1 -- new_foo(47)", __file__,
'-check-prefix=EXPR-PTR-DEPTH1')
# EXPR-PTR-DEPTH1: (foo *) $
# EXPR-PTR-DEPTH1-SAME: a = 47
diff --git a/lldb/test/API/commands/expression/formatters/main.cpp b/lldb/test/API/commands/expression/formatters/main.cpp
index 4ca2504ff8cb..7360c479f10a 100644
--- a/lldb/test/API/commands/expression/formatters/main.cpp
+++ b/lldb/test/API/commands/expression/formatters/main.cpp
@@ -1,6 +1,10 @@
#include <iostream>
#include <string>
+int *new_int(int val) {
+ return new int(val);
+}
+
struct baz
{
int h;
@@ -24,16 +28,22 @@ struct foo
bar b;
foo(int x) : a(x),
- a_ptr(new int(x+1)),
+ a_ptr(new_int(x+1)),
b(2*x) {}
};
+
+foo *new_foo(int x) {
+ return new foo(x);
+}
+
int main(int argc, char** argv)
{
foo foo1(12);
foo foo2(121);
-
+ foo * newd_foo = new_foo(1);
+ delete newd_foo;
foo2.a = 7777; // Stop here
*(foo2.b.i_ptr) = 8888;
foo2.b.b.h = 9999;
diff --git a/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py b/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py
index 422854e38de1..75784f310dde 100644
--- a/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py
+++ b/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py
@@ -24,3 +24,9 @@ def test_constructors(self):
self.expect("expr ClassWithDeletedCtor(1).value", error=True, substrs=["Couldn't lookup symbols:"])
self.expect("expr ClassWithDeletedDefaultCtor().value", error=True, substrs=["Couldn't lookup symbols:"])
+ @skipIfLinux # Fails on some Linux systems with SIGABRT.
+ def test_constructors_new(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.cpp"))
+
+ self.expect_expr("(new ClassWithOneCtor(1)).value; 1", result_type="int", result_value="1")
More information about the lldb-commits
mailing list