diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py | 41 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py | 234 |
2 files changed, 157 insertions, 118 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py index b456de450a8..74b94517fa0 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py @@ -5,20 +5,22 @@ Test lldb Python API SBValue::Cast(SBType) for C++ types. from __future__ import print_function - import unittest2 -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CppValueCastTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @unittest2.expectedFailure("rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance)") + @unittest2.expectedFailure( + "rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance)") @add_test_categories(['pyapi']) def test_value_cast_with_virtual_inheritance(self): """Test SBValue::Cast(SBType) API for C++ types with virtual inheritance.""" @@ -34,23 +36,26 @@ class CppValueCastTestCase(TestBase): self.do_sbvalue_cast(self.exe_name) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. - self.source = 'sbvalue-cast.cpp'; + # Find the line number to break for main.c. + self.source = 'sbvalue-cast.cpp' self.line = line_number(self.source, '// Set breakpoint here.') self.exe_name = self.testMethodName - self.d_virtual = {'CXX_SOURCES': self.source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DDO_VIRTUAL_INHERITANCE'} + self.d_virtual = { + 'CXX_SOURCES': self.source, + 'EXE': self.exe_name, + 'CFLAGS_EXTRAS': '-DDO_VIRTUAL_INHERITANCE'} self.d_regular = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - def do_sbvalue_cast (self, exe_name): + def do_sbvalue_cast(self, exe_name): """Test SBValue::Cast(SBType) API for C++ types.""" exe = os.path.join(os.getcwd(), exe_name) # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: @@ -59,7 +64,8 @@ class CppValueCastTestCase(TestBase): self.assertTrue(breakpoint, VALID_BREAKPOINT) # 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()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) @@ -74,14 +80,16 @@ class CppValueCastTestCase(TestBase): error = lldb.SBError() # First stop is for DerivedA instance. - threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(threads) == 1) thread = threads[0] frame0 = thread.GetFrameAtIndex(0) tellerA = frame0.FindVariable('teller', lldb.eNoDynamicValues) self.DebugSBValue(tellerA) - self.assertTrue(tellerA.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0) == 20) + self.assertTrue(tellerA.GetChildMemberWithName( + 'm_base_val').GetValueAsUnsigned(error, 0) == 20) if self.TraceOn(): for child in tellerA: @@ -102,14 +110,15 @@ class CppValueCastTestCase(TestBase): self.assertTrue(a_member_val.GetValueAsUnsigned(error, 0) == 10) # Second stop is for DerivedB instance. - threads = lldbutil.continue_to_breakpoint (process, breakpoint) - self.assertTrue (len(threads) == 1) + threads = lldbutil.continue_to_breakpoint(process, breakpoint) + self.assertTrue(len(threads) == 1) thread = threads[0] frame0 = thread.GetFrameAtIndex(0) tellerB = frame0.FindVariable('teller', lldb.eNoDynamicValues) self.DebugSBValue(tellerB) - self.assertTrue(tellerB.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0) == 12) + self.assertTrue(tellerB.GetChildMemberWithName( + 'm_base_val').GetValueAsUnsigned(error, 0) == 12) if self.TraceOn(): for child in tellerB: diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py index 98e6ef92665..42db14f21e0 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py @@ -5,29 +5,32 @@ Use lldb Python API to test dynamic values in C++ from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DynamicValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): - # Call super's setUp(). + # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. + # Find the line number to break for main.c. - self.do_something_line = line_number('pass-to-base.cpp', '// Break here in doSomething.') - self.main_first_call_line = line_number('pass-to-base.cpp', - '// Break here and get real addresses of myB and otherB.') - self.main_second_call_line = line_number('pass-to-base.cpp', - '// Break here and get real address of reallyA.') + self.do_something_line = line_number( + 'pass-to-base.cpp', '// Break here in doSomething.') + self.main_first_call_line = line_number( + 'pass-to-base.cpp', + '// Break here and get real addresses of myB and otherB.') + self.main_second_call_line = line_number( + 'pass-to-base.cpp', '// Break here and get real address of reallyA.') @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663") @@ -38,31 +41,36 @@ class DynamicValueTestCase(TestBase): # Create a target from the debugger. - target = self.dbg.CreateTarget (exe) + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: - do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line) + do_something_bpt = target.BreakpointCreateByLocation( + 'pass-to-base.cpp', self.do_something_line) self.assertTrue(do_something_bpt, VALID_BREAKPOINT) - first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line) + first_call_bpt = target.BreakpointCreateByLocation( + 'pass-to-base.cpp', self.main_first_call_line) self.assertTrue(first_call_bpt, VALID_BREAKPOINT) - 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, VALID_BREAKPOINT) # 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()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, first_call_bpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, first_call_bpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) @@ -71,153 +79,175 @@ class DynamicValueTestCase(TestBase): # with the dynamic values we get in doSomething: use_dynamic = lldb.eDynamicCanRunTarget - no_dynamic = lldb.eNoDynamicValues + no_dynamic = lldb.eNoDynamicValues - myB = frame.FindVariable ('myB', no_dynamic); - self.assertTrue (myB) - myB_loc = int (myB.GetLocation(), 16) + myB = frame.FindVariable('myB', no_dynamic) + self.assertTrue(myB) + myB_loc = int(myB.GetLocation(), 16) otherB = frame.FindVariable('otherB', no_dynamic) - self.assertTrue (otherB) - otherB_loc = int (otherB.GetLocation(), 16) + self.assertTrue(otherB) + otherB_loc = int(otherB.GetLocation(), 16) # Okay now run to doSomething: - threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.continue_to_breakpoint(process, do_something_bpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) # Get "this" using FindVariable: - this_static = frame.FindVariable ('this', no_dynamic) - this_dynamic = frame.FindVariable ('this', use_dynamic) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) - + this_static = frame.FindVariable('this', no_dynamic) + this_dynamic = frame.FindVariable('this', use_dynamic) + self.examine_value_object_of_this_ptr( + this_static, this_dynamic, myB_loc) + # Now make sure that the "GetDynamicValue" works: - # This doesn't work currently because we can't get dynamic values from ConstResult objects. + # This doesn't work currently because we can't get dynamic values from + # ConstResult objects. fetched_dynamic_value = this_static.GetDynamicValue(use_dynamic) - self.examine_value_object_of_this_ptr (this_static, fetched_dynamic_value, myB_loc) + self.examine_value_object_of_this_ptr( + this_static, fetched_dynamic_value, myB_loc) # And conversely that the GetDynamicValue() interface also works: fetched_static_value = this_dynamic.GetStaticValue() - self.examine_value_object_of_this_ptr (fetched_static_value, this_dynamic, myB_loc) + self.examine_value_object_of_this_ptr( + fetched_static_value, this_dynamic, myB_loc) # Get "this" using FindValue, make sure that works too: - this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, no_dynamic) - this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, use_dynamic) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) + this_static = frame.FindValue( + 'this', lldb.eValueTypeVariableArgument, no_dynamic) + this_dynamic = frame.FindValue( + 'this', lldb.eValueTypeVariableArgument, use_dynamic) + self.examine_value_object_of_this_ptr( + this_static, this_dynamic, myB_loc) # Get "this" using the EvaluateExpression: - this_static = frame.EvaluateExpression ('this', False) - this_dynamic = frame.EvaluateExpression ('this', True) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) - + this_static = frame.EvaluateExpression('this', False) + this_dynamic = frame.EvaluateExpression('this', True) + self.examine_value_object_of_this_ptr( + this_static, this_dynamic, myB_loc) + # The "frame var" code uses another path to get into children, so let's # make sure that works as well: - self.expect('frame var -d run-target --ptr-depth=2 --show-types anotherA.m_client_A', 'frame var finds its way into a child member', - patterns = ['\(B \*\)']) + self.expect( + 'frame var -d run-target --ptr-depth=2 --show-types anotherA.m_client_A', + 'frame var finds its way into a child member', + patterns=['\(B \*\)']) # Now make sure we also get it right for a reference as well: - anotherA_static = frame.FindVariable ('anotherA', False) - self.assertTrue (anotherA_static) - anotherA_static_addr = int (anotherA_static.GetValue(), 16) + anotherA_static = frame.FindVariable('anotherA', False) + self.assertTrue(anotherA_static) + anotherA_static_addr = int(anotherA_static.GetValue(), 16) - anotherA_dynamic = frame.FindVariable ('anotherA', True) - self.assertTrue (anotherA_dynamic) - anotherA_dynamic_addr = int (anotherA_dynamic.GetValue(), 16) + anotherA_dynamic = frame.FindVariable('anotherA', True) + self.assertTrue(anotherA_dynamic) + anotherA_dynamic_addr = int(anotherA_dynamic.GetValue(), 16) anotherA_dynamic_typename = anotherA_dynamic.GetTypeName() - self.assertTrue (anotherA_dynamic_typename.find('B') != -1) + self.assertTrue(anotherA_dynamic_typename.find('B') != -1) self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr) - anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName('m_b_value', True) - self.assertTrue (anotherA_m_b_value_dynamic) - anotherA_m_b_val = int (anotherA_m_b_value_dynamic.GetValue(), 10) - self.assertTrue (anotherA_m_b_val == 300) + anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName( + 'm_b_value', True) + self.assertTrue(anotherA_m_b_value_dynamic) + anotherA_m_b_val = int(anotherA_m_b_value_dynamic.GetValue(), 10) + self.assertTrue(anotherA_m_b_val == 300) - anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName('m_b_value', True) - self.assertFalse (anotherA_m_b_value_static) + anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName( + 'm_b_value', True) + self.assertFalse(anotherA_m_b_value_static) - # Okay, now continue again, and when we hit the second breakpoint in main + # Okay, now continue again, and when we hit the second breakpoint in + # main - threads = lldbutil.continue_to_breakpoint (process, second_call_bpt) - self.assertTrue (len(threads) == 1) + threads = lldbutil.continue_to_breakpoint(process, second_call_bpt) + self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) - reallyA_value = frame.FindVariable ('reallyA', False) + reallyA_value = frame.FindVariable('reallyA', False) self.assertTrue(reallyA_value) - reallyA_loc = int (reallyA_value.GetLocation(), 16) - + reallyA_loc = int(reallyA_value.GetLocation(), 16) + # Finally continue to doSomething again, and make sure we get the right value for anotherA, # which this time around is just an "A". - threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint(process, do_something_bpt) self.assertTrue(len(threads) == 1) thread = threads[0] frame = thread.GetFrameAtIndex(0) - anotherA_value = frame.FindVariable ('anotherA', True) + anotherA_value = frame.FindVariable('anotherA', True) self.assertTrue(anotherA_value) - anotherA_loc = int (anotherA_value.GetValue(), 16) - self.assertTrue (anotherA_loc == reallyA_loc) - self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1) + anotherA_loc = int(anotherA_value.GetValue(), 16) + self.assertTrue(anotherA_loc == reallyA_loc) + self.assertTrue(anotherA_value.GetTypeName().find('B') == -1) - 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): # Get "this" as its static value - self.assertTrue (this_static) - this_static_loc = int (this_static.GetValue(), 16) - + self.assertTrue(this_static) + this_static_loc = int(this_static.GetValue(), 16) + # Get "this" as its dynamic value - - self.assertTrue (this_dynamic) + + self.assertTrue(this_dynamic) this_dynamic_typename = this_dynamic.GetTypeName() - self.assertTrue (this_dynamic_typename.find('B') != -1) - this_dynamic_loc = int (this_dynamic.GetValue(), 16) - + self.assertTrue(this_dynamic_typename.find('B') != -1) + this_dynamic_loc = int(this_dynamic.GetValue(), 16) + # Make sure we got the right address for "this" - - self.assertTrue (this_dynamic_loc == dynamic_location) + + self.assertTrue(this_dynamic_loc == dynamic_location) # And that the static address is greater than the dynamic one - self.assertTrue (this_static_loc > this_dynamic_loc) - + self.assertTrue(this_static_loc > this_dynamic_loc) + # Now read m_b_value which is only in the dynamic value: use_dynamic = lldb.eDynamicCanRunTarget - no_dynamic = lldb.eNoDynamicValues - - this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', use_dynamic) - self.assertTrue (this_dynamic_m_b_value) - - m_b_value = int (this_dynamic_m_b_value.GetValue(), 0) - self.assertTrue (m_b_value == 10) - + no_dynamic = lldb.eNoDynamicValues + + this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName( + 'm_b_value', use_dynamic) + self.assertTrue(this_dynamic_m_b_value) + + m_b_value = int(this_dynamic_m_b_value.GetValue(), 0) + self.assertTrue(m_b_value == 10) + # Make sure it is not in the static version - this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', no_dynamic) - self.assertFalse (this_static_m_b_value) + this_static_m_b_value = this_static.GetChildMemberWithName( + 'm_b_value', no_dynamic) + self.assertFalse(this_static_m_b_value) - # Okay, now let's make sure that we can get the dynamic type of a child element: + # Okay, now let's make sure that we can get the dynamic type of a child + # element: - contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', use_dynamic) - self.assertTrue (contained_auto_ptr) - contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', use_dynamic) + contained_auto_ptr = this_dynamic.GetChildMemberWithName( + 'm_client_A', use_dynamic) + self.assertTrue(contained_auto_ptr) + contained_b = contained_auto_ptr.GetChildMemberWithName( + '_M_ptr', use_dynamic) if not contained_b: - contained_b = contained_auto_ptr.GetChildMemberWithName ('__ptr_', use_dynamic) - self.assertTrue (contained_b) - - contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', no_dynamic) + contained_b = contained_auto_ptr.GetChildMemberWithName( + '__ptr_', use_dynamic) + self.assertTrue(contained_b) + + contained_b_static = contained_auto_ptr.GetChildMemberWithName( + '_M_ptr', no_dynamic) if not contained_b_static: - contained_b_static = contained_auto_ptr.GetChildMemberWithName ('__ptr_', no_dynamic) - self.assertTrue (contained_b_static) - - contained_b_addr = int (contained_b.GetValue(), 16) - contained_b_static_addr = int (contained_b_static.GetValue(), 16) - - self.assertTrue (contained_b_addr < contained_b_static_addr) + contained_b_static = contained_auto_ptr.GetChildMemberWithName( + '__ptr_', no_dynamic) + self.assertTrue(contained_b_static) + + contained_b_addr = int(contained_b.GetValue(), 16) + contained_b_static_addr = int(contained_b_static.GetValue(), 16) + + self.assertTrue(contained_b_addr < contained_b_static_addr) |