rdar://16424649
Clean up the DynamicValueTestCase Namely, I split off the part of the test that validates child counts to a separate test llvm-svn: 205450
This commit is contained in:
parent
13673ac704
commit
c1fb7bd33e
|
|
@ -0,0 +1,5 @@
|
||||||
|
LEVEL = ../../make
|
||||||
|
|
||||||
|
CXX_SOURCES := pass-to-base.cpp
|
||||||
|
|
||||||
|
include $(LEVEL)/Makefile.rules
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
"""
|
||||||
|
Test that dynamic values update their child count correctly
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os, time
|
||||||
|
import re
|
||||||
|
import unittest2
|
||||||
|
import lldb, lldbutil
|
||||||
|
from lldbtest import *
|
||||||
|
|
||||||
|
class DynamicValueChildCountTestCase(TestBase):
|
||||||
|
|
||||||
|
mydir = TestBase.compute_mydir(__file__)
|
||||||
|
|
||||||
|
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||||
|
@python_api_test
|
||||||
|
@dsym_test
|
||||||
|
@expectedFailurei386("to be figured out")
|
||||||
|
def test_get_dynamic_vals_with_dsym(self):
|
||||||
|
"""Test fetching C++ dynamic values from pointers & references."""
|
||||||
|
self.buildDsym(dictionary=self.getBuildFlags())
|
||||||
|
self.do_get_dynamic_vals()
|
||||||
|
|
||||||
|
@expectedFailureLinux # FIXME: This needs to be root-caused. It looks like the DWARF info is anticipating the derived class assignment.
|
||||||
|
@python_api_test
|
||||||
|
@dwarf_test
|
||||||
|
@expectedFailurei386("to be figured out")
|
||||||
|
def test_get_dynamic_vals_with_dwarf(self):
|
||||||
|
"""Test fetching C++ dynamic values from pointers & references."""
|
||||||
|
self.buildDwarf(dictionary=self.getBuildFlags())
|
||||||
|
self.do_get_dynamic_vals()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# Call super's setUp().
|
||||||
|
TestBase.setUp(self)
|
||||||
|
|
||||||
|
# Find the line number to break for main.c.
|
||||||
|
|
||||||
|
self.main_third_call_line = line_number('pass-to-base.cpp',
|
||||||
|
'// Break here and check b has 0 children')
|
||||||
|
self.main_fourth_call_line = line_number('pass-to-base.cpp',
|
||||||
|
'// Break here and check b still has 0 children')
|
||||||
|
self.main_fifth_call_line = line_number('pass-to-base.cpp',
|
||||||
|
'// Break here and check b has one child now')
|
||||||
|
self.main_sixth_call_line = line_number('pass-to-base.cpp',
|
||||||
|
'// Break here and check b has 0 children again')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def do_get_dynamic_vals(self):
|
||||||
|
"""Get argument vals for the call stack when stopped on a breakpoint."""
|
||||||
|
exe = os.path.join(os.getcwd(), "a.out")
|
||||||
|
|
||||||
|
# Create a target from the debugger.
|
||||||
|
|
||||||
|
target = self.dbg.CreateTarget (exe)
|
||||||
|
self.assertTrue(target, VALID_TARGET)
|
||||||
|
|
||||||
|
# Set up our breakpoints:
|
||||||
|
|
||||||
|
third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line)
|
||||||
|
self.assertTrue(third_call_bpt,
|
||||||
|
VALID_BREAKPOINT)
|
||||||
|
fourth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fourth_call_line)
|
||||||
|
self.assertTrue(fourth_call_bpt,
|
||||||
|
VALID_BREAKPOINT)
|
||||||
|
fifth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fifth_call_line)
|
||||||
|
self.assertTrue(fifth_call_bpt,
|
||||||
|
VALID_BREAKPOINT)
|
||||||
|
sixth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_sixth_call_line)
|
||||||
|
self.assertTrue(sixth_call_bpt,
|
||||||
|
VALID_BREAKPOINT)
|
||||||
|
|
||||||
|
# Now launch the process, and do not stop at the entry point.
|
||||||
|
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||||
|
|
||||||
|
self.assertTrue(process.GetState() == lldb.eStateStopped,
|
||||||
|
PROCESS_STOPPED)
|
||||||
|
|
||||||
|
b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
|
||||||
|
self.assertTrue(b.GetNumChildren() == 0, "b has 0 children")
|
||||||
|
self.runCmd("continue")
|
||||||
|
self.assertTrue(b.GetNumChildren() == 0, "b still has 0 children")
|
||||||
|
self.runCmd("continue")
|
||||||
|
self.assertTrue(b.GetNumChildren() != 0, "b now has 1 child")
|
||||||
|
self.runCmd("continue")
|
||||||
|
self.assertTrue(b.GetNumChildren() == 0, "b didn't go back to 0 children")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import atexit
|
||||||
|
lldb.SBDebugger.Initialize()
|
||||||
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||||
|
unittest2.main()
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class BaseClass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BaseClass();
|
||||||
|
virtual ~BaseClass() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
class DerivedClass : public BaseClass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DerivedClass();
|
||||||
|
virtual ~DerivedClass() { }
|
||||||
|
protected:
|
||||||
|
int mem;
|
||||||
|
};
|
||||||
|
|
||||||
|
BaseClass::BaseClass()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DerivedClass::DerivedClass() : BaseClass()
|
||||||
|
{
|
||||||
|
mem = 101;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
BaseClass *b = nullptr; // Break here and check b has 0 children
|
||||||
|
b = new DerivedClass(); // Break here and check b still has 0 children
|
||||||
|
b = nullptr; // Break here and check b has one child now
|
||||||
|
return 0; // Break here and check b has 0 children again
|
||||||
|
}
|
||||||
|
|
@ -40,15 +40,6 @@ class DynamicValueTestCase(TestBase):
|
||||||
self.main_second_call_line = line_number('pass-to-base.cpp',
|
self.main_second_call_line = line_number('pass-to-base.cpp',
|
||||||
'// Break here and get real address of reallyA.')
|
'// Break here and get real address of reallyA.')
|
||||||
|
|
||||||
self.main_third_call_line = line_number('pass-to-base.cpp',
|
|
||||||
'// Break here and check b has 0 children')
|
|
||||||
self.main_fourth_call_line = line_number('pass-to-base.cpp',
|
|
||||||
'// Break here and check b still has 0 children')
|
|
||||||
self.main_fifth_call_line = line_number('pass-to-base.cpp',
|
|
||||||
'// Break here and check b has one child now')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def examine_value_object_of_this_ptr (self, this_static, this_dynamic, dynamic_location):
|
def examine_value_object_of_this_ptr (self, this_static, this_dynamic, dynamic_location):
|
||||||
|
|
||||||
|
|
@ -129,15 +120,6 @@ class DynamicValueTestCase(TestBase):
|
||||||
second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line)
|
second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line)
|
||||||
self.assertTrue(second_call_bpt,
|
self.assertTrue(second_call_bpt,
|
||||||
VALID_BREAKPOINT)
|
VALID_BREAKPOINT)
|
||||||
third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line)
|
|
||||||
self.assertTrue(third_call_bpt,
|
|
||||||
VALID_BREAKPOINT)
|
|
||||||
fourth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fourth_call_line)
|
|
||||||
self.assertTrue(fourth_call_bpt,
|
|
||||||
VALID_BREAKPOINT)
|
|
||||||
fifth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fifth_call_line)
|
|
||||||
self.assertTrue(fifth_call_bpt,
|
|
||||||
VALID_BREAKPOINT)
|
|
||||||
|
|
||||||
# Now launch the process, and do not stop at the entry point.
|
# Now launch the process, and do not stop at the entry point.
|
||||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||||
|
|
@ -251,20 +233,6 @@ class DynamicValueTestCase(TestBase):
|
||||||
self.assertTrue (anotherA_loc == reallyA_loc)
|
self.assertTrue (anotherA_loc == reallyA_loc)
|
||||||
self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1)
|
self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1)
|
||||||
|
|
||||||
self.runCmd("continue")
|
|
||||||
# self.runCmd("frame select 0")
|
|
||||||
# self.runCmd("frame variable")
|
|
||||||
b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
|
|
||||||
self.assertTrue(b.GetNumChildren() == 0, "b has 0 children")
|
|
||||||
self.runCmd("continue")
|
|
||||||
# self.runCmd("frame select 0")
|
|
||||||
# self.runCmd("frame variable")
|
|
||||||
self.assertTrue(b.GetNumChildren() == 0, "b still has 0 children")
|
|
||||||
self.runCmd("continue")
|
|
||||||
# self.runCmd("frame select 0")
|
|
||||||
# self.runCmd("frame variable")
|
|
||||||
self.assertTrue(b.GetNumChildren() != 0, "b now has 1 child")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import atexit
|
import atexit
|
||||||
lldb.SBDebugger.Initialize()
|
lldb.SBDebugger.Initialize()
|
||||||
|
|
|
||||||
|
|
@ -52,31 +52,6 @@ private:
|
||||||
|
|
||||||
static A* my_global_A_ptr;
|
static A* my_global_A_ptr;
|
||||||
|
|
||||||
class BaseClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BaseClass();
|
|
||||||
virtual ~BaseClass() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DerivedClass : public BaseClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DerivedClass();
|
|
||||||
virtual ~DerivedClass() { }
|
|
||||||
protected:
|
|
||||||
int mem;
|
|
||||||
};
|
|
||||||
|
|
||||||
BaseClass::BaseClass()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DerivedClass::DerivedClass() : BaseClass()
|
|
||||||
{
|
|
||||||
mem = 101;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -90,8 +65,5 @@ main (int argc, char **argv)
|
||||||
A reallyA (500);
|
A reallyA (500);
|
||||||
myB.doSomething (reallyA); // Break here and get real address of reallyA.
|
myB.doSomething (reallyA); // Break here and get real address of reallyA.
|
||||||
|
|
||||||
BaseClass *b = nullptr; // Break here and check b has 0 children
|
|
||||||
b = new DerivedClass(); // Break here and check b still has 0 children
|
|
||||||
b = nullptr; // Break here and check b has one child now
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue