aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py')
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py87
1 files changed, 51 insertions, 36 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py
index fe10120d497e..c915e4b32fad 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py
+++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py
@@ -3,13 +3,14 @@
from __future__ import print_function
-
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class ClassTypesTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -27,7 +28,8 @@ class ClassTypesTestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break on the ctor function of class C.
- lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.cpp", self.line, num_expected_locations=-1)
self.runCmd("run", RUN_SUCCEEDED)
@@ -40,17 +42,20 @@ class ClassTypesTestCase(TestBase):
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
- substrs = ['stopped',
- 'stop reason = breakpoint'])
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
- substrs = [' resolved, hit count = 1'])
+ substrs=[' resolved, hit count = 1'])
# We should be stopped on the ctor function of class C.
- self.expect("frame variable --show-types this", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['C *',
- ' this = '])
+ self.expect(
+ "frame variable --show-types this",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=[
+ 'C *',
+ ' this = '])
@add_test_categories(['pyapi'])
def test_with_python_api(self):
@@ -77,11 +82,12 @@ class ClassTypesTestCase(TestBase):
# Verify the breakpoint just created.
self.expect(str(breakpoint), BREAKPOINT_CREATED, exe=False,
- substrs = ['main.cpp',
- str(self.line)])
+ substrs=['main.cpp',
+ str(self.line)])
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
@@ -92,7 +98,8 @@ class ClassTypesTestCase(TestBase):
lldbutil.state_type_to_str(process.GetState()))
# The stop reason of the thread should be breakpoint.
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
self.assertIsNotNone(thread)
# The filename of frame #0 should be 'main.cpp' and the line number
@@ -100,9 +107,9 @@ class ClassTypesTestCase(TestBase):
self.expect("%s:%d" % (lldbutil.get_filenames(thread)[0],
lldbutil.get_line_numbers(thread)[0]),
"Break correctly at main.cpp:%d" % self.line, exe=False,
- startstr = "main.cpp:")
- ### clang compiled code reported main.cpp:94?
- ### startstr = "main.cpp:93")
+ startstr="main.cpp:")
+ # clang compiled code reported main.cpp:94?
+ # startstr = "main.cpp:93")
# We should be stopped on the breakpoint with a hit count of 1.
self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
@@ -119,49 +126,54 @@ class ClassTypesTestCase(TestBase):
# Is this a case of clang (116.1) generating bad debug info?
#
# Break on the ctor function of class C.
- #self.expect("breakpoint set -M C", BREAKPOINT_CREATED,
+ # self.expect("breakpoint set -M C", BREAKPOINT_CREATED,
# startstr = "Breakpoint created: 1: name = 'C'")
- # Make the test case more robust by using line number to break, instead.
- lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=-1)
+ # Make the test case more robust by using line number to break,
+ # instead.
+ lldbutil.run_break_set_by_file_and_line(
+ self, None, self.line, num_expected_locations=-1)
self.runCmd("run", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
- substrs = ['stopped',
- 'stop reason = breakpoint'])
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
# The breakpoint should have a hit count of 1.
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
- substrs = [' resolved, hit count = 1'])
+ substrs=[' resolved, hit count = 1'])
# Continue on inside the ctor() body...
self.runCmd("register read pc")
self.runCmd("thread step-over")
# Verify that 'frame variable this' gets the data type correct.
- self.expect("frame variable this",VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['C *'])
+ self.expect("frame variable this", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs=['C *'])
- # Verify that frame variable --show-types this->m_c_int behaves correctly.
+ # Verify that frame variable --show-types this->m_c_int behaves
+ # correctly.
self.runCmd("register read pc")
self.runCmd("expr m_c_int")
- self.expect("frame variable --show-types this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY,
- startstr = '(int) this->m_c_int = 66')
+ self.expect(
+ "frame variable --show-types this->m_c_int",
+ VARIABLES_DISPLAYED_CORRECTLY,
+ startstr='(int) this->m_c_int = 66')
# Verify that 'expression this' gets the data type correct.
self.expect("expression this", VARIABLES_DISPLAYED_CORRECTLY,
- substrs = ['C *'])
+ substrs=['C *'])
# rdar://problem/8430916
# expr this->m_c_int returns an incorrect value
#
# Verify that expr this->m_c_int behaves correctly.
self.expect("expression this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY,
- patterns = ['\(int\) \$[0-9]+ = 66'])
+ patterns=['\(int\) \$[0-9]+ = 66'])
- def test_with_constructor_name (self):
+ def test_with_constructor_name(self):
"""Test 'frame variable this' and 'expr this' when stopped inside a constructor."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
@@ -185,11 +197,12 @@ class ClassTypesTestCase(TestBase):
# Verify the breakpoint just created.
self.expect(str(breakpoint), BREAKPOINT_CREATED, exe=False,
- substrs = ['main.cpp',
- str(self.line)])
+ substrs=['main.cpp',
+ str(self.line)])
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
@@ -200,10 +213,12 @@ class ClassTypesTestCase(TestBase):
lldbutil.state_type_to_str(process.GetState()))
# The stop reason of the thread should be breakpoint.
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
self.assertIsNotNone(thread)
frame = thread.frames[0]
- self.assertTrue (frame.IsValid(), "Got a valid frame.")
+ self.assertTrue(frame.IsValid(), "Got a valid frame.")
- self.assertTrue ("C::C" in frame.name, "Constructor name includes class name.")
+ self.assertTrue("C::C" in frame.name,
+ "Constructor name includes class name.")