forked from OSchip/llvm-project
[lldb] Test compatibility between a class type from a member function expr and its original version
This commit is contained in:
parent
54f9ddd806
commit
70a21887f7
|
@ -0,0 +1,3 @@
|
|||
CXX_SOURCES := main.cpp
|
||||
|
||||
include Makefile.rules
|
|
@ -0,0 +1,42 @@
|
|||
"""
|
||||
Tests using a class type that originated from a member function evaluation
|
||||
with the same class type outside a member function.
|
||||
|
||||
When evaluating expressions in a class, LLDB modifies the type of the current
|
||||
class by injecting a "$__lldb_expr" member function into the class. This
|
||||
function should not cause the type to become incompatible with its original
|
||||
definition without the "$__lldb_expr" member.
|
||||
"""
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
class TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@no_debug_info_test
|
||||
def test(self):
|
||||
self.build()
|
||||
lldbutil.run_to_source_breakpoint(self, "// break in member function",
|
||||
lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
# Evaluate an expression in a member function. Store the type of the
|
||||
# 'this' pointer in a persistent variable.
|
||||
self.expect_expr("A $p = *this; $p", result_type="A")
|
||||
|
||||
breakpoint = self.target().BreakpointCreateBySourceRegex(
|
||||
"// break in main", lldb.SBFileSpec("main.cpp"))
|
||||
self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0)
|
||||
threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint)
|
||||
self.assertEqual(len(threads), 1)
|
||||
|
||||
# Evaluate expressions in the main function. Use the persistent type
|
||||
# of "A" that came from an evaluation in a member function with a
|
||||
# normal "A" type and make sure that LLDB can still evaluate
|
||||
# expressions that reference both types at the same time.
|
||||
self.expect_expr("$p.i + a.i", result_type="int", result_value="2")
|
||||
self.expect_expr("a.i + $p.i", result_type="int", result_value="2")
|
||||
self.expect_expr("a = $p; a.i", result_type="int", result_value="1")
|
|
@ -0,0 +1,11 @@
|
|||
struct A {
|
||||
int i = 1;
|
||||
int member_method() {
|
||||
return i; // break in member function
|
||||
}
|
||||
};
|
||||
int main() {
|
||||
A a;
|
||||
int i = a.member_method();
|
||||
return i; // break in main
|
||||
}
|
Loading…
Reference in New Issue