diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities')
292 files changed, 10201 insertions, 6323 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py b/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py index 6423ecf27ae..b3095c758f9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py @@ -5,19 +5,20 @@ Test some lldb command abbreviations and aliases for proper resolution. 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 AbbreviationsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @no_debug_info_test - def test_command_abbreviations_and_aliases (self): + def test_command_abbreviations_and_aliases(self): command_interpreter = self.dbg.GetCommandInterpreter() self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) result = lldb.SBCommandReturnObject() @@ -47,9 +48,12 @@ class AbbreviationsTestCase(TestBase): self.assertTrue(result.GetError().startswith("Ambiguous command")) # Make sure an unabbreviated command is not mangled. - command_interpreter.ResolveCommand("breakpoint set --name main --line 123", result) + command_interpreter.ResolveCommand( + "breakpoint set --name main --line 123", result) self.assertTrue(result.Succeeded()) - self.assertEqual("breakpoint set --name main --line 123", result.GetOutput()) + self.assertEqual( + "breakpoint set --name main --line 123", + result.GetOutput()) # Create some aliases. self.runCmd("com a alias com al") @@ -69,33 +73,40 @@ class AbbreviationsTestCase(TestBase): self.runCmd("alias pltty process launch -s -o %1 -e %1") command_interpreter.ResolveCommand("pltty /dev/tty0", result) self.assertTrue(result.Succeeded()) - self.assertEqual("process launch -s -o /dev/tty0 -e /dev/tty0", result.GetOutput()) + self.assertEqual( + "process launch -s -o /dev/tty0 -e /dev/tty0", + result.GetOutput()) self.runCmd("alias xyzzy breakpoint set -n %1 -l %2") command_interpreter.ResolveCommand("xyzzy main 123", result) self.assertTrue(result.Succeeded()) - self.assertEqual("breakpoint set -n main -l 123", result.GetOutput().strip()) + self.assertEqual( + "breakpoint set -n main -l 123", + result.GetOutput().strip()) # And again, without enough parameters. command_interpreter.ResolveCommand("xyzzy main", result) self.assertFalse(result.Succeeded()) # Check a command that wants the raw input. - command_interpreter.ResolveCommand(r'''sc print("\n\n\tHello!\n")''', result) + command_interpreter.ResolveCommand( + r'''sc print("\n\n\tHello!\n")''', result) self.assertTrue(result.Succeeded()) - self.assertEqual(r'''script print("\n\n\tHello!\n")''', result.GetOutput()) + self.assertEqual( + r'''script print("\n\n\tHello!\n")''', + result.GetOutput()) # Prompt changing stuff should be tested, but this doesn't seem like the # right test to do it in. It has nothing to do with aliases or abbreviations. #self.runCmd("com sou ./change_prompt.lldb") - #self.expect("settings show prompt", + # self.expect("settings show prompt", # startstr = 'prompt (string) = "[with-three-trailing-spaces] "') #self.runCmd("settings clear prompt") - #self.expect("settings show prompt", + # self.expect("settings show prompt", # startstr = 'prompt (string) = "(lldb) "') #self.runCmd("se se prompt 'Sycamore> '") - #self.expect("se sh prompt", + # self.expect("se sh prompt", # startstr = 'prompt (string) = "Sycamore> "') #self.runCmd("se cl prompt") - #self.expect("set sh prompt", + # self.expect("set sh prompt", # startstr = 'prompt (string) = "(lldb) "') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py b/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py index fa6f3f30689..519b93efebe 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py @@ -6,19 +6,20 @@ many commands remain available even after we add/delete commands in the future. 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 CommonShortSpellingsTestCase(TestBase): - + mydir = TestBase.compute_mydir(__file__) @no_debug_info_test - def test_abbrevs2 (self): + def test_abbrevs2(self): command_interpreter = self.dbg.GetCommandInterpreter() self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) result = lldb.SBCommandReturnObject() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py b/lldb/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py index 66ed3ff7329..aecbab1b363 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py @@ -5,13 +5,14 @@ Test that apropos env doesn't crash trying to touch the process plugin commmand from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class AproposWithProcessTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,16 +30,17 @@ class AproposWithProcessTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() aftre the variables are assigned values. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) self.runCmd('apropos env') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py b/lldb/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py index b419ad97a69..f825eaa86e8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.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 BSDArchivesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -18,10 +19,18 @@ class BSDArchivesTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number in a(int) to break at. - self.line = line_number('a.c', '// Set file and line breakpoint inside a().') + self.line = line_number( + 'a.c', '// Set file and line breakpoint inside a().') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows") - @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27795") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows") + @expectedFailureAll( + oslist=["linux"], + archs=[ + "arm", + "aarch64"], + bugnumber="llvm.org/pr27795") def test(self): """Break inside a() and b() defined within libfoo.a.""" self.build() @@ -30,30 +39,32 @@ class BSDArchivesTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside a() by file and line first. - lldbutil.run_break_set_by_file_and_line (self, "a.c", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "a.c", self.line, num_expected_locations=1, loc_exact=True) 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']) # Break at a(int) first. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(int) arg = 1']) + substrs=['(int) arg = 1']) self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(int) __a_global = 1']) + substrs=['(int) __a_global = 1']) # Set breakpoint for b() next. - lldbutil.run_break_set_by_symbol (self, "b", num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, "b", num_expected_locations=1, sym_exact=True) # Continue the program, we should break at b(int) next. self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(int) arg = 2']) + substrs=['(int) arg = 2']) self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(int) __b_global = 2']) + substrs=['(int) __b_global = 2']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py index 6416bccc483..29e75f86308 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py @@ -5,25 +5,28 @@ Test that ASan memory history provider returns correct stack traces 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 lldbplatform from lldbsuite.test import lldbutil + class AsanTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt - def test (self): - self.build () - self.asan_tests () + def test(self): + self.build() + self.asan_tests() def setUp(self): # Call super's setUp(). @@ -33,68 +36,99 @@ class AsanTestCase(TestBase): self.line_free = line_number('main.c', '// free line') self.line_breakpoint = line_number('main.c', '// break line') - def asan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def asan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint) # "memory history" command should not work without a process self.expect("memory history 0", - error = True, - substrs = ["invalid process"]) + error=True, + substrs=["invalid process"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # 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']) # test that the ASan dylib is present - self.expect("image lookup -n __asan_describe_address", "__asan_describe_address should be present", - substrs = ['1 match found']) + self.expect( + "image lookup -n __asan_describe_address", + "__asan_describe_address should be present", + substrs=['1 match found']) # test the 'memory history' command - self.expect("memory history 'pointer'", - substrs = [ - 'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc, - 'Memory deallocated by Thread', 'a.out`f2', 'main.c:%d' % self.line_free]) + self.expect( + "memory history 'pointer'", + substrs=[ + 'Memory allocated by Thread', + 'a.out`f1', + 'main.c:%d' % + self.line_malloc, + 'Memory deallocated by Thread', + 'a.out`f2', + 'main.c:%d' % + self.line_free]) # do the same using SB API process = self.dbg.GetSelectedTarget().process val = process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer") addr = val.GetValueAsUnsigned() - threads = process.GetHistoryThreads(addr); + threads = process.GetHistoryThreads(addr) self.assertEqual(threads.GetSize(), 2) - + history_thread = threads.GetThreadAtIndex(0) self.assertTrue(history_thread.num_frames >= 2) - self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c") - self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_free) - + self.assertEqual(history_thread.frames[1].GetLineEntry( + ).GetFileSpec().GetFilename(), "main.c") + self.assertEqual( + history_thread.frames[1].GetLineEntry().GetLine(), + self.line_free) + history_thread = threads.GetThreadAtIndex(1) self.assertTrue(history_thread.num_frames >= 2) - self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c") - self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc) - - # let's free the container (SBThreadCollection) and see if the SBThreads still live + self.assertEqual(history_thread.frames[1].GetLineEntry( + ).GetFileSpec().GetFilename(), "main.c") + self.assertEqual( + history_thread.frames[1].GetLineEntry().GetLine(), + self.line_malloc) + + # let's free the container (SBThreadCollection) and see if the + # SBThreads still live threads = None self.assertTrue(history_thread.num_frames >= 2) - self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c") - self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc) - + self.assertEqual(history_thread.frames[1].GetLineEntry( + ).GetFileSpec().GetFilename(), "main.c") + self.assertEqual( + history_thread.frames[1].GetLineEntry().GetLine(), + self.line_malloc) + # ASan will break when a report occurs and we'll try the API then self.runCmd("continue") - self.expect("thread list", "Process should be stopped due to ASan report", - substrs = ['stopped', 'stop reason = Use of deallocated memory detected']) - - # make sure the 'memory history' command still works even when we're generating a report now - self.expect("memory history 'another_pointer'", - substrs = [ - 'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc2]) + self.expect( + "thread list", + "Process should be stopped due to ASan report", + substrs=[ + 'stopped', + 'stop reason = Use of deallocated memory detected']) + + # make sure the 'memory history' command still works even when we're + # generating a report now + self.expect( + "memory history 'another_pointer'", + substrs=[ + 'Memory allocated by Thread', + 'a.out`f1', + 'main.c:%d' % + self.line_malloc2]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py index b02732ddedd..b89572dc4ef 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py @@ -5,25 +5,28 @@ Test the AddressSanitizer runtime support for report breakpoint and data extract from __future__ import print_function - -import os, time +import os +import time import json import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class AsanTestReportDataCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt def test(self): - self.build () - self.asan_tests () + self.build() + self.asan_tests() def setUp(self): # Call super's setUp(). @@ -34,26 +37,43 @@ class AsanTestReportDataCase(TestBase): self.line_breakpoint = line_number('main.c', '// break line') self.line_crash = line_number('main.c', '// BOOM line') - def asan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def asan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") - self.expect("thread list", "Process should be stopped due to ASan report", - substrs = ['stopped', 'stop reason = Use of deallocated memory detected']) + self.expect( + "thread list", + "Process should be stopped due to ASan report", + substrs=[ + 'stopped', + 'stop reason = Use of deallocated memory detected']) - self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + self.assertEqual( + self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonInstrumentation) self.expect("bt", "The backtrace should show the crashing line", - substrs = ['main.c:%d' % self.line_crash]) - - self.expect("thread info -s", "The extended stop info should contain the ASan provided fields", - substrs = ["access_size", "access_type", "address", "pc", "description", "heap-use-after-free"]) + substrs=['main.c:%d' % self.line_crash]) + + self.expect( + "thread info -s", + "The extended stop info should contain the ASan provided fields", + substrs=[ + "access_size", + "access_type", + "address", + "pc", + "description", + "heap-use-after-free"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py index 54463c56827..b348e72606a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py @@ -5,8 +5,8 @@ Test process attach/resume. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -14,6 +14,7 @@ from lldbsuite.test import lldbutil exe_name = "AttachResume" # Must match Makefile + class AttachResumeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -41,35 +42,53 @@ class AttachResumeTestCase(TestBase): process = self.dbg.GetSelectedTarget().GetProcess() self.runCmd("c") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) self.runCmd("process interrupt") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateStopped]) # be sure to continue/interrupt/continue (r204504) self.runCmd("c") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) self.runCmd("process interrupt") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateStopped]) # Second interrupt should have no effect. - self.expect("process interrupt", patterns=["Process is not running"], error=True) + self.expect( + "process interrupt", + patterns=["Process is not running"], + error=True) # check that this breakpoint is auto-cleared on detach (r204752) - self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here'))) + self.runCmd("br set -f main.cpp -l %u" % + (line_number('main.cpp', '// Set breakpoint here'))) self.runCmd("c") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning, lldb.eStateStopped]) self.expect('br list', 'Breakpoint not hit', - substrs = ['hit count = 1']) + substrs=['hit count = 1']) # Make sure the breakpoint is not hit again. - self.expect("expr debugger_flag = false", substrs=[" = false"]); + self.expect("expr debugger_flag = false", substrs=[" = false"]) self.runCmd("c") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) # make sure to detach while in running state (r204759) self.runCmd("detach") - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateDetached]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py b/lldb/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py index e31eac48ad7..867b6053a57 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py @@ -5,7 +5,6 @@ Test whether a process started by lldb has no extra file descriptors open. from __future__ import print_function - import os import lldb from lldbsuite.test import lldbutil @@ -28,55 +27,79 @@ class AvoidsFdLeakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") - @skipIfWindows # The check for descriptor leakage needs to be implemented differently here. - @skipIfTargetAndroid() # Android have some other file descriptors open by the shell - def test_fd_leak_basic (self): + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") + # The check for descriptor leakage needs to be implemented differently + # here. + @skipIfWindows + @skipIfTargetAndroid() # Android have some other file descriptors open by the shell + def test_fd_leak_basic(self): self.do_test([]) @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") - @skipIfWindows # The check for descriptor leakage needs to be implemented differently here. - @skipIfTargetAndroid() # Android have some other file descriptors open by the shell - def test_fd_leak_log (self): + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") + # The check for descriptor leakage needs to be implemented differently + # here. + @skipIfWindows + @skipIfTargetAndroid() # Android have some other file descriptors open by the shell + def test_fd_leak_log(self): self.do_test(["log enable -f '/dev/null' lldb commands"]) - def do_test (self, commands): + def do_test(self, commands): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") for c in commands: self.runCmd(c) target = self.dbg.CreateTarget(exe) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - self.assertTrue(process.GetState() == lldb.eStateExited, "Process should have exited.") - self.assertTrue(process.GetExitStatus() == 0, - "Process returned non-zero status. Were incorrect file descriptors passed?") + self.assertTrue( + process.GetState() == lldb.eStateExited, + "Process should have exited.") + self.assertTrue( + process.GetExitStatus() == 0, + "Process returned non-zero status. Were incorrect file descriptors passed?") @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") - @skipIfWindows # The check for descriptor leakage needs to be implemented differently here. - @skipIfTargetAndroid() # Android have some other file descriptors open by the shell - def test_fd_leak_multitarget (self): + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr25624 still failing with Python 2.7.10") + # The check for descriptor leakage needs to be implemented differently + # here. + @skipIfWindows + @skipIfTargetAndroid() # Android have some other file descriptors open by the shell + def test_fd_leak_multitarget(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - breakpoint = target.BreakpointCreateBySourceRegex ('Set breakpoint here', lldb.SBFileSpec ("main.c", False)) + breakpoint = target.BreakpointCreateBySourceRegex( + 'Set breakpoint here', lldb.SBFileSpec("main.c", False)) self.assertTrue(breakpoint, VALID_BREAKPOINT) - process1 = target.LaunchSimple (None, None, self.get_process_working_directory()) + process1 = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process1, PROCESS_IS_VALID) - self.assertTrue(process1.GetState() == lldb.eStateStopped, "Process should have been stopped.") + self.assertTrue( + process1.GetState() == lldb.eStateStopped, + "Process should have been stopped.") target2 = self.dbg.CreateTarget(exe) - process2 = target2.LaunchSimple (None, None, self.get_process_working_directory()) + process2 = target2.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process2, PROCESS_IS_VALID) - self.assertTrue(process2.GetState() == lldb.eStateExited, "Process should have exited.") - self.assertTrue(process2.GetExitStatus() == 0, - "Process returned non-zero status. Were incorrect file descriptors passed?") + self.assertTrue( + process2.GetState() == lldb.eStateExited, + "Process should have exited.") + self.assertTrue( + process2.GetExitStatus() == 0, + "Process returned non-zero status. Were incorrect file descriptors passed?") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py b/lldb/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py index 851e4d376b3..528e52565b5 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py @@ -5,13 +5,14 @@ Test that backticks without a target should work (not infinite looping). 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 BackticksWithNoTargetTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,4 +21,4 @@ class BackticksWithNoTargetTestCase(TestBase): def test_backticks_no_target(self): """A simple test of backticks without a target.""" self.expect("print `1+2-3`", - substrs = [' = 0']) + substrs=[' = 0']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py index 9442a076e2a..a48d5645e5f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py @@ -5,18 +5,19 @@ Test address breakpoints set with shared library of SBAddress work correctly. from __future__ import print_function - -import os, time +import os +import time import re import lldb import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test.lldbtest import * + class AddressBreakpointTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test_address_breakpoints (self): + def test_address_breakpoints(self): """Test address breakpoints set with shared library of SBAddress work correctly.""" self.build() self.address_breakpoints() @@ -34,7 +35,8 @@ class AddressBreakpointTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c")) + breakpoint = target.BreakpointCreateBySourceRegex( + "Set a breakpoint here", lldb.SBFileSpec("main.c")) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -48,7 +50,7 @@ class AddressBreakpointTestCase(TestBase): # Next get the address from the location, and create an address breakpoint using # that address: - + address = location.GetAddress() target.BreakpointDelete(breakpoint.GetID()) @@ -61,16 +63,18 @@ class AddressBreakpointTestCase(TestBase): flags = launch_info.GetLaunchFlags() flags &= ~lldb.eLaunchFlagDisableASLR launch_info.SetLaunchFlags(flags) - + error = lldb.SBError() - process = target.Launch (launch_info, error) + process = target.Launch(launch_info, error) self.assertTrue(process, PROCESS_IS_VALID) # Did we hit our breakpoint? - from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint - threads = get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint") + from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint + threads = get_threads_stopped_at_breakpoint(process, breakpoint) + self.assertTrue( + len(threads) == 1, + "There should be a thread stopped at our breakpoint") # The hit count for the breakpoint should be 1. self.assertTrue(breakpoint.GetHitCount() == 1) @@ -82,10 +86,12 @@ class AddressBreakpointTestCase(TestBase): launch_info.SetLaunchFlags(flags) process = target.Launch(launch_info, error) - self.assertTrue (process, PROCESS_IS_VALID) + self.assertTrue(process, PROCESS_IS_VALID) - thread = get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint") + thread = get_threads_stopped_at_breakpoint(process, breakpoint) + self.assertTrue( + len(threads) == 1, + "There should be a thread stopped at our breakpoint") # The hit count for the breakpoint should now be 2. self.assertTrue(breakpoint.GetHitCount() == 2) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py index 73b3ef5eae2..7876e3b3d90 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py @@ -5,18 +5,19 @@ Test that breakpoints set on a bad address say they are bad. from __future__ import print_function - -import os, time +import os +import time import re import lldb import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test.lldbtest import * + class BadAddressBreakpointTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test_bad_address_breakpoints (self): + def test_bad_address_breakpoints(self): """Test that breakpoints set on a bad address say they are bad.""" self.build() self.address_breakpoints() @@ -34,7 +35,8 @@ class BadAddressBreakpointTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c")) + breakpoint = target.BreakpointCreateBySourceRegex( + "Set a breakpoint here", lldb.SBFileSpec("main.c")) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -47,16 +49,18 @@ class BadAddressBreakpointTestCase(TestBase): VALID_BREAKPOINT_LOCATION) launch_info = lldb.SBLaunchInfo(None) - + error = lldb.SBError() - process = target.Launch (launch_info, error) + process = target.Launch(launch_info, error) self.assertTrue(process, PROCESS_IS_VALID) # Did we hit our breakpoint? - from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint - threads = get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint") + from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint + threads = get_threads_stopped_at_breakpoint(process, breakpoint) + self.assertTrue( + len(threads) == 1, + "There should be a thread stopped at our breakpoint") # The hit count for the breakpoint should be 1. self.assertTrue(breakpoint.GetHitCount() == 1) @@ -72,6 +76,5 @@ class BadAddressBreakpointTestCase(TestBase): for bp_loc in bkpt: self.assertTrue(bp_loc.IsResolved() == False) else: - self.fail("Could not find an illegal address at which to set a bad breakpoint.") - - + self.fail( + "Could not find an illegal address at which to set a bad breakpoint.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py index aa4ee14ffc5..bd5ae0e541d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py @@ -9,6 +9,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * from lldbsuite.test import lldbplatform, lldbplatformutil + class BreakpointCaseSensitivityTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) BREAKPOINT_TEXT = 'Set a breakpoint here' @@ -24,8 +25,9 @@ class BreakpointCaseSensitivityTestCase(TestBase): self.build() self.case_sensitivity_breakpoint(True) - @skipIf(oslist=['windows']) # Skip for windows platforms - @expectedFailureAll() # Failing for unknown reason on non-Windows platforms. + @skipIf(oslist=['windows']) # Skip for windows platforms + # Failing for unknown reason on non-Windows platforms. + @expectedFailureAll() def test_breakpoint_doesnt_match_file_with_different_case(self): """Set breakpoint on file, shouldn't match files with different case on POSIX systems""" self.build() @@ -33,19 +35,19 @@ class BreakpointCaseSensitivityTestCase(TestBase): def case_sensitivity_breakpoint(self, case_insensitive): """Set breakpoint on file, should match files with different case if case_insensitive is True""" - + # use different case to check CreateTarget exe = 'a.out' if case_insensitive: exe = exe.upper() - + exe = os.path.join(os.getcwd(), exe) # Create a target by the debugger. self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - cwd = self.get_process_working_directory(); - + cwd = self.get_process_working_directory() + # try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex for regex in [False, True]: # should always hit @@ -68,47 +70,54 @@ class BreakpointCaseSensitivityTestCase(TestBase): def check_breakpoint(self, file, source_regex, should_hit): """ Check breakpoint hit at given file set by given method - + file: File where insert the breakpoint - + source_regex: True for testing using BreakpointCreateBySourceRegex, False for BreakpointCreateByLocation - + should_hit: True if the breakpoint should hit, False otherwise """ - - desc = ' file %s set by %s' % (file, 'regex' if source_regex else 'location') + + desc = ' file %s set by %s' % ( + file, 'regex' if source_regex else 'location') if source_regex: - breakpoint = self.target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT, - lldb.SBFileSpec(file)) - else: - breakpoint = self.target.BreakpointCreateByLocation(file, self.line) - + breakpoint = self.target.BreakpointCreateBySourceRegex( + self.BREAKPOINT_TEXT, lldb.SBFileSpec(file)) + else: + breakpoint = self.target.BreakpointCreateByLocation( + file, self.line) + self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1, - should_hit, - VALID_BREAKPOINT + desc) + should_hit, + VALID_BREAKPOINT + desc) # Get the breakpoint location from breakpoint after we verified that, # indeed, it has one location. location = breakpoint.GetLocationAtIndex(0) self.assertEqual(location and location.IsEnabled(), - should_hit, - VALID_BREAKPOINT_LOCATION + desc) - - process = self.target.LaunchSimple(None, None, self.get_process_working_directory()) + should_hit, + VALID_BREAKPOINT_LOCATION + desc) + + process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID + desc) if should_hit: # Did we hit our breakpoint? - from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint - threads = get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint" + desc) + from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint + threads = get_threads_stopped_at_breakpoint(process, breakpoint) + self.assertEqual( + len(threads), + 1, + "There should be a thread stopped at breakpoint" + + desc) # The hit count for the breakpoint should be 1. self.assertEqual(breakpoint.GetHitCount(), 1) - + else: # check the breakpoint was not hit self.assertEqual(lldb.eStateExited, process.GetState()) @@ -116,6 +125,6 @@ class BreakpointCaseSensitivityTestCase(TestBase): # let process finish process.Continue() - + # cleanup self.target.BreakpointDelete(breakpoint.GetID()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 78d14b7d770..bfc1cdf3a79 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -5,13 +5,14 @@ Test lldb breakpoint command add/list/delete. 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 BreakpointCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +28,7 @@ class BreakpointCommandTestCase(TestBase): """Test a sequence of breakpoint command add, list, and delete.""" self.build() self.breakpoint_command_sequence() - self.breakpoint_command_script_parameters () + self.breakpoint_command_script_parameters() def setUp(self): # Call super's setUp(). @@ -36,7 +37,8 @@ class BreakpointCommandTestCase(TestBase): self.line = line_number('main.c', '// Set break point at this line.') # disable "There is a running process, kill it and restart?" prompt self.runCmd("settings set auto-confirm true") - self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm")) + self.addTearDownHook( + lambda: self.runCmd("settings clear auto-confirm")) def breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" @@ -45,45 +47,64 @@ class BreakpointCommandTestCase(TestBase): # Add three breakpoints on the same line. The first time we don't specify the file, # since the default file is the one containing main: - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1, loc_exact=True) - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) - # Breakpoint 4 - set at the same location as breakpoint 1 to test setting breakpoint commands on two breakpoints at a time - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + # Breakpoint 4 - set at the same location as breakpoint 1 to test + # setting breakpoint commands on two breakpoints at a time + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") - self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") - self.runCmd("breakpoint command add --python-function bktptcmd.function 3") + self.runCmd( + "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") + self.runCmd( + "breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") + self.runCmd( + "breakpoint command add --python-function bktptcmd.function 3") # Check that the breakpoint commands are correctly set. # The breakpoint list now only contains breakpoint 1. - self.expect("breakpoint list", "Breakpoints 1 & 2 created", - substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line], - patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % self.line] ) - - self.expect("breakpoint list -f", "Breakpoints 1 & 2 created", - substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line], - patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % self.line, - "1.1: .+at main.c:%d, .+unresolved, hit count = 0" % self.line, - "2.1: .+at main.c:%d, .+unresolved, hit count = 0" % self.line]) + self.expect( + "breakpoint list", "Breakpoints 1 & 2 created", substrs=[ + "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % + self.line], patterns=[ + "1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % + self.line]) + + self.expect( + "breakpoint list -f", + "Breakpoints 1 & 2 created", + substrs=[ + "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % + self.line], + patterns=[ + "1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % + self.line, + "1.1: .+at main.c:%d, .+unresolved, hit count = 0" % + self.line, + "2.1: .+at main.c:%d, .+unresolved, hit count = 0" % + self.line]) self.expect("breakpoint command list 1", "Breakpoint 1 command ok", - substrs = ["Breakpoint commands:", - "frame variable --show-types --scope"]) + substrs=["Breakpoint commands:", + "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", - substrs = ["Breakpoint commands:", - "here = open", - "here.write", - "here.close()"]) + substrs=["Breakpoint commands:", + "here = open", + "here.write", + "here.close()"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", - substrs = ["Breakpoint commands:", - "bktptcmd.function(frame, bp_loc, internal_dict)"]) + substrs=["Breakpoint commands:", + "bktptcmd.function(frame, bp_loc, internal_dict)"]) self.expect("breakpoint command list 4", "Breakpoint 4 command ok", - substrs = ["Breakpoint commands:", - "frame variable --show-types --scope"]) + substrs=["Breakpoint commands:", + "frame variable --show-types --scope"]) self.runCmd("breakpoint delete 4") @@ -93,43 +114,68 @@ class BreakpointCommandTestCase(TestBase): # and then specify only one file. The first time we should get two locations, # the second time only one: - lldbutil.run_break_set_by_regexp (self, r"._MyFunction", num_expected_locations=2) - - lldbutil.run_break_set_by_regexp (self, r"._MyFunction", extra_options="-f a.c", num_expected_locations=1) - - lldbutil.run_break_set_by_regexp (self, r"._MyFunction", extra_options="-f a.c -f b.c", num_expected_locations=2) + lldbutil.run_break_set_by_regexp( + self, r"._MyFunction", num_expected_locations=2) + + lldbutil.run_break_set_by_regexp( + self, + r"._MyFunction", + extra_options="-f a.c", + num_expected_locations=1) + + lldbutil.run_break_set_by_regexp( + self, + r"._MyFunction", + extra_options="-f a.c -f b.c", + num_expected_locations=2) # Now try a source regex breakpoint: - lldbutil.run_break_set_by_source_regexp (self, r"is about to return [12]0", extra_options="-f a.c -f b.c", num_expected_locations=2) - - lldbutil.run_break_set_by_source_regexp (self, r"is about to return [12]0", extra_options="-f a.c", num_expected_locations=1) - + lldbutil.run_break_set_by_source_regexp( + self, + r"is about to return [12]0", + extra_options="-f a.c -f b.c", + num_expected_locations=2) + + lldbutil.run_break_set_by_source_regexp( + self, + r"is about to return [12]0", + extra_options="-f a.c", + num_expected_locations=1) + # Run the program. Remove 'output.txt' if it exists. self.RemoveTempFile("output.txt") self.RemoveTempFile("output2.txt") self.runCmd("run", RUN_SUCCEEDED) - # Check that the file 'output.txt' exists and contains the string "lldb". + # Check that the file 'output.txt' exists and contains the string + # "lldb". # The 'output.txt' file should now exist. - self.assertTrue(os.path.isfile("output.txt"), - "'output.txt' exists due to breakpoint command for breakpoint 2.") - self.assertTrue(os.path.isfile("output2.txt"), - "'output2.txt' exists due to breakpoint command for breakpoint 3.") + self.assertTrue( + os.path.isfile("output.txt"), + "'output.txt' exists due to breakpoint command for breakpoint 2.") + self.assertTrue( + os.path.isfile("output2.txt"), + "'output2.txt' exists due to breakpoint command for breakpoint 3.") # Read the output file produced by running the program. with open('output.txt', 'r') as f: output = f.read() - self.expect(output, "File 'output.txt' and the content matches", exe=False, - startstr = "lldb") + self.expect( + output, + "File 'output.txt' and the content matches", + exe=False, + startstr="lldb") with open('output2.txt', 'r') as f: output = f.read() - self.expect(output, "File 'output2.txt' and the content matches", exe=False, - startstr = "lldb") - + self.expect( + output, + "File 'output2.txt' and the content matches", + exe=False, + startstr="lldb") # Finish the program. self.runCmd("process continue") @@ -140,21 +186,31 @@ class BreakpointCommandTestCase(TestBase): # Remove breakpoint 2. self.runCmd("breakpoint delete 2") - self.expect("breakpoint command list 1", - startstr = "Breakpoint 1 does not have an associated command.") - self.expect("breakpoint command list 2", error=True, - startstr = "error: '2' is not a currently valid breakpoint ID.") + self.expect( + "breakpoint command list 1", + startstr="Breakpoint 1 does not have an associated command.") + self.expect( + "breakpoint command list 2", + error=True, + startstr="error: '2' is not a currently valid breakpoint ID.") # The breakpoint list now only contains breakpoint 1. - self.expect("breakpoint list -f", "Breakpoint 1 exists", - patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" % - self.line, - "hit count = 1"]) + self.expect( + "breakpoint list -f", + "Breakpoint 1 exists", + patterns=[ + "1: file = '.*main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" % + self.line, + "hit count = 1"]) # Not breakpoint 2. - self.expect("breakpoint list -f", "No more breakpoint 2", matching=False, - substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" % - self.line]) + self.expect( + "breakpoint list -f", + "No more breakpoint 2", + matching=False, + substrs=[ + "2: file = 'main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" % + self.line]) # Run the program again, with breakpoint 1 remaining. self.runCmd("run", RUN_SUCCEEDED) @@ -163,20 +219,21 @@ class BreakpointCommandTestCase(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 2. self.expect("breakpoint list -f", BREAKPOINT_HIT_TWICE, - substrs = ['resolved, hit count = 2']) + substrs=['resolved, hit count = 2']) - def breakpoint_command_script_parameters (self): + def breakpoint_command_script_parameters(self): """Test that the frame and breakpoint location are being properly passed to the script breakpoint command function.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); here.write(str(frame) + \"\\n\"); here.write(str(bp_loc) + \"\\n\"); here.close()' 1") @@ -184,24 +241,30 @@ class BreakpointCommandTestCase(TestBase): # Remove 'output-2.txt' if it already exists. if (os.path.exists('output-2.txt')): - os.remove ('output-2.txt') + os.remove('output-2.txt') - # Run program, hit breakpoint, and hopefully write out new version of 'output-2.txt' - self.runCmd ("run", RUN_SUCCEEDED) + # Run program, hit breakpoint, and hopefully write out new version of + # 'output-2.txt' + self.runCmd("run", RUN_SUCCEEDED) - # Check that the file 'output.txt' exists and contains the string "lldb". + # Check that the file 'output.txt' exists and contains the string + # "lldb". # The 'output-2.txt' file should now exist. - self.assertTrue(os.path.isfile("output-2.txt"), - "'output-2.txt' exists due to breakpoint command for breakpoint 1.") + self.assertTrue( + os.path.isfile("output-2.txt"), + "'output-2.txt' exists due to breakpoint command for breakpoint 1.") # Read the output file produced by running the program. with open('output-2.txt', 'r') as f: output = f.read() - self.expect (output, "File 'output-2.txt' and the content matches", exe=False, - startstr = "frame #0:", - patterns = ["1.* where = .*main .* resolved, hit count = 1" ]) + self.expect( + output, + "File 'output-2.txt' and the content matches", + exe=False, + startstr="frame #0:", + patterns=["1.* where = .*main .* resolved, hit count = 1"]) # Now remove 'output-2.txt' - os.remove ('output-2.txt') + os.remove('output-2.txt') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py index 4f8ab9e115d..01af8369aaf 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -5,7 +5,6 @@ Test that you can set breakpoint commands successfully with the Python API's: from __future__ import print_function - import os import re import sys @@ -14,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PythonBreakpointCommandSettingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,36 +23,42 @@ class PythonBreakpointCommandSettingTestCase(TestBase): def test_step_out_python(self): """Test stepping out using avoid-no-debug with dsyms.""" self.build() - self.do_set_python_command_from_python () + self.do_set_python_command_from_python() - def setUp (self): + def setUp(self): TestBase.setUp(self) self.main_source = "main.c" self.main_source_spec = lldb.SBFileSpec(self.main_source) - - def do_set_python_command_from_python (self): + def do_set_python_command_from_python(self): exe = os.path.join(os.getcwd(), "a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - body_bkpt = self.target.BreakpointCreateBySourceRegex("Set break point at this line.", self.main_source_spec) + body_bkpt = self.target.BreakpointCreateBySourceRegex( + "Set break point at this line.", self.main_source_spec) self.assertTrue(body_bkpt, VALID_BREAKPOINT) - func_bkpt = self.target.BreakpointCreateBySourceRegex("Set break point at this line.", self.main_source_spec) + func_bkpt = self.target.BreakpointCreateBySourceRegex( + "Set break point at this line.", self.main_source_spec) self.assertTrue(func_bkpt, VALID_BREAKPOINT) - # Also test that setting a source regex breakpoint with an empty file spec list sets it on all files: - no_files_bkpt = self.target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpecList(), lldb.SBFileSpecList()) + # Also test that setting a source regex breakpoint with an empty file + # spec list sets it on all files: + no_files_bkpt = self.target.BreakpointCreateBySourceRegex( + "Set a breakpoint here", lldb.SBFileSpecList(), lldb.SBFileSpecList()) self.assertTrue(no_files_bkpt, VALID_BREAKPOINT) num_locations = no_files_bkpt.GetNumLocations() - self.assertTrue(num_locations >= 2, "Got at least two breakpoint locations") + self.assertTrue( + num_locations >= 2, + "Got at least two breakpoint locations") got_one_in_A = False got_one_in_B = False for idx in range(0, num_locations): - comp_unit = no_files_bkpt.GetLocationAtIndex(idx).GetAddress().GetSymbolContext(lldb.eSymbolContextCompUnit).GetCompileUnit().GetFileSpec() + comp_unit = no_files_bkpt.GetLocationAtIndex(idx).GetAddress().GetSymbolContext( + lldb.eSymbolContextCompUnit).GetCompileUnit().GetFileSpec() print("Got comp unit: ", comp_unit.GetFilename()) if comp_unit.GetFilename() == "a.c": got_one_in_A = True @@ -69,28 +75,36 @@ class PythonBreakpointCommandSettingTestCase(TestBase): import TestBreakpointCommandsFromPython\n\ TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\ print('Hit breakpoint')") - self.assertTrue (error.Success(), "Failed to set the script callback body: %s."%(error.GetCString())) + self.assertTrue( + error.Success(), + "Failed to set the script callback body: %s." % + (error.GetCString())) - self.dbg.HandleCommand("command script import --allow-reload ./bktptcmd.py") + self.dbg.HandleCommand( + "command script import --allow-reload ./bktptcmd.py") func_bkpt.SetScriptCallbackFunction("bktptcmd.function") - # We will use the function that touches a text file, so remove it first: + # We will use the function that touches a text file, so remove it + # first: self.RemoveTempFile("output2.txt") # Now launch the process, and do not stop at entry point. - self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # Now finish, and make sure the return value is correct. - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, body_bkpt) + threads = lldbutil.get_threads_stopped_at_breakpoint( + self.process, body_bkpt) self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.") self.thread = threads[0] - + self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20) # Check for the function version as well, which produced this file: # Remember to clean up after ourselves... - self.assertTrue(os.path.isfile("output2.txt"), - "'output2.txt' exists due to breakpoint command for breakpoint function.") + self.assertTrue( + os.path.isfile("output2.txt"), + "'output2.txt' exists due to breakpoint command for breakpoint function.") self.RemoveTempFile("output2.txt") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py index 1ea71cbde45..baf237bf076 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py @@ -5,12 +5,13 @@ Test _regexp-break command which uses regular expression matching to dispatch to from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class RegexpBreakCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -25,27 +26,47 @@ class RegexpBreakCommandTestCase(TestBase): TestBase.setUp(self) # Find the line number to break inside main(). self.source = 'main.c' - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') def regexp_break_command(self): """Test the super consie "b" command, which is analias for _regexp-break.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - break_results = lldbutil.run_break_set_command (self, "b %d" % self.line) - lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "b %d" % + self.line) + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + line_number=self.line, + num_locations=1) - break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line)) - lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "b %s:%d" % (self.source, self.line)) + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + line_number=self.line, + num_locations=1) # Check breakpoint with full file path. full_path = os.path.join(os.getcwd(), self.source) - break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line)) - lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "b %s:%d" % (full_path, self.line)) + lldbutil.check_breakpoint_result( + self, + break_results, + file_name='main.c', + line_number=self.line, + num_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']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py index 4bbb0327eac..cf1fc2cf02c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -1,6 +1,7 @@ from __future__ import print_function + def function(frame, bp_loc, dict): - there = open("output2.txt", "w"); - print("lldb", file=there) - there.close() + there = open("output2.txt", "w") + print("lldb", file=there) + there.close() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py index 8d2732fd3c2..3fd9b13c711 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py @@ -5,38 +5,43 @@ Test breakpoint conditions with 'breakpoint modify -c <expr> id'. 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 BreakpointConditionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + @skipIfWindows def test_breakpoint_condition_and_run_command(self): """Exercise breakpoint condition with 'breakpoint modify -c <expr> id'.""" self.build() self.breakpoint_conditions() - @skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + @skipIfWindows def test_breakpoint_condition_inline_and_run_command(self): """Exercise breakpoint condition inline with 'breakpoint set'.""" self.build() self.breakpoint_conditions(inline=True) - @skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + @skipIfWindows @add_test_categories(['pyapi']) def test_breakpoint_condition_and_python_api(self): """Use Python APIs to set breakpoint conditions.""" self.build() self.breakpoint_conditions_python() - @skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + # Requires EE to support COFF on Windows (http://llvm.org/pr22232) + @skipIfWindows @add_test_categories(['pyapi']) def test_breakpoint_invalid_condition_and_python_api(self): """Use Python APIs to set breakpoint conditions.""" @@ -47,8 +52,10 @@ class BreakpointConditionsTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. - self.line1 = line_number('main.c', '// Find the line number of function "c" here.') - self.line2 = line_number('main.c', "// Find the line number of c's parent call here.") + self.line1 = line_number( + 'main.c', '// Find the line number of function "c" here.') + self.line2 = line_number( + 'main.c', "// Find the line number of c's parent call here.") def breakpoint_conditions(self, inline=False): """Exercise breakpoint condition with 'breakpoint modify -c <expr> id'.""" @@ -57,10 +64,16 @@ class BreakpointConditionsTestCase(TestBase): if inline: # Create a breakpoint by function name 'c' and set the condition. - lldbutil.run_break_set_by_symbol (self, "c", extra_options="-c 'val == 3'", num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + "c", + extra_options="-c 'val == 3'", + num_expected_locations=1, + sym_exact=True) else: # Create a breakpoint by function name 'c'. - lldbutil.run_break_set_by_symbol (self, "c", num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, "c", num_expected_locations=1, sym_exact=True) # And set a condition on the breakpoint to stop on when 'val == 3'. self.runCmd("breakpoint modify -c 'val == 3' 1") @@ -70,42 +83,50 @@ class BreakpointConditionsTestCase(TestBase): # The process should be stopped at this point. self.expect("process status", PROCESS_STOPPED, - patterns = ['Process .* stopped']) + patterns=['Process .* stopped']) # 'frame variable --show-types val' should return 3 due to breakpoint condition. - self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) val = 3') + self.expect( + "frame variable --show-types val", + VARIABLES_DISPLAYED_CORRECTLY, + startstr='(int) val = 3') # Also check the hit count, which should be 3, by design. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = ["resolved = 1", - "Condition: val == 3", - "hit count = 1"]) + substrs=["resolved = 1", + "Condition: val == 3", + "hit count = 1"]) # The frame #0 should correspond to main.c:36, the executable statement - # in function name 'c'. And the parent frame should point to main.c:24. + # in function name 'c'. And the parent frame should point to + # main.c:24. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_CONDITION, - #substrs = ["stop reason = breakpoint"], - patterns = ["frame #0.*main.c:%d" % self.line1, - "frame #1.*main.c:%d" % self.line2]) + #substrs = ["stop reason = breakpoint"], + patterns=["frame #0.*main.c:%d" % self.line1, + "frame #1.*main.c:%d" % self.line2]) # Test that "breakpoint modify -c ''" clears the condition for the last # created breakpoint, so that when the breakpoint hits, val == 1. self.runCmd("process kill") self.runCmd("breakpoint modify -c ''") - self.expect("breakpoint list -f", BREAKPOINT_STATE_CORRECT, matching=False, - substrs = ["Condition:"]) + self.expect( + "breakpoint list -f", + BREAKPOINT_STATE_CORRECT, + matching=False, + substrs=["Condition:"]) # Now run the program again. self.runCmd("run", RUN_SUCCEEDED) # The process should be stopped at this point. self.expect("process status", PROCESS_STOPPED, - patterns = ['Process .* stopped']) + patterns=['Process .* stopped']) # 'frame variable --show-types val' should return 1 since it is the first breakpoint hit. - self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) val = 1') + self.expect( + "frame variable --show-types val", + VARIABLES_DISPLAYED_CORRECTLY, + startstr='(int) val = 1') self.runCmd("process kill") @@ -124,7 +145,8 @@ class BreakpointConditionsTestCase(TestBase): breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) - # We didn't associate a thread index with the breakpoint, so it should be invalid. + # We didn't associate a thread index with the breakpoint, so it should + # be invalid. self.assertTrue(breakpoint.GetThreadIndex() == lldb.UINT32_MAX, "The thread index should be invalid") # The thread name should be invalid, too. @@ -133,7 +155,8 @@ class BreakpointConditionsTestCase(TestBase): # Let's set the thread index for this breakpoint and verify that it is, # indeed, being set correctly. - breakpoint.SetThreadIndex(1) # There's only one thread for the process. + # There's only one thread for the process. + breakpoint.SetThreadIndex(1) self.assertTrue(breakpoint.GetThreadIndex() == 1, "The thread index has been set correctly") @@ -147,16 +170,19 @@ class BreakpointConditionsTestCase(TestBase): # Set the condition on the breakpoint location. location.SetCondition('val == 3') self.expect(location.GetCondition(), exe=False, - startstr = 'val == 3') + startstr='val == 3') # 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()) self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. from lldbsuite.test.lldbutil import get_stopped_thread thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and @@ -168,7 +194,8 @@ class BreakpointConditionsTestCase(TestBase): # Test that the condition expression didn't create a result variable: options = lldb.SBExpressionOptions() value = frame0.EvaluateExpression("$0", options) - self.assertTrue(value.GetError().Fail(), "Conditions should not make result variables.") + self.assertTrue(value.GetError().Fail(), + "Conditions should not make result variables.") process.Continue() def breakpoint_invalid_conditions_python(self): @@ -189,21 +216,22 @@ class BreakpointConditionsTestCase(TestBase): # Set the condition on the breakpoint. breakpoint.SetCondition('no_such_variable == not_this_one_either') self.expect(breakpoint.GetCondition(), exe=False, - startstr = 'no_such_variable == not_this_one_either') + startstr='no_such_variable == not_this_one_either') # 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()) self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. from lldbsuite.test.lldbutil import get_stopped_thread thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1) # The hit count for the breakpoint should be 1. self.assertTrue(breakpoint.GetHitCount() == 1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py index b7edf2a6e4d..621bd4a55f0 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py @@ -5,47 +5,56 @@ Test lldb breakpoint ids. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class BreakpointIDTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): + def test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out" ]) - - - bpno = lldbutil.run_break_set_by_symbol (self, 'product', num_expected_locations=-1, sym_exact=False) - self.assertTrue (bpno == 1, "First breakpoint number is 1.") - - bpno = lldbutil.run_break_set_by_symbol (self, 'sum', num_expected_locations=-1, sym_exact=False) - self.assertTrue (bpno == 2, "Second breakpoint number is 2.") - - bpno = lldbutil.run_break_set_by_symbol (self, 'junk', num_expected_locations=0, sym_exact=False) - self.assertTrue (bpno == 3, "Third breakpoint number is 3.") - - self.expect ("breakpoint disable 1.1 - 2.2 ", - COMMAND_FAILED_AS_EXPECTED, error = True, - startstr = "error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.") - - self.expect ("breakpoint disable 2 - 2.2", - COMMAND_FAILED_AS_EXPECTED, error = True, - startstr = "error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.") - - self.expect ("breakpoint disable 2.1 - 2", - COMMAND_FAILED_AS_EXPECTED, error = True, - startstr = "error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.") - - self.expect ("breakpoint disable 2.1 - 2.2", - startstr = "2 breakpoints disabled.") - - self.expect ("breakpoint enable 2.*", - patterns = [ ".* breakpoints enabled."] ) + patterns=["Current executable set to .*a.out"]) + + bpno = lldbutil.run_break_set_by_symbol( + self, 'product', num_expected_locations=-1, sym_exact=False) + self.assertTrue(bpno == 1, "First breakpoint number is 1.") + + bpno = lldbutil.run_break_set_by_symbol( + self, 'sum', num_expected_locations=-1, sym_exact=False) + self.assertTrue(bpno == 2, "Second breakpoint number is 2.") + + bpno = lldbutil.run_break_set_by_symbol( + self, 'junk', num_expected_locations=0, sym_exact=False) + self.assertTrue(bpno == 3, "Third breakpoint number is 3.") + + self.expect( + "breakpoint disable 1.1 - 2.2 ", + COMMAND_FAILED_AS_EXPECTED, + error=True, + startstr="error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.") + + self.expect( + "breakpoint disable 2 - 2.2", + COMMAND_FAILED_AS_EXPECTED, + error=True, + startstr="error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.") + + self.expect( + "breakpoint disable 2.1 - 2", + COMMAND_FAILED_AS_EXPECTED, + error=True, + startstr="error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.") + + self.expect("breakpoint disable 2.1 - 2.2", + startstr="2 breakpoints disabled.") + + self.expect("breakpoint enable 2.*", + patterns=[".* breakpoints enabled."]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py index 05ef1c6d94c..09e20bc5ac3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py @@ -5,14 +5,15 @@ Test breakpoint ignore count features. 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 BreakpointIgnoreCountTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,11 +33,16 @@ class BreakpointIgnoreCountTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. - self.line1 = line_number('main.c', '// Find the line number of function "c" here.') - self.line2 = line_number('main.c', '// b(2) -> c(2) Find the call site of b(2).') - self.line3 = line_number('main.c', '// a(3) -> c(3) Find the call site of c(3).') - self.line4 = line_number('main.c', '// a(3) -> c(3) Find the call site of a(3).') - self.line5 = line_number('main.c', '// Find the call site of c in main.') + self.line1 = line_number( + 'main.c', '// Find the line number of function "c" here.') + self.line2 = line_number( + 'main.c', '// b(2) -> c(2) Find the call site of b(2).') + self.line3 = line_number( + 'main.c', '// a(3) -> c(3) Find the call site of c(3).') + self.line4 = line_number( + 'main.c', '// a(3) -> c(3) Find the call site of a(3).') + self.line5 = line_number( + 'main.c', '// Find the call site of c in main.') def breakpoint_ignore_count(self): """Exercise breakpoint ignore count with 'breakpoint set -i <count>'.""" @@ -44,26 +50,33 @@ class BreakpointIgnoreCountTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Create a breakpoint in main.c at line1. - lldbutil.run_break_set_by_file_and_line (self, 'main.c', self.line1, extra_options='-i 1', num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + 'main.c', + self.line1, + extra_options='-i 1', + num_expected_locations=1, + loc_exact=True) # Now run the program. self.runCmd("run", RUN_SUCCEEDED) # The process should be stopped at this point. self.expect("process status", PROCESS_STOPPED, - patterns = ['Process .* stopped']) + patterns=['Process .* stopped']) - # Also check the hit count, which should be 2, due to ignore count of 1. + # Also check the hit count, which should be 2, due to ignore count of + # 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_THRICE, - substrs = ["resolved = 1", - "hit count = 2"]) + substrs=["resolved = 1", + "hit count = 2"]) # The frame #0 should correspond to main.c:37, the executable statement # in function name 'c'. And frame #2 should point to main.c:45. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT, - #substrs = ["stop reason = breakpoint"], - patterns = ["frame #0.*main.c:%d" % self.line1, - "frame #2.*main.c:%d" % self.line2]) + #substrs = ["stop reason = breakpoint"], + patterns=["frame #0.*main.c:%d" % self.line1, + "frame #2.*main.c:%d" % self.line2]) # continue -i 1 is the same as setting the ignore count to 1 again, try that: # Now run the program. @@ -71,21 +84,20 @@ class BreakpointIgnoreCountTestCase(TestBase): # The process should be stopped at this point. self.expect("process status", PROCESS_STOPPED, - patterns = ['Process .* stopped']) + patterns=['Process .* stopped']) - # Also check the hit count, which should be 2, due to ignore count of 1. + # Also check the hit count, which should be 2, due to ignore count of + # 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_THRICE, - substrs = ["resolved = 1", - "hit count = 4"]) + substrs=["resolved = 1", + "hit count = 4"]) # The frame #0 should correspond to main.c:37, the executable statement # in function name 'c'. And frame #2 should point to main.c:45. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT, - #substrs = ["stop reason = breakpoint"], - patterns = ["frame #0.*main.c:%d" % self.line1, - "frame #1.*main.c:%d" % self.line5]) - - + #substrs = ["stop reason = breakpoint"], + patterns=["frame #0.*main.c:%d" % self.line1, + "frame #1.*main.c:%d" % self.line5]) def breakpoint_ignore_count_python(self): """Use Python APIs to set breakpoint ignore count.""" @@ -114,15 +126,18 @@ class BreakpointIgnoreCountTestCase(TestBase): "SetIgnoreCount() works correctly") # 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()) self.assertTrue(process, PROCESS_IS_VALID) # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # frame#2 should be on main.c:48. - #lldbutil.print_stacktraces(process) + # lldbutil.print_stacktraces(process) from lldbsuite.test.lldbutil import get_stopped_thread thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint") + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint") frame0 = thread.GetFrameAtIndex(0) frame1 = thread.GetFrameAtIndex(1) frame2 = thread.GetFrameAtIndex(2) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py index b1e0d3deeae..255b6f7fa29 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py @@ -1,10 +1,11 @@ """ -Test specific to MIPS +Test specific to MIPS """ from __future__ import print_function -import os, time +import os +import time import re import unittest2 import lldb @@ -12,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class AvoidBreakpointInDelaySlotAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,8 +23,8 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): self.build() exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out.*" ]) - + patterns=["Current executable set to .*a.out.*"]) + # Create a target by the debugger. target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -33,7 +35,8 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): VALID_BREAKPOINT) # 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()) self.assertTrue(process, PROCESS_IS_VALID) list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto) @@ -44,7 +47,7 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): self.assertTrue(function) self.function(function, target) - def function (self, function, target): + def function(self, function, target): """Iterate over instructions in function and place a breakpoint on delay slot instruction""" # Get the list of all instructions in the function insts = function.GetInstructions(target) @@ -56,7 +59,7 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): branchinstaddress = inst.GetAddress().GetLoadAddress(target) # Get next instruction i.e delay slot instruction. - delayinst = insts.GetInstructionAtIndex(i+1) + delayinst = insts.GetInstructionAtIndex(i + 1) delayinstaddr = delayinst.GetAddress().GetLoadAddress(target) # Set breakpoint on delay slot instruction @@ -71,9 +74,10 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): # Get the address where breakpoint is actually set. bpaddr = location.GetLoadAddress() - - # Breakpoint address should be adjusted to the address of branch instruction. - self.assertTrue(branchinstaddress == bpaddr) + + # Breakpoint address should be adjusted to the address of + # branch instruction. + self.assertTrue(branchinstaddress == bpaddr) i += 1 else: i += 1 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py index 94fc7bf79f6..214c110afcd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py @@ -6,14 +6,15 @@ parser. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil import shutil import subprocess + class TestBreakpointLanguage(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,7 +24,7 @@ class TestBreakpointLanguage(TestBase): TestBase.setUp(self) # Find the line number to break inside main(). - def check_location_file (self, bp, loc, test_name): + def check_location_file(self, bp, loc, test_name): bp_loc = bp.GetLocationAtIndex(loc) addr = bp_loc.GetAddress() comp_unit = addr.GetCompileUnit() @@ -37,22 +38,40 @@ class TestBreakpointLanguage(TestBase): # Create a target by the debugger. exe = os.path.join(os.getcwd(), "a.out") error = lldb.SBError() - # Don't read in dependencies so we don't come across false matches that + # Don't read in dependencies so we don't come across false matches that # add unwanted breakpoint hits. self.target = self.dbg.CreateTarget(exe, None, None, False, error) self.assertTrue(self.target, VALID_TARGET) - cpp_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches") + cpp_bp = self.target.BreakpointCreateByRegex( + "func_from", + lldb.eLanguageTypeC_plus_plus, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + cpp_bp.GetNumLocations() == 1, + "Only one C++ symbol matches") self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp")) - c_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches") + c_bp = self.target.BreakpointCreateByRegex( + "func_from", + lldb.eLanguageTypeC, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + c_bp.GetNumLocations() == 1, + "Only one C symbol matches") self.assertTrue(self.check_location_file(c_bp, 0, "a.c")) - - objc_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches") - + + objc_bp = self.target.BreakpointCreateByRegex( + "func_from", + lldb.eLanguageTypeObjC, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + objc_bp.GetNumLocations() == 0, + "No ObjC symbol matches") + def test_by_name_breakpoint_language(self): """Test that the name regex breakpoint commands obey the language filter.""" @@ -60,26 +79,59 @@ class TestBreakpointLanguage(TestBase): # Create a target by the debugger. exe = os.path.join(os.getcwd(), "a.out") error = lldb.SBError() - # Don't read in dependencies so we don't come across false matches that + # Don't read in dependencies so we don't come across false matches that # add unwanted breakpoint hits. self.target = self.dbg.CreateTarget(exe, None, None, False, error) self.assertTrue(self.target, VALID_TARGET) - cpp_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches") + cpp_bp = self.target.BreakpointCreateByName( + "func_from_cpp", + lldb.eFunctionNameTypeAuto, + lldb.eLanguageTypeC_plus_plus, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + cpp_bp.GetNumLocations() == 1, + "Only one C++ symbol matches") self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp")) - no_cpp_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(no_cpp_bp.GetNumLocations() == 0, "And the C one doesn't match") - - c_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches") + no_cpp_bp = self.target.BreakpointCreateByName( + "func_from_c", + lldb.eFunctionNameTypeAuto, + lldb.eLanguageTypeC_plus_plus, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + no_cpp_bp.GetNumLocations() == 0, + "And the C one doesn't match") + + c_bp = self.target.BreakpointCreateByName( + "func_from_c", + lldb.eFunctionNameTypeAuto, + lldb.eLanguageTypeC, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + c_bp.GetNumLocations() == 1, + "Only one C symbol matches") self.assertTrue(self.check_location_file(c_bp, 0, "a.c")) - - no_c_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(no_c_bp.GetNumLocations() == 0, "And the C++ one doesn't match") - - objc_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches") - + no_c_bp = self.target.BreakpointCreateByName( + "func_from_cpp", + lldb.eFunctionNameTypeAuto, + lldb.eLanguageTypeC, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + no_c_bp.GetNumLocations() == 0, + "And the C++ one doesn't match") + + objc_bp = self.target.BreakpointCreateByName( + "func_from_cpp", + lldb.eFunctionNameTypeAuto, + lldb.eLanguageTypeObjC, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + objc_bp.GetNumLocations() == 0, + "No ObjC symbol matches") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py index 707b6502e91..fdbd622f767 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py @@ -5,13 +5,14 @@ Test breakpoint commands for a breakpoint ID with multiple locations. 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 BreakpointLocationsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -34,55 +35,72 @@ class BreakpointLocationsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 3 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=3) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=3) # The breakpoint list should show 3 locations. - self.expect("breakpoint list -f", "Breakpoint locations shown correctly", - substrs = ["1: file = 'main.c', line = %d, exact_match = 0, locations = 3" % self.line], - patterns = ["where = a.out`func_inlined .+unresolved, hit count = 0", - "where = a.out`main .+\[inlined\].+unresolved, hit count = 0"]) + self.expect( + "breakpoint list -f", + "Breakpoint locations shown correctly", + substrs=[ + "1: file = 'main.c', line = %d, exact_match = 0, locations = 3" % + self.line], + patterns=[ + "where = a.out`func_inlined .+unresolved, hit count = 0", + "where = a.out`main .+\[inlined\].+unresolved, hit count = 0"]) # The 'breakpoint disable 3.*' command should fail gracefully. self.expect("breakpoint disable 3.*", "Disabling an invalid breakpoint should fail gracefully", error=True, - startstr = "error: '3' is not a valid breakpoint ID.") + startstr="error: '3' is not a valid breakpoint ID.") # The 'breakpoint disable 1.*' command should disable all 3 locations. - self.expect("breakpoint disable 1.*", "All 3 breakpoint locatons disabled correctly", - startstr = "3 breakpoints disabled.") + self.expect( + "breakpoint disable 1.*", + "All 3 breakpoint locatons disabled correctly", + startstr="3 breakpoints disabled.") # Run the program. self.runCmd("run", RUN_SUCCEEDED) # We should not stopped on any breakpoint at all. self.expect("process status", "No stopping on any disabled breakpoint", - patterns = ["^Process [0-9]+ exited with status = 0"]) + patterns=["^Process [0-9]+ exited with status = 0"]) # The 'breakpoint enable 1.*' command should enable all 3 breakpoints. - self.expect("breakpoint enable 1.*", "All 3 breakpoint locatons enabled correctly", - startstr = "3 breakpoints enabled.") + self.expect( + "breakpoint enable 1.*", + "All 3 breakpoint locatons enabled correctly", + startstr="3 breakpoints enabled.") # The 'breakpoint disable 1.1' command should disable 1 location. - self.expect("breakpoint disable 1.1", "1 breakpoint locatons disabled correctly", - startstr = "1 breakpoints disabled.") + self.expect( + "breakpoint disable 1.1", + "1 breakpoint locatons disabled correctly", + startstr="1 breakpoints disabled.") - # Run the program againt. We should stop on the two breakpoint locations. + # Run the program againt. We should stop on the two breakpoint + # locations. self.runCmd("run", RUN_SUCCEEDED) # Stopped once. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Continue the program, there should be another stop. self.runCmd("process continue") # Stopped again. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) - - # At this point, 1.1 has a hit count of 0 and the other a hit count of 1". - self.expect("breakpoint list -f", "The breakpoints should report correct hit counts", - patterns = ["1\.1: .+ unresolved, hit count = 0 +Options: disabled", - "1\.2: .+ resolved, hit count = 1", - "1\.3: .+ resolved, hit count = 1"]) + substrs=["stop reason = breakpoint 1."]) + + # At this point, 1.1 has a hit count of 0 and the other a hit count of + # 1". + self.expect( + "breakpoint list -f", + "The breakpoints should report correct hit counts", + patterns=[ + "1\.1: .+ unresolved, hit count = 0 +Options: disabled", + "1\.2: .+ resolved, hit count = 1", + "1\.3: .+ resolved, hit count = 1"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py index 29afec20233..c0c2267a836 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -5,12 +5,12 @@ Test breakpoint command for different options. from __future__ import print_function - import os import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class BreakpointOptionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,38 +32,59 @@ class BreakpointOptionsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 1", num_expected_locations = 1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 0", num_expected_locations = 1) + lldbutil.run_break_set_by_file_and_line( + self, + "main.cpp", + self.line, + extra_options="-K 1", + num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, + "main.cpp", + self.line, + extra_options="-K 0", + num_expected_locations=1) # This should create a breakpoint 0 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-m 0", num_expected_locations = 0) + lldbutil.run_break_set_by_file_and_line( + self, + "main.cpp", + self.line, + extra_options="-m 0", + num_expected_locations=0) # Run the program. self.runCmd("run", RUN_SUCCEEDED) # Stopped once. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 2."]) + substrs=["stop reason = breakpoint 2."]) # Check the list of breakpoint. - self.expect("breakpoint list -f", "Breakpoint locations shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line, - "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line, - "3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" % self.line]) + self.expect( + "breakpoint list -f", + "Breakpoint locations shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.line, + "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.line, + "3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" % + self.line]) # Continue the program, there should be another stop. self.runCmd("process continue") # Stopped again. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Continue the program, we should exit. self.runCmd("process continue") # We should exit. self.expect("process status", "Process exited successfully", - patterns = ["^Process [0-9]+ exited with status = 0"]) + patterns=["^Process [0-9]+ exited with status = 0"]) def breakpoint_options_language_test(self): """Test breakpoint command for language option.""" @@ -71,23 +92,34 @@ class BreakpointOptionsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 locations. - lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c++", num_expected_locations=1) + lldbutil.run_break_set_by_symbol( + self, + 'ns::func', + sym_exact=False, + extra_options="-L c++", + num_expected_locations=1) # This should create a breakpoint with 0 locations. - lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c", num_expected_locations=0) + lldbutil.run_break_set_by_symbol( + self, + 'ns::func', + sym_exact=False, + extra_options="-L c", + num_expected_locations=0) self.runCmd("settings set target.language c") - lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, num_expected_locations=0) + lldbutil.run_break_set_by_symbol( + self, 'ns::func', sym_exact=False, num_expected_locations=0) # Run the program. self.runCmd("run", RUN_SUCCEEDED) # Stopped once. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Continue the program, we should exit. self.runCmd("process continue") # We should exit. self.expect("process status", "Process exited successfully", - patterns = ["^Process [0-9]+ exited with status = 0"]) + patterns=["^Process [0-9]+ exited with status = 0"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py index 4ca93765b65..2410f2ee82b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py @@ -6,6 +6,7 @@ import os import lldb from lldbsuite.test.lldbtest import * + class BreakpointSetRestart(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -16,12 +17,13 @@ class BreakpointSetRestart(TestBase): cwd = os.getcwd() exe = os.path.join(cwd, 'a.out') - + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) self.dbg.SetAsync(True) - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) event = lldb.SBEvent() @@ -29,15 +31,22 @@ class BreakpointSetRestart(TestBase): while self.dbg.GetListener().WaitForEvent(2, event): if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: break - - bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT, - lldb.SBFileSpec(os.path.join(cwd, 'main.cpp'))) - self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT) + + bp = target.BreakpointCreateBySourceRegex( + self.BREAKPOINT_TEXT, lldb.SBFileSpec( + os.path.join( + cwd, 'main.cpp'))) + self.assertTrue( + bp.IsValid() and bp.GetNumLocations() == 1, + VALID_BREAKPOINT) while self.dbg.GetListener().WaitForEvent(2, event): - if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event): + if lldb.SBProcess.GetStateFromEvent( + event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event): continue if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: continue - self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event))) - + self.fail( + "Setting a breakpoint generated an unexpected event: %s" % + lldb.SBDebugger.StateAsCString( + lldb.SBProcess.GetStateFromEvent(event))) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py index 4933d6d01d4..e4672fbbf1b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py @@ -4,7 +4,6 @@ Test breakpoint command with AT_comp_dir set to symbolic link. from __future__ import print_function - import os import shutil import lldb @@ -17,6 +16,7 @@ _EXE_NAME = 'CompDirSymLink' # Must match Makefile _SRC_FILE = 'main.cpp' _COMP_DIR_SYM_LINK_PROP = 'plugin.symbol-file.dwarf.comp-dir-symlink-paths' + class CompDirSymLinkTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,14 +32,18 @@ class CompDirSymLinkTestCase(TestBase): def test_symlink_paths_set(self): pwd_symlink = self.create_src_symlink() self.doBuild(pwd_symlink) - self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) + self.runCmd( + "settings set %s %s" % + (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line) @skipIf(hostoslist=no_match(["linux"])) def test_symlink_paths_set_procselfcwd(self): pwd_symlink = '/proc/self/cwd' self.doBuild(pwd_symlink) - self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) + self.runCmd( + "settings set %s %s" % + (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line) @skipIf(hostoslist=["windows"]) @@ -47,12 +51,17 @@ class CompDirSymLinkTestCase(TestBase): pwd_symlink = self.create_src_symlink() self.doBuild(pwd_symlink) self.runCmd('settings clear ' + _COMP_DIR_SYM_LINK_PROP) - self.assertRaises(AssertionError, lldbutil.run_break_set_by_file_and_line, self, self.src_path, self.line) + self.assertRaises( + AssertionError, + lldbutil.run_break_set_by_file_and_line, + self, + self.src_path, + self.line) def create_src_symlink(self): pwd_symlink = os.path.join(os.getcwd(), 'pwd_symlink') if os.path.exists(pwd_symlink): - os.unlink(pwd_symlink) + os.unlink(pwd_symlink) os.symlink(os.getcwd(), pwd_symlink) self.addTearDownHook(lambda: os.remove(pwd_symlink)) return pwd_symlink diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py index 472479391c0..312f2944102 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py @@ -5,35 +5,42 @@ Test that we handle breakpoints on consecutive instructions correctly. from __future__ import print_function - import unittest2 import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ConsecutiveBreakpointsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def prepare_test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - breakpoint1 = self.target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp")) - self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) + breakpoint1 = self.target.BreakpointCreateBySourceRegex( + "Set breakpoint here", lldb.SBFileSpec("main.cpp")) + self.assertTrue( + breakpoint1 and breakpoint1.GetNumLocations() == 1, + VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertIsNotNone(self.process, PROCESS_IS_VALID) # We should be stopped at the first breakpoint - self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, breakpoint1) - self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 1") + self.thread = lldbutil.get_one_thread_stopped_at_breakpoint( + self.process, breakpoint1) + self.assertIsNotNone( + self.thread, + "Expected one thread to be stopped at breakpoint 1") # Set breakpoint to the next instruction frame = self.thread.GetFrameAtIndex(0) @@ -42,8 +49,11 @@ class ConsecutiveBreakpointsTestCase(TestBase): instructions = self.target.ReadInstructions(address, 2) self.assertTrue(len(instructions) == 2) self.bkpt_address = instructions[1].GetAddress() - self.breakpoint2 = self.target.BreakpointCreateByAddress(self.bkpt_address.GetLoadAddress(self.target)) - self.assertTrue(self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT) + self.breakpoint2 = self.target.BreakpointCreateByAddress( + self.bkpt_address.GetLoadAddress(self.target)) + self.assertTrue( + self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, + VALID_BREAKPOINT) def finish_test(self): # Run the process until termination @@ -58,8 +68,11 @@ class ConsecutiveBreakpointsTestCase(TestBase): self.process.Continue() self.assertEquals(self.process.GetState(), lldb.eStateStopped) # We should be stopped at the second breakpoint - self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2) - self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2") + self.thread = lldbutil.get_one_thread_stopped_at_breakpoint( + self.process, self.breakpoint2) + self.assertIsNotNone( + self.thread, + "Expected one thread to be stopped at breakpoint 2") self.finish_test() @@ -72,10 +85,15 @@ class ConsecutiveBreakpointsTestCase(TestBase): self.thread.StepInstruction(step_over) self.assertEquals(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target), - self.bkpt_address.GetLoadAddress(self.target)) - self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2) - self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2") + self.assertEquals( + self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress( + self.target), self.bkpt_address.GetLoadAddress( + self.target)) + self.thread = lldbutil.get_one_thread_stopped_at_breakpoint( + self.process, self.breakpoint2) + self.assertIsNotNone( + self.thread, + "Expected one thread to be stopped at breakpoint 2") self.finish_test() @@ -84,8 +102,9 @@ class ConsecutiveBreakpointsTestCase(TestBase): """Test that single step stops, even though the second breakpoint is not valid.""" self.prepare_test() - # Choose a thread other than the current one. A non-existing thread is fine. - thread_index = self.process.GetNumThreads()+1 + # Choose a thread other than the current one. A non-existing thread is + # fine. + thread_index = self.process.GetNumThreads() + 1 self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid()) self.breakpoint2.SetThreadIndex(thread_index) @@ -93,9 +112,13 @@ class ConsecutiveBreakpointsTestCase(TestBase): self.thread.StepInstruction(step_over) self.assertEquals(self.process.GetState(), lldb.eStateStopped) - self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target), - self.bkpt_address.GetLoadAddress(self.target)) - self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete, - "Stop reason should be 'plan complete'") + self.assertEquals( + self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress( + self.target), self.bkpt_address.GetLoadAddress( + self.target)) + self.assertEquals( + self.thread.GetStopReason(), + lldb.eStopReasonPlanComplete, + "Stop reason should be 'plan complete'") self.finish_test() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py index c2aa597214e..adec9fa5ddd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -5,60 +5,64 @@ Test lldb breakpoint ids. 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 TestCPPBreakpointLocations(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") - def test (self): - self.build () - self.breakpoint_id_tests () + def test(self): + self.build() + self.breakpoint_id_tests() def verify_breakpoint_locations(self, target, bp_dict): - + name = bp_dict['name'] names = bp_dict['loc_names'] - bp = target.BreakpointCreateByName (name) - self.assertEquals(bp.GetNumLocations(), len(names), "Make sure we find the right number of breakpoint locations") - + bp = target.BreakpointCreateByName(name) + self.assertEquals( + bp.GetNumLocations(), + len(names), + "Make sure we find the right number of breakpoint locations") + bp_loc_names = list() for bp_loc in bp: bp_loc_names.append(bp_loc.GetAddress().GetFunction().GetName()) - + for name in names: found = name in bp_loc_names if not found: print("Didn't find '%s' in: %s" % (name, bp_loc_names)) - self.assertTrue (found, "Make sure we find all required locations") - - def breakpoint_id_tests (self): - + self.assertTrue(found, "Make sure we find all required locations") + + def breakpoint_id_tests(self): + # Create a target by the debugger. exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) bp_dicts = [ - { 'name' : 'func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] }, - { 'name' : 'func2', 'loc_names' : [ 'a::c::func2()', 'c::d::func2()'] }, - { 'name' : 'func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()', 'c::d::func3()'] }, - { 'name' : 'c::func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] }, - { 'name' : 'c::func2', 'loc_names' : [ 'a::c::func2()'] }, - { 'name' : 'c::func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()'] }, - { 'name' : 'a::c::func1', 'loc_names' : [ 'a::c::func1()'] }, - { 'name' : 'b::c::func1', 'loc_names' : [ 'b::c::func1()'] }, - { 'name' : 'c::d::func2', 'loc_names' : [ 'c::d::func2()'] }, - { 'name' : 'a::c::func1()', 'loc_names' : [ 'a::c::func1()'] }, - { 'name' : 'b::c::func1()', 'loc_names' : [ 'b::c::func1()'] }, - { 'name' : 'c::d::func2()', 'loc_names' : [ 'c::d::func2()'] }, + {'name': 'func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']}, + {'name': 'func2', 'loc_names': ['a::c::func2()', 'c::d::func2()']}, + {'name': 'func3', 'loc_names': ['a::c::func3()', 'b::c::func3()', 'c::d::func3()']}, + {'name': 'c::func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']}, + {'name': 'c::func2', 'loc_names': ['a::c::func2()']}, + {'name': 'c::func3', 'loc_names': ['a::c::func3()', 'b::c::func3()']}, + {'name': 'a::c::func1', 'loc_names': ['a::c::func1()']}, + {'name': 'b::c::func1', 'loc_names': ['b::c::func1()']}, + {'name': 'c::d::func2', 'loc_names': ['c::d::func2()']}, + {'name': 'a::c::func1()', 'loc_names': ['a::c::func1()']}, + {'name': 'b::c::func1()', 'loc_names': ['b::c::func1()']}, + {'name': 'c::d::func2()', 'loc_names': ['c::d::func2()']}, ] - + for bp_dict in bp_dicts: self.verify_breakpoint_locations(target, bp_dict) @@ -68,28 +72,43 @@ class TestCPPBreakpointLocations(TestBase): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - # Don't skip prologue, so we can check the breakpoint address more easily + # Don't skip prologue, so we can check the breakpoint address more + # easily self.runCmd("settings set target.skip-prologue false") try: names = ['~c', 'c::~c', 'c::~c()'] loc_names = {'a::c::~c()', 'b::c::~c()'} - # TODO: For windows targets we should put windows mangled names here - symbols = ['_ZN1a1cD1Ev', '_ZN1a1cD2Ev', '_ZN1b1cD1Ev', '_ZN1b1cD2Ev'] + # TODO: For windows targets we should put windows mangled names + # here + symbols = [ + '_ZN1a1cD1Ev', + '_ZN1a1cD2Ev', + '_ZN1b1cD1Ev', + '_ZN1b1cD2Ev'] for name in names: bp = target.BreakpointCreateByName(name) - bp_loc_names = { bp_loc.GetAddress().GetFunction().GetName() for bp_loc in bp } - self.assertEquals(bp_loc_names, loc_names, "Breakpoint set on the correct symbol") + bp_loc_names = {bp_loc.GetAddress().GetFunction().GetName() + for bp_loc in bp} + self.assertEquals( + bp_loc_names, + loc_names, + "Breakpoint set on the correct symbol") - bp_addresses = { bp_loc.GetLoadAddress() for bp_loc in bp } + bp_addresses = {bp_loc.GetLoadAddress() for bp_loc in bp} symbol_addresses = set() for symbol in symbols: sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode) - self.assertEquals(sc_list.GetSize(), 1, "Found symbol " + symbol) + self.assertEquals( + sc_list.GetSize(), 1, "Found symbol " + symbol) symbol = sc_list.GetContextAtIndex(0).GetSymbol() - symbol_addresses.add(symbol.GetStartAddress().GetLoadAddress(target)) + symbol_addresses.add( + symbol.GetStartAddress().GetLoadAddress(target)) - self.assertEquals(symbol_addresses, bp_addresses, "Breakpoint set on correct address") + self.assertEquals( + symbol_addresses, + bp_addresses, + "Breakpoint set on correct address") finally: self.runCmd("settings clear target.skip-prologue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py index 2aac3a9600d..3019e1c1c55 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py @@ -5,7 +5,6 @@ Test that you can set breakpoint and hit the C++ language exception breakpoint from __future__ import print_function - import os import re import sys @@ -14,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestCPPExceptionBreakpoint (TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,26 +24,31 @@ class TestCPPExceptionBreakpoint (TestBase): def test_cpp_exception_breakpoint(self): """Test setting and hitting the C++ exception breakpoint.""" self.build() - self.do_cpp_exception_bkpt () + self.do_cpp_exception_bkpt() - def setUp (self): + def setUp(self): TestBase.setUp(self) self.main_source = "main.c" self.main_source_spec = lldb.SBFileSpec(self.main_source) - - def do_cpp_exception_bkpt (self): + def do_cpp_exception_bkpt(self): exe = os.path.join(os.getcwd(), "a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - exception_bkpt = self.target.BreakpointCreateForException(lldb.eLanguageTypeC_plus_plus, False, True) - self.assertTrue (exception_bkpt.IsValid(), "Created exception breakpoint.") + exception_bkpt = self.target.BreakpointCreateForException( + lldb.eLanguageTypeC_plus_plus, False, True) + self.assertTrue( + exception_bkpt.IsValid(), + "Created exception breakpoint.") - process = self.target.LaunchSimple (None, None, self.get_process_working_directory()) + process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, exception_bkpt) - self.assertTrue (len(thread_list) == 1, "One thread stopped at the exception breakpoint.") + + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, exception_bkpt) + self.assertTrue(len(thread_list) == 1, + "One thread stopped at the exception breakpoint.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py index de61f9e88f1..d044827e008 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DebugBreakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,19 +24,23 @@ class DebugBreakTestCase(TestBase): # Run the program. target = self.dbg.CreateTarget(exe) - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) # We've hit the first stop, so grab the frame. self.assertEqual(process.GetState(), lldb.eStateStopped) - stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform()=="windows" or lldbplatformutil.getPlatform()=="macosx") else lldb.eStopReasonSignal + stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform( + ) == "windows" or lldbplatformutil.getPlatform() == "macosx") else lldb.eStopReasonSignal thread = lldbutil.get_stopped_thread(process, stop_reason) - self.assertIsNotNone(thread, "Unable to find thread stopped at the __debugbreak()") + self.assertIsNotNone( + thread, "Unable to find thread stopped at the __debugbreak()") frame = thread.GetFrameAtIndex(0) # We should be in funciton 'bar'. self.assertTrue(frame.IsValid()) function_name = frame.GetFunctionName() - self.assertTrue('bar' in function_name, "Unexpected function name {}".format(function_name)) + self.assertTrue('bar' in function_name, + "Unexpected function name {}".format(function_name)) # We should be able to evaluate the parameter foo. value = frame.EvaluateExpression('*foo') @@ -45,10 +50,10 @@ class DebugBreakTestCase(TestBase): # subsequent stop. counter = 1 while counter < 20: - value = frame.EvaluateExpression('count') - self.assertEqual(value.GetValueAsSigned(), counter) - counter += 2 - process.Continue() + value = frame.EvaluateExpression('count') + self.assertEqual(value.GetValueAsSigned(), counter) + counter += 2 + process.Continue() # The inferior should exit after the last iteration. self.assertEqual(process.GetState(), lldb.eStateExited) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py index f2693e6ed59..a934ad356ac 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py @@ -5,12 +5,13 @@ Test breakpoint commands set before we have a target from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class BreakpointInDummyTarget (TestBase): mydir = TestBase.compute_mydir(__file__) @@ -25,43 +26,49 @@ class BreakpointInDummyTarget (TestBase): TestBase.setUp(self) # Find the line number to break inside main(). self.line = line_number('main.c', 'Set a breakpoint on this line.') - self.line2 = line_number ('main.c', 'Set another on this line.') + self.line2 = line_number('main.c', 'Set another on this line.') def dummy_breakpoint_test(self): """Test breakpoint set before we have a target. """ # This should create a breakpoint with 3 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=0) - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line2, num_expected_locations=0) - + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=0) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line2, num_expected_locations=0) + # This is the function to remove breakpoints from the dummy target # to get a clean slate for the next test case. def cleanup(): self.runCmd('breakpoint delete -D -f', check=False) self.runCmd('breakpoint list', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # The breakpoint list should show 3 locations. - self.expect("breakpoint list -f", "Breakpoint locations shown correctly", - substrs = ["1: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line, - "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line2]) + self.expect( + "breakpoint list -f", + "Breakpoint locations shown correctly", + substrs=[ + "1: file = 'main.c', line = %d, exact_match = 0, locations = 1" % + self.line, + "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % + self.line2]) # Run the program. self.runCmd("run", RUN_SUCCEEDED) # Stopped once. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Continue the program, there should be another stop. self.runCmd("process continue") # Stopped again. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 2."]) + substrs=["stop reason = breakpoint 2."]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py index d04178bda78..fe8f430096d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py @@ -6,12 +6,13 @@ another source file) works correctly. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class InlinedBreakpointsTestCase(TestBase): """Bug fixed: rdar://problem/8464339""" @@ -26,32 +27,43 @@ class InlinedBreakpointsTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside basic_type.cpp. - self.line = line_number('basic_type.cpp', '// Set break point at this line.') + self.line = line_number( + 'basic_type.cpp', + '// Set break point at this line.') def inlined_breakpoints(self): """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp).""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # With the inline-breakpoint-strategy, our file+line breakpoint should not resolve to a location. + # With the inline-breakpoint-strategy, our file+line breakpoint should + # not resolve to a location. self.runCmd('settings set target.inline-breakpoint-strategy headers') - # Set a breakpoint and fail because it is in an inlined source implemenation file - lldbutil.run_break_set_by_file_and_line (self, "basic_type.cpp", self.line, num_expected_locations=0) + # Set a breakpoint and fail because it is in an inlined source + # implemenation file + lldbutil.run_break_set_by_file_and_line( + self, "basic_type.cpp", self.line, num_expected_locations=0) - # Now enable breakpoints in implementation files and see the breakpoint set succeed + # Now enable breakpoints in implementation files and see the breakpoint + # set succeed self.runCmd('settings set target.inline-breakpoint-strategy always') # And add hooks to restore the settings during tearDown(). - self.addTearDownHook( - lambda: self.runCmd("settings set target.inline-breakpoint-strategy always")) + self.addTearDownHook(lambda: self.runCmd( + "settings set target.inline-breakpoint-strategy always")) - lldbutil.run_break_set_by_file_and_line (self, "basic_type.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + "basic_type.cpp", + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. # And it should break at basic_type.cpp:176. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint', - 'basic_type.cpp:%d' % self.line]) + substrs=['stopped', + 'stop reason = breakpoint', + 'basic_type.cpp:%d' % self.line]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py index c48cee1bd2b..f43bbb7515c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py @@ -6,8 +6,8 @@ parser. from __future__ import print_function - -import os, time +import os +import time import shutil import subprocess import lldb @@ -15,6 +15,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class TestObjCBreakpoints(TestBase): @@ -34,20 +35,37 @@ class TestObjCBreakpoints(TestBase): self.line = line_number(self.main_source, '// Set breakpoint here') def check_category_breakpoints(self): - name_bp = self.target.BreakpointCreateByName ("myCategoryFunction") - selector_bp = self.target.BreakpointCreateByName ("myCategoryFunction", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(name_bp.GetNumLocations() == selector_bp.GetNumLocations(), 'Make sure setting a breakpoint by name "myCategoryFunction" sets a breakpoint even though it is in a category') + name_bp = self.target.BreakpointCreateByName("myCategoryFunction") + selector_bp = self.target.BreakpointCreateByName( + "myCategoryFunction", + lldb.eFunctionNameTypeSelector, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + name_bp.GetNumLocations() == selector_bp.GetNumLocations(), + 'Make sure setting a breakpoint by name "myCategoryFunction" sets a breakpoint even though it is in a category') for bp_loc in selector_bp: function_name = bp_loc.GetAddress().GetSymbol().GetName() - self.assertTrue(" myCategoryFunction]" in function_name, 'Make sure all function names have " myCategoryFunction]" in their names') - - category_bp = self.target.BreakpointCreateByName ("-[MyClass(MyCategory) myCategoryFunction]") - stripped_bp = self.target.BreakpointCreateByName ("-[MyClass myCategoryFunction]") - stripped2_bp = self.target.BreakpointCreateByName ("[MyClass myCategoryFunction]") - self.assertTrue(category_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name with the category included (-[MyClass(MyCategory) myCategoryFunction])") - self.assertTrue(stripped_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name without the category included (-[MyClass myCategoryFunction])") - self.assertTrue(stripped2_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name without the category included ([MyClass myCategoryFunction])") - + self.assertTrue( + " myCategoryFunction]" in function_name, + 'Make sure all function names have " myCategoryFunction]" in their names') + + category_bp = self.target.BreakpointCreateByName( + "-[MyClass(MyCategory) myCategoryFunction]") + stripped_bp = self.target.BreakpointCreateByName( + "-[MyClass myCategoryFunction]") + stripped2_bp = self.target.BreakpointCreateByName( + "[MyClass myCategoryFunction]") + self.assertTrue( + category_bp.GetNumLocations() == 1, + "Make sure we can set a breakpoint using a full objective C function name with the category included (-[MyClass(MyCategory) myCategoryFunction])") + self.assertTrue( + stripped_bp.GetNumLocations() == 1, + "Make sure we can set a breakpoint using a full objective C function name without the category included (-[MyClass myCategoryFunction])") + self.assertTrue( + stripped2_bp.GetNumLocations() == 1, + "Make sure we can set a breakpoint using a full objective C function name without the category included ([MyClass myCategoryFunction])") + def check_objc_breakpoints(self, have_dsym): """Test constant string generation amd comparison by the expression parser.""" @@ -60,36 +78,55 @@ class TestObjCBreakpoints(TestBase): self.assertTrue(self.target, VALID_TARGET) #---------------------------------------------------------------------- - # Set breakpoints on all selectors whose name is "count". This should - # catch breakpoints that are both C functions _and_ anything whose + # Set breakpoints on all selectors whose name is "count". This should + # catch breakpoints that are both C functions _and_ anything whose # selector is "count" because just looking at "count" we can't tell # definitively if the name is a selector or a C function #---------------------------------------------------------------------- - name_bp = self.target.BreakpointCreateByName ("count") - selector_bp = self.target.BreakpointCreateByName ("count", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(name_bp.GetNumLocations() >= selector_bp.GetNumLocations(), 'Make sure we get at least the same amount of breakpoints if not more when setting by name "count"') - self.assertTrue(selector_bp.GetNumLocations() > 50, 'Make sure we find a lot of "count" selectors') # There are 93 on the latest MacOSX + name_bp = self.target.BreakpointCreateByName("count") + selector_bp = self.target.BreakpointCreateByName( + "count", + lldb.eFunctionNameTypeSelector, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + name_bp.GetNumLocations() >= selector_bp.GetNumLocations(), + 'Make sure we get at least the same amount of breakpoints if not more when setting by name "count"') + self.assertTrue( + selector_bp.GetNumLocations() > 50, + 'Make sure we find a lot of "count" selectors') # There are 93 on the latest MacOSX for bp_loc in selector_bp: function_name = bp_loc.GetAddress().GetSymbol().GetName() - self.assertTrue(" count]" in function_name, 'Make sure all function names have " count]" in their names') + self.assertTrue( + " count]" in function_name, + 'Make sure all function names have " count]" in their names') #---------------------------------------------------------------------- # Set breakpoints on all selectors whose name is "isEqual:". This should # catch breakpoints that are only ObjC selectors because no C function # can end with a : #---------------------------------------------------------------------- - name_bp = self.target.BreakpointCreateByName ("isEqual:") - selector_bp = self.target.BreakpointCreateByName ("isEqual:", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList()) - self.assertTrue(name_bp.GetNumLocations() == selector_bp.GetNumLocations(), 'Make sure setting a breakpoint by name "isEqual:" only sets selector breakpoints') + name_bp = self.target.BreakpointCreateByName("isEqual:") + selector_bp = self.target.BreakpointCreateByName( + "isEqual:", + lldb.eFunctionNameTypeSelector, + lldb.SBFileSpecList(), + lldb.SBFileSpecList()) + self.assertTrue( + name_bp.GetNumLocations() == selector_bp.GetNumLocations(), + 'Make sure setting a breakpoint by name "isEqual:" only sets selector breakpoints') for bp_loc in selector_bp: function_name = bp_loc.GetAddress().GetSymbol().GetName() - self.assertTrue(" isEqual:]" in function_name, 'Make sure all function names have " isEqual:]" in their names') - + self.assertTrue( + " isEqual:]" in function_name, + 'Make sure all function names have " isEqual:]" in their names') + self.check_category_breakpoints() - + if have_dsym: shutil.rmtree(exe + ".dSYM") - self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx', exe]) == 0, 'stripping dylib succeeded') - + self.assertTrue(subprocess.call( + ['/usr/bin/strip', '-Sx', exe]) == 0, 'stripping dylib succeeded') + # Check breakpoints again, this time using the symbol table only self.check_category_breakpoints() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py index 81cab927d21..791cc70a749 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py @@ -5,26 +5,27 @@ This test just tests the source file & function restrictions. 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 TestSourceRegexBreakpoints(TestBase): mydir = TestBase.compute_mydir(__file__) - def test_location (self): + def test_location(self): self.build() self.source_regex_locations() - def test_restrictions (self): - self.build () - self.source_regex_restrictions () - + def test_restrictions(self): + self.build() + self.source_regex_restrictions() - def source_regex_locations (self): + def source_regex_locations(self): """ Test that restricting source expressions to files & to functions. """ # Create a target by the debugger. exe = os.path.join(os.getcwd(), "a.out") @@ -39,24 +40,28 @@ class TestSourceRegexBreakpoints(TestBase): func_names.AppendString("a_func") source_regex = "Set . breakpoint here" - main_break = target.BreakpointCreateBySourceRegex (source_regex, - lldb.SBFileSpecList(), - target_files, - func_names) + main_break = target.BreakpointCreateBySourceRegex( + source_regex, lldb.SBFileSpecList(), target_files, func_names) num_locations = main_break.GetNumLocations() - self.assertTrue(num_locations == 1, "a.c in a_func should give one breakpoint, got %d."%(num_locations)) + self.assertTrue( + num_locations == 1, + "a.c in a_func should give one breakpoint, got %d." % + (num_locations)) loc = main_break.GetLocationAtIndex(0) self.assertTrue(loc.IsValid(), "Got a valid location.") address = loc.GetAddress() - self.assertTrue(address.IsValid(), "Got a valid address from the location.") - + self.assertTrue( + address.IsValid(), + "Got a valid address from the location.") + a_func_line = line_number("a.c", "Set A breakpoint here") line_entry = address.GetLineEntry() self.assertTrue(line_entry.IsValid(), "Got a valid line entry.") - self.assertTrue(line_entry.line == a_func_line, "Our line number matches the one lldbtest found.") + self.assertTrue(line_entry.line == a_func_line, + "Our line number matches the one lldbtest found.") - def source_regex_restrictions (self): + def source_regex_restrictions(self): """ Test that restricting source expressions to files & to functions. """ # Create a target by the debugger. exe = os.path.join(os.getcwd(), "a.out") @@ -67,34 +72,35 @@ class TestSourceRegexBreakpoints(TestBase): target_files = lldb.SBFileSpecList() target_files.Append(lldb.SBFileSpec("main.c")) source_regex = "Set . breakpoint here" - main_break = target.BreakpointCreateBySourceRegex (source_regex, - lldb.SBFileSpecList(), - target_files, - lldb.SBStringList()) + main_break = target.BreakpointCreateBySourceRegex( + source_regex, lldb.SBFileSpecList(), target_files, lldb.SBStringList()) num_locations = main_break.GetNumLocations() - self.assertTrue(num_locations == 2, "main.c should have 2 matches, got %d."%(num_locations)) + self.assertTrue( + num_locations == 2, + "main.c should have 2 matches, got %d." % + (num_locations)) # Now look in both files: target_files.Append(lldb.SBFileSpec("a.c")) - main_break = target.BreakpointCreateBySourceRegex (source_regex, - lldb.SBFileSpecList(), - target_files, - lldb.SBStringList()) + main_break = target.BreakpointCreateBySourceRegex( + source_regex, lldb.SBFileSpecList(), target_files, lldb.SBStringList()) - num_locations =main_break.GetNumLocations() - self.assertTrue(num_locations == 4, "main.c and a.c should have 4 matches, got %d."%(num_locations)) + num_locations = main_break.GetNumLocations() + self.assertTrue( + num_locations == 4, + "main.c and a.c should have 4 matches, got %d." % + (num_locations)) # Now restrict it to functions: func_names = lldb.SBStringList() func_names.AppendString("main_func") - main_break = target.BreakpointCreateBySourceRegex (source_regex, - lldb.SBFileSpecList(), - target_files, - func_names) - - num_locations =main_break.GetNumLocations() - self.assertTrue(num_locations == 2, "main_func in main.c and a.c should have 2 matches, got %d."%(num_locations)) - + main_break = target.BreakpointCreateBySourceRegex( + source_regex, lldb.SBFileSpecList(), target_files, func_names) + num_locations = main_break.GetNumLocations() + self.assertTrue( + num_locations == 2, + "main_func in main.c and a.c should have 2 matches, got %d." % + (num_locations)) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py index 66ba8d07622..17b7b6d395d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py @@ -5,13 +5,13 @@ Test the command history mechanism from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CommandHistoryTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,52 +19,90 @@ class CommandHistoryTestCase(TestBase): @no_debug_info_test def test_history(self): self.runCmd('command history --clear', inHistory=False) - self.runCmd('breakpoint list', check=False, inHistory=True) #0 - self.runCmd('register read', check=False, inHistory=True) #1 - self.runCmd('apropos hello', check=False, inHistory=True) #2 - self.runCmd('memory write', check=False, inHistory=True) #3 - self.runCmd('log list', check=False, inHistory=True) #4 - self.runCmd('disassemble', check=False, inHistory=True) #5 - self.runCmd('expression 1', check=False, inHistory=True) #6 - self.runCmd('type summary list -w default', check=False, inHistory=True) #7 - self.runCmd('version', check=False, inHistory=True) #8 - self.runCmd('frame select 1', check=False, inHistory=True) #9 - - self.expect ("command history -s 3 -c 3", inHistory=True, - substrs = ['3: memory write','4: log list','5: disassemble']) - - self.expect ("command history -s 3 -e 3", inHistory=True, - substrs = ['3: memory write']) - - self.expect ("command history -s 6 -e 7", inHistory=True, - substrs = ['6: expression 1','7: type summary list -w default']) - - self.expect ("command history -c 2", inHistory=True, - substrs = ['0: breakpoint list','1: register read']) - - self.expect ("command history -e 3 -c 1", inHistory=True, - substrs = ['3: memory write']) - - self.expect ("command history -e 2", inHistory=True, - substrs = ['0: breakpoint list','1: register read','2: apropos hello']) - - self.expect ("command history -s 12", inHistory=True, - substrs = ['12: command history -s 6 -e 7','13: command history -c 2','14: command history -e 3 -c 1','15: command history -e 2','16: command history -s 12']) - - self.expect ("command history -s end -c 3", inHistory=True, - substrs = ['15: command history -e 2','16: command history -s 12','17: command history -s end -c 3']) - - self.expect ("command history -s end -e 15", inHistory=True, - substrs = ['15: command history -e 2','16: command history -s 12','17: command history -s end -c 3','command history -s end -e 15']) - - self.expect ("command history -s 5 -c 1", inHistory=True, - substrs = ['5: disassemble']) - - self.expect ("command history -c 1 -s 5", inHistory=True, - substrs = ['5: disassemble']) - - self.expect ("command history -c 1 -e 3", inHistory=True, - substrs = ['3: memory write']) - - self.expect ("command history -c 1 -e 3 -s 5",error=True, inHistory=True, - substrs = ['error: --count, --start-index and --end-index cannot be all specified in the same invocation']) + self.runCmd('breakpoint list', check=False, inHistory=True) # 0 + self.runCmd('register read', check=False, inHistory=True) # 1 + self.runCmd('apropos hello', check=False, inHistory=True) # 2 + self.runCmd('memory write', check=False, inHistory=True) # 3 + self.runCmd('log list', check=False, inHistory=True) # 4 + self.runCmd('disassemble', check=False, inHistory=True) # 5 + self.runCmd('expression 1', check=False, inHistory=True) # 6 + self.runCmd( + 'type summary list -w default', + check=False, + inHistory=True) # 7 + self.runCmd('version', check=False, inHistory=True) # 8 + self.runCmd('frame select 1', check=False, inHistory=True) # 9 + + self.expect( + "command history -s 3 -c 3", + inHistory=True, + substrs=[ + '3: memory write', + '4: log list', + '5: disassemble']) + + self.expect("command history -s 3 -e 3", inHistory=True, + substrs=['3: memory write']) + + self.expect( + "command history -s 6 -e 7", + inHistory=True, + substrs=[ + '6: expression 1', + '7: type summary list -w default']) + + self.expect("command history -c 2", inHistory=True, + substrs=['0: breakpoint list', '1: register read']) + + self.expect("command history -e 3 -c 1", inHistory=True, + substrs=['3: memory write']) + + self.expect( + "command history -e 2", + inHistory=True, + substrs=[ + '0: breakpoint list', + '1: register read', + '2: apropos hello']) + + self.expect( + "command history -s 12", + inHistory=True, + substrs=[ + '12: command history -s 6 -e 7', + '13: command history -c 2', + '14: command history -e 3 -c 1', + '15: command history -e 2', + '16: command history -s 12']) + + self.expect( + "command history -s end -c 3", + inHistory=True, + substrs=[ + '15: command history -e 2', + '16: command history -s 12', + '17: command history -s end -c 3']) + + self.expect( + "command history -s end -e 15", + inHistory=True, + substrs=[ + '15: command history -e 2', + '16: command history -s 12', + '17: command history -s end -c 3', + 'command history -s end -e 15']) + + self.expect("command history -s 5 -c 1", inHistory=True, + substrs=['5: disassemble']) + + self.expect("command history -c 1 -s 5", inHistory=True, + substrs=['5: disassemble']) + + self.expect("command history -c 1 -e 3", inHistory=True, + substrs=['3: memory write']) + + self.expect( + "command history -c 1 -e 3 -s 5", + error=True, + inHistory=True, + substrs=['error: --count, --start-index and --end-index cannot be all specified in the same invocation']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py index 5b680ec65de..e1c5b4b4825 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -5,18 +5,20 @@ Test lldb 'commands regex' command which allows the user to create a regular exp from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CommandRegexTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") @no_debug_info_test def test_command_regex(self): """Test a simple scenario of 'command regex' invocation and subsequent use.""" @@ -25,7 +27,8 @@ class CommandRegexTestCase(TestBase): regex_prompt = "Enter one of more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n" regex_prompt1 = "\r\n" - child = pexpect.spawn('%s %s' % (lldbtest_config.lldbExec, self.lldbOption)) + child = pexpect.spawn('%s %s' % + (lldbtest_config.lldbExec, self.lldbOption)) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout @@ -44,11 +47,13 @@ class CommandRegexTestCase(TestBase): child.sendline('Help__') # If we see the familiar 'help' output, the test is done. child.expect('Debugger commands:') - # Try and incorrectly remove "Help__" using "command unalias" and verify we fail + # Try and incorrectly remove "Help__" using "command unalias" and + # verify we fail child.sendline('command unalias Help__') - child.expect_exact("error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command") + child.expect_exact( + "error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command") child.expect_exact(prompt) - + # Delete the regex command using "command delete" child.sendline('command delete Help__') child.expect_exact(prompt) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py index 97e52231e81..d562cb1511a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py @@ -5,33 +5,34 @@ Test lldb Python commands. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * + class CmdPythonTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): - self.build () - self.pycmd_tests () + def test(self): + self.build() + self.pycmd_tests() - def pycmd_tests (self): + def pycmd_tests(self): self.runCmd("command source py_import") # Verify command that specifies eCommandRequiresTarget returns failure # without a target. self.expect('targetname', - substrs = ['a.out'], matching=False, error=True) + substrs=['a.out'], matching=False, error=True) - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out" ]) + patterns=["Current executable set to .*a.out"]) self.expect('targetname', - substrs = ['a.out'], matching=True, error=False) + substrs=['a.out'], matching=True, error=False) # This is the function to remove the custom commands in order to have a # clean slate for the next test case. @@ -57,86 +58,89 @@ class CmdPythonTestCase(TestBase): self.HideStdout() self.expect('welcome Enrico', - substrs = ['Hello Enrico, welcome to LLDB']); - + substrs=['Hello Enrico, welcome to LLDB']) + self.expect("help welcome", - substrs = ['Just a docstring for welcome_impl', - 'A command that says hello to LLDB users']) + substrs=['Just a docstring for welcome_impl', + 'A command that says hello to LLDB users']) self.expect("help", - substrs = ['For more information run', - 'welcome']) + substrs=['For more information run', + 'welcome']) self.expect("help -a", - substrs = ['For more information run', - 'welcome']) + substrs=['For more information run', + 'welcome']) self.expect("help -u", matching=False, - substrs = ['For more information run']) + substrs=['For more information run']) - self.runCmd("command script delete welcome"); + self.runCmd("command script delete welcome") self.expect('welcome Enrico', matching=False, error=True, - substrs = ['Hello Enrico, welcome to LLDB']); + substrs=['Hello Enrico, welcome to LLDB']) self.expect('targetname fail', error=True, - substrs = ['a test for error in command']) + substrs=['a test for error in command']) self.expect('command script list', - substrs = ['targetname', - 'For more information run']) + substrs=['targetname', + 'For more information run']) self.expect("help targetname", - substrs = ['Expects', '\'raw\'', 'input', - 'help', 'raw-input']) + substrs=['Expects', '\'raw\'', 'input', + 'help', 'raw-input']) self.expect("longwait", - substrs = ['Done; if you saw the delays I am doing OK']) + substrs=['Done; if you saw the delays I am doing OK']) self.runCmd("b main") self.runCmd("run") self.runCmd("mysto 3") self.expect("frame variable array", - substrs = ['[0] = 79630','[1] = 388785018','[2] = 0']) + substrs=['[0] = 79630', '[1] = 388785018', '[2] = 0']) self.runCmd("mysto 3") self.expect("frame variable array", - substrs = ['[0] = 79630','[4] = 388785018','[5] = 0']) + substrs=['[0] = 79630', '[4] = 388785018', '[5] = 0']) # we cannot use the stepover command to check for async execution mode since LLDB # seems to get confused when events start to queue up self.expect("tell_sync", - substrs = ['running sync']) + substrs=['running sync']) self.expect("tell_async", - substrs = ['running async']) + substrs=['running async']) self.expect("tell_curr", - substrs = ['I am running sync']) - + substrs=['I am running sync']) + # check that the execution context is passed in to commands that ask for it - self.expect("takes_exe_ctx", substrs = ["a.out"]) + self.expect("takes_exe_ctx", substrs=["a.out"]) # Test that a python command can redefine itself self.expect('command script add -f foobar welcome -h "just some help"') - + self.runCmd("command script clear") # Test that re-defining an existing command works - self.runCmd('command script add my_command --class welcome.WelcomeCommand') - self.expect('my_command Blah', substrs = ['Hello Blah, welcome to LLDB']) + self.runCmd( + 'command script add my_command --class welcome.WelcomeCommand') + self.expect('my_command Blah', substrs=['Hello Blah, welcome to LLDB']) - self.runCmd('command script add my_command --class welcome.TargetnameCommand') - self.expect('my_command', substrs = ['a.out']) + self.runCmd( + 'command script add my_command --class welcome.TargetnameCommand') + self.expect('my_command', substrs=['a.out']) self.runCmd("command script clear") - + self.expect('command script list', matching=False, - substrs = ['targetname', - 'longwait']) + substrs=['targetname', + 'longwait']) self.expect('command script add -f foobar frame', error=True, - substrs = ['cannot add command']) + substrs=['cannot add command']) # http://llvm.org/bugs/show_bug.cgi?id=11569 - # LLDBSwigPythonCallCommand crashes when a command script returns an object + # LLDBSwigPythonCallCommand crashes when a command script returns an + # object self.runCmd('command script add -f bug11569 bug11569') # This should not crash. self.runCmd('bug11569', check=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py index 93897d88098..3c124de79bf 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py @@ -3,5 +3,4 @@ def bug11569(debugger, args, result, dict): http://llvm.org/bugs/show_bug.cgi?id=11569 LLDBSwigPythonCallCommand crashes when a command script returns an object. """ - return ["return", "a", "non-string", "should", "not", "crash", "LLDB"]; - + return ["return", "a", "non-string", "should", "not", "crash", "LLDB"] diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py index 01c3f35bf30..01e7902b0f3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py @@ -3,13 +3,15 @@ from __future__ import print_function - -import os, sys, time +import os +import sys +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ImportTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -47,29 +49,31 @@ class ImportTestCase(TestBase): self.runCmd("command script import ./bar/bar.py --allow-reload") self.expect("command script import ./nosuchfile.py", - error=True, startstr='error: module importing failed') + error=True, startstr='error: module importing failed') self.expect("command script import ./nosuchfolder/", - error=True, startstr='error: module importing failed') + error=True, startstr='error: module importing failed') self.expect("command script import ./foo/foo.py", error=False) self.runCmd("command script import --allow-reload ./thepackage") - self.expect("TPcommandA",substrs=["hello world A"]) - self.expect("TPcommandB",substrs=["hello world B"]) + self.expect("TPcommandA", substrs=["hello world A"]) + self.expect("TPcommandB", substrs=["hello world B"]) self.runCmd("script import dummymodule") self.expect("command script import ./dummymodule.py", error=False) - self.expect("command script import --allow-reload ./dummymodule.py", error=False) + self.expect( + "command script import --allow-reload ./dummymodule.py", + error=False) self.runCmd("command script add -f foo.foo_function foocmd") self.runCmd("command script add -f foobar.foo_function foobarcmd") self.runCmd("command script add -f bar.bar_function barcmd") self.expect("foocmd hello", - substrs = ['foo says', 'hello']) + substrs=['foo says', 'hello']) self.expect("foo2cmd hello", - substrs = ['foo2 says', 'hello']) + substrs=['foo2 says', 'hello']) self.expect("barcmd hello", - substrs = ['barutil says', 'bar told me', 'hello']) + substrs=['barutil says', 'bar told me', 'hello']) self.expect("barothercmd hello", - substrs = ['barutil says', 'bar told me', 'hello']) + substrs=['barutil says', 'bar told me', 'hello']) self.expect("foobarcmd hello", - substrs = ['foobar says', 'hello']) + substrs=['foobar says', 'hello']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py index bbc41f3b217..444e00976ad 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py @@ -1,12 +1,15 @@ from __future__ import print_function + def bar_function(debugger, args, result, dict): - global UtilityModule - print(UtilityModule.barutil_function("bar told me " + args), file=result) - return None + global UtilityModule + print(UtilityModule.barutil_function("bar told me " + args), file=result) + return None + def __lldb_init_module(debugger, session_dict): - global UtilityModule - UtilityModule = __import__("barutil") - debugger.HandleCommand("command script add -f bar.bar_function barothercmd") - return None
\ No newline at end of file + global UtilityModule + UtilityModule = __import__("barutil") + debugger.HandleCommand( + "command script add -f bar.bar_function barothercmd") + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py index 0d3d2eb1b2d..70ecea30057 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py @@ -1,2 +1,2 @@ def barutil_function(x): - return "barutil says: " + x + return "barutil says: " + x diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py index dcc724ec9c2..668a5b90ea4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py @@ -1,2 +1,2 @@ def no_useful_code(foo): - return foo + return foo diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py index 659ded22c90..6ef71064c9a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py @@ -1,5 +1,6 @@ from __future__ import print_function + def foo_function(debugger, args, result, dict): - print("foobar says " + args, file=result) - return None + print("foobar says " + args, file=result) + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py index 51cc0c3bab1..1ccc3892939 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py @@ -1,5 +1,6 @@ from __future__ import print_function + def foo_function(debugger, args, result, dict): - print("foo says " + args, file=result) - return None + print("foo says " + args, file=result) + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py index 6863454ca6e..71657c299c2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py @@ -1,9 +1,11 @@ from __future__ import print_function + def foo2_function(debugger, args, result, dict): - print("foo2 says " + args, file=result) - return None + print("foo2 says " + args, file=result) + return None + def __lldb_init_module(debugger, session_dict): - debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd") - return None
\ No newline at end of file + debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd") + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py index 4f7ebebd4dd..01fd5138583 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py @@ -3,13 +3,15 @@ from __future__ import print_function - -import os, sys, time +import os +import sys +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class Rdar12586188TestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +29,11 @@ class Rdar12586188TestCase(TestBase): def run_test(self): """Check that we handle an ImportError in a special way when command script importing files.""" - self.expect("command script import ./fail12586188.py --allow-reload", - error=True, substrs = ['raise ImportError("I do not want to be imported")']) - self.expect("command script import ./fail212586188.py --allow-reload", - error=True, substrs = ['raise ValueError("I do not want to be imported")']) + self.expect( + "command script import ./fail12586188.py --allow-reload", + error=True, + substrs=['raise ImportError("I do not want to be imported")']) + self.expect( + "command script import ./fail212586188.py --allow-reload", + error=True, + substrs=['raise ValueError("I do not want to be imported")']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py index add85a73f85..ea385e03e04 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py @@ -1,4 +1,4 @@ def f(x): - return x + 1 + return x + 1 raise ImportError("I do not want to be imported") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py index 1549a036590..8dbc0e67ba1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py @@ -1,4 +1,4 @@ def f(x): - return x + 1 + return x + 1 raise ValueError("I do not want to be imported") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py index fb65305d205..9694b084295 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py @@ -1,6 +1,7 @@ import six + def command(debugger, command, result, internal_dict): - result.PutCString(six.u("hello world A")) - return None + result.PutCString(six.u("hello world A")) + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py index 60b31b89f6d..94a333bc696 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py @@ -1,6 +1,7 @@ import six + def command(debugger, command, result, internal_dict): - result.PutCString(six.u("hello world B")) - return None + result.PutCString(six.u("hello world B")) + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py index 1181462af86..24cdea60f2c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py @@ -3,6 +3,9 @@ from __future__ import absolute_import from . import TPunitA from . import TPunitB -def __lldb_init_module(debugger,*args): - debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA") - debugger.HandleCommand("command script add -f thepackage.TPunitB.command TPcommandB") + +def __lldb_init_module(debugger, *args): + debugger.HandleCommand( + "command script add -f thepackage.TPunitA.command TPcommandA") + debugger.HandleCommand( + "command script add -f thepackage.TPunitB.command TPcommandB") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py index 656cd150293..88a20cb4567 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py @@ -5,19 +5,21 @@ import sys import os import time + def StepOver(debugger, args, result, dict): - """ - Step over a given number of times instead of only just once - """ - arg_split = args.split(" ") - print(type(arg_split)) - count = int(arg_split[0]) - for i in range(0,count): - debugger.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver(lldb.eOnlyThisThread) - print("step<%d>"%i) + """ + Step over a given number of times instead of only just once + """ + arg_split = args.split(" ") + print(type(arg_split)) + count = int(arg_split[0]) + for i in range(0, count): + debugger.GetSelectedTarget().GetProcess( + ).GetSelectedThread().StepOver(lldb.eOnlyThisThread) + print("step<%d>" % i) -def __lldb_init_module(debugger, session_dict): - # by default, --synchronicity is set to synchronous - debugger.HandleCommand("command script add -f mysto.StepOver mysto") - return None +def __lldb_init_module(debugger, session_dict): + # by default, --synchronicity is set to synchronous + debugger.HandleCommand("command script add -f mysto.StepOver mysto") + return None diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py index 5dbf09fbbec..0539d7c1721 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py @@ -1,18 +1,23 @@ from __future__ import print_function -import lldb, sys +import lldb +import sys + class WelcomeCommand(object): + def __init__(self, debugger, session_dict): pass - + def get_short_help(self): return "Just a docstring for welcome_impl\nA command that says hello to LLDB users" - + def __call__(self, debugger, args, exe_ctx, result): - print('Hello ' + args + ', welcome to LLDB', file=result); - return None; + print('Hello ' + args + ', welcome to LLDB', file=result) + return None + class TargetnameCommand(object): + def __init__(self, debugger, session_dict): pass @@ -22,10 +27,11 @@ class TargetnameCommand(object): print('Current target ' + file.GetFilename(), file=result) if args == 'fail': result.SetError('a test for error in command') - + def get_flags(self): return lldb.eCommandRequiresTarget + def print_wait_impl(debugger, args, result, dict): result.SetImmediateOutputFile(sys.stdout) print('Trying to do long task..', file=result) @@ -35,12 +41,13 @@ def print_wait_impl(debugger, args, result, dict): time.sleep(1) print('Done; if you saw the delays I am doing OK', file=result) + def check_for_synchro(debugger, args, result, dict): - if debugger.GetAsync() == True: + if debugger.GetAsync(): print('I am running async', file=result) if debugger.GetAsync() == False: print('I am running sync', file=result) + def takes_exe_ctx(debugger, args, exe_ctx, result, dict): print(str(exe_ctx.GetTarget()), file=result) - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py index 694728a9f9c..eb63c707989 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py @@ -5,18 +5,20 @@ Test lldb Python commands. from __future__ import print_function -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * + class CommandScriptAliasTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): - self.pycmd_tests () + def test(self): + self.pycmd_tests() - def pycmd_tests (self): + def pycmd_tests(self): self.runCmd("command script import tcsacmd.py") self.runCmd("command script add -f tcsacmd.some_command_here attach") @@ -32,6 +34,7 @@ class CommandScriptAliasTestCase(TestBase): if not self.TraceOn(): self.HideStdout() - self.expect('attach a', substrs = ['Victory is mine']); + self.expect('attach a', substrs=['Victory is mine']) self.runCmd("command script delete attach") - self.runCmd('attach noprocessexistswiththisname', check=False) # this can't crash but we don't care whether the actual attach works + # this can't crash but we don't care whether the actual attach works + self.runCmd('attach noprocessexistswiththisname', check=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py index 6c60e3ca1a5..d5bb6131210 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py @@ -1,11 +1,12 @@ from __future__ import print_function -import lldb, sys +import lldb +import sys -def some_command_here(debugger, command, result, d): - if command == "a": - print("Victory is mine", file=result) - return True - else: - print("Sadness for all", file=result) - return False +def some_command_here(debugger, command, result, d): + if command == "a": + print("Victory is mine", file=result) + return True + else: + print("Sadness for all", file=result) + return False diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py index a843d08a97d..975ad32689b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py @@ -5,14 +5,15 @@ Test that LLDB correctly allows scripted commands to set an immediate output fil 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.lldbpexpect import * from lldbsuite.test import lldbutil + class CommandScriptImmediateOutputTestCase (PExpectTest): mydir = TestBase.compute_mydir(__file__) @@ -22,10 +23,12 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): # Call super's setUp(). PExpectTest.setUp(self) - @skipIfRemote # test not remote-ready llvm.org/pr24813 - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfRemote # test not remote-ready llvm.org/pr24813 + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139") - def test_command_script_immediate_output_console (self): + def test_command_script_immediate_output_console(self): """Test that LLDB correctly allows scripted commands to set immediate output to the console.""" self.launch(timeout=10) @@ -33,27 +36,33 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): prompt = "\(lldb\) " self.sendline('command script import %s' % script, patterns=[prompt]) - self.sendline('command script add -f custom_command.command_function mycommand', patterns=[prompt]) - self.sendline('mycommand', patterns='this is a test string, just a test string') + self.sendline( + 'command script add -f custom_command.command_function mycommand', + patterns=[prompt]) + self.sendline( + 'mycommand', + patterns='this is a test string, just a test string') self.sendline('command script delete mycommand', patterns=[prompt]) self.quit(gracefully=False) - @skipIfRemote # test not remote-ready llvm.org/pr24813 - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfRemote # test not remote-ready llvm.org/pr24813 + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139") - def test_command_script_immediate_output_file (self): + def test_command_script_immediate_output_file(self): """Test that LLDB correctly allows scripted commands to set immediate output to a file.""" self.launch(timeout=10) - test_files = {os.path.join(os.getcwd(), 'read.txt') :'r', - os.path.join(os.getcwd(), 'write.txt') :'w', - os.path.join(os.getcwd(), 'append.txt') :'a', - os.path.join(os.getcwd(), 'write_plus.txt') :'w+', - os.path.join(os.getcwd(), 'read_plus.txt') :'r+', - os.path.join(os.getcwd(), 'append_plus.txt') :'a+'} + test_files = {os.path.join(os.getcwd(), 'read.txt'): 'r', + os.path.join(os.getcwd(), 'write.txt'): 'w', + os.path.join(os.getcwd(), 'append.txt'): 'a', + os.path.join(os.getcwd(), 'write_plus.txt'): 'w+', + os.path.join(os.getcwd(), 'read_plus.txt'): 'r+', + os.path.join(os.getcwd(), 'append_plus.txt'): 'a+'} starter_string = 'Starter Garbage\n' - write_string = 'writing to file with mode: ' + write_string = 'writing to file with mode: ' for path, mode in test_files.iteritems(): with open(path, 'w+') as init: @@ -64,7 +73,9 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): self.sendline('command script import %s' % script, patterns=[prompt]) - self.sendline('command script add -f custom_command.write_file mywrite', patterns=[prompt]) + self.sendline( + 'command script add -f custom_command.write_file mywrite', + patterns=[prompt]) for path, mode in test_files.iteritems(): command = 'mywrite "' + path + '" ' + mode @@ -79,8 +90,8 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): if mode in ['r', 'a', 'a+']: self.assertEquals(result.readline(), starter_string) if mode in ['w', 'w+', 'r+', 'a', 'a+']: - self.assertEquals(result.readline(), write_string + mode + '\n') + self.assertEquals( + result.readline(), write_string + mode + '\n') self.assertTrue(os.path.isfile(path)) os.remove(path) - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py index 30a3cfb9093..e0c24055c83 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py @@ -3,15 +3,17 @@ from __future__ import print_function import sys import shlex + def command_function(debugger, command, exe_ctx, result, internal_dict): - result.SetImmediateOutputFile(sys.__stdout__) - print('this is a test string, just a test string', file=result) + result.SetImmediateOutputFile(sys.__stdout__) + print('this is a test string, just a test string', file=result) + def write_file(debugger, command, exe_ctx, result, internal_dict): - args = shlex.split(command) - path = args[0] - mode = args[1] - with open(path, mode) as f: - result.SetImmediateOutputFile(f) - if not mode in ['r']: - print('writing to file with mode: ' + mode, file=result) + args = shlex.split(command) + path = args[0] + mode = args[1] + with open(path, mode) as f: + result.SetImmediateOutputFile(f) + if not mode in ['r']: + print('writing to file with mode: ' + mode, file=result) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py index 0d4eb0776e7..cee9bd27218 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py @@ -7,13 +7,14 @@ See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673. from __future__ import print_function - -import os, sys +import os +import sys import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CommandSourceTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -35,4 +36,4 @@ class CommandSourceTestCase(TestBase): import datetime self.expect(result.GetOutput(), "script my.date() runs successfully", exe=False, - substrs = [str(datetime.date.today())]) + substrs=[str(datetime.date.today())]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_source/my.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_source/my.py index cb2fd012e4b..bd97fda3cbb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_source/my.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_source/my.py @@ -1,5 +1,6 @@ from __future__ import print_function + def date(): import datetime today = datetime.date.today() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py b/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py index 7a9ded03ad2..d4d9c58b0bc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -5,7 +5,6 @@ Test the lldb command line completion mechanism. from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * @@ -13,6 +12,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbplatform from lldbsuite.test import lldbutil + class CommandLineCompletionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,29 +27,31 @@ class CommandLineCompletionTestCase(TestBase): pass @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_at(self): """Test that 'at' completes to 'attach '.""" self.complete_from_to('at', 'attach ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_de(self): """Test that 'de' completes to 'detach '.""" self.complete_from_to('de', 'detach ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_process_attach_dash_dash_con(self): """Test that 'process attach --con' completes to 'process attach --continue '.""" - self.complete_from_to('process attach --con', 'process attach --continue ') + self.complete_from_to( + 'process attach --con', + 'process attach --continue ') # <rdar://problem/11052829> @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_infinite_loop_while_completing(self): """Test that 'process print hello\' completes to itself and does not infinite loop.""" @@ -57,147 +59,176 @@ class CommandLineCompletionTestCase(TestBase): turn_off_re_match=True) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_co(self): """Test that 'watchpoint co' completes to 'watchpoint command '.""" self.complete_from_to('watchpoint co', 'watchpoint command ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_command_space(self): """Test that 'watchpoint command ' completes to ['Available completions:', 'add', 'delete', 'list'].""" - self.complete_from_to('watchpoint command ', ['Available completions:', 'add', 'delete', 'list']) + self.complete_from_to( + 'watchpoint command ', [ + 'Available completions:', 'add', 'delete', 'list']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_command_a(self): """Test that 'watchpoint command a' completes to 'watchpoint command add '.""" - self.complete_from_to('watchpoint command a', 'watchpoint command add ') + self.complete_from_to( + 'watchpoint command a', + 'watchpoint command add ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_set_variable_dash_w(self): """Test that 'watchpoint set variable -w' completes to 'watchpoint set variable -w '.""" - self.complete_from_to('watchpoint set variable -w', 'watchpoint set variable -w ') + self.complete_from_to( + 'watchpoint set variable -w', + 'watchpoint set variable -w ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_set_variable_dash_w_space(self): """Test that 'watchpoint set variable -w ' completes to ['Available completions:', 'read', 'write', 'read_write'].""" - self.complete_from_to('watchpoint set variable -w ', ['Available completions:', 'read', 'write', 'read_write']) + self.complete_from_to('watchpoint set variable -w ', + ['Available completions:', 'read', 'write', 'read_write']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_set_ex(self): """Test that 'watchpoint set ex' completes to 'watchpoint set expression '.""" - self.complete_from_to('watchpoint set ex', 'watchpoint set expression ') + self.complete_from_to( + 'watchpoint set ex', + 'watchpoint set expression ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_set_var(self): """Test that 'watchpoint set var' completes to 'watchpoint set variable '.""" self.complete_from_to('watchpoint set var', 'watchpoint set variable ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_watchpoint_set_variable_dash_w_read_underbar(self): """Test that 'watchpoint set variable -w read_' completes to 'watchpoint set variable -w read_write'.""" - self.complete_from_to('watchpoint set variable -w read_', 'watchpoint set variable -w read_write') + self.complete_from_to( + 'watchpoint set variable -w read_', + 'watchpoint set variable -w read_write') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_help_fi(self): """Test that 'help fi' completes to ['Available completions:', 'file', 'finish'].""" - self.complete_from_to('help fi', ['Available completions:', 'file', 'finish']) + self.complete_from_to( + 'help fi', [ + 'Available completions:', 'file', 'finish']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_help_watchpoint_s(self): """Test that 'help watchpoint s' completes to 'help watchpoint set '.""" self.complete_from_to('help watchpoint s', 'help watchpoint set ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_append_target_er(self): """Test that 'settings append target.er' completes to 'settings append target.error-path'.""" - self.complete_from_to('settings append target.er', 'settings append target.error-path') + self.complete_from_to( + 'settings append target.er', + 'settings append target.error-path') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_insert_after_target_en(self): """Test that 'settings insert-after target.env' completes to 'settings insert-after target.env-vars'.""" - self.complete_from_to('settings insert-after target.env', 'settings insert-after target.env-vars') + self.complete_from_to( + 'settings insert-after target.env', + 'settings insert-after target.env-vars') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_insert_before_target_en(self): """Test that 'settings insert-before target.env' completes to 'settings insert-before target.env-vars'.""" - self.complete_from_to('settings insert-before target.env', 'settings insert-before target.env-vars') + self.complete_from_to( + 'settings insert-before target.env', + 'settings insert-before target.env-vars') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_replace_target_ru(self): """Test that 'settings replace target.ru' completes to 'settings replace target.run-args'.""" - self.complete_from_to('settings replace target.ru', 'settings replace target.run-args') + self.complete_from_to( + 'settings replace target.ru', + 'settings replace target.run-args') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_s(self): """Test that 'settings s' completes to ['Available completions:', 'set', 'show'].""" - self.complete_from_to('settings s', ['Available completions:', 'set', 'show']) + self.complete_from_to( + 'settings s', [ + 'Available completions:', 'set', 'show']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_th(self): """Test that 'settings set th' completes to 'settings set thread-format'.""" self.complete_from_to('settings set th', 'settings set thread-format') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_s_dash(self): """Test that 'settings set -' completes to 'settings set -g'.""" self.complete_from_to('settings set -', 'settings set -g') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_clear_th(self): """Test that 'settings clear th' completes to 'settings clear thread-format'.""" - self.complete_from_to('settings clear th', 'settings clear thread-format') + self.complete_from_to( + 'settings clear th', + 'settings clear thread-format') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_ta(self): """Test that 'settings set ta' completes to 'settings set target.'.""" - self.complete_from_to('settings set target.ma', 'settings set target.max-') + self.complete_from_to( + 'settings set target.ma', + 'settings set target.max-') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_target_exec(self): """Test that 'settings set target.exec' completes to 'settings set target.exec-search-paths '.""" - self.complete_from_to('settings set target.exec', 'settings set target.exec-search-paths') + self.complete_from_to( + 'settings set target.exec', + 'settings set target.exec-search-paths') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_target_pr(self): """Test that 'settings set target.pr' completes to ['Available completions:', @@ -208,21 +239,25 @@ class CommandLineCompletionTestCase(TestBase): 'target.process.']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_target_process(self): """Test that 'settings set target.process' completes to 'settings set target.process.'.""" - self.complete_from_to('settings set target.process', 'settings set target.process.') + self.complete_from_to( + 'settings set target.process', + 'settings set target.process.') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_target_process_dot(self): """Test that 'settings set target.process.t' completes to 'settings set target.process.thread.'.""" - self.complete_from_to('settings set target.process.t', 'settings set target.process.thread.') + self.complete_from_to( + 'settings set target.process.t', + 'settings set target.process.thread.') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_settings_set_target_process_thread_dot(self): """Test that 'settings set target.process.thread.' completes to ['Available completions:', @@ -233,31 +268,39 @@ class CommandLineCompletionTestCase(TestBase): 'target.process.thread.trace-thread']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_target_space(self): """Test that 'target ' completes to ['Available completions:', 'create', 'delete', 'list', 'modules', 'select', 'stop-hook', 'variable'].""" self.complete_from_to('target ', - ['Available completions:', 'create', 'delete', 'list', - 'modules', 'select', 'stop-hook', 'variable']) + ['Available completions:', + 'create', + 'delete', + 'list', + 'modules', + 'select', + 'stop-hook', + 'variable']) @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_target_create_dash_co(self): """Test that 'target create --co' completes to 'target variable --core '.""" self.complete_from_to('target create --co', 'target create --core ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot + @skipIfFreeBSD # timing out on the FreeBSD buildbot @no_debug_info_test def test_target_va(self): """Test that 'target va' completes to 'target variable '.""" self.complete_from_to('target va', 'target variable ') @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @expectedFailureAll(oslist=lldbplatform.darwin_all, bugnumber="llvm.org/pr25485") + @expectedFailureAll( + oslist=lldbplatform.darwin_all, + bugnumber="llvm.org/pr25485") def test_symbol_name(self): self.build() self.complete_from_to('''file a.out @@ -277,7 +320,7 @@ class CommandLineCompletionTestCase(TestBase): # later on. if not isinstance(patterns, list): patterns = [patterns] - + # The default lldb prompt. prompt = "(lldb) " @@ -304,7 +347,7 @@ class CommandLineCompletionTestCase(TestBase): # stop further logging. child.logfile_send = None child.logfile_read = None - + with open('child_send.txt', 'r') as fs: if self.TraceOn(): print("\n\nContents of child_send.txt:") @@ -318,10 +361,13 @@ class CommandLineCompletionTestCase(TestBase): # The matching could be verbatim or using generic re pattern. for p in patterns: # Test that str_input completes to our patterns or substrings. - # If each pattern/substring matches from_child, the completion mechanism works! + # If each pattern/substring matches from_child, the completion + # mechanism works! if turn_off_re_match: - self.expect(from_child, msg=COMPLETION_MSG(str_input, p), exe=False, - substrs = [p]) + self.expect( + from_child, msg=COMPLETION_MSG( + str_input, p), exe=False, substrs=[p]) else: - self.expect(from_child, msg=COMPLETION_MSG(str_input, p), exe=False, - patterns = [p]) + self.expect( + from_child, msg=COMPLETION_MSG( + str_input, p), exe=False, patterns=[p]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py index 7fcb44f0b3e..cec06e48f1c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py @@ -5,8 +5,8 @@ Test conditionally break on a function and inspect its variables. from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * @@ -18,6 +18,7 @@ from lldbsuite.test import lldbutil # # This class currently fails for clang as well as llvm-gcc. + class ConditionalBreakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,7 +34,9 @@ class ConditionalBreakTestCase(TestBase): self.build() self.simulate_conditional_break_by_user() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265: args in frames other than #0 are not evaluated correctly") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr26265: args in frames other than #0 are not evaluated correctly") def do_conditional_break(self): """Exercise some thread and frame APIs to break if c() is called by a().""" exe = os.path.join(os.getcwd(), "a.out") @@ -45,7 +48,8 @@ class ConditionalBreakTestCase(TestBase): self.assertTrue(breakpoint, VALID_BREAKPOINT) # 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()) self.assertTrue(process, PROCESS_IS_VALID) @@ -54,7 +58,8 @@ class ConditionalBreakTestCase(TestBase): STOPPED_DUE_TO_BREAKPOINT) # Find the line number where a's parent frame function is c. - line = line_number('main.c', + line = line_number( + 'main.c', "// Find the line number where c's parent frame is a here.") # Suppose we are only interested in the call scenario where c()'s @@ -66,15 +71,17 @@ class ConditionalBreakTestCase(TestBase): for j in range(10): if self.TraceOn(): print("j is: ", j) - thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) - self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint") - + thread = lldbutil.get_one_thread_stopped_at_breakpoint( + process, breakpoint) + self.assertIsNotNone( + thread, "Expected one thread to be stopped at the breakpoint") + if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) name0 = frame0.GetFunction().GetName() frame1 = thread.GetFrameAtIndex(1) name1 = frame1.GetFunction().GetName() - #lldbutil.print_stacktrace(thread) + # lldbutil.print_stacktrace(thread) self.assertTrue(name0 == "c", "Break on function c()") if (name1 == "a"): # By design, we know that a() calls c() only from main.c:27. @@ -83,7 +90,8 @@ class ConditionalBreakTestCase(TestBase): self.assertTrue(frame1.GetLineEntry().GetLine() == line, "Immediate caller a() at main.c:%d" % line) - # And the local variable 'val' should have a value of (int) 3. + # And the local variable 'val' should have a value of (int) + # 3. val = frame1.FindVariable("val") self.assertEqual("int", val.GetTypeName()) self.assertEqual("3", val.GetValue()) @@ -109,28 +117,28 @@ class ConditionalBreakTestCase(TestBase): self.runCmd("file a.out") self.runCmd("command source .lldb") - self.runCmd ("break list") + self.runCmd("break list") if self.TraceOn(): print("About to run.") self.runCmd("run", RUN_SUCCEEDED) - self.runCmd ("break list") + self.runCmd("break list") if self.TraceOn(): print("Done running") # 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 frame info for frame #0 points to a.out`c and its immediate caller # (frame #1) points to a.out`a. self.expect("frame info", "We should stop at c()", - substrs = ["a.out`c"]) + substrs=["a.out`c"]) # Select our parent frame as the current frame. self.runCmd("frame select 1") self.expect("frame info", "The immediate caller should be a()", - substrs = ["a.out`a"]) + substrs=["a.out`a"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/conditional_break.py b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/conditional_break.py index b30a34e56b1..a62dd923af9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/conditional_break.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/conditional_break.py @@ -1,6 +1,7 @@ import sys import lldb + def stop_if_called_from_a(frame, bp_loc, dict): thread = frame.GetThread() @@ -19,12 +20,11 @@ def stop_if_called_from_a(frame, bp_loc, dict): should_stop = True if thread.GetNumFrames() >= 2: - if (thread.frames[0].function.name == 'c' and thread.frames[1].function.name == 'a'): + if (thread.frames[0].function.name == + 'c' and thread.frames[1].function.name == 'a'): should_stop = True else: should_stop = False dbg.SetAsync(old_async) return should_stop - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py index fca56dd93a8..f8ce069478f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py @@ -60,28 +60,31 @@ class TestDarwinLogFilterMatchActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_chain_partial_match(self): """Test that fall-through reject, doesn't accept only partial match of activity-chain.""" self.do_test( ["--no-match-accepts false", - "--filter \"accept activity-chain match parent-activity:child-activity\"", # Match the second fully. + # Match the second fully. + "--filter \"accept activity-chain match parent-activity:child-activity\"", "--filter \"accept activity-chain match parent-ac\""]) # Only partially match the first. # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_chain_full_match(self): @@ -93,11 +96,12 @@ class TestDarwinLogFilterMatchActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity-chain rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_chain_second_rule(self): @@ -111,7 +115,9 @@ class TestDarwinLogFilterMatchActivityChain(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the activity-chain of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py index edb5914bfbf..12a430295a7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py @@ -60,29 +60,32 @@ class TestDarwinLogFilterMatchActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_partial_match(self): """Test that fall-through reject, accept match activity via partial match does not accept.""" self.do_test( ["--no-match-accepts false", - "--filter \"accept activity match child-activity\"", # Fully match second message. + # Fully match second message. + "--filter \"accept activity match child-activity\"", "--filter \"accept activity match parent-\""] # Only partially match first message. ) # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_full_match(self): @@ -95,11 +98,12 @@ class TestDarwinLogFilterMatchActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_second_rule(self): @@ -115,7 +119,9 @@ class TestDarwinLogFilterMatchActivity(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the activity of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py index 21d8bfb9d6a..8ce4d4135d1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py @@ -60,27 +60,32 @@ class TestDarwinLogFilterMatchCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that category. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_category_partial_match(self): """Test that fall-through reject, accept regex category via partial match works.""" self.do_test( ["--no-match-accepts false", - "--filter \"accept category match cat2\"", # Fully match the second message. + # Fully match the second message. + "--filter \"accept category match cat2\"", "--filter \"accept category match at1\""] # Only partially match first message. Should not show up. ) # We should only see the second log message as we only accept # that category. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_category_full_match(self): @@ -93,10 +98,12 @@ class TestDarwinLogFilterMatchCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via category rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_category_second_rule(self): @@ -112,7 +119,9 @@ class TestDarwinLogFilterMatchCategory(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the category of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py index c9b05184e36..8a6ab43a609 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py @@ -40,7 +40,6 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): # Turn on process monitor logging while we work out issues. self.enable_process_monitor_logging = True - def tearDown(self): # Shut down the process if it's still running. if self.child: @@ -58,7 +57,7 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): EXPECT_REGEXES = [ re.compile(r"log message ([^-]+)-(\S+)"), re.compile(r"exited with status") - ] + ] @decorators.skipUnlessDarwin def test_filter_accept_message_full_match(self): @@ -72,10 +71,12 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that message contents. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_no_accept_message_partial_match(self): @@ -90,10 +91,12 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): # We should only see the second log message as the partial match on # the first message should not pass. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_category_full_match(self): @@ -107,10 +110,12 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via message contents rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_category_second_rule(self): @@ -126,7 +131,9 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the category of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py index e9cfa7def13..5afe649e16a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py @@ -60,27 +60,32 @@ class TestDarwinLogFilterMatchSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that subsystem. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_subsystem_partial_match(self): """Test that fall-through reject, doesn't accept match subsystem via partial-match.""" self.do_test( ["--no-match-accepts false", - "--filter \"accept subsystem match org.llvm.lldb.test.sub2\"", # Fully match second message subsystem. + # Fully match second message subsystem. + "--filter \"accept subsystem match org.llvm.lldb.test.sub2\"", "--filter \"accept subsystem match sub1\""] # Only partially match first subsystem. ) # We should only see the second log message as we only accept # that subsystem. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_subsystem_full_match(self): @@ -93,10 +98,12 @@ class TestDarwinLogFilterMatchSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via subsystem rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_subsystem_second_rule(self): @@ -112,7 +119,9 @@ class TestDarwinLogFilterMatchSubsystem(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the subsystem of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py index a2f5abf1a54..74be57aeef8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py @@ -60,11 +60,12 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_chain_partial_match(self): @@ -76,11 +77,12 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_chain_full_match(self): @@ -92,11 +94,12 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity-chain rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat1"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat1"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_chain_partial_match(self): @@ -108,11 +111,12 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity-chain rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_chain_second_rule(self): @@ -126,7 +130,9 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the activity-chain of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py index 286ad72953b..55f015403d1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py @@ -60,11 +60,12 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_partial_match(self): @@ -77,11 +78,12 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that activity. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_full_match(self): @@ -94,11 +96,12 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_activity_partial_match(self): @@ -111,11 +114,12 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via activity rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") - + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_activity_second_rule(self): @@ -131,7 +135,9 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the activity of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py index 0389f624e61..6786d6f009b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py @@ -60,10 +60,12 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that category. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_category_partial_match(self): @@ -76,10 +78,12 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that category. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_category_full_match(self): @@ -92,10 +96,12 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via category rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_category_partial_match(self): @@ -108,10 +114,12 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via category rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_category_second_rule(self): @@ -127,7 +135,9 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the category of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py index 2134977aa94..28677b54c75 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py @@ -77,10 +77,12 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that subsystem. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_subsystem_partial_match(self): @@ -93,10 +95,12 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we only accept # that subsystem. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_subsystem_full_match(self): @@ -109,10 +113,12 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via subsystem rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_reject_subsystem_partial_match(self): @@ -125,10 +131,12 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): # We should only see the second log message as we rejected the first # via subsystem rejection. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_filter_accept_subsystem_second_rule(self): @@ -144,7 +152,9 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): # the first filter doesn't match any, and the second filter matches # the subsystem of the second log message. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) == "sub2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 0) and ( + self.child.match.group(1) == "sub2"), + "first log line should not be present, second log line " + "should be") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py index c5d98ae208e..65822cab430 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py @@ -64,9 +64,8 @@ class TestDarwinLogMessageFormat(darwin_log.DarwinLogTestBase): # content. self.assertIsNotNone(self.child.match) self.assertFalse((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) != ""), - "we should not have seen a header") - + (self.child.match.group(1) != ""), + "we should not have seen a header") @decorators.skipUnlessDarwin def test_display_with_header_works(self): @@ -83,8 +82,8 @@ class TestDarwinLogMessageFormat(darwin_log.DarwinLogTestBase): # content. self.assertIsNotNone(self.child.match) self.assertTrue((len(self.child.match.groups()) > 0) and - (self.child.match.group(1) != ""), - "we should have printed a header") + (self.child.match.group(1) != ""), + "we should have printed a header") def assert_header_contains_timestamp(self, header): fields = header.split(',') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py index d44437cd14b..85b8e30f606 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py @@ -60,10 +60,12 @@ class TestDarwinLogSourceDebug(darwin_log.DarwinLogTestBase): # We should only see the second log message as the first is a # debug-level message and we're not including debug-level messages. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_source_explicitly_include_debug(self): diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py index d47d85a27fd..44348374636 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py @@ -61,10 +61,12 @@ class TestDarwinLogSourceInfo(darwin_log.DarwinLogTestBase): # We should only see the second log message as the first is an # info-level message and we're not including debug-level messages. self.assertIsNotNone(self.child.match) - self.assertTrue((len(self.child.match.groups()) > 1) and - (self.child.match.group(2) == "cat2"), - "first log line should not be present, second log line " - "should be") + self.assertTrue( + (len( + self.child.match.groups()) > 1) and ( + self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") @decorators.skipUnlessDarwin def test_source_include_info_level(self): diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py index 54272e59333..0459058f3ae 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 DataFormatterBoolRefPtr(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class DataFormatterBoolRefPtr(TestBase): """Test the formatters we use for BOOL& and BOOL* in Objective-C.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -56,23 +58,24 @@ class DataFormatterBoolRefPtr(TestBase): # Now check that we use the right summary for BOOL& self.expect('frame variable yes_ref', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no_ref', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset_ref', substrs = ['12']) - + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset_ref', substrs=['12']) # Now check that we use the right summary for BOOL* self.expect('frame variable yes_ptr', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no_ptr', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset_ptr', substrs = ['12']) - + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset_ptr', substrs=['12']) # Now check that we use the right summary for BOOL self.expect('frame variable yes', - substrs = ['YES']) + substrs=['YES']) self.expect('frame variable no', - substrs = ['NO']) - if not(isiOS): self.expect('frame variable unset', substrs = ['12']) + substrs=['NO']) + if not(isiOS): + self.expect('frame variable unset', substrs=['12']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py index 914c5260ac2..9b430c726e1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 CompactVectorsFormattingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,14 +29,15 @@ class CompactVectorsFormattingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,15 +47,17 @@ class CompactVectorsFormattingTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('frame variable', - substrs = ['(vFloat) valueFL = (1.25, 0, 0.25, 0)', - '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(int32_t [4]) valueI32 = (1, 0, 4, 0)', - '(vDouble) valueDL = (1.25, 2.25)', - '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)', - '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(vUInt32) valueU32 = (1, 2, 3, 4)', - "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)", - '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)', - '(vSInt32) valueS32 = (4, 3, 2, 1)', - '(vBool32) valueBool32 = (0, 1, 0, 1)']) + self.expect( + 'frame variable', + substrs=[ + '(vFloat) valueFL = (1.25, 0, 0.25, 0)', + '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(int32_t [4]) valueI32 = (1, 0, 4, 0)', + '(vDouble) valueDL = (1.25, 2.25)', + '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)', + '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(vUInt32) valueU32 = (1, 2, 3, 4)', + "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)", + '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)', + '(vSInt32) valueS32 = (4, 3, 2, 1)', + '(vBool32) valueBool32 = (0, 1, 0, 1)']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index 8166d1540ca..050f5236445 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class AdvDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,103 +27,116 @@ class AdvDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) - + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("type summary add --summary-string \"pippo\" \"i_am_cool\"") - self.runCmd("type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"") + self.runCmd( + "type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"") self.expect("frame variable cool_boy", - substrs = ['pippo']) + substrs=['pippo']) self.expect("frame variable cooler_boy", - substrs = ['pluto']) + substrs=['pluto']) self.runCmd("type summary delete i_am_cool") - + self.expect("frame variable cool_boy", - substrs = ['pluto']) + substrs=['pluto']) self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]") + + self.runCmd( + "type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]") self.expect("frame variable int_array", - substrs = ['1,2,3,4,5']) + substrs=['1,2,3,4,5']) # this will fail if we don't do [] as regex correctly - self.runCmd('type summary add --summary-string "${var[].integer}" "i_am_cool[]') - + self.runCmd( + 'type summary add --summary-string "${var[].integer}" "i_am_cool[]') + self.expect("frame variable cool_array", - substrs = ['1,1,1,1,6']) + substrs=['1,1,1,1,6']) self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"${var[1-0]%x}\" \"int\"") - + + self.runCmd( + "type summary add --summary-string \"${var[1-0]%x}\" \"int\"") + self.expect("frame variable iAmInt", - substrs = ['01']) - - self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" \"int\"") - + substrs=['01']) + + self.runCmd( + "type summary add --summary-string \"${var[0-1]%x}\" \"int\"") + self.expect("frame variable iAmInt", - substrs = ['01']) + substrs=['01']) self.runCmd("type summary clear") self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" int") - self.runCmd("type summary add --summary-string \"${var[0-31]%x}\" float") - + self.runCmd( + "type summary add --summary-string \"${var[0-31]%x}\" float") + self.expect("frame variable *pointer", - substrs = ['0x', - '2']) + substrs=['0x', + '2']) - # check fix for <rdar://problem/11338654> LLDB crashes when using a "type summary" that uses bitfields with no format + # check fix for <rdar://problem/11338654> LLDB crashes when using a + # "type summary" that uses bitfields with no format self.runCmd("type summary add --summary-string \"${var[0-1]}\" int") self.expect("frame variable iAmInt", - substrs = ['9 1']) + substrs=['9 1']) self.expect("frame variable cool_array[3].floating", - substrs = ['0x']) - - self.runCmd("type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") + substrs=['0x']) + + self.runCmd( + "type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") self.expect("frame variable pointer", - substrs = ['low bits are', - 'tgt is 6']) + substrs=['low bits are', + 'tgt is 6']) - self.expect("frame variable int_array --summary-string \"${*var[0-1]}\"", - substrs = ['3']) + self.expect( + "frame variable int_array --summary-string \"${*var[0-1]}\"", + substrs=['3']) self.runCmd("type summary clear") - - self.runCmd('type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"') + + self.runCmd( + 'type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"') self.expect("frame variable int_array", - substrs = ['1,2']) + substrs=['1,2']) - self.runCmd('type summary add --summary-string \"${var[0-1]}\" "int []"') + self.runCmd( + 'type summary add --summary-string \"${var[0-1]}\" "int []"') self.expect("frame variable int_array", - substrs = ['1,2']) + substrs=['1,2']) self.runCmd("type summary clear") @@ -130,156 +144,179 @@ class AdvDataFormatterTestCase(TestBase): self.runCmd("type summary add -c i_am_cool") self.expect("frame variable cool_array", - substrs = ['[0]', - '[1]', - '[2]', - '[3]', - '[4]', - 'integer', - 'character', - 'floating']) - - self.runCmd("type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") + substrs=['[0]', + '[1]', + '[2]', + '[3]', + '[4]', + 'integer', + 'character', + 'floating']) + + self.runCmd( + "type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") self.expect("frame variable wrapper", - substrs = ['int = 4', - 'float = 1.1']) + substrs=['int = 4', + 'float = 1.1']) + + self.runCmd( + "type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") - self.runCmd("type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") - self.expect("frame variable wrapper", - substrs = ['low bits = 1']) - + substrs=['low bits = 1']) + self.expect("frame variable *wrap_pointer", - substrs = ['low bits = 1']) + substrs=['low bits = 1']) self.runCmd("type summary clear") - self.expect("frame variable int_array --summary-string \"${var[0][0-2]%hex}\"", - substrs = ['0x', - '7']) + self.expect( + "frame variable int_array --summary-string \"${var[0][0-2]%hex}\"", + substrs=[ + '0x', + '7']) self.runCmd("type summary clear") - self.runCmd("type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") + self.runCmd( + "type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") - self.expect("frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"", - substrs = ['1 are low bits of integer 9.', - 'If I pretend it is an array I get [9,']) + self.expect( + "frame variable couple --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\"", + substrs=[ + '1 are low bits of integer 9.', + 'If I pretend it is an array I get [9,']) # if the summary has an error, we still display the value - self.expect("frame variable couple --summary-string \"${*var.sp.foo[0-2]\"", - substrs = ['(Couple) couple = {','x = 0x','y = 0x','z = 0x','s = 0x']) - - - self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") + self.expect( + "frame variable couple --summary-string \"${*var.sp.foo[0-2]\"", + substrs=[ + '(Couple) couple = {', + 'x = 0x', + 'y = 0x', + 'z = 0x', + 's = 0x']) + + self.runCmd( + "type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") self.expect("frame variable sparray", - substrs = ['[0x0000000f,0x0000000c,0x00000009]']) - - # check that we can format a variable in a summary even if a format is defined for its datatype + substrs=['[0x0000000f,0x0000000c,0x00000009]']) + + # check that we can format a variable in a summary even if a format is + # defined for its datatype self.runCmd("type format add -f hex int") - self.runCmd("type summary add --summary-string \"x=${var.x%d}\" Simple") + self.runCmd( + "type summary add --summary-string \"x=${var.x%d}\" Simple") self.expect("frame variable a_simple_object", - substrs = ['x=3']) + substrs=['x=3']) self.expect("frame variable a_simple_object", matching=False, - substrs = ['0x0']) + substrs=['0x0']) # now check that the default is applied if we do not hand out a format self.runCmd("type summary add --summary-string \"x=${var.x}\" Simple") self.expect("frame variable a_simple_object", matching=False, - substrs = ['x=3']) + substrs=['x=3']) self.expect("frame variable a_simple_object", matching=True, - substrs = ['x=0x00000003']) + substrs=['x=0x00000003']) # check that we can correctly cap the number of children shown self.runCmd("settings set target.max-children-count 5") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - '...']) + substrs=['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + '...']) # check that no further stuff is printed (not ALL values are checked!) self.expect('frame variable a_long_guy', matching=False, - substrs = ['f_1', - 'g_1', - 'h_1', - 'i_1', - 'j_1', - 'q_1', - 'a_2', - 'f_2', - 't_2', - 'w_2']) + substrs=['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) self.runCmd("settings set target.max-children-count 1") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - '...']) + substrs=['a_1', + '...']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['b_1', - 'c_1', - 'd_1', - 'e_1']) + substrs=['b_1', + 'c_1', + 'd_1', + 'e_1']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['f_1', - 'g_1', - 'h_1', - 'i_1', - 'j_1', - 'q_1', - 'a_2', - 'f_2', - 't_2', - 'w_2']) + substrs=['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) self.runCmd("settings set target.max-children-count 30") self.expect('frame variable a_long_guy', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - 'z_1', - 'a_2', - 'b_2', - 'c_2', - 'd_2', - '...']) + substrs=['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2', + '...']) self.expect('frame variable a_long_guy', matching=False, - substrs = ['e_2', - 'n_2', - 'r_2', - 'i_2', - 'k_2', - 'o_2']) - - # override the cap - self.expect('frame variable a_long_guy --show-all-children', matching=True, - substrs = ['a_1', - 'b_1', - 'c_1', - 'd_1', - 'e_1', - 'z_1', - 'a_2', - 'b_2', - 'c_2', - 'd_2']) - self.expect('frame variable a_long_guy --show-all-children', matching=True, - substrs = ['e_2', - 'n_2', - 'r_2', - 'i_2', - 'k_2', - 'o_2']) - self.expect('frame variable a_long_guy --show-all-children', matching=False, - substrs = ['...']) + substrs=['e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + + # override the cap + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=True, + substrs=[ + 'a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2']) + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=True, + substrs=[ + 'e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + self.expect( + 'frame variable a_long_guy --show-all-children', + matching=False, + substrs=['...']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py index f8209f03d0c..2d01eb79e18 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 CategoriesDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,14 +28,15 @@ class CategoriesDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case (most of these categories do not @@ -46,286 +48,312 @@ class CategoriesDataFormatterTestCase(TestBase): self.runCmd('type category delete Category2', check=False) self.runCmd('type category delete NewCategory', check=False) self.runCmd("type category delete CircleCategory", check=False) - self.runCmd("type category delete RectangleStarCategory", check=False) + self.runCmd( + "type category delete RectangleStarCategory", + check=False) self.runCmd("type category delete BaseCategory", check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # Add a summary to a new category and check that it works - self.runCmd("type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory") + self.runCmd( + "type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory") self.expect("frame variable r1 r2 r3", matching=False, - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) - + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) + self.runCmd("type category enable NewCategory") self.expect("frame variable r1 r2 r3", matching=True, - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) - + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) + # Disable the category and check that the old stuff is there self.runCmd("type category disable NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) # Re-enable the category and check that it works self.runCmd("type category enable NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = ARectangle', - 'r2 = ARectangle', - 'r3 = ARectangle']) + substrs=['r1 = ARectangle', + 'r2 = ARectangle', + 'r3 = ARectangle']) # Delete the category and the old stuff should be there self.runCmd("type category delete NewCategory") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) - - # Add summaries to two different categories and check that we can switch - self.runCmd("type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) + + # Add summaries to two different categories and check that we can + # switch + self.runCmd( + "type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") self.runCmd("type summary add --python-script \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2") # check that enable A B is the same as enable B enable A self.runCmd("type category enable Category1 Category2") - + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.runCmd("type category disable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Area = ', - 'r2 = Area = ', - 'r3 = Area = ']) + substrs=['r1 = Area = ', + 'r2 = Area = ', + 'r3 = Area = ']) # switch again self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Re-enable the category and show that the preference is persisted self.runCmd("type category disable Category2") self.runCmd("type category enable Category2") - + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Area = ', - 'r2 = Area = ', - 'r3 = Area = ']) + substrs=['r1 = Area = ', + 'r2 = Area = ', + 'r3 = Area = ']) # Now delete the favorite summary self.runCmd("type summary delete Rectangle -w Category2") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Delete the summary from the default category (that does not have it) self.runCmd("type summary delete Rectangle", check=False) self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) # Now add another summary to another category and switch back and forth self.runCmd("type category delete Category1 Category2") - self.runCmd("type summary add Rectangle -w Category1 --summary-string \"Category1\"") - self.runCmd("type summary add Rectangle -w Category2 --summary-string \"Category2\"") + self.runCmd( + "type summary add Rectangle -w Category1 --summary-string \"Category1\"") + self.runCmd( + "type summary add Rectangle -w Category2 --summary-string \"Category2\"") self.runCmd("type category enable Category2") self.runCmd("type category enable Category1") - + self.runCmd("type summary list -w Category1") - self.expect("type summary list -w NoSuchCategoryHere", substrs=['no matching results found']) - + self.expect("type summary list -w NoSuchCategoryHere", + substrs=['no matching results found']) + self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category1', - 'r2 = Category1', - 'r3 = Category1']) + substrs=['r1 = Category1', + 'r2 = Category1', + 'r3 = Category1']) self.runCmd("type category disable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category2', - 'r2 = Category2', - 'r3 = Category2']) + substrs=['r1 = Category2', + 'r2 = Category2', + 'r3 = Category2']) # Check that re-enabling an enabled category works self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Category1', - 'r2 = Category1', - 'r3 = Category1']) + substrs=['r1 = Category1', + 'r2 = Category1', + 'r3 = Category1']) self.runCmd("type category delete Category1") self.runCmd("type category delete Category2") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = {', - 'r2 = {', - 'r3 = {']) - - # Check that multiple summaries can go into one category - self.runCmd("type summary add -w Category1 --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle") - self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" Circle") - + substrs=['r1 = {', + 'r2 = {', + 'r3 = {']) + + # Check that multiple summaries can go into one category + self.runCmd( + "type summary add -w Category1 --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle") + self.runCmd( + "type summary add -w Category1 --summary-string \"Radius = ${var.r}\" Circle") + self.runCmd("type category enable Category1") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.expect("frame variable c1 c2 c3", - substrs = ['c1 = Radius = ', - 'c2 = Radius = ', - 'c3 = Radius = ']) + substrs=['c1 = Radius = ', + 'c2 = Radius = ', + 'c3 = Radius = ']) self.runCmd("type summary delete Circle -w Category1") - + self.expect("frame variable c1 c2 c3", - substrs = ['c1 = {', - 'c2 = {', - 'c3 = {']) + substrs=['c1 = {', + 'c2 = {', + 'c3 = {']) # Add a regex based summary to a category - self.runCmd("type summary add -w Category1 --summary-string \"Radius = ${var.r}\" -x Circle") + self.runCmd( + "type summary add -w Category1 --summary-string \"Radius = ${var.r}\" -x Circle") self.expect("frame variable r1 r2 r3", - substrs = ['r1 = Width = ', - 'r2 = Width = ', - 'r3 = Width = ']) + substrs=['r1 = Width = ', + 'r2 = Width = ', + 'r3 = Width = ']) self.expect("frame variable c1 c2 c3", - substrs = ['c1 = Radius = ', - 'c2 = Radius = ', - 'c3 = Radius = ']) + substrs=['c1 = Radius = ', + 'c2 = Radius = ', + 'c3 = Radius = ']) # Delete it self.runCmd("type summary delete Circle -w Category1") self.expect("frame variable c1 c2 c3", - substrs = ['c1 = {', - 'c2 = {', - 'c3 = {']) - - # Change a summary inside a category and check that the change is reflected - self.runCmd("type summary add Circle -w Category1 --summary-string \"summary1\"") + substrs=['c1 = {', + 'c2 = {', + 'c3 = {']) + + # Change a summary inside a category and check that the change is + # reflected + self.runCmd( + "type summary add Circle -w Category1 --summary-string \"summary1\"") self.expect("frame variable c1 c2 c3", - substrs = ['c1 = summary1', - 'c2 = summary1', - 'c3 = summary1']) + substrs=['c1 = summary1', + 'c2 = summary1', + 'c3 = summary1']) + + self.runCmd( + "type summary add Circle -w Category1 --summary-string \"summary2\"") - self.runCmd("type summary add Circle -w Category1 --summary-string \"summary2\"") - self.expect("frame variable c1 c2 c3", - substrs = ['c1 = summary2', - 'c2 = summary2', - 'c3 = summary2']) + substrs=['c1 = summary2', + 'c2 = summary2', + 'c3 = summary2']) # Check that our order of priority works. Start by clearing categories self.runCmd("type category delete Category1") - self.runCmd("type summary add Shape -w BaseCategory --summary-string \"AShape\"") + self.runCmd( + "type summary add Shape -w BaseCategory --summary-string \"AShape\"") self.runCmd("type category enable BaseCategory") self.expect("print (Shape*)&c1", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)&r1", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)c_ptr", - substrs = ['AShape']) + substrs=['AShape']) self.expect("print (Shape*)r_ptr", - substrs = ['AShape']) + substrs=['AShape']) - self.runCmd("type summary add Circle -w CircleCategory --summary-string \"ACircle\"") - self.runCmd("type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"") + self.runCmd( + "type summary add Circle -w CircleCategory --summary-string \"ACircle\"") + self.runCmd( + "type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"") self.runCmd("type category enable CircleCategory") self.expect("frame variable c1", - substrs = ['ACircle']) + substrs=['ACircle']) self.expect("frame variable c_ptr", - substrs = ['ACircle']) + substrs=['ACircle']) - self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"") + self.runCmd( + "type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"") self.runCmd("type category enable RectangleStarCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - 'ARectangleStar']) + substrs=['ACircle', + 'ARectangleStar']) self.runCmd("type category enable RectangleCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - 'ACircle', - 'ARectangle']) + substrs=['ACircle', + 'ACircle', + 'ARectangle']) # Check that abruptly deleting an enabled category does not crash us self.runCmd("type category delete RectangleCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", - substrs = ['ACircle', - '(Rectangle) r1 = ', 'w = 5', 'h = 6', - 'ACircle', - 'ARectangleStar']) - + substrs=['ACircle', + '(Rectangle) r1 = ', 'w = 5', 'h = 6', + 'ACircle', + 'ARectangleStar']) + # check that list commands work self.expect("type category list", - substrs = ['RectangleStarCategory (enabled)']) + substrs=['RectangleStarCategory (enabled)']) self.expect("type summary list", - substrs = ['ARectangleStar']) + substrs=['ARectangleStar']) # Disable a category and check that it fallsback self.runCmd("type category disable CircleCategory") - + # check that list commands work self.expect("type category list", - substrs = ['CircleCategory (disabled']) + substrs=['CircleCategory (disabled']) self.expect("frame variable c1 r_ptr", - substrs = ['AShape', - 'ARectangleStar']) + substrs=['AShape', + 'ARectangleStar']) # check that filters work into categories - self.runCmd("type filter add Rectangle --child w --category RectangleCategory") + self.runCmd( + "type filter add Rectangle --child w --category RectangleCategory") self.runCmd("type category enable RectangleCategory") - self.runCmd("type summary add Rectangle --category RectangleCategory --summary-string \" \" -e") + self.runCmd( + "type summary add Rectangle --category RectangleCategory --summary-string \" \" -e") self.expect('frame variable r2', - substrs = ['w = 9']) + substrs=['w = 9']) self.runCmd("type summary add Rectangle --summary-string \" \" -e") self.expect('frame variable r2', matching=False, - substrs = ['h = 16']) + substrs=['h = 16']) # Now delete all categories - self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory") + self.runCmd( + "type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory") # check that a deleted category with filter does not blow us up self.expect('frame variable r2', - substrs = ['w = 9', - 'h = 16']) + substrs=['w = 9', + 'h = 16']) # and also validate that one can print formatters for a language - self.expect('type summary list -l c++', substrs=['vector', 'map', 'list', 'string']) + self.expect( + 'type summary list -l c++', + substrs=[ + 'vector', + 'map', + 'list', + 'string']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py index 99443a04f67..0518a75051b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 CppDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,24 +23,27 @@ class CppDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) self.expect("frame variable", - substrs = ['(Speed) SPILookHex = 5.55' # Speed by default is 5.55. - ]); + substrs=['(Speed) SPILookHex = 5.55' # Speed by default is 5.55. + ]) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -57,210 +61,238 @@ class CppDataFormatterTestCase(TestBase): # The type format list should show our custom formats. self.expect("type format list", - substrs = ['RealNumber', - 'Speed', - 'BitField', - 'Type1', - 'Type2']) + substrs=['RealNumber', + 'Speed', + 'BitField', + 'Type1', + 'Type2']) self.expect("frame variable", - patterns = ['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now. - ]); - + patterns=['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now. + ]) + # gcc4.2 on Mac OS X skips typedef chains in the DWARF output - if self.getCompiler() in ['clang', 'llvm-gcc']: + if self.getCompiler() in ['clang', 'llvm-gcc']: self.expect("frame variable", - patterns = ['\(SignalMask\) SMILookHex = 0x[0-9a-f]+' # SignalMask should look hex-ish now. - ]); + patterns=['\(SignalMask\) SMILookHex = 0x[0-9a-f]+' # SignalMask should look hex-ish now. + ]) self.expect("frame variable", matching=False, - patterns = ['\(Type4\) T4ILookChar = 0x[0-9a-f]+' # Type4 should NOT look hex-ish now. - ]); - + patterns=['\(Type4\) T4ILookChar = 0x[0-9a-f]+' # Type4 should NOT look hex-ish now. + ]) + # Now let's delete the 'Speed' custom format. self.runCmd("type format delete Speed") # The type format list should not show 'Speed' at this point. self.expect("type format list", matching=False, - substrs = ['Speed']) + substrs=['Speed']) # Delete type format for 'Speed', we should expect an error message. self.expect("type format delete Speed", error=True, - substrs = ['no custom formatter for Speed']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") - + substrs=['no custom formatter for Speed']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.expect("frame variable strarr", - substrs = ['arr = "Hello world!"']) - + substrs=['arr = "Hello world!"']) + self.runCmd("type summary clear") - - self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v") - + + self.runCmd( + "type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v") + self.expect("frame variable strptr", - substrs = ['ptr = "Hello world!"']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") - + substrs=['ptr = "Hello world!"']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.expect("frame variable strarr", - substrs = ['arr = "Hello world!']) + substrs=['arr = "Hello world!']) - # check that rdar://problem/10011145 (Standard summary format for char[] doesn't work as the result of "expr".) is solved + # check that rdar://problem/10011145 (Standard summary format for + # char[] doesn't work as the result of "expr".) is solved self.expect("p strarr", - substrs = ['arr = "Hello world!']) + substrs=['arr = "Hello world!']) self.expect("frame variable strptr", - substrs = ['ptr = "Hello world!"']) + substrs=['ptr = "Hello world!"']) self.expect("p strptr", - substrs = ['ptr = "Hello world!"']) + substrs=['ptr = "Hello world!"']) - self.expect("p (char*)\"1234567890123456789012345678901234567890123456789012345678901234ABC\"", - substrs = ['(char *) $', ' = ptr = ', ' "1234567890123456789012345678901234567890123456789012345678901234ABC"']) + self.expect( + "p (char*)\"1234567890123456789012345678901234567890123456789012345678901234ABC\"", + substrs=[ + '(char *) $', + ' = ptr = ', + ' "1234567890123456789012345678901234567890123456789012345678901234ABC"']) self.runCmd("type summary add -c Point") - + self.expect("frame variable iAmSomewhere", - substrs = ['x = 4', - 'y = 6']) - + substrs=['x = 4', + 'y = 6']) + self.expect("type summary list", - substrs = ['Point', - 'one-line']) + substrs=['Point', + 'one-line']) self.runCmd("type summary add --summary-string \"y=${var.y%x}\" Point") self.expect("frame variable iAmSomewhere", - substrs = ['y=0x']) - - self.runCmd("type summary add --summary-string \"y=${var.y},x=${var.x}\" Point") - + substrs=['y=0x']) + + self.runCmd( + "type summary add --summary-string \"y=${var.y},x=${var.x}\" Point") + self.expect("frame variable iAmSomewhere", - substrs = ['y=6', - 'x=4']) + substrs=['y=6', + 'x=4']) self.runCmd("type summary add --summary-string \"hello\" Point -e") self.expect("type summary list", - substrs = ['Point', - 'show children']) - + substrs=['Point', + 'show children']) + self.expect("frame variable iAmSomewhere", - substrs = ['hello', - 'x = 4', - '}']) + substrs=['hello', + 'x = 4', + '}']) - self.runCmd("type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") + self.runCmd( + "type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") self.expect("frame variable cool_pointer->floating", - substrs = ['Sign: true', - 'Exponent: 0x', - '80']) + substrs=['Sign: true', + 'Exponent: 0x', + '80']) self.runCmd("type summary add --summary-string \"a test\" i_am_cool") self.expect("frame variable cool_pointer", - substrs = ['a test']) + substrs=['a test']) + + self.runCmd( + "type summary add --summary-string \"a test\" i_am_cool --skip-pointers") - self.runCmd("type summary add --summary-string \"a test\" i_am_cool --skip-pointers") - self.expect("frame variable cool_pointer", - substrs = ['a test'], - matching = False) + substrs=['a test'], + matching=False) - self.runCmd("type summary add --summary-string \"${var[1-3]}\" \"int [5]\"") + self.runCmd( + "type summary add --summary-string \"${var[1-3]}\" \"int [5]\"") self.expect("frame variable int_array", - substrs = ['2', - '3', - '4']) + substrs=['2', + '3', + '4']) self.runCmd("type summary clear") - self.runCmd("type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"") - self.runCmd("type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"") + self.runCmd( + "type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"") + self.runCmd( + "type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"") self.expect("frame variable cool_array", - substrs = ['1,1,6']) + substrs=['1,1,6']) self.expect("frame variable cool_pointer", - substrs = ['3,0,0']) + substrs=['3,0,0']) # test special symbols for formatting variables into summaries - self.runCmd("type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool") + self.runCmd( + "type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool") self.runCmd("type summary delete \"i_am_cool [5]\"") - + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = cool object @ 0x', - '[1] = cool object @ 0x', - '[2] = cool object @ 0x', - '[3] = cool object @ 0x', - '[4] = cool object @ 0x']) - - # test getting similar output by exploiting ${var} = 'type @ location' for aggregates + substrs=['[0] = cool object @ 0x', + '[1] = cool object @ 0x', + '[2] = cool object @ 0x', + '[3] = cool object @ 0x', + '[4] = cool object @ 0x']) + + # test getting similar output by exploiting ${var} = 'type @ location' + # for aggregates self.runCmd("type summary add --summary-string \"${var}\" i_am_cool") - + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = i_am_cool @ 0x', - '[1] = i_am_cool @ 0x', - '[2] = i_am_cool @ 0x', - '[3] = i_am_cool @ 0x', - '[4] = i_am_cool @ 0x']) - - - # test getting same output by exploiting %T and %L together for aggregates - self.runCmd("type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool") - + substrs=['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + + # test getting same output by exploiting %T and %L together for + # aggregates + self.runCmd( + "type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool") + # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not # going to be the case self.expect("frame variable cool_array", - substrs = ['[0] = i_am_cool @ 0x', - '[1] = i_am_cool @ 0x', - '[2] = i_am_cool @ 0x', - '[3] = i_am_cool @ 0x', - '[4] = i_am_cool @ 0x']) - + substrs=['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + self.runCmd("type summary add --summary-string \"goofy\" i_am_cool") - self.runCmd("type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler") + self.runCmd( + "type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # check that unwanted type specifiers are removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"class i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"class i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"enum i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"enum i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"struct i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"struct i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # many spaces, but we still do the right thing self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"union i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"union i_am_cool\"") self.expect("frame variable the_coolest_guy", - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) # but that not *every* specifier is removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add --summary-string \"goofy\" \"wrong i_am_cool\"") + self.runCmd( + "type summary add --summary-string \"goofy\" \"wrong i_am_cool\"") self.expect("frame variable the_coolest_guy", matching=False, - substrs = ['(i_am_cooler) the_coolest_guy = goofy']) - - # check that formats are not sticking since that is the behavior we want - self.expect("frame variable iAmInt --format hex", substrs = ['(int) iAmInt = 0x00000001']) - self.expect("frame variable iAmInt", matching=False, substrs = ['(int) iAmInt = 0x00000001']) - self.expect("frame variable iAmInt", substrs = ['(int) iAmInt = 1']) + substrs=['(i_am_cooler) the_coolest_guy = goofy']) + + # check that formats are not sticking since that is the behavior we + # want + self.expect("frame variable iAmInt --format hex", + substrs=['(int) iAmInt = 0x00000001']) + self.expect( + "frame variable iAmInt", + matching=False, + substrs=['(int) iAmInt = 0x00000001']) + self.expect("frame variable iAmInt", substrs=['(int) iAmInt = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py index 2c2e0843117..e192943f381 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 DataFormatterDisablingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,62 +23,69 @@ class DataFormatterDisablingTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Check that we can properly disable all data formatter categories.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): - self.runCmd('type category enable *', check=False) + self.runCmd('type category enable *', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) #self.runCmd('type category enable system VectorTypes libcxx gnu-libstdc++ CoreGraphics CoreServices AppKit CoreFoundation objc default', check=False) - self.expect('type category list', substrs = ['system','enabled',]) + self.expect('type category list', substrs=['system', 'enabled', ]) self.expect("frame variable numbers", - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) - self.expect('frame variable string1', substrs = ['hello world']) + self.expect('frame variable string1', substrs=['hello world']) # now disable them all and check that nothing is formatted self.runCmd('type category disable *') self.expect("frame variable numbers", matching=False, - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) + + self.expect( + 'frame variable string1', + matching=False, + substrs=['hello world']) - self.expect('frame variable string1', matching=False, substrs = ['hello world']) + self.expect('type summary list', substrs=[ + 'Category: system (disabled)']) - self.expect('type summary list', substrs=['Category: system (disabled)']) + self.expect('type category list', substrs=['system', 'disabled', ]) - self.expect('type category list', substrs = ['system','disabled',]) - # now enable and check that we are back to normal self.runCmd("type category enable *") - self.expect('type category list', substrs = ['system','enabled']) + self.expect('type category list', substrs=['system', 'enabled']) self.expect("frame variable numbers", - substrs = ['[0] = 1', '[3] = 1234']) + substrs=['[0] = 1', '[3] = 1234']) - self.expect('frame variable string1', substrs = ['hello world']) + self.expect('frame variable string1', substrs=['hello world']) - self.expect('type category list', substrs = ['system','enabled']) + self.expect('type category list', substrs=['system', 'enabled']) # last check - our cleanup will re-enable everything self.runCmd('type category disable *') - self.expect('type category list', substrs = ['system','disabled']) + self.expect('type category list', substrs=['system', 'disabled']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py index 1659ade74a0..710cfa8fe12 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class EnumFormatTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,21 +27,22 @@ class EnumFormatTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) self.expect("frame variable", - substrs = ['(Foo) f = Case45', - '(int) x = 1', - '(int) y = 45', - '(int) z = 43' - ]); + substrs=['(Foo) f = Case45', + '(int) x = 1', + '(int) y = 45', + '(int) z = 43' + ]) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -55,11 +57,11 @@ class EnumFormatTestCase(TestBase): # The type format list should show our custom formats. self.expect("type format list -w default", - substrs = ['int: as type Foo']) + substrs=['int: as type Foo']) self.expect("frame variable", - substrs = ['(Foo) f = Case45', - '(int) x = Case1', - '(int) y = Case45', - '(int) z = 43' - ]); + substrs=['(Foo) f = Case45', + '(int) x = Case1', + '(int) y = Case45', + '(int) z = 43' + ]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py index df3bef091c8..d3d93dabc7f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class GlobalsDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,8 @@ class GlobalsDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,27 +43,29 @@ class GlobalsDataFormatterTestCase(TestBase): # Simply check we can get at global variables self.expect("target variable g_point", - substrs = ['JustATest']) + substrs=['JustATest']) self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) # Print some information about the variables # (we ignore the actual values) - self.runCmd("type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") + self.runCmd( + "type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") self.expect("target variable g_point", - substrs = ['x=', - 'y=']) - + substrs=['x=', + 'y=']) + self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) # Test Python code on resulting SBValue - self.runCmd("type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") + self.runCmd( + "type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") self.expect("target variable g_point", - substrs = ['x=']) - + substrs=['x=']) + self.expect("target variable g_point_pointer", - substrs = ['(Point *) g_point_pointer =']) + substrs=['(Point *) g_point_pointer =']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py index e9ac79ad08e..f4f0a485989 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NamedSummariesDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,15 +27,16 @@ class NamedSummariesDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) + # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): @@ -44,81 +46,88 @@ class NamedSummariesDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") - self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") - self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second") - self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") - + self.runCmd( + "type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") + self.runCmd( + "type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") + self.runCmd( + "type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second") + self.runCmd( + "type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") + self.expect('type summary list', substrs=['AllUseIt']) - + self.expect("frame variable first", - substrs = ['First: x=12']) + substrs=['First: x=12']) self.expect("frame variable first --summary AllUseIt", - substrs = ['AllUseIt: x=12']) - + substrs=['AllUseIt: x=12']) + # We *DO NOT* remember the summary choice anymore self.expect("frame variable first", matching=False, - substrs = ['AllUseIt: x=12']) + substrs=['AllUseIt: x=12']) self.expect("frame variable first", - substrs = ['First: x=12']) + substrs=['First: x=12']) + + self.runCmd("thread step-over") # 2 - self.runCmd("thread step-over") # 2 - self.expect("frame variable first", - substrs = ['First: x=12']) - + substrs=['First: x=12']) + self.expect("frame variable first --summary AllUseIt", - substrs = ['AllUseIt: x=12', - 'y=34']) + substrs=['AllUseIt: x=12', + 'y=34']) self.expect("frame variable second --summary AllUseIt", - substrs = ['AllUseIt: x=65', - 'y=43.25']) + substrs=['AllUseIt: x=65', + 'y=43.25']) self.expect("frame variable third --summary AllUseIt", - substrs = ['AllUseIt: x=96', - 'z=', - 'E']) + substrs=['AllUseIt: x=96', + 'z=', + 'E']) + + self.runCmd("thread step-over") # 3 - self.runCmd("thread step-over") # 3 - self.expect("frame variable second", - substrs = ['Second: x=65', - 'y=0x']) - + substrs=['Second: x=65', + 'y=0x']) + # <rdar://problem/11576143> decided that invalid summaries will raise an error # instead of just defaulting to the base summary - self.expect("frame variable second --summary NoSuchSummary",error=True, - substrs = ['must specify a valid named summary']) - + self.expect( + "frame variable second --summary NoSuchSummary", + error=True, + substrs=['must specify a valid named summary']) + self.runCmd("thread step-over") - - self.runCmd("type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") - + + self.runCmd( + "type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") + self.expect("frame variable first", - substrs = ['FirstAndFriends: x=12', - 'y=34']) + substrs=['FirstAndFriends: x=12', + 'y=34']) self.runCmd("type summary delete First") - + self.expect("frame variable first --summary FirstAndFriends", - substrs = ['FirstAndFriends: x=12', - 'y=34']) - + substrs=['FirstAndFriends: x=12', + 'y=34']) + self.expect("frame variable first", matching=True, - substrs = ['x = 12', - 'y = 34']) - + substrs=['x = 12', + 'y = 34']) + self.runCmd("type summary delete FirstAndFriends") self.expect("type summary delete NoSuchSummary", error=True) self.runCmd("type summary delete AllUseIt") - + self.expect("frame variable first", matching=False, - substrs = ['FirstAndFriends']) + substrs=['FirstAndFriends']) - self.runCmd("thread step-over") # 4 + self.runCmd("thread step-over") # 4 - self.expect("frame variable first",matching=False, - substrs = ['FirstAndFriends: x=12', - 'y=34']) + self.expect("frame variable first", matching=False, + substrs=['FirstAndFriends: x=12', + 'y=34']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index 4392cead5a1..6d38578dae7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -6,14 +6,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 ObjCDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,7 +25,7 @@ class ObjCDataFormatterTestCase(TestBase): self.build() self.plain_data_formatter_commands() - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.appkit_common_data_formatters_command() commands() @@ -49,25 +50,21 @@ class ObjCDataFormatterTestCase(TestBase): """Test formatters for NSURL.""" self.appkit_tester_impl(self.nsurl_data_formatter_commands) - @skipUnlessDarwin def test_nserror_with_run_command(self): """Test formatters for NSError.""" self.appkit_tester_impl(self.nserror_data_formatter_commands) - @skipUnlessDarwin def test_nsbundle_with_run_command(self): """Test formatters for NSBundle.""" self.appkit_tester_impl(self.nsbundle_data_formatter_commands) - @skipUnlessDarwin def test_nsexception_with_run_command(self): """Test formatters for NSException.""" self.appkit_tester_impl(self.nsexception_data_formatter_commands) - @skipUnlessDarwin def test_nsdate_with_run_command(self): """Test formatters for NSDate.""" @@ -101,14 +98,15 @@ class ObjCDataFormatterTestCase(TestBase): """Test basic ObjC formatting behavior.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -123,57 +121,58 @@ class ObjCDataFormatterTestCase(TestBase): self.runCmd("type summary add --summary-string \"${var%@}\" MyClass") self.expect("frame variable object2", - substrs = ['MyOtherClass']); - + substrs=['MyOtherClass']) + self.expect("frame variable *object2", - substrs = ['MyOtherClass']); + substrs=['MyOtherClass']) # Now let's delete the 'MyClass' custom summary. self.runCmd("type summary delete MyClass") # The type format list should not show 'MyClass' at this point. self.expect("type summary list", matching=False, - substrs = ['MyClass']) + substrs=['MyClass']) self.runCmd("type summary add --summary-string \"a test\" MyClass") - + self.expect("frame variable *object2", - substrs = ['*object2 =', - 'MyClass = a test', - 'backup = ']); - + substrs=['*object2 =', + 'MyClass = a test', + 'backup = ']) + self.expect("frame variable object2", matching=False, - substrs = ['a test']); - + substrs=['a test']) + self.expect("frame variable object", - substrs = ['a test']); - + substrs=['a test']) + self.expect("frame variable *object", - substrs = ['a test']); + substrs=['a test']) self.expect('frame variable myclass', - substrs = ['(Class) myclass = NSValue']) + substrs=['(Class) myclass = NSValue']) self.expect('frame variable myclass2', - substrs = ['(Class) myclass2 = ','NS','String']) + substrs=['(Class) myclass2 = ', 'NS', 'String']) self.expect('frame variable myclass3', - substrs = ['(Class) myclass3 = Molecule']) + substrs=['(Class) myclass3 = Molecule']) self.expect('frame variable myclass4', - substrs = ['(Class) myclass4 = NSMutableArray']) + substrs=['(Class) myclass4 = NSMutableArray']) self.expect('frame variable myclass5', - substrs = ['(Class) myclass5 = nil']) + substrs=['(Class) myclass5 = nil']) def appkit_common_data_formatters_command(self): """Test formatters for AppKit classes.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -184,132 +183,183 @@ class ObjCDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + def nsnumber_data_formatter_commands(self): # Now enable AppKit and check we are displaying Cocoa classes correctly self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num9', - substrs = ['(NSNumber *) num1 = ',' (int)5', - '(NSNumber *) num2 = ',' (float)3.1', - '(NSNumber *) num3 = ',' (double)3.14', - '(NSNumber *) num4 = ',' (long)-2', - '(NSNumber *) num5 = ',' (char)65', - '(NSNumber *) num6 = ',' (long)255', - '(NSNumber *) num7 = ','2000000', - '(NSNumber *) num9 = ',' (short)-31616']) + substrs=['(NSNumber *) num1 = ', ' (int)5', + '(NSNumber *) num2 = ', ' (float)3.1', + '(NSNumber *) num3 = ', ' (double)3.14', + '(NSNumber *) num4 = ', ' (long)-2', + '(NSNumber *) num5 = ', ' (char)65', + '(NSNumber *) num6 = ', ' (long)255', + '(NSNumber *) num7 = ', '2000000', + '(NSNumber *) num9 = ', ' (short)-31616']) self.expect('frame variable num_at1 num_at2 num_at3 num_at4', - substrs = ['(NSNumber *) num_at1 = ',' (int)12', - '(NSNumber *) num_at2 = ',' (int)-12', - '(NSNumber *) num_at3 = ',' (double)12.5', - '(NSNumber *) num_at4 = ',' (double)-12.5']) + substrs=['(NSNumber *) num_at1 = ', ' (int)12', + '(NSNumber *) num_at2 = ', ' (int)-12', + '(NSNumber *) num_at3 = ', ' (double)12.5', + '(NSNumber *) num_at4 = ', ' (double)-12.5']) def nscontainers_data_formatter_commands(self): - self.expect('frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', - substrs = ['(NSArray *) newArray = ','@"50 elements"', - '(NSDictionary *) newDictionary = ',' 12 key/value pairs', - '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs', - '(CFArrayRef) cfarray_ref = ','@"3 elements"', - '(CFMutableArrayRef) mutable_array_ref = ','@"11 elements"']) + self.expect( + 'frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', + substrs=[ + '(NSArray *) newArray = ', + '@"50 elements"', + '(NSDictionary *) newDictionary = ', + ' 12 key/value pairs', + '(NSDictionary *) newMutableDictionary = ', + ' 21 key/value pairs', + '(CFArrayRef) cfarray_ref = ', + '@"3 elements"', + '(CFMutableArrayRef) mutable_array_ref = ', + '@"11 elements"']) self.expect('frame variable iset1 iset2 imset', - substrs = ['4 indexes','512 indexes','10 indexes']) + substrs=['4 indexes', '512 indexes', '10 indexes']) - self.expect('frame variable binheap_ref', - substrs = ['(CFBinaryHeapRef) binheap_ref = ','@"21 items"']) + self.expect( + 'frame variable binheap_ref', + substrs=[ + '(CFBinaryHeapRef) binheap_ref = ', + '@"21 items"']) - self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"']) + self.expect( + 'expression -d run -- [NSArray new]', + substrs=['@"0 elements"']) def nsdata_data_formatter_commands(self): - self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', - substrs = ['(NSData *) immutableData = ',' 4 bytes', - '(NSData *) mutableData = ',' 14 bytes', - '(CFDataRef) data_ref = ','@"5 bytes"', - '(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"', - '(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"']) + self.expect( + 'frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', + substrs=[ + '(NSData *) immutableData = ', + ' 4 bytes', + '(NSData *) mutableData = ', + ' 14 bytes', + '(CFDataRef) data_ref = ', + '@"5 bytes"', + '(CFMutableDataRef) mutable_data_ref = ', + '@"5 bytes"', + '(CFMutableStringRef) mutable_string_ref = ', + ' @"Wish ya knew"']) def nsurl_data_formatter_commands(self): - self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref', - substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar', - 'cfchildurl_ref = ','@"page.html -- http://www.foo.bar', - '(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"']) - - self.expect('frame variable nsurl nsurl2 nsurl3', - substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar', - '(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar', - '(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"']) + self.expect( + 'frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref', + substrs=[ + '(CFURLRef) cfurl_ref = ', + '@"http://www.foo.bar', + 'cfchildurl_ref = ', + '@"page.html -- http://www.foo.bar', + '(CFURLRef) cfgchildurl_ref = ', + '@"?whatever -- http://www.foo.bar/page.html"']) + + self.expect( + 'frame variable nsurl nsurl2 nsurl3', + substrs=[ + '(NSURL *) nsurl = ', + '@"http://www.foo.bar', + '(NSURL *) nsurl2 =', + '@"page.html -- http://www.foo.bar', + '(NSURL *) nsurl3 = ', + '@"?whatever -- http://www.foo.bar/page.html"']) def nserror_data_formatter_commands(self): self.expect('frame variable nserror', - substrs = ['domain: @"Foobar" - code: 12']) + substrs=['domain: @"Foobar" - code: 12']) self.expect('frame variable nserrorptr', - substrs = ['domain: @"Foobar" - code: 12']) + substrs=['domain: @"Foobar" - code: 12']) self.expect('frame variable nserror->_userInfo', - substrs = ['2 key/value pairs']) + substrs=['2 key/value pairs']) - self.expect('frame variable nserror->_userInfo --ptr-depth 1 -d run-target', - substrs = ['@"a"','@"b"',"1","2"]) + self.expect( + 'frame variable nserror->_userInfo --ptr-depth 1 -d run-target', + substrs=[ + '@"a"', + '@"b"', + "1", + "2"]) def nsbundle_data_formatter_commands(self): - self.expect('frame variable bundle_string bundle_url main_bundle', - substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"', - '(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Foundation.framework"', - '(NSBundle *) main_bundle = ','data-formatter-objc']) + self.expect( + 'frame variable bundle_string bundle_url main_bundle', + substrs=[ + '(NSBundle *) bundle_string = ', + ' @"/System/Library/Frameworks/Accelerate.framework"', + '(NSBundle *) bundle_url = ', + ' @"/System/Library/Frameworks/Foundation.framework"', + '(NSBundle *) main_bundle = ', + 'data-formatter-objc']) def nsexception_data_formatter_commands(self): - self.expect('frame variable except0 except1 except2 except3', - substrs = ['(NSException *) except0 = ','name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"', - '(NSException *) except1 = ','name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"', - '(NSException *) except2 = ','name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"', - '(NSException *) except3 = ','name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"']) + self.expect( + 'frame variable except0 except1 except2 except3', + substrs=[ + '(NSException *) except0 = ', + 'name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"', + '(NSException *) except1 = ', + 'name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"', + '(NSException *) except2 = ', + 'name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"', + '(NSException *) except3 = ', + 'name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"']) def nsdate_data_formatter_commands(self): - self.expect('frame variable date1 date2', - patterns = ['(1985-04-10|1985-04-11)','(2011-01-01|2010-12-31)']) + self.expect( + 'frame variable date1 date2', + patterns=[ + '(1985-04-10|1985-04-11)', + '(2011-01-01|2010-12-31)']) # this test might fail if we hit the breakpoint late on December 31st of some given year # and midnight comes between hitting the breakpoint and running this line of code # hopefully the output will be revealing enough in that case :-) now_year = '%s-' % str(datetime.datetime.now().year) - self.expect('frame variable date3', substrs = [now_year]) - self.expect('frame variable date4', substrs = ['1970']) - self.expect('frame variable date5', substrs = [now_year]) + self.expect('frame variable date3', substrs=[now_year]) + self.expect('frame variable date4', substrs=['1970']) + self.expect('frame variable date5', substrs=[now_year]) self.expect('frame variable date1_abs date2_abs', - substrs = ['1985-04','2011-01']) + substrs=['1985-04', '2011-01']) - self.expect('frame variable date3_abs', substrs = [now_year]) - self.expect('frame variable date4_abs', substrs = ['1970']) - self.expect('frame variable date5_abs', substrs = [now_year]) + self.expect('frame variable date3_abs', substrs=[now_year]) + self.expect('frame variable date4_abs', substrs=['1970']) + self.expect('frame variable date5_abs', substrs=[now_year]) self.expect('frame variable cupertino home europe', - substrs = ['@"America/Los_Angeles"', - '@"Europe/Rome"', - '@"Europe/Paris"']) + substrs=['@"America/Los_Angeles"', + '@"Europe/Rome"', + '@"Europe/Paris"']) self.expect('frame variable cupertino_ns home_ns europe_ns', - substrs = ['@"America/Los_Angeles"', - '@"Europe/Rome"', - '@"Europe/Paris"']) - - self.expect('frame variable mut_bv', - substrs = ['(CFMutableBitVectorRef) mut_bv = ', '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00']) + substrs=['@"America/Los_Angeles"', + '@"Europe/Rome"', + '@"Europe/Paris"']) + self.expect( + 'frame variable mut_bv', + substrs=[ + '(CFMutableBitVectorRef) mut_bv = ', + '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00']) def expr_objc_data_formatter_commands(self): """Test common cases of expression parser <--> formatters interaction.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -323,36 +373,41 @@ class ObjCDataFormatterTestCase(TestBase): # check that the formatters are able to deal safely and correctly # with ValueObjects that the expression parser returns - self.expect('expression ((id)@"Hello for long enough to avoid short string types")', matching=False, - substrs = ['Hello for long enough to avoid short string types']) + self.expect( + 'expression ((id)@"Hello for long enough to avoid short string types")', + matching=False, + substrs=['Hello for long enough to avoid short string types']) - self.expect('expression -d run -- ((id)@"Hello for long enough to avoid short string types")', - substrs = ['Hello for long enough to avoid short string types']) + self.expect( + 'expression -d run -- ((id)@"Hello for long enough to avoid short string types")', + substrs=['Hello for long enough to avoid short string types']) self.expect('expr -d run -- label1', - substrs = ['Process Name']) - - self.expect('expr -d run -- @"Hello for long enough to avoid short string types"', - substrs = ['Hello for long enough to avoid short string types']) + substrs=['Process Name']) - self.expect('expr -d run --object-description -- @"Hello for long enough to avoid short string types"', - substrs = ['Hello for long enough to avoid short string types']) - self.expect('expr -d run --object-description -- @"Hello"', matching=False, - substrs = ['@"Hello" Hello']) + self.expect( + 'expr -d run -- @"Hello for long enough to avoid short string types"', + substrs=['Hello for long enough to avoid short string types']) + self.expect( + 'expr -d run --object-description -- @"Hello for long enough to avoid short string types"', + substrs=['Hello for long enough to avoid short string types']) + self.expect('expr -d run --object-description -- @"Hello"', + matching=False, substrs=['@"Hello" Hello']) def cf_data_formatter_commands(self): """Test formatters for Core OSX frameworks.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -361,50 +416,53 @@ class ObjCDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # check formatters for common Objective-C types - expect_strings = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', - '(CFRange) cf_range = location=4 length=4', - '(NSPoint) ns_point = (x = 4, y = 4)', - '(NSRange) ns_range = location=4, length=4', - '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', - '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', - '(NSSize) ns_size = (width = 5, height = 7)', - '(CGSize) cg_size = (width = 1, height = 6)', - '(CGPoint) cg_point = (x = 2, y = 7)', - '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', - '(Rect) rect = (t=4, l=8, b=4, r=7)', - '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', - '(Point) point = (v=7, h=12)', - '(Point *) point_ptr = (v=7, h=12)', - '1985', - 'foo_selector_impl']; - + expect_strings = [ + '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', + '(CFRange) cf_range = location=4 length=4', + '(NSPoint) ns_point = (x = 4, y = 4)', + '(NSRange) ns_range = location=4, length=4', + '(NSRect) ns_rect = (origin = (x = 1, y = 1), size = (width = 5, height = 5))', + '(NSRectArray) ns_rect_arr = ((x = 1, y = 1), (width = 5, height = 5)), ...', + '(NSSize) ns_size = (width = 5, height = 7)', + '(CGSize) cg_size = (width = 1, height = 6)', + '(CGPoint) cg_point = (x = 2, y = 7)', + '(CGRect) cg_rect = (origin = (x = 1, y = 2), size = (width = 7, height = 7))', + '(Rect) rect = (t=4, l=8, b=4, r=7)', + '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', + '(Point) point = (v=7, h=12)', + '(Point *) point_ptr = (v=7, h=12)', + '1985', + 'foo_selector_impl'] + if self.getArchitecture() in ['i386', 'x86_64']: expect_strings.append('(HIPoint) hi_point = (x=7, y=12)') - expect_strings.append('(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)') - expect_strings.append('(RGBColor) rgb_color = red=3 green=56 blue=35') - expect_strings.append('(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') - - self.expect("frame variable", - substrs = expect_strings) + expect_strings.append( + '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)') + expect_strings.append( + '(RGBColor) rgb_color = red=3 green=56 blue=35') + expect_strings.append( + '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') + self.expect("frame variable", + substrs=expect_strings) def kvo_data_formatter_commands(self): """Test the behavior of formatters when KVO is in use.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -420,18 +478,23 @@ class ObjCDataFormatterTestCase(TestBase): # we should be able to dynamically figure out that the KVO implementor class # is a subclass of Molecule, and use the appropriate summary for it self.runCmd("type summary add -s JustAMoleculeHere Molecule") - self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + self.expect('frame variable molecule', substrs=['JustAMoleculeHere']) self.runCmd("next") self.expect("thread list", - substrs = ['stopped', - 'step over']) - self.expect('frame variable molecule', substrs = ['JustAMoleculeHere']) + substrs=['stopped', + 'step over']) + self.expect('frame variable molecule', substrs=['JustAMoleculeHere']) self.runCmd("next") - # check that NSMutableDictionary's formatter is not confused when dealing with a KVO'd dictionary - self.expect('frame variable newMutableDictionary', substrs = ['(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs']) + # check that NSMutableDictionary's formatter is not confused when + # dealing with a KVO'd dictionary + self.expect( + 'frame variable newMutableDictionary', + substrs=[ + '(NSDictionary *) newMutableDictionary = ', + ' 21 key/value pairs']) - lldbutil.run_break_set_by_regexp (self, 'setAtoms') + lldbutil.run_break_set_by_regexp(self, 'setAtoms') self.runCmd("continue") - self.expect("frame variable _cmd",substrs = ['setAtoms:']) + self.expect("frame variable _cmd", substrs=['setAtoms:']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py index 89145553d35..5ef84b019df 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py @@ -6,30 +6,32 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import datetime import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSIndexPathDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -38,7 +40,6 @@ class NSIndexPathDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) commands() @@ -56,15 +57,58 @@ class NSIndexPathDataFormatterTestCase(TestBase): def nsindexpath_data_formatter_commands(self): # check 'frame variable' - self.expect('frame variable --ptr-depth=1 -d run -- indexPath1', substrs = ['[0] = 1']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath2', substrs = ['[0] = 1', '[1] = 2']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath3', substrs = ['[0] = 1', '[1] = 2', '[2] = 3']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath4', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) - self.expect('frame variable --ptr-depth=1 -d run -- indexPath5', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[4] = 5']) - + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath1', + substrs=['[0] = 1']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath2', + substrs=[ + '[0] = 1', + '[1] = 2']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath3', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath4', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4']) + self.expect( + 'frame variable --ptr-depth=1 -d run -- indexPath5', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[4] = 5']) + # and 'expression' - self.expect('expression --ptr-depth=1 -d run -- indexPath1', substrs = ['[0] = 1']) - self.expect('expression --ptr-depth=1 -d run -- indexPath2', substrs = ['[0] = 1', '[1] = 2']) - self.expect('expression --ptr-depth=1 -d run -- indexPath3', substrs = ['[0] = 1', '[1] = 2', '[2] = 3']) - self.expect('expression --ptr-depth=1 -d run -- indexPath4', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) - self.expect('expression --ptr-depth=1 -d run -- indexPath5', substrs = ['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[4] = 5']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath1', + substrs=['[0] = 1']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath2', + substrs=[ + '[0] = 1', + '[1] = 2']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath3', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) + self.expect('expression --ptr-depth=1 -d run -- indexPath4', + substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4']) + self.expect( + 'expression --ptr-depth=1 -d run -- indexPath5', + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[4] = 5']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py index f5c79259377..12e62f62ee9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py @@ -6,30 +6,32 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import datetime import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class NSStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def appkit_tester_impl(self,commands): + def appkit_tester_impl(self, commands): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -38,7 +40,6 @@ class NSStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) commands() @@ -58,7 +59,6 @@ class NSStringDataFormatterTestCase(TestBase): """Test formatters for NSString.""" self.appkit_tester_impl(self.nsstring_withNULs_commands) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -67,42 +67,55 @@ class NSStringDataFormatterTestCase(TestBase): def rdar11106605_commands(self): """Check that Unicode characters come out of CFString summary correctly.""" - self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.']) - self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?']) - self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt']) - self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを']) - self.expect('frame variable hebrew', substrs = ['לילה טוב']) + self.expect('frame variable italian', substrs=[ + 'L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.']) + self.expect('frame variable french', substrs=[ + 'Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?']) + self.expect('frame variable german', substrs=[ + 'Über-Ich und aus den Ansprüchen der sozialen Umwelt']) + self.expect('frame variable japanese', substrs=['色は匂へど散りぬるを']) + self.expect('frame variable hebrew', substrs=['לילה טוב']) def nsstring_data_formatter_commands(self): self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12', - substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', - # '(NSString *) str0 = ',' @"255"', - '(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"', - '(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"', - '(NSString *) str3 = ',' @"A string made with the at sign is here"', - '(NSString *) str4 = ',' @"This is string number 4 right here"', - '(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"', - '(NSString *) str6 = ',' @"1ST"', - '(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime', - '(NSString *) str9 = ',' @"a very much boring task to write a string this way!!', - '(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"', - '(NSString *) str11 = ',' @"__NSCFString"', - '(NSString *) label1 = ',' @"Process Name: "', - '(NSString *) label2 = ',' @"Process Id: "', - '(NSString *) str12 = ',' @"Process Name: a.out Process Id:']) - self.expect('frame variable attrString mutableAttrString mutableGetConst', - substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"', - '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"', - '(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"']) - - self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff']) - self.expect('frame variable path',substrs = ['usr/blah/stuff']) + substrs=['(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"', + # '(NSString *) str0 = ',' @"255"', + '(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"', + '(NSString *) str2 = ', ' @"A rather short UTF8 NSString object is here"', + '(NSString *) str3 = ', ' @"A string made with the at sign is here"', + '(NSString *) str4 = ', ' @"This is string number 4 right here"', + '(NSString *) str5 = ', ' @"{{1, 1}, {5, 5}}"', + '(NSString *) str6 = ', ' @"1ST"', + '(NSString *) str8 = ', ' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime', + '(NSString *) str9 = ', ' @"a very much boring task to write a string this way!!', + '(NSString *) str10 = ', ' @"This is a Unicode string σ number 4 right here"', + '(NSString *) str11 = ', ' @"__NSCFString"', + '(NSString *) label1 = ', ' @"Process Name: "', + '(NSString *) label2 = ', ' @"Process Id: "', + '(NSString *) str12 = ', ' @"Process Name: a.out Process Id:']) + self.expect( + 'frame variable attrString mutableAttrString mutableGetConst', + substrs=[ + '(NSAttributedString *) attrString = ', + ' @"hello world from foo"', + '(NSAttributedString *) mutableAttrString = ', + ' @"hello world from foo"', + '(NSString *) mutableGetConst = ', + ' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"']) + + self.expect('expr -d run-target -- path', substrs=['usr/blah/stuff']) + self.expect('frame variable path', substrs=['usr/blah/stuff']) def nsstring_withNULs_commands(self): """Check that the NSString formatter supports embedded NULs in the text""" - self.expect('po strwithNULs', substrs=['a very much boring task to write']) + self.expect( + 'po strwithNULs', + substrs=['a very much boring task to write']) self.expect('expr [strwithNULs length]', substrs=['54']) - self.expect('frame variable strwithNULs', substrs=['@"a very much boring task to write\\0a string this way!!']) - self.expect('po strwithNULs2', substrs=['a very much boring task to write']) + self.expect('frame variable strwithNULs', substrs=[ + '@"a very much boring task to write\\0a string this way!!']) + self.expect('po strwithNULs2', substrs=[ + 'a very much boring task to write']) self.expect('expr [strwithNULs2 length]', substrs=['52']) - self.expect('frame variable strwithNULs2', substrs=['@"a very much boring task to write\\0a string this way!!']) + self.expect('frame variable strwithNULs2', substrs=[ + '@"a very much boring task to write\\0a string this way!!']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py index 3c9be04a2f6..bf600219bce 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 DataFormatterOneIsSingularTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class DataFormatterOneIsSingularTestCase(TestBase): """Test that 1 item is not as reported as 1 items.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -54,26 +56,26 @@ class DataFormatterOneIsSingularTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable key', - substrs = ['@"1 element"']) + substrs=['@"1 element"']) self.expect('frame variable key', matching=False, - substrs = ['1 elements']) + substrs=['1 elements']) self.expect('frame variable value', - substrs = ['@"1 element"']) + substrs=['@"1 element"']) self.expect('frame variable value', matching=False, - substrs = ['1 elements']) + substrs=['1 elements']) self.expect('frame variable dict', - substrs = ['1 key/value pair']) + substrs=['1 key/value pair']) self.expect('frame variable dict', matching=False, - substrs = ['1 key/value pairs']) + substrs=['1 key/value pairs']) self.expect('frame variable imset', - substrs = ['1 index']) + substrs=['1 index']) self.expect('frame variable imset', matching=False, - substrs = ['1 indexes']) + substrs=['1 indexes']) self.expect('frame variable binheap_ref', - substrs = ['@"1 item"']) + substrs=['@"1 item"']) self.expect('frame variable binheap_ref', matching=False, - substrs = ['1 items']) + substrs=['1 items']) self.expect('frame variable immutableData', - substrs = ['1 byte']) + substrs=['1 byte']) self.expect('frame variable immutableData', matching=False, - substrs = ['1 bytes']) + substrs=['1 bytes']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py index 86cd3c42728..ebabe307661 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class PtrToArrayDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,14 +31,15 @@ class PtrToArrayDataFormatterTestCase(TestBase): """Test that LLDB handles the clang typeclass Paren correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -49,9 +51,9 @@ class PtrToArrayDataFormatterTestCase(TestBase): self.addTearDownHook(cleanup) self.expect('p *(int (*)[3])foo', - substrs = ['(int [3]) $','[0] = 1','[1] = 2','[2] = 3']) + substrs=['(int [3]) $', '[0] = 1', '[1] = 2', '[2] = 3']) self.expect('p *(int (*)[3])foo', matching=False, - substrs = ['01 00 00 00 02 00 00 00 03 00 00 00']) + substrs=['01 00 00 00 02 00 00 00 03 00 00 00']) self.expect('p *(int (*)[3])foo', matching=False, - substrs = ['0x000000030000000200000001']) + substrs=['0x000000030000000200000001']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py index c7ff28874c5..75d1853f6a7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py @@ -5,18 +5,19 @@ Test lldb data formatter subsystem. 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 PythonSynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -27,20 +28,22 @@ class PythonSynthDataFormatterTestCase(TestBase): self.build() self.rdar10960550_formatter_commands() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - self.line2 = line_number('main.cpp', '// Set cast break point at this line.') - self.line3 = line_number('main.cpp', '// Set second cast break point at this line.') + self.line2 = line_number('main.cpp', + '// Set cast break point at this line.') + self.line3 = line_number( + 'main.cpp', '// Set second cast break point at this line.') def data_formatter_commands(self): """Test using Python synthetic children provider.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -48,8 +51,8 @@ class PythonSynthDataFormatterTestCase(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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -64,9 +67,9 @@ class PythonSynthDataFormatterTestCase(TestBase): # print the f00_1 variable without a synth self.expect("frame variable f00_1", - substrs = ['a = 1', - 'b = 2', - 'r = 34']); + substrs=['a = 1', + 'b = 2', + 'r = 34']) # now set up the synth self.runCmd("script from fooSynthProvider import *") @@ -81,30 +84,32 @@ class PythonSynthDataFormatterTestCase(TestBase): # check that we get the two real vars and the fake_a variables self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 1']) # check that we do not get the extra vars self.expect("frame variable f00_1", matching=False, - substrs = ['b = 2']); - + substrs=['b = 2']) + # check access to members by name self.expect('frame variable f00_1.fake_a', - substrs = ['%d' % fake_a_val]) - + substrs=['%d' % fake_a_val]) + # check access to members by index self.expect('frame variable f00_1[1]', - substrs = ['%d' % fake_a_val]) - + substrs=['%d' % fake_a_val]) + # put synthetic children in summary in several combinations - self.runCmd("type summary add --summary-string \"fake_a=${svar.fake_a}\" foo") + self.runCmd( + "type summary add --summary-string \"fake_a=${svar.fake_a}\" foo") self.expect('frame variable f00_1', - substrs = ['fake_a=%d' % fake_a_val]) - self.runCmd("type summary add --summary-string \"fake_a=${svar[1]}\" foo") + substrs=['fake_a=%d' % fake_a_val]) + self.runCmd( + "type summary add --summary-string \"fake_a=${svar[1]}\" foo") self.expect('frame variable f00_1', - substrs = ['fake_a=%d' % fake_a_val]) - + substrs=['fake_a=%d' % fake_a_val]) + # clear the summary self.runCmd("type summary delete foo") @@ -117,9 +122,9 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00000200 self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 2']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 2']) # check that altering the object also alters fake_a self.runCmd("expr f00_1.a = 280") @@ -130,9 +135,9 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00011800 self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 280']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 280']) # check that expanding a pointer does the right thing if process.GetByteOrder() == lldb.eByteOrderLittle: @@ -141,94 +146,97 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00000c00 self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now add a filter.. it should fail self.expect("type filter add foo --child b --child j", error=True, - substrs = ['cannot add']) - + substrs=['cannot add']) + # we get the synth again.. self.expect('frame variable f00_1', matching=False, - substrs = ['b = 1', - 'j = 17']) + substrs=['b = 1', + 'j = 17']) self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now delete the synth and add the filter self.runCmd("type synth delete foo") self.runCmd("type filter add foo --child b --child j") - + self.expect('frame variable f00_1', - substrs = ['b = 2', - 'j = 18']) + substrs=['b = 2', + 'j = 18']) self.expect("frame variable --ptr-depth 1 f00_ptr", matching=False, - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) + # now add the synth and it should fail self.expect("type synth add -l fooSynthProvider foo", error=True, - substrs = ['cannot add']) - + substrs=['cannot add']) + # check the listing self.expect('type synth list', matching=False, - substrs = ['foo', - 'Python class fooSynthProvider']) - self.expect('type filter list', - substrs = ['foo', - '.b', - '.j']) - + substrs=['foo', + 'Python class fooSynthProvider']) + self.expect('type filter list', + substrs=['foo', + '.b', + '.j']) + # delete the filter, add the synth self.runCmd("type filter delete foo") self.runCmd("type synth add -l fooSynthProvider foo") - + self.expect('frame variable f00_1', matching=False, - substrs = ['b = 2', - 'j = 18']) - self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs = ['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) + substrs=['b = 2', + 'j = 18']) + self.expect("frame variable --ptr-depth 1 f00_ptr", + substrs=['r = 45', + 'fake_a = %d' % fake_a_val, + 'a = 12']) # check the listing self.expect('type synth list', - substrs = ['foo', - 'Python class fooSynthProvider']) + substrs=['foo', + 'Python class fooSynthProvider']) self.expect('type filter list', matching=False, - substrs = ['foo', - '.b', - '.j']) - + substrs=['foo', + '.b', + '.j']) + # delete the synth and check that we get good output self.runCmd("type synth delete foo") - + self.expect("frame variable f00_1", - substrs = ['a = 280', - 'b = 2', - 'j = 18']); + substrs=['a = 280', + 'b = 2', + 'j = 18']) self.expect("frame variable f00_1", matching=False, - substrs = ['fake_a = ']) + substrs=['fake_a = ']) def rdar10960550_formatter_commands(self): """Test that synthetic children persist stoppoints.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - # The second breakpoint is on a multi-line expression, so the comment can't be on the right line... - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=1, loc_exact=False) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=1, loc_exact=True) + # The second breakpoint is on a multi-line expression, so the comment + # can't be on the right line... + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line2, num_expected_locations=1, loc_exact=False) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line3, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -248,25 +256,28 @@ class PythonSynthDataFormatterTestCase(TestBase): # but their values change correctly across stop-points - in order to do this, self.runCmd("next") # does not work because it forces a wipe of the stack frame - this is why we are using this more contrived # mechanism to achieve our goal of preserving test_cast as a VO - test_cast = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('test_cast') + test_cast = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('test_cast') str_cast = str(test_cast) if self.TraceOn(): - print(str_cast) + print(str_cast) self.assertTrue(str_cast.find('A') != -1, 'could not find A in output') self.assertTrue(str_cast.find('B') != -1, 'could not find B in output') self.assertTrue(str_cast.find('C') != -1, 'could not find C in output') self.assertTrue(str_cast.find('D') != -1, 'could not find D in output') - self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0') + self.assertTrue( + str_cast.find("4 = '\\0'") != -1, + 'could not find item 4 == 0') self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver() str_cast = str(test_cast) if self.TraceOn(): - print(str_cast) + print(str_cast) # we detect that all the values of the child objects have changed - but the counter-generated item # is still fixed at 0 because it is cached - this would fail if update(self): in ftsp returned False @@ -275,4 +286,6 @@ class PythonSynthDataFormatterTestCase(TestBase): self.assertTrue(str_cast.find('X') != -1, 'could not find X in output') self.assertTrue(str_cast.find('T') != -1, 'could not find T in output') self.assertTrue(str_cast.find('F') != -1, 'could not find F in output') - self.assertTrue(str_cast.find("4 = '\\0'") != -1, 'could not find item 4 == 0') + self.assertTrue( + str_cast.find("4 = '\\0'") != -1, + 'could not find item 4 == 0') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py index 0dc2c233e2a..45fb00468e0 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py @@ -1,23 +1,30 @@ import lldb + + class fooSynthProvider: - def __init__(self, valobj, dict): - self.valobj = valobj; - self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) - def num_children(self): - return 3; - def get_child_at_index(self, index): - if index == 0: - child = self.valobj.GetChildMemberWithName('a'); - if index == 1: - child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); - if index == 2: - child = self.valobj.GetChildMemberWithName('r'); - return child; - def get_child_index(self, name): - if name == 'a': - return 0; - if name == 'fake_a': - return 1; - return 2; - def update(self): - return True
\ No newline at end of file + + def __init__(self, valobj, dict): + self.valobj = valobj + self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) + + def num_children(self): + return 3 + + def get_child_at_index(self, index): + if index == 0: + child = self.valobj.GetChildMemberWithName('a') + if index == 1: + child = self.valobj.CreateChildAtOffset('fake_a', 1, self.int_type) + if index == 2: + child = self.valobj.GetChildMemberWithName('r') + return child + + def get_child_index(self, name): + if name == 'a': + return 0 + if name == 'fake_a': + return 1 + return 2 + + def update(self): + return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py index d162b00db32..b96dbac6f50 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py @@ -2,31 +2,39 @@ import lldb counter = 0 + class ftsp: - def __init__(self, valobj, dict): - self.valobj = valobj; - def num_children(self): - if self.char.IsValid(): - return 5; - return 0; - def get_child_index(self,name): - return 0; - def get_child_at_index(self,index): - if index == 0: - return self.x.Cast(self.char) - if index == 4: - return self.valobj.CreateValueFromExpression(str(index),'(char)('+str(self.count)+')') - return self.x.CreateChildAtOffset(str(index), - index, - self.char); - def update(self): - self.x = self.valobj.GetChildMemberWithName('x'); - self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar) - global counter - self.count = counter - counter = counter + 1 - return True # important: if we return False here, or fail to return, the test will fail + + def __init__(self, valobj, dict): + self.valobj = valobj + + def num_children(self): + if self.char.IsValid(): + return 5 + return 0 + + def get_child_index(self, name): + return 0 + + def get_child_at_index(self, index): + if index == 0: + return self.x.Cast(self.char) + if index == 4: + return self.valobj.CreateValueFromExpression( + str(index), '(char)(' + str(self.count) + ')') + return self.x.CreateChildAtOffset(str(index), + index, + self.char) + + def update(self): + self.x = self.valobj.GetChildMemberWithName('x') + self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar) + global counter + self.count = counter + counter = counter + 1 + return True # important: if we return False here, or fail to return, the test will fail + def __lldb_init_module(debugger, dict): - global counter - counter = 0
\ No newline at end of file + global counter + counter = 0 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py index 7ebc1c14ce1..3355ca16305 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class ScriptDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,14 +31,15 @@ class ScriptDataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -51,121 +53,133 @@ class ScriptDataFormatterTestCase(TestBase): # Set the script here to ease the formatting script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');' - self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool --python-script \"%s\"" % + script) self.expect('type summary list i_am_cool', substrs=[script]) self.expect("frame variable one", - substrs = ['Hello from Python', - '1 time!']) + substrs=['Hello from Python', + '1 time!']) self.expect("frame variable two", - substrs = ['Hello from Python', - '4 times!']) - - self.runCmd("n"); # skip ahead to make values change + substrs=['Hello from Python', + '4 times!']) + + self.runCmd("n") # skip ahead to make values change self.expect("frame variable three", - substrs = ['Hello from Python, 10 times!', - 'Hello from Python, 4 times!']) + substrs=['Hello from Python, 10 times!', + 'Hello from Python, 4 times!']) + + self.runCmd("n") # skip ahead to make values change - self.runCmd("n"); # skip ahead to make values change - self.expect("frame variable two", - substrs = ['Hello from Python', - '1 time!']) + substrs=['Hello from Python', + '1 time!']) script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'int says \' + a_val; return str;' # Check that changes in the script are immediately reflected - self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool --python-script \"%s\"" % + script) self.expect("frame variable two", - substrs = ['int says 1']) - + substrs=['int says 1']) + self.expect("frame variable twoptr", - substrs = ['int says 1']) + substrs=['int says 1']) # Change the summary - self.runCmd("type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") + self.runCmd( + "type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") self.expect("frame variable two", - substrs = ['int says 1', - 'and float says 2.71']) + substrs=['int says 1', + 'and float says 2.71']) # Try it for pointers self.expect("frame variable twoptr", - substrs = ['int says 1', - 'and float says 2.71']) + substrs=['int says 1', + 'and float says 2.71']) # Force a failure for pointers - self.runCmd("type summary add i_am_cool -p --python-script \"%s\"" % script) + self.runCmd( + "type summary add i_am_cool -p --python-script \"%s\"" % + script) self.expect("frame variable twoptr", matching=False, - substrs = ['and float says 2.71']) + substrs=['and float says 2.71']) - script = 'return \'Python summary\''; + script = 'return \'Python summary\'' - self.runCmd("type summary add --name test_summary --python-script \"%s\"" % script) + self.runCmd( + "type summary add --name test_summary --python-script \"%s\"" % + script) # attach the Python named summary to someone self.expect("frame variable one --summary test_summary", - substrs = ['Python summary']) + substrs=['Python summary']) # should not bind to the type self.expect("frame variable two", matching=False, - substrs = ['Python summary']) + substrs=['Python summary']) # and should not stick to the variable - self.expect("frame variable one",matching=False, - substrs = ['Python summary']) + self.expect("frame variable one", matching=False, + substrs=['Python summary']) - self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool --summary-string \"Text summary\"") # should be temporary only - self.expect("frame variable one",matching=False, - substrs = ['Python summary']) + self.expect("frame variable one", matching=False, + substrs=['Python summary']) # use the type summary self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) - self.runCmd("n"); # skip ahead to make values change + self.runCmd("n") # skip ahead to make values change # both should use the type summary now self.expect("frame variable one", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) # disable type summary for pointers, and make a Python regex summary - self.runCmd("type summary add i_am_cool -p --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool -p --summary-string \"Text summary\"") self.runCmd("type summary add -x cool --python-script \"%s\"" % script) # variables should stick to the type summary self.expect("frame variable one", - substrs = ['Text summary']) + substrs=['Text summary']) self.expect("frame variable two", - substrs = ['Text summary']) + substrs=['Text summary']) # array and pointer should match the Python one self.expect("frame variable twoptr", - substrs = ['Python summary']) - + substrs=['Python summary']) + self.expect("frame variable array", - substrs = ['Python summary']) + substrs=['Python summary']) # return pointers to the type summary - self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") + self.runCmd( + "type summary add i_am_cool --summary-string \"Text summary\"") self.expect("frame variable one", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable two", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable twoptr", - substrs = ['Text summary']) - + substrs=['Text summary']) + self.expect("frame variable array", - substrs = ['Python summary']) + substrs=['Python summary']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py index c186f1465cf..5b52277e8b7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py @@ -5,19 +5,24 @@ Test lldb data formatter subsystem. 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 SkipSummaryDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -34,15 +39,15 @@ class SkipSummaryDataFormatterTestCase(TestBase): self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) #import lldbsuite.test.lldbutil as lldbutil - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) - + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -55,122 +60,146 @@ class SkipSummaryDataFormatterTestCase(TestBase): # Setup the summaries for this scenario #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string") - self.runCmd("type summary add --summary-string \"Level 1\" \"DeepData_1\"") - self.runCmd("type summary add --summary-string \"Level 2\" \"DeepData_2\" -e") - self.runCmd("type summary add --summary-string \"Level 3\" \"DeepData_3\"") - self.runCmd("type summary add --summary-string \"Level 4\" \"DeepData_4\"") - self.runCmd("type summary add --summary-string \"Level 5\" \"DeepData_5\"") - + self.runCmd( + "type summary add --summary-string \"Level 1\" \"DeepData_1\"") + self.runCmd( + "type summary add --summary-string \"Level 2\" \"DeepData_2\" -e") + self.runCmd( + "type summary add --summary-string \"Level 3\" \"DeepData_3\"") + self.runCmd( + "type summary add --summary-string \"Level 4\" \"DeepData_4\"") + self.runCmd( + "type summary add --summary-string \"Level 5\" \"DeepData_5\"") + # Default case, just print out summaries self.expect('frame variable', - substrs = ['(DeepData_1) data1 = Level 1', - '(DeepData_2) data2 = Level 2 {', - 'm_child1 = Level 3', - 'm_child2 = Level 3', - 'm_child3 = Level 3', - 'm_child4 = Level 3', - '}']) + substrs=['(DeepData_1) data1 = Level 1', + '(DeepData_2) data2 = Level 2 {', + 'm_child1 = Level 3', + 'm_child2 = Level 3', + 'm_child3 = Level 3', + 'm_child4 = Level 3', + '}']) # Skip the default (should be 1) levels of summaries self.expect('frame variable --no-summary-depth', - substrs = ['(DeepData_1) data1 = {', - 'm_child1 = 0x', - '}', - '(DeepData_2) data2 = {', - 'm_child1 = Level 3', - 'm_child2 = Level 3', - 'm_child3 = Level 3', - 'm_child4 = Level 3', - '}']) + substrs=['(DeepData_1) data1 = {', + 'm_child1 = 0x', + '}', + '(DeepData_2) data2 = {', + 'm_child1 = Level 3', + 'm_child2 = Level 3', + 'm_child3 = Level 3', + 'm_child4 = Level 3', + '}']) # Now skip 2 levels of summaries self.expect('frame variable --no-summary-depth=2', - substrs = ['(DeepData_1) data1 = {', - 'm_child1 = 0x', - '}', - '(DeepData_2) data2 = {', - 'm_child1 = {', - 'm_child1 = 0x', - 'Level 4', - 'm_child2 = {', - 'm_child3 = {', - '}']) + substrs=['(DeepData_1) data1 = {', + 'm_child1 = 0x', + '}', + '(DeepData_2) data2 = {', + 'm_child1 = {', + 'm_child1 = 0x', + 'Level 4', + 'm_child2 = {', + 'm_child3 = {', + '}']) # Check that no "Level 3" comes out - self.expect('frame variable data1.m_child1 --no-summary-depth=2', matching=False, - substrs = ['Level 3']) + self.expect( + 'frame variable data1.m_child1 --no-summary-depth=2', + matching=False, + substrs=['Level 3']) # Now expand a pointer with 2 level of skipped summaries self.expect('frame variable data1.m_child1 --no-summary-depth=2', - substrs = ['(DeepData_2 *) data1.m_child1 = 0x']) + substrs=['(DeepData_2 *) data1.m_child1 = 0x']) # Deref and expand said pointer self.expect('frame variable *data1.m_child1 --no-summary-depth=2', - substrs = ['(DeepData_2) *data1.m_child1 = {', - 'm_child2 = {', - 'm_child1 = 0x', - 'Level 4', - '}']) + substrs=['(DeepData_2) *data1.m_child1 = {', + 'm_child2 = {', + 'm_child1 = 0x', + 'Level 4', + '}']) # Expand an expression, skipping 2 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=2', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_child2 = {', - 'm_child1 = Level 5', - 'm_child2 = Level 5', - 'm_child3 = Level 5', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2 --no-summary-depth=2', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_child2 = {', + 'm_child1 = Level 5', + 'm_child2 = Level 5', + 'm_child3 = Level 5', + '}']) # Expand same expression, skipping only 1 layer of summaries - self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=1', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_child1 = 0x', - 'Level 4', - 'm_child2 = Level 4', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2 --no-summary-depth=1', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_child1 = 0x', + 'Level 4', + 'm_child2 = Level 4', + '}']) # Bad debugging info on SnowLeopard gcc (Apple Inc. build 5666). # Skip the following tests if the condition is met. if self.getCompiler().endswith('gcc') and not self.getCompiler().endswith('llvm-gcc'): - import re - gcc_version_output = system([[lldbutil.which(self.getCompiler()), "-v"]])[1] - #print("my output:", gcc_version_output) - for line in gcc_version_output.split(os.linesep): - m = re.search('\(Apple Inc\. build ([0-9]+)\)', line) - #print("line:", line) - if m: - gcc_build = int(m.group(1)) - #print("gcc build:", gcc_build) - if gcc_build >= 5666: - # rdar://problem/9804600" - self.skipTest("rdar://problem/9804600 wrong namespace for std::string in debug info") + import re + gcc_version_output = system( + [[lldbutil.which(self.getCompiler()), "-v"]])[1] + #print("my output:", gcc_version_output) + for line in gcc_version_output.split(os.linesep): + m = re.search('\(Apple Inc\. build ([0-9]+)\)', line) + #print("line:", line) + if m: + gcc_build = int(m.group(1)) + #print("gcc build:", gcc_build) + if gcc_build >= 5666: + # rdar://problem/9804600" + self.skipTest( + "rdar://problem/9804600 wrong namespace for std::string in debug info") # Expand same expression, skipping 3 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3', - substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', - 'm_some_text = "Just a test"', - 'm_child2 = {', - 'm_some_text = "Just a test"']) - - # Expand within a standard string (might depend on the implementation of the C++ stdlib you use) - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2', - substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', - 'm_some_text = {', - '_M_dataplus = (_M_p = "Just a test")']) + self.expect( + 'frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3', + substrs=[ + '(DeepData_3) data1.m_child1->m_child2 = {', + 'm_some_text = "Just a test"', + 'm_child2 = {', + 'm_some_text = "Just a test"']) + + # Expand within a standard string (might depend on the implementation + # of the C++ stdlib you use) + self.expect( + 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2', + substrs=[ + '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', + 'm_some_text = {', + '_M_dataplus = (_M_p = "Just a test")']) # Repeat the above, but only skip 1 level of summaries - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1', - substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', - 'm_some_text = "Just a test"', - '}']) - - # Change summary and expand, first without --no-summary-depth then with --no-summary-depth - self.runCmd("type summary add --summary-string \"${var.m_some_text}\" DeepData_5") - - self.expect('fr var data2.m_child4.m_child2.m_child2', - substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) - - self.expect('fr var data2.m_child4.m_child2.m_child2 --no-summary-depth', - substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = {', - 'm_some_text = "Just a test"', - '}']) + self.expect( + 'frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1', + substrs=[ + '(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', + 'm_some_text = "Just a test"', + '}']) + + # Change summary and expand, first without --no-summary-depth then with + # --no-summary-depth + self.runCmd( + "type summary add --summary-string \"${var.m_some_text}\" DeepData_5") + + self.expect('fr var data2.m_child4.m_child2.m_child2', substrs=[ + '(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) + + self.expect( + 'fr var data2.m_child4.m_child2.m_child2 --no-summary-depth', + substrs=[ + '(DeepData_5) data2.m_child4.m_child2.m_child2 = {', + 'm_some_text = "Just a test"', + '}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py index b3f8ba7d048..9e82f11ff36 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py @@ -5,18 +5,21 @@ Test lldb data formatter subsystem. 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 SmartArrayDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test data formatter commands.""" self.build() @@ -32,7 +35,8 @@ class SmartArrayDataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -40,9 +44,9 @@ class SmartArrayDataFormatterTestCase(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']) + # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): @@ -56,338 +60,400 @@ class SmartArrayDataFormatterTestCase(TestBase): self.runCmd("type summary add --summary-string \"${var%V}\" SomeData") self.expect("frame variable data", - substrs = ['SomeData @ 0x']) + substrs=['SomeData @ 0x']) # ${var%s} - self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%s}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) - - self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") - + substrs=['ptr = \"', + 'Nested Hello world!']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") + self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) - + substrs=['arr = \"', + 'Hello world!']) + self.expect("frame variable other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) # ${var%c} - self.runCmd("type summary add --summary-string \"ptr = ${var%c}\" \"char *\"") - + self.runCmd( + "type summary add --summary-string \"ptr = ${var%c}\" \"char *\"") + self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) - + substrs=['arr = \"', + 'Nested Hello world!']) + self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = \"', - 'Nested Hello world!']) + substrs=['arr = \"', + 'Nested Hello world!']) # ${var%char[]} - self.runCmd("type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) # ${var%a} - self.runCmd("type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("frame variable other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) self.expect("p strarr", - substrs = ['arr = \"', - 'Hello world!']) + substrs=['arr = \"', + 'Hello world!']) self.expect("p other.strarr", - substrs = ['arr = ', - 'Nested Hello world!']) + substrs=['arr = ', + 'Nested Hello world!']) - self.runCmd("type summary add --summary-string \"ptr = ${var%a}\" \"char *\"") + self.runCmd( + "type summary add --summary-string \"ptr = ${var%a}\" \"char *\"") self.expect("frame variable strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("frame variable other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) + + self.runCmd( + "type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"") - self.runCmd("type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"") - # I do not know the size of the data, but you are asking for a full array slice.. # use the ${var%char[]} to obtain a string as result self.expect("frame variable strptr", matching=False, - substrs = ['ptr = \"', - 'Hello world!']) - + substrs=['ptr = \"', + 'Hello world!']) + self.expect("frame variable other.strptr", matching=False, - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) self.expect("p strptr", matching=False, - substrs = ['ptr = \"', - 'Hello world!']) + substrs=['ptr = \"', + 'Hello world!']) self.expect("p other.strptr", matching=False, - substrs = ['ptr = \"', - 'Nested Hello world!']) + substrs=['ptr = \"', + 'Nested Hello world!']) # You asked an array-style printout... - self.runCmd("type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"") - + self.runCmd( + "type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"") + self.expect("frame variable strptr", - substrs = ['ptr = ', - '[{H},{e}]']) - + substrs=['ptr = ', + '[{H},{e}]']) + self.expect("frame variable other.strptr", - substrs = ['ptr = ', - '[{N},{e}]']) + substrs=['ptr = ', + '[{N},{e}]']) self.expect("p strptr", - substrs = ['ptr = ', - '[{H},{e}]']) + substrs=['ptr = ', + '[{H},{e}]']) self.expect("p other.strptr", - substrs = ['ptr = ', - '[{N},{e}]']) + substrs=['ptr = ', + '[{N},{e}]']) # using [] is required here - self.runCmd("type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"") - - self.expect("frame variable intarr",matching=False, - substrs = ['0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) - - self.expect("frame variable other.intarr", matching=False, - substrs = ['0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) - - self.runCmd("type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) - - self.expect("frame variable other.intarr", - substrs = ['intarr = arr =', - '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + self.runCmd( + "type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"") + + self.expect("frame variable intarr", matching=False, substrs=[ + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect("frame variable other.intarr", matching=False, substrs=[ + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"") + + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr =', + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '{0x00000001},{0x00000001},{0x00000002},{0x00000003},{0x00000005}']) - - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}']) + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") + + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '{0x00000001},{0x00000001},{0x00000002},{0x00000003},{0x00000005}']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}']) # printing full array as an array - self.runCmd("type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"") - - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + self.runCmd( + "type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"") - self.expect("frame variable other.intarr", - substrs = ['intarr = arr =', - '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) + + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr =', + '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"") - - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '{78.5},{77.25},{78},{76.125},{76.75},{76.875},{77}']) - - self.expect("frame variable other.flarr", - substrs = ['flarr = arr = ', - '{25.5},{25.25},{25.125},{26.75},{27.375},{27.5},{26.125}']) - + self.runCmd( + "type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"") + + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '{78.5},{77.25},{78},{76.125},{76.75},{76.875},{77}']) + + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr = ', + '{25.5},{25.25},{25.125},{26.75},{27.375},{27.5},{26.125}']) + # printing full array as an array - self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"") - + self.runCmd( + "type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"") + self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '78.5,77.25,78,76.125,76.75,76.875,77']) - + substrs=['flarr = arr =', + '78.5,77.25,78,76.125,76.75,76.875,77']) + self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '25.5,25.25,25.125,26.75,27.375,27.5,26.125']) + substrs=['flarr = arr =', + '25.5,25.25,25.125,26.75,27.375,27.5,26.125']) # using array smart summary strings for pointers should make no sense - self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"") - self.runCmd("type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"") self.expect("frame variable flptr", matching=False, - substrs = ['78.5,77.25,78,76.125,76.75,76.875,77']) - + substrs=['78.5,77.25,78,76.125,76.75,76.875,77']) + self.expect("frame variable intptr", matching=False, - substrs = ['1,1,2,3,5']) + substrs=['1,1,2,3,5']) # use y and Y - self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"") - self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) else: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '42 9d 00 00,42 9a 80 00,42 9c 00 00,42 98 40 00,42 99 80 00,42 99 c0 00,42 9a 00 00']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '42 9d 00 00,42 9a 80 00,42 9c 00 00,42 98 40 00,42 99 80 00,42 99 c0 00,42 9a 00 00']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) else: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '41 cc 00 00,41 ca 00 00,41 c9 00 00,41 d6 00 00,41 db 00 00,41 dc 00 00,41 d1 00 00']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '41 cc 00 00,41 ca 00 00,41 c9 00 00,41 d6 00 00,41 db 00 00,41 dc 00 00,41 d1 00 00']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) else: - self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '00 00 00 01,00 00 00 01,00 00 00 02,00 00 00 03,00 00 00 05']) + self.expect( + "frame variable intarr", + substrs=[ + 'intarr = arr =', + '00 00 00 01,00 00 00 01,00 00 00 02,00 00 00 03,00 00 00 05']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) else: - self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '00 00 00 09,00 00 00 08,00 00 00 07,00 00 00 06,00 00 00 05']) - - self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"") - self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") - + self.expect( + "frame variable other.intarr", + substrs=[ + 'intarr = arr = ', + '00 00 00 09,00 00 00 08,00 00 00 07,00 00 00 06,00 00 00 05']) + + self.runCmd( + "type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"") + self.runCmd( + "type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") + if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '00 00 9d 42 ...B,00 80 9a 42 ...B,00 00 9c 42 ...B,00 40 98 42 .@.B,00 80 99 42 ...B,00 c0 99 42 ...B,00 00 9a 42 ...B']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '00 00 9d 42 ...B,00 80 9a 42 ...B,00 00 9c 42 ...B,00 40 98 42 .@.B,00 80 99 42 ...B,00 c0 99 42 ...B,00 00 9a 42 ...B']) else: - self.expect("frame variable flarr", - substrs = ['flarr = arr =', - '42 9d 00 00 B...,42 9a 80 00 B...,42 9c 00 00 B...,42 98 40 00 B.@.,42 99 80 00 B...,42 99 c0 00 B...,42 9a 00 00 B...']) + self.expect( + "frame variable flarr", + substrs=[ + 'flarr = arr =', + '42 9d 00 00 B...,42 9a 80 00 B...,42 9c 00 00 B...,42 98 40 00 B.@.,42 99 80 00 B...,42 99 c0 00 B...,42 9a 00 00 B...']) if process.GetByteOrder() == lldb.eByteOrderLittle: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '00 00 cc 41 ...A,00 00 ca 41 ...A,00 00 c9 41 ...A,00 00 d6 41 ...A,00 00 db 41 ...A,00 00 dc 41 ...A,00 00 d1 41 ...A']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '00 00 cc 41 ...A,00 00 ca 41 ...A,00 00 c9 41 ...A,00 00 d6 41 ...A,00 00 db 41 ...A,00 00 dc 41 ...A,00 00 d1 41 ...A']) else: - self.expect("frame variable other.flarr", - substrs = ['flarr = arr =', - '41 cc 00 00 A...,41 ca 00 00 A...,41 c9 00 00 A...,41 d6 00 00 A...,41 db 00 00 A...,41 dc 00 00 A...,41 d1 00 00 A...']) + self.expect( + "frame variable other.flarr", + substrs=[ + 'flarr = arr =', + '41 cc 00 00 A...,41 ca 00 00 A...,41 c9 00 00 A...,41 d6 00 00 A...,41 db 00 00 A...,41 dc 00 00 A...,41 d1 00 00 A...']) if process.GetByteOrder() == lldb.eByteOrderLittle: self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '....,01 00 00 00', - '....,05 00 00 00']) + substrs=['intarr = arr =', + '....,01 00 00 00', + '....,05 00 00 00']) else: self.expect("frame variable intarr", - substrs = ['intarr = arr =', - '....,00 00 00 01', - '....,00 00 00 05']) + substrs=['intarr = arr =', + '....,00 00 00 01', + '....,00 00 00 05']) if process.GetByteOrder() == lldb.eByteOrderLittle: self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '09 00 00 00', - '....,07 00 00 00']) + substrs=['intarr = arr = ', + '09 00 00 00', + '....,07 00 00 00']) else: self.expect("frame variable other.intarr", - substrs = ['intarr = arr = ', - '00 00 00 09', - '....,00 00 00 07']) + substrs=['intarr = arr = ', + '00 00 00 09', + '....,00 00 00 07']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py index 083f713c259..2b63dbb1c83 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 LibCxxAtomicTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,30 +24,39 @@ class LibCxxAtomicTestCase(TestBase): return var @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test(self): """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) + s = self.get_variable('s') i = self.get_variable('i') - - if self.TraceOn(): print(s) - if self.TraceOn(): print(i) - + + if self.TraceOn(): + print(s) + if self.TraceOn(): + print(i) + self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5") self.assertTrue(s.GetNumChildren() == 2, "s has two children") - self.assertTrue(s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, "s.x == 1") - self.assertTrue(s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, "s.y == 2") + self.assertTrue( + s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, + "s.x == 1") + self.assertTrue( + s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, + "s.y == 2") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py index a5eec8a0362..6a832e02990 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 LibCxxFunctionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,28 +24,33 @@ class LibCxxFunctionTestCase(TestBase): return var @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test(self): """Test that std::function as defined by libc++ is correctly printed by LLDB""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) + f1 = self.get_variable('f1') f2 = self.get_variable('f2') - - if self.TraceOn(): print(f1) - if self.TraceOn(): print(f2) - + + if self.TraceOn(): + print(f1) + if self.TraceOn(): + print(f2) + self.assertTrue(f1.GetValueAsUnsigned(0) != 0, 'f1 has a valid value') self.assertTrue(f2.GetValueAsUnsigned(0) != 0, 'f2 has a valid value') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py index d452c1be69b..f0857f420fc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py @@ -5,37 +5,44 @@ Test lldb data formatter subsystem. 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 InitializerListTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") - @expectedFailureAll(oslist=["linux"], bugnumber="fails on clang 3.5 and tot") + @expectedFailureAll( + oslist=["linux"], + bugnumber="fails on clang 3.5 and tot") def test(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) - self.expect("frame variable ili", substrs = ['[1] = 2','[4] = 5']) - self.expect("frame variable ils", substrs = ['[4] = "surprise it is a long string!! yay!!"']) + self.expect("frame variable ili", substrs=['[1] = 2', '[4] = 5']) + self.expect("frame variable ils", substrs=[ + '[4] = "surprise it is a long string!! yay!!"']) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py index 23f6956cf3f..cbcdc2ce739 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 LibcxxIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that libc++ iterators format properly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,21 +50,31 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 0', + 'second = 12']) + self.expect('expr iimI', substrs=['first = 0', 'second = 12']) - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index 6fcdc37465d..61101411f65 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -5,13 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,31 +23,39 @@ class LibcxxListDataFormatterTestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - self.line2 = line_number('main.cpp', '// Set second break point at this line.') - self.line3 = line_number('main.cpp', '// Set third break point at this line.') - self.line4 = line_number('main.cpp', '// Set fourth break point at this line.') + self.line2 = line_number('main.cpp', + '// Set second break point at this line.') + self.line3 = line_number('main.cpp', + '// Set third break point at this line.') + self.line4 = line_number('main.cpp', + '// Set fourth break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://25499635") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - 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.line2, num_expected_locations=-1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=-1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line4, num_expected_locations=-1) + + 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.line2, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line3, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line4, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -54,135 +64,154 @@ class LibcxxListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable numbers_list --show-types") - self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("p numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 1 items', - '[0] = ', - '0x12345678']) + substrs=['list has 1 items', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['list has 4 items', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); + substrs=['0x11223344']) self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['list has 4 items', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("type format delete int") self.runCmd("c") self.expect("frame variable text_list", - substrs = ['list has 3 items', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart']) + substrs=['list has 3 items', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") self.expect("p text_list", - substrs = ['list has 3 items', - '\"goofy\"', - '\"is\"', - '\"smart\"']) - + substrs=['list has 3 items', + '\"goofy\"', + '\"is\"', + '\"smart\"']) + self.runCmd("n") # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + substrs=['!!!']) + self.runCmd("continue") - + # check that the list provider correctly updates if elements move countingList = self.frame().FindVariable("countingList") countingList.SetPreferDynamicValue(True) countingList.SetPreferSyntheticValue(True) - - self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141") - self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141") - + + self.assertTrue(countingList.GetChildAtIndex( + 0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141") + self.assertTrue(countingList.GetChildAtIndex( + 1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141") + self.runCmd("continue") - self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "uniqued list[0] == 3141") - self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, "uniqued list[1] == 3142") + self.assertTrue( + countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, + "uniqued list[0] == 3141") + self.assertTrue( + countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, + "uniqued list[1] == 3142") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py index 9e68e1dbc00..e2e082c795f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py @@ -6,19 +6,21 @@ corruption). from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @add_test_categories(["pyapi"]) @skipIfDarwin # rdar://25499635 def test_with_run_command(self): @@ -27,29 +29,47 @@ class LibcxxListDataFormatterTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") - file_spec = lldb.SBFileSpec ("main.cpp", False) - breakpoint1 = target.BreakpointCreateBySourceRegex('// Set break point at this line.', file_spec) + file_spec = lldb.SBFileSpec("main.cpp", False) + breakpoint1 = target.BreakpointCreateBySourceRegex( + '// Set break point at this line.', file_spec) self.assertTrue(breakpoint1 and breakpoint1.IsValid()) - breakpoint2 = target.BreakpointCreateBySourceRegex('// Set second break point at this line.', file_spec) + breakpoint2 = target.BreakpointCreateBySourceRegex( + '// Set second break point at this line.', file_spec) self.assertTrue(breakpoint2 and breakpoint2.IsValid()) # Run the program, it should stop at breakpoint 1. - process = target.LaunchSimple(None, None, self.get_process_working_directory()) - lldbutil.skip_if_library_missing(self, target, lldbutil.PrintableRegex("libc\+\+")) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + lldbutil.skip_if_library_missing( + self, target, lldbutil.PrintableRegex("libc\+\+")) self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) # verify our list is displayed correctly - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[5] = 6']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[5] = 6']) # Continue to breakpoint 2. process.Continue() self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) # The list is now inconsistent. However, we should be able to get the first three # elements at least (and most importantly, not crash). - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) # Run to completion. process.Continue() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index cecc3178b31..7433a0b0da2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. 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 LibcxxMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,259 +45,269 @@ class LibcxxMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) - self.runCmd("continue"); - + self.runCmd("continue") + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) - self.runCmd("continue"); + self.runCmd("continue") self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py index eb74818c91f..66091e6e113 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -5,35 +5,39 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMultiMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -42,259 +46,269 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py index cfdfd07ddec..d40bce83e0a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. 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 LibcxxMultiSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,30 +45,78 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"]) + self.expect( + "frame variable ii", + substrs=[ + "size=6", + "[0] = 0", + "[1] = 1", + "[2] = 2", + "[3] = 3", + "[4] = 4", + "[5] = 5"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("frame variable ii[2]",substrs = [" = 2"]) + self.expect( + "frame variable ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect( + "p ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable ii[2]", substrs=[" = 2"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) - self.expect("frame variable ss",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) + self.expect("frame variable ss", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"']) + self.expect( + "frame variable ss", + substrs=[ + "size=2", + '[0] = "a"', + '[1] = "a very long string is right here"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("frame variable ss[2]",substrs = [' = "b"']) + self.expect( + "frame variable ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect( + "p ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect("frame variable ss[2]", substrs=[' = "b"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) + self.expect( + "frame variable ss", + substrs=[ + "size=3", + '[0] = "a"', + '[1] = "a very long string is right here"', + '[2] = "c"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py index 00c1e548cf6..be1547ea5d8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -5,24 +5,25 @@ Test lldb data formatter subsystem. 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 LibcxxSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - + # bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py index 76eedb8c891..b0e84121dde 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. 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 LibcxxStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,22 +25,24 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,40 +51,51 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) self.runCmd("n") - TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne"); + TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne") summaryOptions = lldb.SBTypeSummaryOptions() summaryOptions.SetCapping(lldb.eTypeSummaryUncapped) uncappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(uncappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions) uncappedSummary = uncappedSummaryStream.GetData() - self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string") + self.assertTrue(uncappedSummary.find("someText") > 0, + "uncappedSummary does not include the full string") summaryOptions.SetCapping(lldb.eTypeSummaryCapped) cappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(cappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions) cappedSummary = cappedSummaryStream.GetData() - self.assertTrue(cappedSummary.find("someText") <= 0, "cappedSummary includes the full string") - - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.assertTrue( + cappedSummary.find("someText") <= 0, + "cappedSummary includes the full string") + + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py index 4765cd70f67..8a08d38975c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py @@ -5,34 +5,37 @@ Test lldb data formatter subsystem. 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 LibcxxUnorderedDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,12 +44,14 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) self.look_for_content_and_continue( "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me']) @@ -72,6 +77,6 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): '(\[\d\] = "world"(\\n|.)+){2}']) def look_for_content_and_continue(self, var_name, patterns): - self.expect( ("frame variable %s" % var_name), patterns=patterns) - self.expect( ("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py index fe3b6c115e3..43d5ad4f103 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 LibcxxVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows. + @skipIfWindows # libc++ not ported to Windows. def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - 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) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +50,33 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) - - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) + + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py index 9a145fba73e..719ed730050 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. 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 LibcxxVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "break here")) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,51 +45,54 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") @@ -94,88 +101,89 @@ class LibcxxVectorDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); + substrs=['1234']) # clear out the vector and see that we do the right thing once again lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); + substrs=['is']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py index dbaa37daa2d..53ab11bcc8c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 StdIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,24 @@ class StdIteratorDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") def test_with_run_command(self): """Test that libstdcpp iterators format properly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,19 +49,29 @@ class StdIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) - - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) - - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) - - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) + + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 0', + 'second = 12']) + self.expect('expr iimI', substrs=['first = 0', 'second = 12']) + + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) + + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index 55658af1f2a..a7f8c4b1e17 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 StdListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,23 +22,26 @@ class StdListDataFormatterTestCase(TestBase): TestBase.setUp(self) # Find the line numbers to break at for the different tests. self.line = line_number('main.cpp', '// Set break point at this line.') - self.optional_line = line_number('main.cpp', '// Optional break point at this line.') - self.final_line = line_number('main.cpp', '// Set final break point at this line.') + self.optional_line = line_number( + 'main.cpp', '// Optional break point at this line.') + self.final_line = line_number( + 'main.cpp', '// Set final break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,7 +50,9 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,134 +62,148 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['size=0', - '{}']) - self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False, - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + self.expect( + "frame variable &numbers_list._M_impl._M_node --raw", + matching=False, + substrs=[ + 'size=0', + '{}']) self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect("p numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=1', - '[0] = ', - '0x12345678']) + substrs=['size=1', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['size=4', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); - + substrs=['0x11223344']) + # but check that expression does not rely on us self.expect("expression numbers_list[0]", matching=False, error=True, - substrs = ['0x12345678']) + substrs=['0x12345678']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) self.runCmd("type format delete int") self.runCmd("n") - + self.expect("frame variable text_list", - substrs = ['size=0', - '{}']) - - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1) + substrs=['size=0', + '{}']) + + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.final_line, num_expected_locations=-1) self.runCmd("c", 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']) self.expect("frame variable text_list", - substrs = ['size=4', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart', - '[3]', '!!!']) + substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) self.expect("p text_list", - substrs = ['size=4', - '\"goofy\"', - '\"is\"', - '\"smart\"', - '\"!!!\"']) - + substrs=['size=4', + '\"goofy\"', + '\"is\"', + '\"smart\"', + '\"!!!\"']) + # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + substrs=['!!!']) + # but check that expression does not rely on us self.expect("expression text_list[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py index ff99255aec0..f5dbadb6958 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 StdMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,22 +23,25 @@ class StdMapDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows @skipIfFreeBSD def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,278 +50,289 @@ class StdMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable ii --show-types") - - self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") - + + self.runCmd( + "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 2 items', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['map has 2 items', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 4 items', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['map has 4 items', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) - + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) + self.expect("p ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); - + substrs=['first =', + 'second =']) + self.expect("frame variable ii[8]", matching=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) self.runCmd("c") - + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) - + substrs=['map has 0 items', + '{}']) + self.runCmd("frame variable si --show-types") self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("c") self.expect('frame variable si', - substrs = ['map has 1 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['map has 1 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) self.expect("p si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'four', - 'second = 4']); + substrs=['first = ', 'four', + 'second = 4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) self.runCmd("c") - + self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable is --show-types") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); + substrs=['first = ', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) self.runCmd("c") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable ss --show-types") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) + self.expect("p ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) # check access-by-index self.expect("frame variable ss[3]", - substrs = ['gatto', 'cat']); + substrs=['gatto', 'cat']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") - + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) self.runCmd("c") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py index 20b1a3d2115..8d940c2686a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py @@ -4,43 +4,46 @@ Test lldb data formatter subsystem. 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 StdSmartPtrDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin def test_with_run_command(self): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") 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']) + + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = 123']) + self.expect("frame variable ssp", substrs=['ssp = "foobar"']) - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = 123']) - self.expect("frame variable ssp", substrs = ['ssp = "foobar"']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = 123']) + self.expect("frame variable swp", substrs=['swp = "foobar"']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = 123']) - self.expect("frame variable swp", substrs = ['swp = "foobar"']) - self.runCmd("continue") - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = nullptr']) - self.expect("frame variable ssp", substrs = ['ssp = nullptr']) + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = nullptr']) + self.expect("frame variable ssp", substrs=['ssp = nullptr']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = nullptr']) - self.expect("frame variable swp", substrs = ['swp = nullptr']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = nullptr']) + self.expect("frame variable swp", substrs=['swp = nullptr']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py index fde2f791183..67823c95f13 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. 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 StdStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class StdStringDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,7 +47,9 @@ class StdStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,12 +60,22 @@ class StdStringDataFormatterTestCase(TestBase): var_q = self.frame().FindVariable('q') var_Q = self.frame().FindVariable('Q') - self.assertTrue(var_s.GetSummary() == 'L"hello world! מזל טוב!"', "s summary wrong") + self.assertTrue( + var_s.GetSummary() == 'L"hello world! מזל טוב!"', + "s summary wrong") self.assertTrue(var_S.GetSummary() == 'L"!!!!"', "S summary wrong") - self.assertTrue(var_mazeltov.GetSummary() == 'L"מזל טוב"', "mazeltov summary wrong") - self.assertTrue(var_q.GetSummary() == '"hello world"', "q summary wrong") - self.assertTrue(var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', "Q summary wrong") + self.assertTrue( + var_mazeltov.GetSummary() == 'L"מזל טוב"', + "mazeltov summary wrong") + self.assertTrue( + var_q.GetSummary() == '"hello world"', + "q summary wrong") + self.assertTrue( + var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', + "Q summary wrong") self.runCmd("next") - self.assertTrue(var_S.GetSummary() == 'L"!!!!!"', "new S summary wrong") + self.assertTrue( + var_S.GetSummary() == 'L"!!!!!"', + "new S summary wrong") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py index f5cf7c04c3a..eff5feedd42 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 StdVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,23 +23,28 @@ class StdVBoolDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows. + @expectedFailureAll( + oslist=['freebsd'], + bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows. @skipIfDarwin def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - 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) # 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +53,33 @@ class StdVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py index 4a352ef41c1..5de64f636cc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 StdVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,21 +24,24 @@ class StdVectorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIfFreeBSD - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @expectedFailureAll( + compiler="icc", + bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,163 +50,171 @@ class StdVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data - self.runCmd("c"); - + self.runCmd("c") + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") #import time - #time.sleep(19) + # time.sleep(19) self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") # add some more data - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); - + substrs=['1234']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression numbers[6]", matching=False, error=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers").MightHaveChildren(), "numbers.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers").MightHaveChildren(), + "numbers.MightHaveChildren() says False for non empty!") # clear out the vector and see that we do the right thing once again self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.runCmd("c") self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); - + substrs=['is']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression strings[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("strings").MightHaveChildren(), "strings.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("strings").MightHaveChildren(), + "strings.MightHaveChildren() says False for non empty!") self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py index 8cebf20ddd2..8fff07d89dc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class SynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class SynthDataFormatterTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,158 +50,171 @@ class SynthDataFormatterTestCase(TestBase): # Pick some values and check that the basics work self.runCmd("type filter add BagOfInts --child x --child z") self.expect("frame variable int_bag", - substrs = ['x = 6', - 'z = 8']) + substrs=['x = 6', + 'z = 8']) # Check we can still access the missing child by summary - self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\"") + self.runCmd( + "type summary add BagOfInts --summary-string \"y=${var.y}\"") self.expect('frame variable int_bag', - substrs = ['y=7']) - - # Even if we have synth children, the summary prevails + substrs=['y=7']) + + # Even if we have synth children, the summary prevails self.expect("frame variable int_bag", matching=False, - substrs = ['x = 6', - 'z = 8']) - + substrs=['x = 6', + 'z = 8']) + # if we skip synth and summary show y - self.expect("frame variable int_bag --synthetic-type false --no-summary-depth=1", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) - + self.expect( + "frame variable int_bag --synthetic-type false --no-summary-depth=1", + substrs=[ + 'x = 6', + 'y = 7', + 'z = 8']) + # if we ask for raw output same happens self.expect("frame variable int_bag --raw-output", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) - + substrs=['x = 6', + 'y = 7', + 'z = 8']) + # Summary+Synth must work together - self.runCmd("type summary add BagOfInts --summary-string \"x=${var.x}\" -e") + self.runCmd( + "type summary add BagOfInts --summary-string \"x=${var.x}\" -e") self.expect('frame variable int_bag', - substrs = ['x=6', - 'x = 6', - 'z = 8']) - + substrs=['x=6', + 'x = 6', + 'z = 8']) + # Same output, but using Python - self.runCmd("type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e") + self.runCmd( + "type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e") self.expect('frame variable int_bag', - substrs = ['x=6', - 'x = 6', - 'z = 8']) + substrs=['x=6', + 'x = 6', + 'z = 8']) # If I skip summaries, still give me the artificial children self.expect("frame variable int_bag --no-summary-depth=1", - substrs = ['x = 6', - 'z = 8']) + substrs=['x = 6', + 'z = 8']) # Delete synth and check that the view reflects it immediately self.runCmd("type filter delete BagOfInts") self.expect("frame variable int_bag", - substrs = ['x = 6', - 'y = 7', - 'z = 8']) + substrs=['x = 6', + 'y = 7', + 'z = 8']) - # Add the synth again and check that it's honored deeper in the hierarchy + # Add the synth again and check that it's honored deeper in the + # hierarchy self.runCmd("type filter add BagOfInts --child x --child z") self.expect('frame variable bag_bag', - substrs = ['x = x=69 {', - 'x = 69', - 'z = 71', - 'y = x=66 {', - 'x = 66', - 'z = 68']) + substrs=['x = x=69 {', + 'x = 69', + 'z = 71', + 'y = x=66 {', + 'x = 66', + 'z = 68']) self.expect('frame variable bag_bag', matching=False, - substrs = ['y = 70', - 'y = 67']) + substrs=['y = 70', + 'y = 67']) # Check that a synth can expand nested stuff self.runCmd("type filter add BagOfBags --child x.y --child y.z") self.expect('frame variable bag_bag', - substrs = ['x.y = 70', - 'y.z = 68']) + substrs=['x.y = 70', + 'y.z = 68']) # ...even if we get -> and . wrong self.runCmd("type filter add BagOfBags --child x.y --child \"y->z\"") self.expect('frame variable bag_bag', - substrs = ['x.y = 70', - 'y->z = 68']) + substrs=['x.y = 70', + 'y->z = 68']) # ...even bitfields - self.runCmd("type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") + self.runCmd( + "type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") self.expect('frame variable bag_bag --show-types', - substrs = ['x.y = 70', - '(int:2) y->z[1-2] = 2']) + substrs=['x.y = 70', + '(int:2) y->z[1-2] = 2']) # ...even if we format the bitfields - self.runCmd("type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") + self.runCmd( + "type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") self.runCmd("type format add \"int:1\" -f bool") self.expect('frame variable bag_bag --show-types', - substrs = ['x.y = 70', - '(int:1) y->y[0-0] = true']) - + substrs=['x.y = 70', + '(int:1) y->y[0-0] = true']) + # ...even if we use one-liner summaries self.runCmd("type summary add -c BagOfBags") - self.expect('frame variable bag_bag', - substrs = ['(BagOfBags) bag_bag = (x.y = 70, y->y[0-0] = true)']) - + self.expect('frame variable bag_bag', substrs=[ + '(BagOfBags) bag_bag = (x.y = 70, y->y[0-0] = true)']) + self.runCmd("type summary delete BagOfBags") # now check we are dynamic (and arrays work) - self.runCmd("type filter add Plenty --child bitfield --child array[0] --child array[2]") + self.runCmd( + "type filter add Plenty --child bitfield --child array[0] --child array[2]") self.expect('frame variable plenty_of_stuff', - substrs = ['bitfield = 1', - 'array[0] = 5', - 'array[2] = 3']) - + substrs=['bitfield = 1', + 'array[0] = 5', + 'array[2] = 3']) + self.runCmd("n") self.expect('frame variable plenty_of_stuff', - substrs = ['bitfield = 17', - 'array[0] = 5', - 'array[2] = 3']) - + substrs=['bitfield = 17', + 'array[0] = 5', + 'array[2] = 3']) + # skip synthetic children self.expect('frame variable plenty_of_stuff --synthetic-type no', - substrs = ['some_values = 0x', - 'array = 0x', - 'array_size = 5']) + substrs=['some_values = 0x', + 'array = 0x', + 'array_size = 5']) - # check flat printing with synthetic children self.expect('frame variable plenty_of_stuff --flat', - substrs = ['plenty_of_stuff.bitfield = 17', - '*(plenty_of_stuff.array) = 5', - '*(plenty_of_stuff.array) = 3']) - + substrs=['plenty_of_stuff.bitfield = 17', + '*(plenty_of_stuff.array) = 5', + '*(plenty_of_stuff.array) = 3']) + # check that we do not lose location information for our children self.expect('frame variable plenty_of_stuff --location', - substrs = ['0x', - ': bitfield = 17']) + substrs=['0x', + ': bitfield = 17']) # check we work across pointer boundaries self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', - substrs = ['(BagOfInts *) plenty_of_stuff.some_values', - 'x = 5', - 'z = 7']) + substrs=['(BagOfInts *) plenty_of_stuff.some_values', + 'x = 5', + 'z = 7']) # but not if we don't want to self.runCmd("type filter add BagOfInts --child x --child z -p") self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', - substrs = ['(BagOfInts *) plenty_of_stuff.some_values', - 'x = 5', - 'y = 6', - 'z = 7']) + substrs=['(BagOfInts *) plenty_of_stuff.some_values', + 'x = 5', + 'y = 6', + 'z = 7']) # check we're dynamic even if nested self.runCmd("type filter add BagOfBags --child x.z") self.expect('frame variable bag_bag', - substrs = ['x.z = 71']) + substrs=['x.z = 71']) self.runCmd("n") self.expect('frame variable bag_bag', - substrs = ['x.z = 12']) + substrs=['x.z = 12']) - self.runCmd('type summary add -e -s "I am always empty but have" EmptyStruct') - self.expect('frame variable es', substrs = ["I am always empty but have {}"]) + self.runCmd( + 'type summary add -e -s "I am always empty but have" EmptyStruct') + self.expect('frame variable es', substrs=[ + "I am always empty but have {}"]) self.runCmd('type summary add -e -h -s "I am really empty" EmptyStruct') - self.expect('frame variable es', substrs = ["I am really empty"]) - self.expect('frame variable es', substrs = ["I am really empty {}"], matching=False) + self.expect('frame variable es', substrs=["I am really empty"]) + self.expect( + 'frame variable es', + substrs=["I am really empty {}"], + matching=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py index 6a03456e5c3..75d3b4e5f5c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 DataFormatterSynthTypeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,20 +23,21 @@ class DataFormatterSynthTypeTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', 'break here') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test using Python synthetic children provider to provide a typename.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py index 42737140b11..fa47ca2cfe6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py @@ -1,22 +1,30 @@ class myIntSynthProvider(object): - def __init__(self, valobj, dict): - self.valobj = valobj; - self.val = self.valobj.GetChildMemberWithName("theValue") - def num_children(self): - return 0; - def get_child_at_index(self, index): - return None - def get_child_index(self, name): - return None - def update(self): - return False - def has_children(self): - return False - def get_type_name(self): - return "ThisTestPasses" + + def __init__(self, valobj, dict): + self.valobj = valobj + self.val = self.valobj.GetChildMemberWithName("theValue") + + def num_children(self): + return 0 + + def get_child_at_index(self, index): + return None + + def get_child_index(self, name): + return None + + def update(self): + return False + + def has_children(self): + return False + + def get_type_name(self): + return "ThisTestPasses" class myArraySynthProvider(object): + def __init__(self, valobj, dict): self.valobj = valobj self.array = self.valobj.GetChildMemberWithName("array") @@ -27,10 +35,10 @@ class myArraySynthProvider(object): return max_count def get_child_at_index(self, index): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def get_child_index(self, name): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def has_children(self): return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py index 5d796f9bf99..6e7ac2c13f3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 DataFormatterSynthValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,24 @@ class DataFormatterSynthValueTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', 'break here') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test using Python synthetic children provider to provide a value.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,7 +52,7 @@ class DataFormatterSynthValueTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + x = self.frame().FindVariable("x") x.SetPreferSyntheticValue(True) y = self.frame().FindVariable("y") @@ -62,9 +66,11 @@ class DataFormatterSynthValueTestCase(TestBase): y_val = y.GetValueAsUnsigned z_val = z.GetValueAsUnsigned q_val = q.GetValueAsUnsigned - + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val())) + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) self.assertFalse(x_val() == 3, "x == 3 before synthetics") self.assertFalse(y_val() == 4, "y == 4 before synthetics") @@ -76,23 +82,34 @@ class DataFormatterSynthValueTestCase(TestBase): self.runCmd("type synth add -l myIntSynthProvider myInt") self.runCmd("type synth add -l myArraySynthProvider myArray") self.runCmd("type synth add -l myIntSynthProvider myIntAndStuff") - + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val())) - + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) + self.assertTrue(x_val() == 3, "x != 3 after synthetics") self.assertTrue(y_val() == 4, "y != 4 after synthetics") self.assertTrue(z_val() == 7, "z != 7 after synthetics") self.assertTrue(q_val() == 8, "q != 8 after synthetics") - + self.expect("frame variable x", substrs=['3']) - self.expect("frame variable x", substrs=['theValue = 3'], matching=False) + self.expect( + "frame variable x", + substrs=['theValue = 3'], + matching=False) self.expect("frame variable q", substrs=['8']) - self.expect("frame variable q", substrs=['theValue = 8'], matching=False) - - # check that an aptly defined synthetic provider does not affect one-lining - self.expect("expression struct S { myInt theInt{12}; }; S()", substrs = ['(theInt = 12)']) - + self.expect( + "frame variable q", + substrs=['theValue = 8'], + matching=False) + + # check that an aptly defined synthetic provider does not affect + # one-lining + self.expect( + "expression struct S { myInt theInt{12}; }; S()", + substrs=['(theInt = 12)']) + # check that we can use a synthetic value in a summary self.runCmd("type summary add hasAnInt -s ${var.theInt}") hi = self.frame().FindVariable("hi") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py index c8517a44293..82da6f9da92 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py @@ -1,22 +1,30 @@ class myIntSynthProvider(object): - def __init__(self, valobj, dict): - self.valobj = valobj; - self.val = self.valobj.GetChildMemberWithName("theValue") - def num_children(self): - return 0; - def get_child_at_index(self, index): - return None - def get_child_index(self, name): - return None - def update(self): - return False - def has_children(self): - return False - def get_value(self): - return self.val + + def __init__(self, valobj, dict): + self.valobj = valobj + self.val = self.valobj.GetChildMemberWithName("theValue") + + def num_children(self): + return 0 + + def get_child_at_index(self, index): + return None + + def get_child_index(self, name): + return None + + def update(self): + return False + + def has_children(self): + return False + + def get_value(self): + return self.val class myArraySynthProvider(object): + def __init__(self, valobj, dict): self.valobj = valobj self.array = self.valobj.GetChildMemberWithName("array") @@ -27,10 +35,10 @@ class myArraySynthProvider(object): return max_count def get_child_at_index(self, index): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def get_child_index(self, name): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def has_children(self): return True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py index 886d09fda45..734e711fb7f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py @@ -2,4 +2,7 @@ from __future__ import absolute_import from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + lldbinline.expectedFailureAll( + oslist=["windows"], bugnumber="llvm.org/pr24663")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py index 5cb7c82c9e0..0c15c793e1f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py @@ -5,12 +5,13 @@ Check if changing Format on an SBValue correctly propagates that new format to c from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class FormatPropagationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,14 +28,15 @@ class FormatPropagationTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,18 +49,24 @@ class FormatPropagationTestCase(TestBase): # extract the parent and the children frame = self.frame() parent = self.frame().FindVariable("f") - self.assertTrue(parent != None and parent.IsValid(),"could not find f") + self.assertTrue( + parent is not None and parent.IsValid(), + "could not find f") X = parent.GetChildMemberWithName("X") - self.assertTrue(X != None and X.IsValid(),"could not find X") + self.assertTrue(X is not None and X.IsValid(), "could not find X") Y = parent.GetChildMemberWithName("Y") - self.assertTrue(Y != None and Y.IsValid(),"could not find Y") + self.assertTrue(Y is not None and Y.IsValid(), "could not find Y") # check their values now self.assertTrue(X.GetValue() == "1", "X has an invalid value") self.assertTrue(Y.GetValue() == "2", "Y has an invalid value") # set the format on the parent parent.SetFormat(lldb.eFormatHex) - self.assertTrue(X.GetValue() == "0x00000001", "X has not changed format") - self.assertTrue(Y.GetValue() == "0x00000002", "Y has not changed format") + self.assertTrue( + X.GetValue() == "0x00000001", + "X has not changed format") + self.assertTrue( + Y.GetValue() == "0x00000002", + "Y has not changed format") # Step and check if the values make sense still self.runCmd("next") self.assertTrue(X.GetValue() == "0x00000004", "X has not become 4") @@ -71,5 +79,7 @@ class FormatPropagationTestCase(TestBase): parent.SetFormat(lldb.eFormatDefault) X.SetFormat(lldb.eFormatHex) Y.SetFormat(lldb.eFormatDefault) - self.assertTrue(X.GetValue() == "0x00000004", "X is not hex as it asked") + self.assertTrue( + X.GetValue() == "0x00000004", + "X is not hex as it asked") self.assertTrue(Y.GetValue() == "2", "Y is not defaulted") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py index 555351998c2..d6303fe8b73 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py @@ -5,12 +5,13 @@ Test that the user can input a format but it will not prevail over summary forma from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class FrameFormatSmallStructTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,13 +27,14 @@ class FrameFormatSmallStructTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) - self.expect("thread list", substrs = ['addPair(p=(x = 3, y = -3))']) + self.expect("thread list", substrs=['addPair(p=(x = 3, y = -3))']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py index 3c28b68056f..32fbf48dcc6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class DataFormatterHexCapsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class DataFormatterHexCapsTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,38 +47,43 @@ class DataFormatterHexCapsTestCase(TestBase): self.addTearDownHook(cleanup) self.runCmd("type format add -f uppercase int") - + self.expect('frame variable mine', - substrs = ['mine = ', - 'first = 0x001122AA', 'second = 0x1122BB44']) + substrs=['mine = ', + 'first = 0x001122AA', 'second = 0x1122BB44']) self.runCmd("type format add -f hex int") self.expect('frame variable mine', - substrs = ['mine = ', - 'first = 0x001122aa', 'second = 0x1122bb44']) + substrs=['mine = ', + 'first = 0x001122aa', 'second = 0x1122bb44']) self.runCmd("type format delete int") - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%x}\" foo") + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%x}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0x001122AA and 0x1122bb44']) + substrs=['(foo) mine = 0x001122AA and 0x1122bb44']) - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo") + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%X}\" foo") self.runCmd("next") self.runCmd("next") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xAABBCCDD and 0x1122BB44']) + substrs=['(foo) mine = 0xAABBCCDD and 0x1122BB44']) - self.runCmd("type summary add -s \"${var.first%x} and ${var.second%X}\" foo") + self.runCmd( + "type summary add -s \"${var.first%x} and ${var.second%X}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xaabbccdd and 0x1122BB44']) + substrs=['(foo) mine = 0xaabbccdd and 0x1122BB44']) self.runCmd("next") self.runCmd("next") - self.runCmd("type summary add -s \"${var.first%x} and ${var.second%x}\" foo") + self.runCmd( + "type summary add -s \"${var.first%x} and ${var.second%x}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xaabbccdd and 0xff00ff00']) - self.runCmd("type summary add -s \"${var.first%X} and ${var.second%X}\" foo") + substrs=['(foo) mine = 0xaabbccdd and 0xff00ff00']) + self.runCmd( + "type summary add -s \"${var.first%X} and ${var.second%X}\" foo") self.expect('frame variable mine', - substrs = ['(foo) mine = 0xAABBCCDD and 0xFF00FF00']) + substrs=['(foo) mine = 0xAABBCCDD and 0xFF00FF00']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py index f30733d2d81..b7f60cfac41 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class LanguageCategoryUpdatesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +27,11 @@ class LanguageCategoryUpdatesTestCase(TestBase): # This is the function to remove the custom formats in order to have a # clean slate for the next test case. def cleanup(): - if hasattr(self, 'type_category') and hasattr(self, 'type_specifier'): + if hasattr( + self, + 'type_category') and hasattr( + self, + 'type_specifier'): self.type_category.DeleteTypeSummary(self.type_specifier) # Execute the cleanup function during test case tear down. @@ -35,25 +40,47 @@ class LanguageCategoryUpdatesTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) - - self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True) - - self.type_category = self.dbg.GetCategory(lldb.eLanguageTypeC_plus_plus) - type_summary = lldb.SBTypeSummary.CreateWithSummaryString("this is an object of type S") + substrs=['stopped', + 'stop reason = breakpoint']) + + self.expect( + "frame variable", + substrs=[ + '(S)', + 'object', + '123', + '456'], + matching=True) + + self.type_category = self.dbg.GetCategory( + lldb.eLanguageTypeC_plus_plus) + type_summary = lldb.SBTypeSummary.CreateWithSummaryString( + "this is an object of type S") self.type_specifier = lldb.SBTypeNameSpecifier('S') self.type_category.AddTypeSummary(self.type_specifier, type_summary) - self.expect("frame variable", substrs = ['this is an object of type S'], matching=True) - - self.type_category.DeleteTypeSummary(self.type_specifier) - self.expect("frame variable", substrs = ['this is an object of type S'], matching=False) - self.expect("frame variable", substrs = ['(S)', 'object', '123', '456'], matching=True) + self.expect( + "frame variable", + substrs=['this is an object of type S'], + matching=True) + self.type_category.DeleteTypeSummary(self.type_specifier) + self.expect( + "frame variable", + substrs=['this is an object of type S'], + matching=False) + self.expect( + "frame variable", + substrs=[ + '(S)', + 'object', + '123', + '456'], + matching=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py index 871cc19373a..87fc2d1802b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 NSArraySyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSArraySyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,19 +52,59 @@ class NSArraySyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable arr', - substrs = ['@"6 elements"']) + substrs=['@"6 elements"']) self.expect('frame variable other_arr', - substrs = ['@"4 elements"']) - self.expect('frame variable arr --ptr-depth 1', - substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x']) - self.expect('frame variable other_arr --ptr-depth 1', - substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x']) - self.expect('frame variable arr --ptr-depth 1 -d no-run-target', - substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) - self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target', - substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"']) - self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target', - substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com']) + substrs=['@"4 elements"']) + self.expect( + 'frame variable arr --ptr-depth 1', + substrs=[ + '@"6 elements"', + '[0] = 0x', + '[1] = 0x', + '[2] = 0x', + '[3] = 0x', + '[4] = 0x', + '[5] = 0x']) + self.expect( + 'frame variable other_arr --ptr-depth 1', + substrs=[ + '@"4 elements"', + '[0] = 0x', + '[1] = 0x', + '[2] = 0x', + '[3] = 0x']) + self.expect( + 'frame variable arr --ptr-depth 1 -d no-run-target', + substrs=[ + '@"6 elements"', + '@"hello"', + '@"world"', + '@"this"', + '@"is"', + '@"me"', + '@"http://www.apple.com']) + self.expect( + 'frame variable other_arr --ptr-depth 1 -d no-run-target', + substrs=[ + '@"4 elements"', + '(int)5', + '@"a string"', + '@"6 elements"']) + self.expect( + 'frame variable other_arr --ptr-depth 2 -d no-run-target', + substrs=[ + '@"4 elements"', + '@"6 elements" {', + '@"hello"', + '@"world"', + '@"this"', + '@"is"', + '@"me"', + '@"http://www.apple.com']) - self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!") - self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!") + self.assertTrue( + self.frame().FindVariable("arr").MightHaveChildren(), + "arr says it does not have children!") + self.assertTrue( + self.frame().FindVariable("other_arr").MightHaveChildren(), + "arr says it does not have children!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py index 5ee54c3a295..85675d21123 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 NSDictionarySyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSDictionarySyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,21 +52,73 @@ class NSDictionarySyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable dictionary', - substrs = ['3 key/value pairs']) + substrs=['3 key/value pairs']) self.expect('frame variable mutabledict', - substrs = ['4 key/value pairs']) - self.expect('frame variable dictionary --ptr-depth 1', - substrs = ['3 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ']) - self.expect('frame variable mutabledict --ptr-depth 1', - substrs = ['4 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ','[3] = ']) - self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target', - substrs = ['3 key/value pairs','@"bar"','@"2 elements"','@"baz"','2 key/value pairs']) - self.expect('frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs']) - self.expect('frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"']) - self.expect('frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target', - substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"','(int)1','@"two"']) + substrs=['4 key/value pairs']) + self.expect( + 'frame variable dictionary --ptr-depth 1', + substrs=[ + '3 key/value pairs', + '[0] = ', + 'key = 0x', + 'value = 0x', + '[1] = ', + '[2] = ']) + self.expect( + 'frame variable mutabledict --ptr-depth 1', + substrs=[ + '4 key/value pairs', + '[0] = ', + 'key = 0x', + 'value = 0x', + '[1] = ', + '[2] = ', + '[3] = ']) + self.expect( + 'frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target', + substrs=[ + '3 key/value pairs', + '@"bar"', + '@"2 elements"', + '@"baz"', + '2 key/value pairs']) + self.expect( + 'frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs']) + self.expect( + 'frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs', + '@"bar"', + '@"2 elements"']) + self.expect( + 'frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target', + substrs=[ + '4 key/value pairs', + '(int)23', + '@"123"', + '@"http://www.apple.com"', + '@"sourceofstuff"', + '3 key/value pairs', + '@"bar"', + '@"2 elements"', + '(int)1', + '@"two"']) - self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!") - self.assertTrue(self.frame().FindVariable("mutabledict").MightHaveChildren(), "mutable says it does not have children!") + self.assertTrue( + self.frame().FindVariable("dictionary").MightHaveChildren(), + "dictionary says it does not have children!") + self.assertTrue( + self.frame().FindVariable("mutabledict").MightHaveChildren(), + "mutable says it does not have children!") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py index d1680434d3b..6affc5a71fa 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 NSSetSyntheticTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class NSSetSyntheticTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,26 +52,64 @@ class NSSetSyntheticTestCase(TestBase): # Now check that we are displaying Cocoa classes correctly self.expect('frame variable set', - substrs = ['4 elements']) + substrs=['4 elements']) self.expect('frame variable mutable', - substrs = ['9 elements']) - self.expect('frame variable set --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['9 elements','(int)5','@"3 elements"','@"www.apple.com"','(int)3','@"world"','(int)4']) + substrs=['9 elements']) + self.expect( + 'frame variable set --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '9 elements', + '(int)5', + '@"3 elements"', + '@"www.apple.com"', + '(int)3', + '@"world"', + '(int)4']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['0 elements']) + substrs=['0 elements']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['4 elements']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) + substrs=['4 elements']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) self.runCmd("next") self.expect('frame variable mutable', - substrs = ['4 elements']) - self.expect('frame variable mutable --ptr-depth 1 -d run -T', - substrs = ['4 elements','[0]','[1]','[2]','[3]','hello','world','(int)1','(int)2']) + substrs=['4 elements']) + self.expect( + 'frame variable mutable --ptr-depth 1 -d run -T', + substrs=[ + '4 elements', + '[0]', + '[1]', + '[2]', + '[3]', + 'hello', + 'world', + '(int)1', + '(int)2']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py index 4158ec8a661..7ffddc5ec67 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 DataFormatterOSTypeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class DataFormatterOSTypeTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,4 +52,4 @@ class DataFormatterOSTypeTestCase(TestBase): # Now check that we use the right summary for OSType self.expect('frame variable', - substrs = ["'test'","'best'"]) + substrs=["'test'", "'best'"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py index 700b7418118..49cda4ae6cc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 PrintArrayTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -32,14 +33,15 @@ class PrintArrayTestCase(TestBase): """Test that expr -Z works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -50,21 +52,85 @@ class PrintArrayTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - - self.expect('expr --element-count 3 -- data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) + + self.expect( + 'expr --element-count 3 -- data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) self.expect('expr data', substrs=['int *', '$', '0x']) - self.expect('expr -f binary --element-count 0 -- data', substrs=['int *', '$', '0b']) - self.expect('expr -f hex --element-count 3 -- data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) - self.expect('expr -f binary --element-count 2 -- data', substrs=['int *', '$', '0x', '[0] = 0b', '1', '[1] = 0b', '11']) + self.expect( + 'expr -f binary --element-count 0 -- data', + substrs=[ + 'int *', + '$', + '0b']) + self.expect( + 'expr -f hex --element-count 3 -- data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) + self.expect( + 'expr -f binary --element-count 2 -- data', + substrs=[ + 'int *', + '$', + '0x', + '[0] = 0b', + '1', + '[1] = 0b', + '11']) self.expect('parray 3 data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray `1 + 1 + 1` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray `data[1]` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) - self.expect('parray/x 3 data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) - self.expect('parray/x `data[1]` data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) + self.expect( + 'parray `1 + 1 + 1` data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) + self.expect( + 'parray `data[1]` data', + substrs=[ + '[0] = 1', + '[1] = 3', + '[2] = 5']) + self.expect( + 'parray/x 3 data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) + self.expect( + 'parray/x `data[1]` data', + substrs=[ + '[0] = 0x', + '1', + '[1] = 0x', + '3', + '[2] = 0x', + '5']) # check error conditions - self.expect('expr --element-count 10 -- 123', error=True, substrs=['expression cannot be used with --element-count as it does not refer to a pointer']) - self.expect('expr --element-count 10 -- (void*)123', error=True, substrs=['expression cannot be used with --element-count as it refers to a pointer to void']) - self.expect('parray data', error=True, substrs=["invalid element count 'data'"]) - self.expect('parray data data', error=True, substrs=["invalid element count 'data'"]) - self.expect('parray', error=True, substrs=['Not enough arguments provided']) + self.expect( + 'expr --element-count 10 -- 123', + error=True, + substrs=['expression cannot be used with --element-count as it does not refer to a pointer']) + self.expect( + 'expr --element-count 10 -- (void*)123', + error=True, + substrs=['expression cannot be used with --element-count as it refers to a pointer to void']) + self.expect('parray data', error=True, substrs=[ + "invalid element count 'data'"]) + self.expect( + 'parray data data', + error=True, + substrs=["invalid element count 'data'"]) + self.expect('parray', error=True, substrs=[ + 'Not enough arguments provided']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py index 7eb26a56986..83408e7b456 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 PrintObjectArrayTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class PrintObjectArrayTestCase(TestBase): """Test that expr -O -Z works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.mm", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -52,9 +54,59 @@ class PrintObjectArrayTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('expr --element-count 3 --object-description -- objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) - self.expect('poarray 3 objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) - self.expect('expr --element-count 3 --object-description --description-verbosity=full -- objects', substrs=['[0] =', '3735928559', '4276993775', '3203398366', '[1] =', 'Hello', 'World', '[2] =', 'Two =', '1 =']) - self.expect('parray 3 objects', substrs=['[0] = 0x', '[1] = 0x', '[2] = 0x']) - self.expect('expr --element-count 3 -d run -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs']) - self.expect('expr --element-count 3 -d run --ptr-depth=1 -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs', '3735928559', '4276993775', '3203398366', '"Hello"', '"World"']) + self.expect( + 'expr --element-count 3 --object-description -- objects', + substrs=[ + '3735928559', + '4276993775', + '3203398366', + 'Hello', + 'World', + 'Two =', + '1 =']) + self.expect( + 'poarray 3 objects', + substrs=[ + '3735928559', + '4276993775', + '3203398366', + 'Hello', + 'World', + 'Two =', + '1 =']) + self.expect( + 'expr --element-count 3 --object-description --description-verbosity=full -- objects', + substrs=[ + '[0] =', + '3735928559', + '4276993775', + '3203398366', + '[1] =', + 'Hello', + 'World', + '[2] =', + 'Two =', + '1 =']) + self.expect( + 'parray 3 objects', + substrs=[ + '[0] = 0x', + '[1] = 0x', + '[2] = 0x']) + self.expect( + 'expr --element-count 3 -d run -- objects', + substrs=[ + '3 elements', + '2 elements', + '2 key/value pairs']) + self.expect( + 'expr --element-count 3 -d run --ptr-depth=1 -- objects', + substrs=[ + '3 elements', + '2 elements', + '2 key/value pairs', + '3735928559', + '4276993775', + '3203398366', + '"Hello"', + '"World"']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py index bf98559cd0c..69b9dd04887 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class PtrRef2TypedefTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,20 +21,21 @@ class PtrRef2TypedefTestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set breakpoint here') - + def test_with_run_command(self): """Test that a pointer/reference to a typedef is formatted as we want.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,10 +50,18 @@ class PtrRef2TypedefTestCase(TestBase): self.runCmd('type summary add --cascade true -s "IntLRef" "int &"') self.runCmd('type summary add --cascade true -s "IntRRef" "int &&"') - self.expect("frame variable x", substrs = ['(Foo *) x = 0x','IntPointer']) + self.expect( + "frame variable x", + substrs=[ + '(Foo *) x = 0x', + 'IntPointer']) # note: Ubuntu 12.04 x86_64 build with gcc 4.8.2 is getting a # const after the ref that isn't showing up on FreeBSD. This # tweak changes the behavior so that the const is not part of # the match. - self.expect("frame variable y", substrs = ['(Foo &', ') y = 0x','IntLRef']) - self.expect("frame variable z", substrs = ['(Foo &&', ') z = 0x','IntRRef']) + self.expect( + "frame variable y", substrs=[ + '(Foo &', ') y = 0x', 'IntLRef']) + self.expect( + "frame variable z", substrs=[ + '(Foo &&', ') z = 0x', 'IntRRef']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py index db2d5806e09..2ff27ae2047 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 PyObjectSynthProviderTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,14 +34,15 @@ class PyObjectSynthProviderTestCase(TestBase): """Test that the PythonObjectSyntheticChildProvider helper class works""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -51,9 +53,20 @@ class PyObjectSynthProviderTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + self.runCmd('command script import provider.py') - self.runCmd('type synthetic add Foo --python-class provider.SyntheticChildrenProvider') + self.runCmd( + 'type synthetic add Foo --python-class provider.SyntheticChildrenProvider') self.expect('frame variable f.Name', substrs=['"Enrico"']) - self.expect('frame variable f', substrs=['ID = 123456', 'Name = "Enrico"', 'Rate = 1.25']) - self.expect('expression f', substrs=['ID = 123456', 'Name = "Enrico"', 'Rate = 1.25']) + self.expect( + 'frame variable f', + substrs=[ + 'ID = 123456', + 'Name = "Enrico"', + 'Rate = 1.25']) + self.expect( + 'expression f', + substrs=[ + 'ID = 123456', + 'Name = "Enrico"', + 'Rate = 1.25']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py index 134ae83aa1c..c263190c102 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/provider.py @@ -2,12 +2,15 @@ import lldb import lldb.formatters import lldb.formatters.synth -class SyntheticChildrenProvider(lldb.formatters.synth.PythonObjectSyntheticChildProvider): + +class SyntheticChildrenProvider( + lldb.formatters.synth.PythonObjectSyntheticChildProvider): + def __init__(self, value, internal_dict): - lldb.formatters.synth.PythonObjectSyntheticChildProvider.__init__(self, value, internal_dict) + lldb.formatters.synth.PythonObjectSyntheticChildProvider.__init__( + self, value, internal_dict) def make_children(self): - return [("ID", 123456), - ("Name", "Enrico"), - ("Rate", 1.25)] - + return [("ID", 123456), + ("Name", "Enrico"), + ("Rate", 1.25)] diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py index 13b84e9f74c..0a039107d84 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py @@ -5,12 +5,13 @@ Test that ValueObjectPrinter does not cause an infinite loop when a reference to from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class DataFormatterRefPtrRecursionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,16 +27,17 @@ class DataFormatterRefPtrRecursionTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) - self.expect("frame variable foo", substrs = []); - self.expect("frame variable foo --ptr-depth=1", substrs = ['ID = 1']); - self.expect("frame variable foo --ptr-depth=2", substrs = ['ID = 1']); - self.expect("frame variable foo --ptr-depth=3", substrs = ['ID = 1']); + self.expect("frame variable foo", substrs=[]) + self.expect("frame variable foo --ptr-depth=1", substrs=['ID = 1']) + self.expect("frame variable foo --ptr-depth=2", substrs=['ID = 1']) + self.expect("frame variable foo --ptr-depth=3", substrs=['ID = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py index 791ce27dad0..804905106df 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py @@ -1,4 +1,6 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.skipIfFreeBSD, decorators.skipIfLinux, decorators.skipIfWindows]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py index e26344f2711..c76b421a1ea 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py @@ -1,4 +1,7 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll( + oslist=["windows"], bugnumber="llvm.org/pr24772")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py index 2873e35368f..d7862d2327c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class Radar9974002DataFormatterTestCase(TestBase): # test for rdar://problem/9974002 () @@ -26,18 +27,20 @@ class Radar9974002DataFormatterTestCase(TestBase): """Test that that file and class static variables display correctly.""" self.build() if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion(): - self.skipTest("llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") + self.skipTest( + "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,87 +50,98 @@ class Radar9974002DataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") - + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) self.runCmd("type summary add -s foo contained") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) self.runCmd("type summary delete contained") self.runCmd("n") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) self.runCmd("type summary add -s foo contained") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', 'foo']) + substrs=['mine = ', + '1', 'foo']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '0x000000']) + substrs=['mine = ', + '1', '0x000000']) - self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + self.runCmd( + "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") self.expect('frame variable mine', - substrs = ['mine = ', - '1', '<parent is NULL>']) + substrs=['mine = ', + '1', '<parent is NULL>']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py index e8b6c1ad95f..6d519761b7b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py @@ -5,13 +5,14 @@ Check for an issue where capping does not work because the Target pointer appear 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 SyntheticCappingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +28,8 @@ class SyntheticCappingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -35,8 +37,8 @@ class SyntheticCappingTestCase(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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,7 +47,9 @@ class SyntheticCappingTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -60,25 +64,25 @@ class SyntheticCappingTestCase(TestBase): else: fake_a_val = 0x00000100 - # check that the synthetic children work, so we know we are doing the right thing + # check that the synthetic children work, so we know we are doing the + # right thing self.expect("frame variable f00_1", - substrs = ['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']); + substrs=['r = 34', + 'fake_a = %d' % fake_a_val, + 'a = 1']) # check that capping works self.runCmd("settings set target.max-children-count 2", check=False) - + self.expect("frame variable f00_1", - substrs = ['...', - 'fake_a = %d' % fake_a_val, - 'a = 1']); - + substrs=['...', + 'fake_a = %d' % fake_a_val, + 'a = 1']) + self.expect("frame variable f00_1", matching=False, - substrs = ['r = 34']); + substrs=['r = 34']) - self.runCmd("settings set target.max-children-count 256", check=False) self.expect("frame variable f00_1", matching=True, - substrs = ['r = 34']); + substrs=['r = 34']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py index 1a7e5679c0b..124eb5d31ba 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py @@ -1,21 +1,27 @@ import lldb + + class fooSynthProvider: + def __init__(self, valobj, dict): - self.valobj = valobj; + self.valobj = valobj self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) + def num_children(self): - return 3; + return 3 + def get_child_at_index(self, index): if index == 0: - child = self.valobj.GetChildMemberWithName('a'); + child = self.valobj.GetChildMemberWithName('a') if index == 1: - child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); + child = self.valobj.CreateChildAtOffset('fake_a', 1, self.int_type) if index == 2: - child = self.valobj.GetChildMemberWithName('r'); - return child; + child = self.valobj.GetChildMemberWithName('r') + return child + def get_child_index(self, name): if name == 'a': - return 0; + return 0 if name == 'fake_a': - return 1; - return 2; + return 1 + return 2 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py index 23a31da685d..29c1214564d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - import datetime -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 SyntheticFilterRecomputingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,14 +30,15 @@ class SyntheticFilterRecomputingTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -49,27 +51,37 @@ class SyntheticFilterRecomputingTestCase(TestBase): self.addTearDownHook(cleanup) # Now run the bulk of the test - id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x") + id_x = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable("x") id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) id_x.SetPreferSyntheticValue(True) - + if self.TraceOn(): self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") - self.assertTrue(id_x.GetSummary() == '@"5 elements"', "array does not get correct summary") + self.assertTrue( + id_x.GetSummary() == '@"5 elements"', + "array does not get correct summary") self.runCmd("next") self.runCmd("frame select 0") - id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x") + id_x = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable("x") id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) id_x.SetPreferSyntheticValue(True) if self.TraceOn(): self.runCmd("expr --dynamic-type run-target --ptr-depth 1 -- x") - self.assertTrue(id_x.GetNumChildren() == 7, "dictionary does not have 7 children") + self.assertTrue( + id_x.GetNumChildren() == 7, + "dictionary does not have 7 children") id_x.SetPreferSyntheticValue(False) - self.assertFalse(id_x.GetNumChildren() == 7, "dictionary still looks synthetic") + self.assertFalse( + id_x.GetNumChildren() == 7, + "dictionary still looks synthetic") id_x.SetPreferSyntheticValue(True) - self.assertTrue(id_x.GetSummary() == "7 key/value pairs", "dictionary does not get correct summary") + self.assertTrue( + id_x.GetSummary() == "7 key/value pairs", + "dictionary does not get correct summary") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py index 6568056f761..1cc2a0e431a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 TypeSummaryListArgumentTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,9 +24,28 @@ class TypeSummaryListArgumentTestCase(TestBase): @no_debug_info_test def test_type_summary_list_with_arg(self): """Test that the 'type summary list' command handles command line arguments properly""" - self.expect('type summary list Foo', substrs=['Category: default', 'Category: system']) - self.expect('type summary list char', substrs=['char *', 'unsigned char']) - - self.expect('type summary list -w default', substrs=['system'], matching=False) - self.expect('type summary list -w system unsigned', substrs=['default', '0-9'], matching=False) - self.expect('type summary list -w system char', substrs=['unsigned char *'], matching=True) + self.expect( + 'type summary list Foo', + substrs=[ + 'Category: default', + 'Category: system']) + self.expect( + 'type summary list char', + substrs=[ + 'char *', + 'unsigned char']) + + self.expect( + 'type summary list -w default', + substrs=['system'], + matching=False) + self.expect( + 'type summary list -w system unsigned', + substrs=[ + 'default', + '0-9'], + matching=False) + self.expect( + 'type summary list -w system char', + substrs=['unsigned char *'], + matching=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py index 63a4a3a4ba8..2e66b800b15 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. 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 TypeSummaryListScriptTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,14 +32,15 @@ class TypeSummaryListScriptTestCase(TestBase): """Test printing out Python summary formatters.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -53,9 +55,11 @@ class TypeSummaryListScriptTestCase(TestBase): self.runCmd("command script import tslsformatters.py") - self.expect("frame variable myStruct", substrs=['A data formatter at work']) - - self.expect('type summary list', substrs=['Struct_SummaryFormatter']) - self.expect('type summary list Struct', substrs=['Struct_SummaryFormatter']) - + self.expect( + "frame variable myStruct", + substrs=['A data formatter at work']) + self.expect('type summary list', substrs=['Struct_SummaryFormatter']) + self.expect( + 'type summary list Struct', + substrs=['Struct_SummaryFormatter']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py index d1ce8b7db17..03fe17bfe76 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py @@ -1,10 +1,12 @@ import lldb + def Struct_SummaryFormatter(valobj, internal_dict): return 'A data formatter at work' category = lldb.debugger.CreateCategory("TSLSFormatters") category.SetEnabled(True) -summary = lldb.SBTypeSummary.CreateWithFunctionName("tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade) +summary = lldb.SBTypeSummary.CreateWithFunctionName( + "tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade) spec = lldb.SBTypeNameSpecifier("Struct", False) category.AddTypeSummary(spec, summary) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py index 41b8c3499cc..7e67f73b709 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py @@ -1,4 +1,7 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(compiler="gcc")]) +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll( + compiler="gcc")]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py index dba2816d264..d970d11a2ba 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py @@ -5,12 +5,13 @@ Test that the user can input a format but it will not prevail over summary forma from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class UserFormatVSSummaryTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,16 +27,18 @@ class UserFormatVSSummaryTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) - self.expect("frame variable p1", substrs = ['(Pair) p1 = (x = 3, y = -3)']); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = (x = 3, y = -3)']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,12 +51,24 @@ class UserFormatVSSummaryTestCase(TestBase): self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"') - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']); - self.expect("frame variable -f x p1", substrs = ['(Pair) p1 = x=0x00000003,y=0xfffffffd'], matching=False); - self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'], matching=False); - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=3,y=4294967293']) + self.expect( + "frame variable -f x p1", + substrs=['(Pair) p1 = x=0x00000003,y=0xfffffffd'], + matching=False) + self.expect( + "frame variable -f d p1", + substrs=['(Pair) p1 = x=3,y=-3'], + matching=False) + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=3,y=4294967293']) self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"') - self.expect("frame variable p1", substrs = ['(Pair) p1 = x=0x00000003,y=4294967293']); - self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'],matching=False); + self.expect("frame variable p1", substrs=[ + '(Pair) p1 = x=0x00000003,y=4294967293']) + self.expect( + "frame variable -f d p1", + substrs=['(Pair) p1 = x=3,y=-3'], + matching=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py index 5899469651d..53073f6d910 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class VarInAggregateMisuseTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class VarInAggregateMisuseTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -43,32 +45,36 @@ class VarInAggregateMisuseTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") - + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") + self.expect('frame variable mine_ptr', - substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) + substrs=['SUMMARY SUCCESS summarize_ptr_t @ ']) self.expect('frame variable *mine_ptr', - substrs = ['SUMMARY SUCCESS summarize_t @']) + substrs=['SUMMARY SUCCESS summarize_t @']) - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable mine_ptr', - substrs = ['SUMMARY SUCCESS 10']) + substrs=['SUMMARY SUCCESS 10']) self.expect('frame variable *mine_ptr', - substrs = ['SUMMARY SUCCESS 10']) + substrs=['SUMMARY SUCCESS 10']) self.runCmd("type summary add --summary-string \"${var}\" Summarize") - self.runCmd("type summary add --summary-string \"${var}\" -e TwoSummarizes") - + self.runCmd( + "type summary add --summary-string \"${var}\" -e TwoSummarizes") + self.expect('frame variable', - substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', - 'first = summarize_t @ ', - 'second = summarize_t @ ']) - - self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") + substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = summarize_t @ ', + 'second = summarize_t @ ']) + + self.runCmd( + "type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable', - substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', - 'first = SUMMARY SUCCESS 1', - 'second = SUMMARY SUCCESS 3']) + substrs=['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = SUMMARY SUCCESS 1', + 'second = SUMMARY SUCCESS 3']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py index f3eced62589..cde0ef40962 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py @@ -5,14 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import os.path import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class PythonSynthDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class PythonSynthDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', ' // Set breakpoint here.') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser def test_with_run_command(self): """Test using Python synthetic children provider.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,10 +50,11 @@ class PythonSynthDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + self.runCmd("command script import helperfunc.py") - self.runCmd('type summary add -x "^something<.*>$" -s "T is a ${script.var:helperfunc.f}"') + self.runCmd( + 'type summary add -x "^something<.*>$" -s "T is a ${script.var:helperfunc.f}"') + + self.expect("frame variable x", substrs=['T is a non-pointer type']) - self.expect("frame variable x", substrs = ['T is a non-pointer type']); - - self.expect("frame variable y", substrs = ['T is a pointer type']); + self.expect("frame variable y", substrs=['T is a pointer type']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py index 01562c5baa8..75654e4b4ed 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/helperfunc.py @@ -1,5 +1,6 @@ import lldb -def f(value,d): - return "pointer type" if value.GetType().GetTemplateArgumentType(0).IsPointerType() else "non-pointer type" +def f(value, d): + return "pointer type" if value.GetType().GetTemplateArgumentType( + 0).IsPointerType() else "non-pointer type" diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py index 365ddff3c7e..2d4cd5782fd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py @@ -5,13 +5,14 @@ Check that vector types format properly 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 VectorTypesFormattingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class VectorTypesFormattingTestCase(TestBase): self.line = line_number('main.cpp', '// break here') # rdar://problem/14035604 - @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension + @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension def test_with_run_command(self): """Check that vector types format properly""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,29 +48,43 @@ class VectorTypesFormattingTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - pass # my code never fails - + pass # my code never fails + v = self.frame().FindVariable("v") v.SetPreferSyntheticValue(True) v.SetFormat(lldb.eFormatVectorOfFloat32) - - if self.TraceOn(): print(v) - - self.assertTrue(v.GetNumChildren() == 4, "v as float32[] has 4 children") - self.assertTrue(v.GetChildAtIndex(0).GetData().float[0] == 1.25, "child 0 == 1.25") - self.assertTrue(v.GetChildAtIndex(1).GetData().float[0] == 1.25, "child 1 == 1.25") - self.assertTrue(v.GetChildAtIndex(2).GetData().float[0] == 2.50, "child 2 == 2.50") - self.assertTrue(v.GetChildAtIndex(3).GetData().float[0] == 2.50, "child 3 == 2.50") - - self.expect("expr -f int16_t[] -- v", substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)']) - self.expect("expr -f uint128_t[] -- v", substrs=['(85236745249553456609335044694184296448)']) - self.expect("expr -f float32[] -- v", substrs=['(1.25, 1.25, 2.5, 2.5)']) - + + if self.TraceOn(): + print(v) + + self.assertTrue( + v.GetNumChildren() == 4, + "v as float32[] has 4 children") + self.assertTrue(v.GetChildAtIndex(0).GetData().float[ + 0] == 1.25, "child 0 == 1.25") + self.assertTrue(v.GetChildAtIndex(1).GetData().float[ + 0] == 1.25, "child 1 == 1.25") + self.assertTrue(v.GetChildAtIndex(2).GetData().float[ + 0] == 2.50, "child 2 == 2.50") + self.assertTrue(v.GetChildAtIndex(3).GetData().float[ + 0] == 2.50, "child 3 == 2.50") + + self.expect("expr -f int16_t[] -- v", + substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)']) + self.expect("expr -f uint128_t[] -- v", + substrs=['(85236745249553456609335044694184296448)']) + self.expect( + "expr -f float32[] -- v", + substrs=['(1.25, 1.25, 2.5, 2.5)']) + oldValue = v.GetChildAtIndex(0).GetValue() v.SetFormat(lldb.eFormatHex) newValue = v.GetChildAtIndex(0).GetValue() - self.assertFalse(oldValue == newValue, "values did not change along with format") - + self.assertFalse(oldValue == newValue, + "values did not change along with format") + v.SetFormat(lldb.eFormatVectorOfFloat32) oldValueAgain = v.GetChildAtIndex(0).GetValue() - self.assertTrue(oldValue == oldValueAgain, "same format but different values") + self.assertTrue( + oldValue == oldValueAgain, + "same format but different values") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py index efbaa69eef5..355d60ade90 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py @@ -5,21 +5,26 @@ Test that breakpoint works correctly in the presence of dead-code stripping. 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 DeadStripTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @expectedFailureAll(debug_info="dwo", bugnumber="llvm.org/pr25087") - @expectedFailureAll(oslist=["linux"], debug_info="gmodules", bugnumber="llvm.org/pr27865") - @skipIfFreeBSD # The -dead_strip linker option isn't supported on FreeBSD versions of ld. + @expectedFailureAll( + oslist=["linux"], + debug_info="gmodules", + bugnumber="llvm.org/pr27865") + # The -dead_strip linker option isn't supported on FreeBSD versions of ld. + @skipIfFreeBSD def test(self): """Test breakpoint works correctly with dead-code stripping.""" self.build() @@ -27,34 +32,37 @@ class DeadStripTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name f1 (live code). - lldbutil.run_break_set_by_symbol (self, "f1", num_expected_locations=1, module_name="a.out") + lldbutil.run_break_set_by_symbol( + self, "f1", num_expected_locations=1, module_name="a.out") # Break by function name f2 (dead code). - lldbutil.run_break_set_by_symbol (self, "f2", num_expected_locations=0, module_name="a.out") + lldbutil.run_break_set_by_symbol( + self, "f2", num_expected_locations=0, module_name="a.out") # Break by function name f3 (live code). - lldbutil.run_break_set_by_symbol (self, "f3", num_expected_locations=1, module_name="a.out") + lldbutil.run_break_set_by_symbol( + self, "f3", num_expected_locations=1, module_name="a.out") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint (breakpoint #1). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'a.out`f1', - 'stop reason = breakpoint']) + substrs=['stopped', + 'a.out`f1', + 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f 1", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) self.runCmd("continue") # The stop reason of the thread should be breakpoint (breakpoint #3). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'a.out`f3', - 'stop reason = breakpoint']) + substrs=['stopped', + 'a.out`f3', + 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f 3", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs=[' resolved, hit count = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py index be0ea144133..e5d81d8cefc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py @@ -5,29 +5,37 @@ Test some lldb command abbreviations. 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 DisassemblyTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="function names print fully demangled instead of name-only") + @expectedFailureAll( + oslist=["windows"], + bugnumber="function names print fully demangled instead of name-only") def test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out.*" ]) + patterns=["Current executable set to .*a.out.*"]) - match_object = lldbutil.run_break_set_command (self, "br s -n sum") - lldbutil.check_breakpoint_result (self, match_object, symbol_name='sum', symbol_match_exact=False, num_locations=1) + match_object = lldbutil.run_break_set_command(self, "br s -n sum") + lldbutil.check_breakpoint_result( + self, + match_object, + symbol_name='sum', + symbol_match_exact=False, + num_locations=1) self.expect("run", - patterns = [ "Process .* launched: "]) + patterns=["Process .* launched: "]) self.runCmd("dis -f") disassembly = self.res.GetOutput() @@ -40,7 +48,7 @@ class DisassemblyTestCase(TestBase): elif arch in ["arm", "aarch64"]: breakpoint_opcodes = ["brk", "udf"] instructions = [' add ', ' ldr ', ' str '] - elif re.match("mips" , arch): + elif re.match("mips", arch): breakpoint_opcodes = ["break"] instructions = ['lw', 'sw'] elif arch in ["s390x"]: @@ -48,11 +56,17 @@ class DisassemblyTestCase(TestBase): instructions = [' l ', ' a ', ' st '] else: # TODO please add your arch here - self.fail('unimplemented for arch = "{arch}"'.format(arch=self.getArchitecture())) + self.fail( + 'unimplemented for arch = "{arch}"'.format( + arch=self.getArchitecture())) # make sure that the software breakpoint has been removed for op in breakpoint_opcodes: self.assertFalse(op in disassembly) # make sure a few reasonable assembly instructions are here - self.expect(disassembly, exe=False, startstr = "a.out`sum", substrs = instructions) + self.expect( + disassembly, + exe=False, + startstr="a.out`sum", + substrs=instructions) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py b/lldb/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py index 37593768f4a..79e4e627592 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py @@ -5,32 +5,33 @@ Test that dynamic values update their child count correctly 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 DynamicValueChildCountTestCase(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.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') + 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') @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663") @@ -42,26 +43,31 @@ class DynamicValueChildCountTestCase(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: - third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line) + 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) + 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) + 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) + 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()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) @@ -73,4 +79,6 @@ class DynamicValueChildCountTestCase(TestBase): 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") + self.assertTrue( + b.GetNumChildren() == 0, + "b didn't go back to 0 children") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py b/lldb/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py index 4b1880dee96..604249e14cf 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py @@ -3,13 +3,13 @@ from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ConvenienceVariablesCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,9 +20,11 @@ class ConvenienceVariablesCase(TestBase): # Find the line number to break on inside main.cpp. self.line = line_number('main.c', 'Hello world.') - @skipIfFreeBSD # llvm.org/pr17228 + @skipIfFreeBSD # llvm.org/pr17228 @skipIfRemote - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") def test_with_run_commands(self): """Test convenience variables lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame.""" self.build() @@ -32,7 +34,9 @@ class ConvenienceVariablesCase(TestBase): python_prompt = ">>> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe)) + self.child = pexpect.spawn( + '%s %s %s' % + (lldbtest_config.lldbExec, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): @@ -56,25 +60,33 @@ class ConvenienceVariablesCase(TestBase): child.sendline('print(lldb.debugger)') child.expect_exact(python_prompt) self.expect(child.before, exe=False, - patterns = ['Debugger \(instance: .*, id: \d\)']) + patterns=['Debugger \(instance: .*, id: \d\)']) child.sendline('print(lldb.target)') child.expect_exact(python_prompt) self.expect(child.before, exe=False, - substrs = ['a.out']) + substrs=['a.out']) child.sendline('print(lldb.process)') child.expect_exact(python_prompt) - self.expect(child.before, exe=False, - patterns = ['SBProcess: pid = \d+, state = stopped, threads = \d, executable = a.out']) + self.expect(child.before, exe=False, patterns=[ + 'SBProcess: pid = \d+, state = stopped, threads = \d, executable = a.out']) child.sendline('print(lldb.thread)') child.expect_exact(python_prompt) # Linux outputs decimal tid and 'name' instead of 'queue' - self.expect(child.before, exe=False, - patterns = ['thread #1: tid = (0x[0-9a-f]+|[0-9]+), 0x[0-9a-f]+ a\.out`main\(argc=1, argv=0x[0-9a-f]+\) \+ \d+ at main\.c:%d, (name|queue) = \'.+\', stop reason = breakpoint 1\.1' % self.line]) + self.expect( + child.before, + exe=False, + patterns=[ + 'thread #1: tid = (0x[0-9a-f]+|[0-9]+), 0x[0-9a-f]+ a\.out`main\(argc=1, argv=0x[0-9a-f]+\) \+ \d+ at main\.c:%d, (name|queue) = \'.+\', stop reason = breakpoint 1\.1' % + self.line]) child.sendline('print(lldb.frame)') child.expect_exact(python_prompt) - self.expect(child.before, exe=False, - patterns = ['frame #0: 0x[0-9a-f]+ a\.out`main\(argc=1, argv=0x[0-9a-f]+\) \+ \d+ at main\.c:%d' % self.line]) + self.expect( + child.before, + exe=False, + patterns=[ + 'frame #0: 0x[0-9a-f]+ a\.out`main\(argc=1, argv=0x[0-9a-f]+\) \+ \d+ at main\.c:%d' % + self.line]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py index 912d51fb6b0..98b002eb288 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py @@ -4,7 +4,6 @@ Test some lldb command abbreviations. from __future__ import print_function - import lldb import os import time @@ -13,14 +12,16 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def execute_command (command): + +def execute_command(command): #print('%% %s' % (command)) (exit_status, output) = seven.get_command_status_output(command) - #if output: + # if output: # print(output) #print('status = %u' % (exit_status)) return exit_status + class ExecTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,35 +29,42 @@ class ExecTestCase(TestBase): @skipUnlessDarwin def test(self): if self.getArchitecture() == 'x86_64': - source = os.path.join (os.getcwd(), "main.cpp") - o_file = os.path.join (os.getcwd(), "main.o") - execute_command ("'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" % (os.environ["CC"], source, o_file)) - execute_command ("'%s' -g -O0 -arch i386 -arch x86_64 '%s'" % (os.environ["CC"], o_file)) + source = os.path.join(os.getcwd(), "main.cpp") + o_file = os.path.join(os.getcwd(), "main.o") + execute_command( + "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" % + (os.environ["CC"], source, o_file)) + execute_command( + "'%s' -g -O0 -arch i386 -arch x86_64 '%s'" % + (os.environ["CC"], o_file)) if self.debug_info != "dsym": - dsym_path = os.path.join (os.getcwd(), "a.out.dSYM") - execute_command ("rm -rf '%s'" % (dsym_path)) + dsym_path = os.path.join(os.getcwd(), "a.out.dSYM") + execute_command("rm -rf '%s'" % (dsym_path)) else: self.build() - exe = os.path.join (os.getcwd(), "a.out") - + exe = os.path.join(os.getcwd(), "a.out") + # Create the target target = self.dbg.CreateTarget(exe) - + # Create any breakpoints we need - breakpoint = target.BreakpointCreateBySourceRegex ('Set breakpoint 1 here', lldb.SBFileSpec ("main.cpp", False)) + breakpoint = target.BreakpointCreateBySourceRegex( + 'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False)) self.assertTrue(breakpoint, VALID_BREAKPOINT) # Launch the process - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - + for i in range(6): # The stop reason of the thread should be breakpoint. self.assertTrue(process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) - threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) self.assertTrue(len(threads) == 1) # We had a deadlock tearing down the TypeSystemMap on exec, but only if some @@ -65,21 +73,28 @@ class ExecTestCase(TestBase): thread = threads[0] value = thread.frames[0].EvaluateExpression("1 + 2") - self.assertTrue(value.IsValid(), "Expression evaluated successfully") + self.assertTrue( + value.IsValid(), + "Expression evaluated successfully") int_value = value.GetValueAsSigned() self.assertTrue(int_value == 3, "Expression got the right result.") # Run and we should stop due to exec process.Continue() - + self.assertTrue(process.GetState() == lldb.eStateStopped, "Process should be stopped at __dyld_start") - - threads = lldbutil.get_stopped_threads(process, lldb.eStopReasonExec) - self.assertTrue(len(threads) == 1, "We got a thread stopped for exec.") - # Run and we should stop at breakpoint in main after exec - process.Continue() + threads = lldbutil.get_stopped_threads( + process, lldb.eStopReasonExec) + self.assertTrue( + len(threads) == 1, + "We got a thread stopped for exec.") + + # Run and we should stop at breakpoint in main after exec + process.Continue() - threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) - self.assertTrue(len(threads) == 1, "Stopped at breakpoint in exec'ed process.") + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(threads) == 1, + "Stopped at breakpoint in exec'ed process.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py b/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py index 1492fe06922..21d4357a6ff 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py @@ -5,14 +5,15 @@ Test that expr will time out and allow other threads to run if it blocks. 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 ExprDoesntDeadlockTestCase(TestBase): def getCategories(self): @@ -21,7 +22,9 @@ class ExprDoesntDeadlockTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946') - @expectedFailureAll(oslist=["windows"], bugnumber="Windows doesn't have pthreads, test needs to be ported") + @expectedFailureAll( + oslist=["windows"], + bugnumber="Windows doesn't have pthreads, test needs to be ported") def test_with_run_command(self): """Test that expr will time out and allow other threads to run if it blocks.""" self.build() @@ -31,10 +34,12 @@ class ExprDoesntDeadlockTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - # Now create a breakpoint at source line before call_me_to_get_lock gets called. + # Now create a breakpoint at source line before call_me_to_get_lock + # gets called. - main_file_spec = lldb.SBFileSpec ("locking.c") - breakpoint = target.BreakpointCreateBySourceRegex('Break here', main_file_spec) + main_file_spec = lldb.SBFileSpec("locking.c") + breakpoint = target.BreakpointCreateBySourceRegex( + 'Break here', main_file_spec) if self.TraceOn(): print("breakpoint:", breakpoint) self.assertTrue(breakpoint and @@ -42,16 +47,19 @@ class ExprDoesntDeadlockTestCase(TestBase): VALID_BREAKPOINT) # 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()) self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. from lldbsuite.test.lldbutil import get_stopped_thread thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) - var = frame0.EvaluateExpression ("call_me_to_get_lock()") - self.assertTrue (var.IsValid()) - self.assertTrue (var.GetValueAsSigned (0) == 567) + var = frame0.EvaluateExpression("call_me_to_get_lock()") + self.assertTrue(var.IsValid()) + self.assertTrue(var.GetValueAsSigned(0) == 567) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py b/lldb/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py index 6d2763c1ead..1feab9d1c4b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py @@ -4,7 +4,6 @@ Test some lldb command abbreviations. from __future__ import print_function - import lldb import os import time @@ -13,7 +12,8 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def execute_command (command): + +def execute_command(command): # print('%% %s' % (command)) (exit_status, output) = seven.get_command_status_output(command) # if output: @@ -21,39 +21,48 @@ def execute_command (command): # print('status = %u' % (exit_status)) return exit_status + class FatArchiveTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin - def test (self): + def test(self): if self.getArchitecture() == 'x86_64': - execute_command ("make CC='%s'" % (os.environ["CC"])) - self.main () + execute_command("make CC='%s'" % (os.environ["CC"])) + self.main() else: - self.skipTest("This test requires x86_64 as the architecture for the inferior") + self.skipTest( + "This test requires x86_64 as the architecture for the inferior") - def main (self): + def main(self): '''This test compiles a quick example by making a fat file (universal) full of skinny .o files and makes sure we can use them to resolve breakpoints when doing DWARF in .o file debugging. The only thing this test needs to do is to compile and set a breakpoint in the target and verify any breakpoint locations have valid debug info for the function, and source file and line.''' - exe = os.path.join (os.getcwd(), "a.out") - + exe = os.path.join(os.getcwd(), "a.out") + # Create the target target = self.dbg.CreateTarget(exe) - + # Create a breakpoint by name - breakpoint = target.BreakpointCreateByName ('foo', exe) + breakpoint = target.BreakpointCreateByName('foo', exe) self.assertTrue(breakpoint, VALID_BREAKPOINT) # Make sure the breakpoint resolves to a function, file and line for bp_loc in breakpoint: - # Get a section offset address (lldb.SBAddress) from the breakpoint location + # Get a section offset address (lldb.SBAddress) from the breakpoint + # location bp_loc_addr = bp_loc.GetAddress() line_entry = bp_loc_addr.GetLineEntry() function = bp_loc_addr.GetFunction() - self.assertTrue(function.IsValid(), "Verify breakpoint in fat BSD archive has valid function debug info") - self.assertTrue(line_entry.GetFileSpec(), "Verify breakpoint in fat BSD archive has source file information") - self.assertTrue(line_entry.GetLine() != 0, "Verify breakpoint in fat BSD archive has source line information") + self.assertTrue( + function.IsValid(), + "Verify breakpoint in fat BSD archive has valid function debug info") + self.assertTrue( + line_entry.GetFileSpec(), + "Verify breakpoint in fat BSD archive has source file information") + self.assertTrue( + line_entry.GetLine() != 0, + "Verify breakpoint in fat BSD archive has source line information") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py b/lldb/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py index 0ba036124b0..b7592c93704 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py @@ -5,24 +5,28 @@ Test the command history mechanism from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestFormats(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") def test_formats(self): """Test format string functionality.""" self.build() import pexpect prompt = "(lldb) " - child = pexpect.spawn('%s %s -x -o "b main" -o r a.out' % (lldbtest_config.lldbExec, self.lldbOption)) + child = pexpect.spawn( + '%s %s -x -o "b main" -o r a.out' % + (lldbtest_config.lldbExec, self.lldbOption)) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout @@ -30,13 +34,13 @@ class TestFormats(TestBase): self.child = child # Substitute 'Help!' for 'help' using the 'commands regex' mechanism. - child.expect_exact(prompt + 'target create "a.out"') - child.expect_exact(prompt + 'b main') - child.expect_exact(prompt + 'r') + child.expect_exact(prompt + 'target create "a.out"') + child.expect_exact(prompt + 'b main') + child.expect_exact(prompt + 'r') child.expect_exact(prompt) child.sendline() - # child.expect_exact(prompt + "target create") - # + # child.expect_exact(prompt + "target create") + # # child.sendline("command regex 'Help__'") # child.expect_exact(regex_prompt) # child.sendline('s/^$/help/') @@ -51,7 +55,7 @@ class TestFormats(TestBase): # child.sendline('command unalias Help__') # child.expect_exact("error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command") # child.expect_exact(prompt) - # + # # # Delete the regex command using "command delete" # child.sendline('command delete Help__') # child.expect_exact(prompt) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py index 0f1c109676c..46264f3dfe8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestArray(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,8 @@ class TestArray(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", substrs=["a[10]"]) + substrs=['stopped']) + self.expect( + "frame diagnose", + "Crash diagnosis was accurate", + substrs=["a[10]"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py index e90e8668f7f..dd8ff949fa9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestBadReference(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,5 @@ class TestBadReference(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "f->b") + substrs=['stopped']) + self.expect("frame diagnose", "Crash diagnosis was accurate", "f->b") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py index bd25a29fab0..a8708169bb3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseDereferenceArgument(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,8 @@ class TestDiagnoseDereferenceArgument(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "f->b->d") + substrs=['stopped']) + self.expect( + "frame diagnose", + "Crash diagnosis was accurate", + "f->b->d") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py index 28872929b91..80128eec1f7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseDereferenceArgument(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,8 @@ class TestDiagnoseDereferenceArgument(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "f->b->d") + substrs=['stopped']) + self.expect( + "frame diagnose", + "Crash diagnosis was accurate", + "f->b->d") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py index 597ced3c0d9..672b1e9814b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseDereferenceFunctionReturn(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,6 +22,10 @@ class TestDiagnoseDereferenceFunctionReturn(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", substrs = ["GetAFoo", "->b"]) - + substrs=['stopped']) + self.expect( + "frame diagnose", + "Crash diagnosis was accurate", + substrs=[ + "GetAFoo", + "->b"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py index fe71e528d8f..233c9e403bd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseDereferenceThis(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,8 @@ class TestDiagnoseDereferenceThis(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "this->a") + substrs=['stopped']) + self.expect( + "frame diagnose", + "Crash diagnosis was accurate", + "this->a") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py index 1438747c1a1..267223ad085 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseInheritance(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,5 @@ class TestDiagnoseInheritance(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "d") + substrs=['stopped']) + self.expect("frame diagnose", "Crash diagnosis was accurate", "d") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py index cdddd8483a6..a1a17c94176 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestLocalVariable(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,5 @@ class TestLocalVariable(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "myInt") + substrs=['stopped']) + self.expect("frame diagnose", "Crash diagnosis was accurate", "myInt") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py index 6f7e55b4629..adf092d8615 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestDiagnoseVirtualMethodCall(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,5 +22,5 @@ class TestDiagnoseVirtualMethodCall(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", - substrs = ['stopped']) - self.expect("frame diagnose", "Crash diagnosis was accurate", "foo") + substrs=['stopped']) + self.expect("frame diagnose", "Crash diagnosis was accurate", "foo") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py index ceeb2eadaf4..7b048fedebb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py @@ -3,79 +3,117 @@ from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test import lldbutil from lldbsuite.test import lldbplatformutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * + class AssertingInferiorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") - @expectedFailureAll(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr25338") - @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips') + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAll( + oslist=["linux"], + archs=["arm"], + bugnumber="llvm.org/pr25338") + @expectedFailureAll(bugnumber="llvm.org/pr26592", triple='^mips') def test_inferior_asserting(self): """Test that lldb reliably catches the inferior asserting (command).""" self.build() self.inferior_asserting() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") - @expectedFailureAndroid(api_levels=list(range(16 + 1))) # b.android.com/179836 + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAndroid( + api_levels=list( + range( + 16 + + 1))) # b.android.com/179836 def test_inferior_asserting_register(self): """Test that lldb reliably reads registers from the inferior after asserting (command).""" self.build() self.inferior_asserting_registers() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") - @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") - @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips') + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAll( + oslist=["linux"], + archs=[ + "aarch64", + "arm"], + bugnumber="llvm.org/pr25338") + @expectedFailureAll(bugnumber="llvm.org/pr26592", triple='^mips') def test_inferior_asserting_disassemble(self): """Test that lldb reliably disassembles frames after asserting (command).""" self.build() self.inferior_asserting_disassemble() @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") def test_inferior_asserting_python(self): """Test that lldb reliably catches the inferior asserting (Python API).""" self.build() self.inferior_asserting_python() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") - @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") - @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips') + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAll( + oslist=["linux"], + archs=[ + "aarch64", + "arm"], + bugnumber="llvm.org/pr25338") + @expectedFailureAll(bugnumber="llvm.org/pr26592", triple='^mips') def test_inferior_asserting_expr(self): """Test that the lldb expression interpreter can read from the inferior after asserting (command).""" self.build() self.inferior_asserting_expr() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") - @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") - @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips') + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") + @expectedFailureAll( + oslist=["linux"], + archs=[ + "aarch64", + "arm"], + bugnumber="llvm.org/pr25338") + @expectedFailureAll(bugnumber="llvm.org/pr26592", triple='^mips') def test_inferior_asserting_step(self): """Test that lldb functions correctly after stepping through a call to assert().""" self.build() self.inferior_asserting_step() def set_breakpoint(self, line): - lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", line, num_expected_locations=1, loc_exact=True) def check_stop_reason(self): - matched = lldbplatformutil.match_android_device(self.getArchitecture(), valid_api_levels=list(range(1, 16+1))) + matched = lldbplatformutil.match_android_device( + self.getArchitecture(), valid_api_levels=list(range(1, 16 + 1))) if matched: - # On android until API-16 the abort() call ended in a sigsegv instead of in a sigabrt + # On android until API-16 the abort() call ended in a sigsegv + # instead of in a sigabrt stop_reason = 'stop reason = signal SIGSEGV' else: stop_reason = 'stop reason = signal SIGABRT' # The stop reason of the thread should be an abort signal or exception. self.expect("thread list", STOPPED_DUE_TO_ASSERT, - substrs = ['stopped', - stop_reason]) + substrs=['stopped', + stop_reason]) return stop_reason @@ -95,12 +133,12 @@ class AssertingInferiorTestCase(TestBase): # And it should report a backtrace that includes the assert site. self.expect("thread backtrace all", - substrs = [stop_reason, 'main', 'argc', 'argv']) + substrs=[stop_reason, 'main', 'argc', 'argv']) # And it should report the correct line number. self.expect("thread backtrace all", - substrs = [stop_reason, - 'main.c:%d' % self.line]) + substrs=[stop_reason, + 'main.c:%d' % self.line]) def inferior_asserting_python(self): """Inferior asserts upon launching; lldb should catch the event and stop.""" @@ -111,7 +149,8 @@ class AssertingInferiorTestCase(TestBase): # Now launch the process, and do not stop at entry point. # Both argv and envp are null. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " @@ -133,7 +172,8 @@ class AssertingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # lldb should be able to read from registers from the inferior after asserting. + # lldb should be able to read from registers from the inferior after + # asserting. lldbplatformutil.check_first_register_readable(self) def inferior_asserting_disassemble(self): @@ -145,7 +185,7 @@ class AssertingInferiorTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. - target.LaunchSimple (None, None, self.get_process_working_directory()) + target.LaunchSimple(None, None, self.get_process_working_directory()) self.check_stop_reason() process = target.GetProcess() @@ -154,17 +194,20 @@ class AssertingInferiorTestCase(TestBase): thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid(), "current thread is valid") - lastframeID = thread.GetFrameAtIndex(thread.GetNumFrames() - 1).GetFrameID() + lastframeID = thread.GetFrameAtIndex( + thread.GetNumFrames() - 1).GetFrameID() isi386Arch = False if "i386" in self.getArchitecture(): isi386Arch = True - # lldb should be able to disassemble frames from the inferior after asserting. + # lldb should be able to disassemble frames from the inferior after + # asserting. for frame in thread: self.assertTrue(frame.IsValid(), "current frame is valid") - self.runCmd("frame select " + str(frame.GetFrameID()), RUN_SUCCEEDED) + self.runCmd("frame select " + + str(frame.GetFrameID()), RUN_SUCCEEDED) # Don't expect the function name to be in the disassembly as the assert # function might be a no-return function where the PC is past the end @@ -174,11 +217,14 @@ class AssertingInferiorTestCase(TestBase): pc_backup_offset = 1 if frame.GetFrameID() == 0: pc_backup_offset = 0 - if isi386Arch == True: + if isi386Arch: if lastframeID == frame.GetFrameID(): pc_backup_offset = 0 - self.expect("disassemble -a %s" % (frame.GetPC() - pc_backup_offset), - substrs = ['<+0>: ']) + self.expect( + "disassemble -a %s" % + (frame.GetPC() - + pc_backup_offset), + substrs=['<+0>: ']) def check_expr_in_main(self, thread): depth = thread.GetNumFrames() @@ -186,17 +232,19 @@ class AssertingInferiorTestCase(TestBase): frame = thread.GetFrameAtIndex(i) self.assertTrue(frame.IsValid(), "current frame is valid") if self.TraceOn(): - print("Checking if function %s is main" % frame.GetFunctionName()) + print( + "Checking if function %s is main" % + frame.GetFunctionName()) if 'main' == frame.GetFunctionName(): frame_id = frame.GetFrameID() self.runCmd("frame select " + str(frame_id), RUN_SUCCEEDED) - self.expect("p argc", substrs = ['(int)', ' = 1']) - self.expect("p hello_world", substrs = ['Hello']) - self.expect("p argv[0]", substrs = ['a.out']) - self.expect("p null_ptr", substrs = ['= 0x0']) - return True - return False + self.expect("p argc", substrs=['(int)', ' = 1']) + self.expect("p hello_world", substrs=['Hello']) + self.expect("p argv[0]", substrs=['a.out']) + self.expect("p null_ptr", substrs=['= 0x0']) + return True + return False def inferior_asserting_expr(self): """Test that the lldb expression interpreter can read symbols after asserting.""" @@ -207,7 +255,7 @@ class AssertingInferiorTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. - target.LaunchSimple (None, None, self.get_process_working_directory()) + target.LaunchSimple(None, None, self.get_process_working_directory()) self.check_stop_reason() process = target.GetProcess() @@ -216,8 +264,11 @@ class AssertingInferiorTestCase(TestBase): thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid(), "current thread is valid") - # The lldb expression interpreter should be able to read from addresses of the inferior after a call to assert(). - self.assertTrue(self.check_expr_in_main(thread), "cannot find 'main' in the backtrace") + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a call to assert(). + self.assertTrue( + self.check_expr_in_main(thread), + "cannot find 'main' in the backtrace") def inferior_asserting_step(self): """Test that lldb functions correctly after stepping through a call to assert().""" @@ -229,20 +280,21 @@ class AssertingInferiorTestCase(TestBase): # Launch the process, and do not stop at the entry point. self.set_breakpoint(self.line) - target.LaunchSimple (None, None, self.get_process_working_directory()) + target.LaunchSimple(None, None, self.get_process_working_directory()) self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['main.c:%d' % self.line, - 'stop reason = breakpoint']) + substrs=['main.c:%d' % self.line, + 'stop reason = breakpoint']) self.runCmd("next") stop_reason = self.check_stop_reason() - # lldb should be able to read from registers from the inferior after asserting. + # lldb should be able to read from registers from the inferior after + # asserting. if "x86_64" in self.getArchitecture(): - self.expect("register read rbp", substrs = ['rbp = 0x']) + self.expect("register read rbp", substrs=['rbp = 0x']) if "i386" in self.getArchitecture(): - self.expect("register read ebp", substrs = ['ebp = 0x']) + self.expect("register read ebp", substrs=['ebp = 0x']) process = target.GetProcess() self.assertTrue(process.IsValid(), "current process is valid") @@ -250,10 +302,13 @@ class AssertingInferiorTestCase(TestBase): thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid(), "current thread is valid") - # The lldb expression interpreter should be able to read from addresses of the inferior after a call to assert(). - self.assertTrue(self.check_expr_in_main(thread), "cannot find 'main' in the backtrace") + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a call to assert(). + self.assertTrue( + self.check_expr_in_main(thread), + "cannot find 'main' in the backtrace") # And it should report the correct line number. self.expect("thread backtrace all", - substrs = [stop_reason, - 'main.c:%d' % self.line]) + substrs=[stop_reason, + 'main.c:%d' % self.line]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py index 359846c314f..3620de61a2e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py @@ -3,14 +3,15 @@ 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 configuration from lldbsuite.test import lldbutil + class ChangedInferiorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -47,12 +48,12 @@ class ChangedInferiorTestCase(TestBase): # We should have one crashing thread self.assertEqual( - len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), - 1, - STOPPED_DUE_TO_EXC_BAD_ACCESS) + len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), + 1, + STOPPED_DUE_TO_EXC_BAD_ACCESS) # And it should report the correct line number. - self.expect("thread backtrace all", substrs = ['main.c:%d' % self.line1]) + self.expect("thread backtrace all", substrs=['main.c:%d' % self.line1]) def inferior_not_crashing(self): """Test lldb reloads the inferior after it was changed during the session.""" @@ -61,22 +62,23 @@ class ChangedInferiorTestCase(TestBase): self.runCmd("process status") self.assertNotEqual( - len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), - 1, - "Inferior changed, but lldb did not perform a reload") + len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), + 1, + "Inferior changed, but lldb did not perform a reload") # Break inside the main. - lldbutil.run_break_set_by_file_and_line (self, "main2.c", self.line2, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main2.c", self.line2, num_expected_locations=1, loc_exact=True) 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']) self.runCmd("frame variable int_ptr") self.expect("frame variable *int_ptr", - substrs = ['= 7']) + substrs=['= 7']) self.expect("expression *int_ptr", - substrs = ['= 7']) + substrs=['= 7']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py index f6d79ca06e7..d058b1cac56 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -3,74 +3,94 @@ from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test import lldbutil from lldbsuite.test import lldbplatformutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * + class CrashingInferiorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing(self): """Test that lldb reliably catches the inferior crashing (command).""" self.build() self.inferior_crashing() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_register(self): """Test that lldb reliably reads registers from the inferior after crashing (command).""" self.build() self.inferior_crashing_registers() @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_python(self): """Test that lldb reliably catches the inferior crashing (Python API).""" self.build() self.inferior_crashing_python() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.build() self.inferior_crashing_expr() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_step(self): """Test that stepping after a crash behaves correctly.""" self.build() self.inferior_crashing_step() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") - @skipIfTargetAndroid() # debuggerd interferes with this test on Android + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @skipIfTargetAndroid() # debuggerd interferes with this test on Android def test_inferior_crashing_step_after_break(self): """Test that lldb functions correctly after stepping through a crash.""" self.build() self.inferior_crashing_step_after_break() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") - @skipIfLinux # Inferior exits after stepping after a segfault. This is working as intended IMHO. + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + # Inferior exits after stepping after a segfault. This is working as + # intended IMHO. + @skipIfLinux def test_inferior_crashing_expr_step_and_expr(self): """Test that lldb expressions work before and after stepping after a crash.""" self.build() self.inferior_crashing_expr_step_expr() def set_breakpoint(self, line): - lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", line, num_expected_locations=1, loc_exact=True) def check_stop_reason(self): # We should have one crashing thread self.assertEqual( - len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), - 1, - STOPPED_DUE_TO_EXC_BAD_ACCESS) + len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), + 1, + STOPPED_DUE_TO_EXC_BAD_ACCESS) def get_api_stop_reason(self): return lldb.eStopReasonException @@ -95,13 +115,13 @@ class CrashingInferiorTestCase(TestBase): else: stop_reason = 'stop reason = invalid address' self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, - substrs = ['stopped', - stop_reason]) + substrs=['stopped', + stop_reason]) # And it should report the correct line number. self.expect("thread backtrace all", - substrs = [stop_reason, - 'main.c:%d' % self.line]) + substrs=[stop_reason, + 'main.c:%d' % self.line]) def inferior_crashing_python(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" @@ -112,7 +132,8 @@ class CrashingInferiorTestCase(TestBase): # Now launch the process, and do not stop at entry point. # Both argv and envp are null. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " @@ -120,7 +141,10 @@ class CrashingInferiorTestCase(TestBase): lldbutil.state_type_to_str(process.GetState())) threads = lldbutil.get_crashed_threads(self, process) - self.assertEqual(len(threads), 1, "Failed to stop the thread upon bad access exception") + self.assertEqual( + len(threads), + 1, + "Failed to stop the thread upon bad access exception") if self.TraceOn(): lldbutil.print_stacktrace(threads[0]) @@ -133,7 +157,8 @@ class CrashingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # lldb should be able to read from registers from the inferior after crashing. + # lldb should be able to read from registers from the inferior after + # crashing. lldbplatformutil.check_first_register_readable(self) def inferior_crashing_expr(self): @@ -144,12 +169,13 @@ class CrashingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p argc", - startstr = '(int) $0 = 1') + startstr='(int) $0 = 1') self.expect("p hello_world", - substrs = ['Hello']) + substrs=['Hello']) def inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" @@ -160,24 +186,26 @@ class CrashingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['main.c:%d' % self.line, - 'stop reason = breakpoint']) + substrs=['main.c:%d' % self.line, + 'stop reason = breakpoint']) self.runCmd("next") self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p argv[0]", - substrs = ['a.out']) + substrs=['a.out']) self.expect("p null_ptr", - substrs = ['= 0x0']) + substrs=['= 0x0']) - # lldb should be able to read from registers from the inferior after crashing. + # lldb should be able to read from registers from the inferior after + # crashing. lldbplatformutil.check_first_register_readable(self) # And it should report the correct line number. self.expect("thread backtrace all", - substrs = ['main.c:%d' % self.line]) + substrs=['main.c:%d' % self.line]) def inferior_crashing_step_after_break(self): """Test that lldb behaves correctly when stepping after a crash.""" @@ -187,15 +215,20 @@ class CrashingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - expected_state = 'exited' # Provide the exit code. + expected_state = 'exited' # Provide the exit code. if self.platformIsDarwin(): - expected_state = 'stopped' # TODO: Determine why 'next' and 'continue' have no effect after a crash. + # TODO: Determine why 'next' and 'continue' have no effect after a + # crash. + expected_state = 'stopped' self.expect("next", - substrs = ['Process', expected_state]) + substrs=['Process', expected_state]) if expected_state == 'exited': - self.expect("thread list", error=True,substrs = ['Process must be launched']) + self.expect( + "thread list", + error=True, + substrs=['Process must be launched']) else: self.check_stop_reason() @@ -207,13 +240,15 @@ class CrashingInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p argv[0]", - substrs = ['a.out']) + substrs=['a.out']) self.runCmd("next") self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p argv[0]", - substrs = ['a.out']) + substrs=['a.out']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py index 82e55a575f1..f04173a3e8d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py @@ -3,19 +3,22 @@ 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 lldbplatformutil from lldbsuite.test import lldbutil + class CrashingRecursiveInferiorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing(self): """Test that lldb reliably catches the inferior crashing (command).""" @@ -49,13 +52,15 @@ class CrashingRecursiveInferiorTestCase(TestBase): @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939') @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") - @skipIfTargetAndroid() # debuggerd interferes with this test on Android + @skipIfTargetAndroid() # debuggerd interferes with this test on Android def test_recursive_inferior_crashing_step_after_break(self): """Test that lldb functions correctly after stepping through a crash.""" self.build() self.recursive_inferior_crashing_step_after_break() - @skipIfLinux # Inferior exits after stepping after a segfault. This is working as intended IMHO. + # Inferior exits after stepping after a segfault. This is working as + # intended IMHO. + @skipIfLinux @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing_expr_step_and_expr(self): """Test that lldb expressions work before and after stepping after a crash.""" @@ -63,14 +68,15 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.recursive_inferior_crashing_expr_step_expr() def set_breakpoint(self, line): - lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", line, num_expected_locations=1, loc_exact=True) def check_stop_reason(self): # We should have one crashing thread self.assertEqual( - len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), - 1, - STOPPED_DUE_TO_EXC_BAD_ACCESS) + len(lldbutil.get_crashed_threads(self, self.dbg.GetSelectedTarget().GetProcess())), + 1, + STOPPED_DUE_TO_EXC_BAD_ACCESS) def setUp(self): # Call super's setUp(). @@ -93,17 +99,24 @@ class CrashingRecursiveInferiorTestCase(TestBase): else: stop_reason = 'stop reason = invalid address' self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, - substrs = ['stopped', - stop_reason]) - - # And it should report a backtrace that includes main and the crash site. - self.expect("thread backtrace all", - substrs = [stop_reason, 'main', 'argc', 'argv', 'recursive_function']) + substrs=['stopped', + stop_reason]) + + # And it should report a backtrace that includes main and the crash + # site. + self.expect( + "thread backtrace all", + substrs=[ + stop_reason, + 'main', + 'argc', + 'argv', + 'recursive_function']) # And it should report the correct line number. self.expect("thread backtrace all", - substrs = [stop_reason, - 'main.c:%d' % self.line]) + substrs=[stop_reason, + 'main.c:%d' % self.line]) def recursive_inferior_crashing_python(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" @@ -114,7 +127,8 @@ class CrashingRecursiveInferiorTestCase(TestBase): # Now launch the process, and do not stop at entry point. # Both argv and envp are null. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " @@ -122,7 +136,10 @@ class CrashingRecursiveInferiorTestCase(TestBase): lldbutil.state_type_to_str(process.GetState())) threads = lldbutil.get_crashed_threads(self, process) - self.assertEqual(len(threads), 1, "Failed to stop the thread upon bad access exception") + self.assertEqual( + len(threads), + 1, + "Failed to stop the thread upon bad access exception") if self.TraceOn(): lldbutil.print_stacktrace(threads[0]) @@ -135,7 +152,8 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # lldb should be able to read from registers from the inferior after crashing. + # lldb should be able to read from registers from the inferior after + # crashing. lldbplatformutil.check_first_register_readable(self) def recursive_inferior_crashing_expr(self): @@ -146,9 +164,10 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p i", - startstr = '(int) $0 =') + startstr='(int) $0 =') def recursive_inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" @@ -159,22 +178,24 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['main.c:%d' % self.line, - 'stop reason = breakpoint']) + substrs=['main.c:%d' % self.line, + 'stop reason = breakpoint']) self.runCmd("next") self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p i", - substrs = ['(int) $0 =']) + substrs=['(int) $0 =']) - # lldb should be able to read from registers from the inferior after crashing. + # lldb should be able to read from registers from the inferior after + # crashing. lldbplatformutil.check_first_register_readable(self) # And it should report the correct line number. self.expect("thread backtrace all", - substrs = ['main.c:%d' % self.line]) + substrs=['main.c:%d' % self.line]) def recursive_inferior_crashing_step_after_break(self): """Test that lldb behaves correctly when stepping after a crash.""" @@ -184,15 +205,20 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - expected_state = 'exited' # Provide the exit code. + expected_state = 'exited' # Provide the exit code. if self.platformIsDarwin(): - expected_state = 'stopped' # TODO: Determine why 'next' and 'continue' have no effect after a crash. + # TODO: Determine why 'next' and 'continue' have no effect after a + # crash. + expected_state = 'stopped' self.expect("next", - substrs = ['Process', expected_state]) + substrs=['Process', expected_state]) if expected_state == 'exited': - self.expect("thread list", error=True,substrs = ['Process must be launched']) + self.expect( + "thread list", + error=True, + substrs=['Process must be launched']) else: self.check_stop_reason() @@ -204,14 +230,16 @@ class CrashingRecursiveInferiorTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) self.check_stop_reason() - # The lldb expression interpreter should be able to read from addresses of the inferior after a crash. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a crash. self.expect("p null", - startstr = '(char *) $0 = 0x0') + startstr='(char *) $0 = 0x0') self.runCmd("next") - # The lldb expression interpreter should be able to read from addresses of the inferior after a step. + # The lldb expression interpreter should be able to read from addresses + # of the inferior after a step. self.expect("p null", - startstr = '(char *) $1 = 0x0') + startstr='(char *) $1 = 0x0') self.check_stop_reason() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py b/lldb/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py index 8257106888d..cb801242aa5 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py @@ -3,19 +3,23 @@ from __future__ import print_function - -import os, time, sys +import os +import time +import sys import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestInlineStepping(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFailureAll(compiler="icc", bugnumber="# Not really a bug. ICC combines two inlined functions.") + @expectedFailureAll( + compiler="icc", + bugnumber="# Not really a bug. ICC combines two inlined functions.") def test_with_python_api(self): """Test stepping over and into inlined functions.""" self.build() @@ -26,7 +30,7 @@ class TestInlineStepping(TestBase): """Test stepping over and into inlined functions.""" self.build() self.inline_stepping_step_over() - + @add_test_categories(['pyapi']) def test_step_in_template_with_python_api(self): """Test stepping in to templated functions.""" @@ -39,10 +43,21 @@ class TestInlineStepping(TestBase): # Find the line numbers that we will step to in main: self.main_source = "calling.cpp" self.source_lines = {} - functions = ['caller_ref_1', 'caller_ref_2', 'inline_ref_1', 'inline_ref_2', 'called_by_inline_ref', 'caller_trivial_1', 'caller_trivial_2', 'inline_trivial_1', 'inline_trivial_2', 'called_by_inline_trivial' ] + functions = [ + 'caller_ref_1', + 'caller_ref_2', + 'inline_ref_1', + 'inline_ref_2', + 'called_by_inline_ref', + 'caller_trivial_1', + 'caller_trivial_2', + 'inline_trivial_1', + 'inline_trivial_2', + 'called_by_inline_trivial'] for name in functions: - self.source_lines[name] = line_number(self.main_source, "// In " + name + ".") - self.main_source_spec = lldb.SBFileSpec (self.main_source) + self.source_lines[name] = line_number( + self.main_source, "// In " + name + ".") + self.main_source_spec = lldb.SBFileSpec(self.main_source) def do_step(self, step_type, destination_line_entry, test_stack_depth): expected_stack_depth = self.thread.GetNumFrames() @@ -55,58 +70,79 @@ class TestInlineStepping(TestBase): elif step_type == "over": self.thread.StepOver() else: - self.fail ("Unrecognized step type: " + step_type) + self.fail("Unrecognized step type: " + step_type) - threads = lldbutil.get_stopped_threads (self.process, lldb.eStopReasonPlanComplete) + threads = lldbutil.get_stopped_threads( + self.process, lldb.eStopReasonPlanComplete) if len(threads) != 1: destination_description = lldb.SBStream() destination_line_entry.GetDescription(destination_description) - self.fail ("Failed to stop due to step " + step_type + " operation stepping to: " + destination_description.GetData()) + self.fail( + "Failed to stop due to step " + + step_type + + " operation stepping to: " + + destination_description.GetData()) self.thread = threads[0] stop_line_entry = self.thread.GetFrameAtIndex(0).GetLineEntry() - self.assertTrue (stop_line_entry.IsValid(), "Stop line entry was not valid.") - - # Don't use the line entry equal operator because we don't care about the column number. - stop_at_right_place = (stop_line_entry.GetFileSpec() == destination_line_entry.GetFileSpec() and stop_line_entry.GetLine() == destination_line_entry.GetLine()) - if stop_at_right_place == False: + self.assertTrue( + stop_line_entry.IsValid(), + "Stop line entry was not valid.") + + # Don't use the line entry equal operator because we don't care about + # the column number. + stop_at_right_place = (stop_line_entry.GetFileSpec() == destination_line_entry.GetFileSpec( + ) and stop_line_entry.GetLine() == destination_line_entry.GetLine()) + if not stop_at_right_place: destination_description = lldb.SBStream() destination_line_entry.GetDescription(destination_description) actual_description = lldb.SBStream() stop_line_entry.GetDescription(actual_description) - self.fail ("Step " + step_type + " stopped at wrong place: expected: " + destination_description.GetData() + " got: " + actual_description.GetData() + ".") + self.fail( + "Step " + + step_type + + " stopped at wrong place: expected: " + + destination_description.GetData() + + " got: " + + actual_description.GetData() + + ".") real_stack_depth = self.thread.GetNumFrames() if test_stack_depth and real_stack_depth != expected_stack_depth: destination_description = lldb.SBStream() destination_line_entry.GetDescription(destination_description) - self.fail ("Step %s to %s got wrong number of frames, should be: %d was: %d."%(step_type, destination_description.GetData(), expected_stack_depth, real_stack_depth)) - + self.fail( + "Step %s to %s got wrong number of frames, should be: %d was: %d." % + (step_type, + destination_description.GetData(), + expected_stack_depth, + real_stack_depth)) + def run_step_sequence(self, step_sequence): """This function takes a list of duples instructing how to run the program. The first element in each duple is a source pattern for the target location, and the second is the operation that will take you from the current source location to the target location. It will then run all the steps in the sequence. - It will check that you arrived at the expected source location at each step, and that the stack depth changed + It will check that you arrived at the expected source location at each step, and that the stack depth changed correctly for the operation in the sequence.""" target_line_entry = lldb.SBLineEntry() target_line_entry.SetFileSpec(self.main_source_spec) test_stack_depth = True - # Work around for <rdar://problem/16363195>, the darwin unwinder seems flakey about whether it duplicates the first frame + # Work around for <rdar://problem/16363195>, the darwin unwinder seems flakey about whether it duplicates the first frame # or not, which makes counting stack depth unreliable. if self.platformIsDarwin(): test_stack_depth = False for step_pattern in step_sequence: - step_stop_line = line_number (self.main_source, step_pattern[0]) + step_stop_line = line_number(self.main_source, step_pattern[0]) target_line_entry.SetLine(step_stop_line) - self.do_step (step_pattern[1], target_line_entry, test_stack_depth) - + self.do_step(step_pattern[1], target_line_entry, test_stack_depth) + def inline_stepping(self): """Use Python APIs to test stepping over and hitting breakpoints.""" exe = os.path.join(os.getcwd(), "a.out") @@ -114,19 +150,22 @@ class TestInlineStepping(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - break_1_in_main = target.BreakpointCreateBySourceRegex ('// Stop here and step over to set up stepping over.', self.main_source_spec) + break_1_in_main = target.BreakpointCreateBySourceRegex( + '// Stop here and step over to set up stepping over.', self.main_source_spec) self.assertTrue(break_1_in_main, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main) + threads = lldbutil.get_threads_stopped_at_breakpoint( + self.process, break_1_in_main) if len(threads) != 1: - self.fail ("Failed to stop at first breakpoint in main.") + self.fail("Failed to stop at first breakpoint in main.") self.thread = threads[0] @@ -135,60 +174,73 @@ class TestInlineStepping(TestBase): # gets set past the insertion line in the function. # Then test stepping over a simple inlined function. Note, to test all the parts of the inlined stepping # the calls inline_stepping_1 and inline_stepping_2 should line up at the same address, that way we will test - # the "virtual" stepping. + # the "virtual" stepping. # FIXME: Put in a check to see if that is true and warn if it is not. - step_sequence = [["// At inline_trivial_1 called from main.", "over"], + step_sequence = [["// At inline_trivial_1 called from main.", "over"], ["// At first call of caller_trivial_1 in main.", "over"]] self.run_step_sequence(step_sequence) - + # Now step from caller_ref_1 all the way into called_by_inline_trivial - step_sequence = [["// In caller_trivial_1.", "into"], - ["// In caller_trivial_2.", "into"], + step_sequence = [["// In caller_trivial_1.", "into"], + ["// In caller_trivial_2.", "into"], ["// In inline_trivial_1.", "into"], ["// In inline_trivial_2.", "into"], ["// At caller_by_inline_trivial in inline_trivial_2.", "over"], ["// In called_by_inline_trivial.", "into"]] self.run_step_sequence(step_sequence) - # Now run to the inline_trivial_1 just before the immediate step into inline_trivial_2: + # Now run to the inline_trivial_1 just before the immediate step into + # inline_trivial_2: - break_2_in_main = target.BreakpointCreateBySourceRegex ('// At second call of caller_trivial_1 in main.', self.main_source_spec) + break_2_in_main = target.BreakpointCreateBySourceRegex( + '// At second call of caller_trivial_1 in main.', self.main_source_spec) self.assertTrue(break_2_in_main, VALID_BREAKPOINT) - threads = lldbutil.continue_to_breakpoint (self.process, break_2_in_main) - self.assertTrue (len(threads) == 1, "Successfully ran to call site of second caller_trivial_1 call.") + threads = lldbutil.continue_to_breakpoint( + self.process, break_2_in_main) + self.assertTrue( + len(threads) == 1, + "Successfully ran to call site of second caller_trivial_1 call.") self.thread = threads[0] - - step_sequence = [["// In caller_trivial_1.", "into"], - ["// In caller_trivial_2.", "into"], + + step_sequence = [["// In caller_trivial_1.", "into"], + ["// In caller_trivial_2.", "into"], ["// In inline_trivial_1.", "into"]] self.run_step_sequence(step_sequence) - # Then call some trivial function, and make sure we end up back where we were in the inlined call stack: - + # Then call some trivial function, and make sure we end up back where + # we were in the inlined call stack: + frame = self.thread.GetFrameAtIndex(0) before_line_entry = frame.GetLineEntry() - value = frame.EvaluateExpression ("function_to_call()") + value = frame.EvaluateExpression("function_to_call()") after_line_entry = frame.GetLineEntry() - self.assertTrue (before_line_entry.GetLine() == after_line_entry.GetLine(), "Line entry before and after function calls are the same.") + self.assertTrue( + before_line_entry.GetLine() == after_line_entry.GetLine(), + "Line entry before and after function calls are the same.") - # Now make sure stepping OVER in the middle of the stack works, and then check finish from the inlined frame: + # Now make sure stepping OVER in the middle of the stack works, and + # then check finish from the inlined frame: step_sequence = [["// At increment in inline_trivial_1.", "over"], ["// At increment in caller_trivial_2.", "out"]] self.run_step_sequence(step_sequence) + # Now run to the place in main just before the first call to + # caller_ref_1: - # Now run to the place in main just before the first call to caller_ref_1: - - break_3_in_main = target.BreakpointCreateBySourceRegex ('// At first call of caller_ref_1 in main.', self.main_source_spec) + break_3_in_main = target.BreakpointCreateBySourceRegex( + '// At first call of caller_ref_1 in main.', self.main_source_spec) self.assertTrue(break_3_in_main, VALID_BREAKPOINT) - threads = lldbutil.continue_to_breakpoint (self.process, break_3_in_main) - self.assertTrue (len(threads) == 1, "Successfully ran to call site of first caller_ref_1 call.") + threads = lldbutil.continue_to_breakpoint( + self.process, break_3_in_main) + self.assertTrue( + len(threads) == 1, + "Successfully ran to call site of first caller_ref_1 call.") self.thread = threads[0] step_sequence = [["// In caller_ref_1.", "into"], @@ -201,7 +253,7 @@ class TestInlineStepping(TestBase): ["// At increment in inline_ref_1.", "over"], ["// In caller_ref_2.", "out"], ["// At increment in caller_ref_2.", "over"]] - self.run_step_sequence (step_sequence) + self.run_step_sequence(step_sequence) def inline_stepping_step_over(self): """Use Python APIs to test stepping over and hitting breakpoints.""" @@ -210,26 +262,29 @@ class TestInlineStepping(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - break_1_in_main = target.BreakpointCreateBySourceRegex ('// At second call of caller_ref_1 in main.', self.main_source_spec) + break_1_in_main = target.BreakpointCreateBySourceRegex( + '// At second call of caller_ref_1 in main.', self.main_source_spec) self.assertTrue(break_1_in_main, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main) + threads = lldbutil.get_threads_stopped_at_breakpoint( + self.process, break_1_in_main) if len(threads) != 1: - self.fail ("Failed to stop at first breakpoint in main.") + self.fail("Failed to stop at first breakpoint in main.") self.thread = threads[0] step_sequence = [["// In caller_ref_1.", "into"], ["// In caller_ref_2.", "into"], ["// At increment in caller_ref_2.", "over"]] - self.run_step_sequence (step_sequence) + self.run_step_sequence(step_sequence) def step_in_template(self): """Use Python APIs to test stepping in to templated functions.""" @@ -238,30 +293,38 @@ class TestInlineStepping(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - break_1_in_main = target.BreakpointCreateBySourceRegex ('// Call max_value template', self.main_source_spec) + break_1_in_main = target.BreakpointCreateBySourceRegex( + '// Call max_value template', self.main_source_spec) self.assertTrue(break_1_in_main, VALID_BREAKPOINT) - - break_2_in_main = target.BreakpointCreateBySourceRegex ('// Call max_value specialized', self.main_source_spec) + + break_2_in_main = target.BreakpointCreateBySourceRegex( + '// Call max_value specialized', self.main_source_spec) self.assertTrue(break_2_in_main, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main) + threads = lldbutil.get_threads_stopped_at_breakpoint( + self.process, break_1_in_main) if len(threads) != 1: - self.fail ("Failed to stop at first breakpoint in main.") + self.fail("Failed to stop at first breakpoint in main.") self.thread = threads[0] step_sequence = [["// In max_value template", "into"]] self.run_step_sequence(step_sequence) - - threads = lldbutil.continue_to_breakpoint (self.process, break_2_in_main) - self.assertEqual(len(threads), 1, "Successfully ran to call site of second caller_trivial_1 call.") + + threads = lldbutil.continue_to_breakpoint( + self.process, break_2_in_main) + self.assertEqual( + len(threads), + 1, + "Successfully ran to call site of second caller_trivial_1 call.") self.thread = threads[0] - + step_sequence = [["// In max_value specialized", "into"]] self.run_step_sequence(step_sequence) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py index 336260a8e4a..7ccfaa688b8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -15,7 +15,9 @@ class JITLoaderGDBTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipTestIfFn(lambda : "Skipped because the test crashes the test runner", bugnumber="llvm.org/pr24702") + @skipTestIfFn( + lambda: "Skipped because the test crashes the test runner", + bugnumber="llvm.org/pr24702") @unittest2.expectedFailure("llvm.org/pr24702") def test_bogus_values(self): """Test that we handle inferior misusing the GDB JIT interface""" @@ -27,10 +29,12 @@ class JITLoaderGDBTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # launch the process, 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()) self.assertTrue(process, PROCESS_IS_VALID) - # The inferior will now pass bogus values over the interface. Make sure we don't crash. + # The inferior will now pass bogus values over the interface. Make sure + # we don't crash. self.assertEqual(process.GetState(), lldb.eStateExited) self.assertEqual(process.GetExitStatus(), 0) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py b/lldb/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py index 28d8cccacfc..0ebb99d3fd4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py @@ -4,7 +4,6 @@ Test that argdumper is a viable launching strategy. from __future__ import print_function - import lldb import os import time @@ -12,40 +11,50 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LaunchWithShellExpandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr24778 llvm.org/pr22627") + @expectedFailureAll( + oslist=[ + "windows", + "linux", + "freebsd"], + bugnumber="llvm.org/pr24778 llvm.org/pr22627") def test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") - + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("target create %s" % exe) - + # Create the target target = self.dbg.CreateTarget(exe) - + # Create any breakpoints we need - breakpoint = target.BreakpointCreateBySourceRegex ('break here', lldb.SBFileSpec ("main.cpp", False)) + breakpoint = target.BreakpointCreateBySourceRegex( + 'break here', lldb.SBFileSpec("main.cpp", False)) self.assertTrue(breakpoint, VALID_BREAKPOINT) - self.runCmd("process launch -X true -w %s -- fi*.tx? () > <" % (os.getcwd())) + self.runCmd( + "process launch -X true -w %s -- fi*.tx? () > <" % + (os.getcwd())) process = self.process() self.assertTrue(process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) - thread = process.GetThreadAtIndex (0) + thread = process.GetThreadAtIndex(0) - self.assertTrue (thread.IsValid(), - "Process stopped at 'main' should have a valid thread"); + self.assertTrue(thread.IsValid(), + "Process stopped at 'main' should have a valid thread") stop_reason = thread.GetStopReason() - - self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, - "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); + + self.assertTrue( + stop_reason == lldb.eStopReasonBreakpoint, + "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint") self.expect("frame variable argv[1]", substrs=['file1.txt']) self.expect("frame variable argv[2]", substrs=['file2.txt']) @@ -54,47 +63,57 @@ class LaunchWithShellExpandTestCase(TestBase): self.expect("frame variable argv[5]", substrs=['()']) self.expect("frame variable argv[6]", substrs=['>']) self.expect("frame variable argv[7]", substrs=['<']) - self.expect("frame variable argv[5]", substrs=['file5.tyx'], matching=False) - self.expect("frame variable argv[8]", substrs=['file5.tyx'], matching=False) + self.expect( + "frame variable argv[5]", + substrs=['file5.tyx'], + matching=False) + self.expect( + "frame variable argv[8]", + substrs=['file5.tyx'], + matching=False) self.runCmd("process kill") - self.runCmd('process launch -X true -w %s -- "foo bar"' % (os.getcwd())) - + self.runCmd( + 'process launch -X true -w %s -- "foo bar"' % + (os.getcwd())) + process = self.process() self.assertTrue(process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) - thread = process.GetThreadAtIndex (0) + thread = process.GetThreadAtIndex(0) - self.assertTrue (thread.IsValid(), - "Process stopped at 'main' should have a valid thread"); + self.assertTrue(thread.IsValid(), + "Process stopped at 'main' should have a valid thread") stop_reason = thread.GetStopReason() - - self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, - "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); - + + self.assertTrue( + stop_reason == lldb.eStopReasonBreakpoint, + "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint") + self.expect("frame variable argv[1]", substrs=['foo bar']) self.runCmd("process kill") self.runCmd('process launch -X true -w %s -- foo\ bar' % (os.getcwd())) - + process = self.process() self.assertTrue(process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) - thread = process.GetThreadAtIndex (0) + thread = process.GetThreadAtIndex(0) - self.assertTrue (thread.IsValid(), - "Process stopped at 'main' should have a valid thread"); + self.assertTrue(thread.IsValid(), + "Process stopped at 'main' should have a valid thread") stop_reason = thread.GetStopReason() - - self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, - "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); - + + self.assertTrue( + stop_reason == lldb.eStopReasonBreakpoint, + "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint") + self.expect("frame variable argv[1]", substrs=['foo bar']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py b/lldb/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py index a2a43bf2fab..85741f548f3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py @@ -5,24 +5,26 @@ Test lldb 'commands regex' command which allows the user to create a regular exp from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestHomeDirectory(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") @no_debug_info_test def test_tilde_home_directory(self): - """Test that we can resolve "~/" in paths correctly. + """Test that we can resolve "~/" in paths correctly. When a path starts with "~/", we use llvm::sys::path::home_directory() to resolve the home directory. This currently relies on "HOME" being set in the - environment. While this is usually set, we can't rely upon that. We might + environment. While this is usually set, we can't rely upon that. We might eventually get a fix into llvm::sys::path::home_directory() so it doesn't rely on having to have an environment variable set, but until then we have work around code in FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to ensure @@ -31,7 +33,9 @@ class TestHomeDirectory(TestBase): import pexpect prompt = "(lldb) " - child = pexpect.spawn('%s --no-use-colors %s' % (lldbtest_config.lldbExec, self.lldbOption)) + child = pexpect.spawn( + '%s --no-use-colors %s' % + (lldbtest_config.lldbExec, self.lldbOption)) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout @@ -39,7 +43,7 @@ class TestHomeDirectory(TestBase): self.child = child # Resolve "~/." to the full path of our home directory + "/." - if 'HOME' in os.environ: + if 'HOME' in os.environ: home_dir = os.environ['HOME'] if self.TraceOn(): print("home directory is: '%s'" % (home_dir)) @@ -49,11 +53,14 @@ class TestHomeDirectory(TestBase): child.sendline('''script str(lldb.SBFileSpec("~/.", True))''') child.expect_exact(home_dir) child.expect_exact(prompt) - child.sendline('''script import os; os.unsetenv('HOME'); str(lldb.SBFileSpec("~/", True))'''); + child.sendline( + '''script import os; os.unsetenv('HOME'); str(lldb.SBFileSpec("~/", True))''') child.expect_exact(home_dir) child.expect_exact(prompt) elif self.TraceOn(): - print('''home directory "%s" doesn't exist, skipping home directory test''' % (home_dir)) + print( + '''home directory "%s" doesn't exist, skipping home directory test''' % + (home_dir)) elif self.TraceOn(): print('"HOME" not in environment, skipping home directory test') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index 3a703b2ee04..8b3ce441ced 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -5,18 +5,19 @@ Test that breakpoint by symbol name works correctly with dynamic libs. 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 -@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + +@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently class LoadUnloadTestCase(TestBase): - def getCategories (self): + def getCategories(self): return ['basic_process'] mydir = TestBase.compute_mydir(__file__) @@ -25,19 +26,30 @@ class LoadUnloadTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break for main.cpp. - self.line = line_number('main.cpp', - '// Set break point at this line for test_lldb_process_load_and_unload_commands().') - self.line_d_function = line_number('d.cpp', - '// Find this line number within d_dunction().') + self.line = line_number( + 'main.cpp', + '// Set break point at this line for test_lldb_process_load_and_unload_commands().') + self.line_d_function = line_number( + 'd.cpp', '// Find this line number within d_dunction().') if not self.platformIsDarwin(): if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ: - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd()) + self.runCmd( + "settings set target.env-vars " + + self.dylibPath + + "=" + + os.environ["LD_LIBRARY_PATH"] + + ":" + + os.getcwd()) else: if lldb.remote_platform: wd = lldb.remote_platform.GetWorkingDirectory() else: wd = os.getcwd() - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + wd) + self.runCmd( + "settings set target.env-vars " + + self.dylibPath + + "=" + + wd) def copy_shlibs_to_remote(self, hidden_dir=False): """ Copies the shared libs required by this test suite to remote. @@ -72,9 +84,9 @@ class LoadUnloadTestCase(TestBase): "Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" % (wd, err.GetCString())) - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @not_remote_testsuite_ready - @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_modules_search_paths(self): """Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'.""" @@ -96,17 +108,22 @@ class LoadUnloadTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.expect("target modules list", - substrs = [old_dylib]) - #self.expect("target modules list -t 3", + substrs=[old_dylib]) + # self.expect("target modules list -t 3", # patterns = ["%s-[^-]*-[^-]*" % self.getArchitecture()]) # Add an image search path substitution pair. - self.runCmd("target modules search-paths add %s %s" % (os.getcwd(), new_dir)) + self.runCmd( + "target modules search-paths add %s %s" % + (os.getcwd(), new_dir)) self.expect("target modules search-paths list", - substrs = [os.getcwd(), new_dir]) + substrs=[os.getcwd(), new_dir]) - self.expect("target modules search-paths query %s" % os.getcwd(), "Image search path successfully transformed", - substrs = [new_dir]) + self.expect( + "target modules search-paths query %s" % + os.getcwd(), + "Image search path successfully transformed", + substrs=[new_dir]) # Obliterate traces of libd from the old location. os.remove(old_dylib) @@ -118,16 +135,19 @@ class LoadUnloadTestCase(TestBase): self.runCmd("settings show target.env-vars") remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath - self.addTearDownHook(lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) + self.addTearDownHook( + lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) self.runCmd("run") - self.expect("target modules list", "LLDB successfully locates the relocated dynamic library", - substrs = [new_dylib]) + self.expect( + "target modules list", + "LLDB successfully locates the relocated dynamic library", + substrs=[new_dylib]) - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support - @expectedFailureAndroid # wrong source file shows up for hidden library - @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @expectedFailureAndroid # wrong source file shows up for hidden library + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_dyld_library_path(self): """Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else.""" @@ -156,15 +176,17 @@ class LoadUnloadTestCase(TestBase): old_dylib = os.path.join(old_dir, dylibName) remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath - self.addTearDownHook(lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) + self.addTearDownHook( + lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) # For now we don't track (DY)LD_LIBRARY_PATH, so the old library will be in # the modules list. self.expect("target modules list", - substrs = [os.path.basename(old_dylib)], + substrs=[os.path.basename(old_dylib)], matching=True) - lldbutil.run_break_set_by_file_and_line (self, "d.cpp", self.line_d_function, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "d.cpp", self.line_d_function, num_expected_locations=1) # After run, make sure the non-hidden library is picked up. self.expect("run", substrs=["return", "700"]) @@ -180,9 +202,14 @@ class LoadUnloadTestCase(TestBase): # This time, the hidden library should be picked up. self.expect("run", substrs=["return", "12345"]) - @expectedFailureAll(bugnumber="llvm.org/pr25805", hostoslist=["windows"], compiler="gcc", archs=["i386"], triple='.*-android') - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support - @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @expectedFailureAll( + bugnumber="llvm.org/pr25805", + hostoslist=["windows"], + compiler="gcc", + archs=["i386"], + triple='.*-android') + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" @@ -196,7 +223,8 @@ class LoadUnloadTestCase(TestBase): # Break at main.cpp before the call to dlopen(). # Use lldb's process load command to load the dylib, instead. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -211,13 +239,23 @@ class LoadUnloadTestCase(TestBase): dylibName = 'libloadunload_a.so' # Make sure that a_function does not exist at this point. - self.expect("image lookup -n a_function", "a_function should not exist yet", - error=True, matching=False, patterns = ["1 match found"]) + self.expect( + "image lookup -n a_function", + "a_function should not exist yet", + error=True, + matching=False, + patterns=["1 match found"]) # Use lldb 'process load' to load the dylib. - self.expect("process load %s --install" % dylibName, "%s loaded correctly" % dylibName, - patterns = ['Loading "%s".*ok' % dylibName, - 'Image [0-9]+ loaded']) + self.expect( + "process load %s --install" % + dylibName, + "%s loaded correctly" % + dylibName, + patterns=[ + 'Loading "%s".*ok' % + dylibName, + 'Image [0-9]+ loaded']) # Search for and match the "Image ([0-9]+) loaded" pattern. output = self.res.GetOutput() @@ -230,16 +268,26 @@ class LoadUnloadTestCase(TestBase): index = match.group(1) # Now we should have an entry for a_function. - self.expect("image lookup -n a_function", "a_function should now exist", - patterns = ["1 match found .*%s" % dylibName]) + self.expect( + "image lookup -n a_function", + "a_function should now exist", + patterns=[ + "1 match found .*%s" % + dylibName]) # Use lldb 'process unload' to unload the dylib. - self.expect("process unload %s" % index, "%s unloaded correctly" % dylibName, - patterns = ["Unloading .* with index %s.*ok" % index]) + self.expect( + "process unload %s" % + index, + "%s unloaded correctly" % + dylibName, + patterns=[ + "Unloading .* with index %s.*ok" % + index]) self.runCmd("process continue") - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support def test_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" @@ -251,19 +299,20 @@ class LoadUnloadTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name a_function (not yet loaded). - lldbutil.run_break_set_by_symbol (self, "a_function", num_expected_locations=0) + lldbutil.run_break_set_by_symbol( + self, "a_function", num_expected_locations=0) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint and at a_function. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'a_function', - 'stop reason = breakpoint']) + substrs=['stopped', + 'a_function', + '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']) # Issue the 'contnue' command. We should stop agaian at a_function. # The stop reason of the thread should be breakpoint and at a_function. @@ -272,17 +321,17 @@ class LoadUnloadTestCase(TestBase): # rdar://problem/8508987 # The a_function breakpoint should be encountered twice. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'a_function', - 'stop reason = breakpoint']) + substrs=['stopped', + 'a_function', + 'stop reason = breakpoint']) # The breakpoint should have a hit count of 2. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 2']) + substrs=[' resolved, hit count = 2']) - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support - @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently - def test_step_over_load (self): + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_step_over_load(self): """Test stepping over code that loads a shared library works correctly.""" # Invoke the default build rule. @@ -293,26 +342,29 @@ class LoadUnloadTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name a_function (not yet loaded). - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint and at a_function. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) + + self.runCmd( + "thread step-over", + "Stepping over function that loads library") - self.runCmd("thread step-over", "Stepping over function that loads library") - # The stop reason should be step end. - self.expect("thread list", "step over succeeded.", - substrs = ['stopped', - 'stop reason = step over']) + self.expect("thread list", "step over succeeded.", + substrs=['stopped', + 'stop reason = step over']) - @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support - @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently @unittest2.expectedFailure("llvm.org/pr25806") - def test_static_init_during_load (self): + def test_static_init_during_load(self): """Test that we can set breakpoints correctly in static initializers""" self.build() @@ -321,33 +373,36 @@ class LoadUnloadTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - a_init_bp_num = lldbutil.run_break_set_by_symbol(self, "a_init", num_expected_locations=0) - b_init_bp_num = lldbutil.run_break_set_by_symbol(self, "b_init", num_expected_locations=0) - d_init_bp_num = lldbutil.run_break_set_by_symbol(self, "d_init", num_expected_locations=1) + a_init_bp_num = lldbutil.run_break_set_by_symbol( + self, "a_init", num_expected_locations=0) + b_init_bp_num = lldbutil.run_break_set_by_symbol( + self, "b_init", num_expected_locations=0) + d_init_bp_num = lldbutil.run_break_set_by_symbol( + self, "d_init", num_expected_locations=1) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'd_init', - 'stop reason = breakpoint %d' % d_init_bp_num]) + substrs=['stopped', + 'd_init', + 'stop reason = breakpoint %d' % d_init_bp_num]) self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'a_init', - 'stop reason = breakpoint %d' % a_init_bp_num]) + substrs=['stopped', + 'a_init', + 'stop reason = breakpoint %d' % a_init_bp_num]) self.expect("thread backtrace", - substrs = ['a_init', - 'dlopen', - 'main']) + substrs=['a_init', + 'dlopen', + 'main']) self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'b_init', - 'stop reason = breakpoint %d' % b_init_bp_num]) + substrs=['stopped', + 'b_init', + 'stop reason = breakpoint %d' % b_init_bp_num]) self.expect("thread backtrace", - substrs = ['b_init', - 'dlopen', - 'main']) + substrs=['b_init', + 'dlopen', + 'main']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py b/lldb/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py index d9f2b223189..dd4ab4cab2a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py @@ -5,13 +5,13 @@ Test the use of setjmp/longjmp for non-local goto operations in a single-threade from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LongjmpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,8 +19,8 @@ class LongjmpTestCase(TestBase): def setUp(self): TestBase.setUp(self) - @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp - @skipIfFreeBSD # llvm.org/pr17214 + @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp + @skipIfFreeBSD # llvm.org/pr17214 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_step_out(self): @@ -28,8 +28,8 @@ class LongjmpTestCase(TestBase): self.build() self.step_out() - @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp - @skipIfFreeBSD # llvm.org/pr17214 + @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp + @skipIfFreeBSD # llvm.org/pr17214 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_step_over(self): @@ -37,8 +37,8 @@ class LongjmpTestCase(TestBase): self.build() self.step_over() - @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp - @skipIfFreeBSD # llvm.org/pr17214 + @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp + @skipIfFreeBSD # llvm.org/pr17214 @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_step_back_out(self): @@ -52,19 +52,20 @@ class LongjmpTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main(). - lldbutil.run_break_set_by_symbol (self, symbol, num_expected_locations=-1) + lldbutil.run_break_set_by_symbol( + self, symbol, 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']) def check_status(self): # Note: Depending on the generated mapping of DWARF to assembly, # the process may have stopped or exited. self.expect("process status", PROCESS_STOPPED, - patterns = ['Process .* exited with status = 0']) + patterns=['Process .* exited with status = 0']) def step_out(self): self.start_test("do_jump") @@ -79,7 +80,7 @@ class LongjmpTestCase(TestBase): def step_back_out(self): self.start_test("main") - + self.runCmd("thread step-over", RUN_SUCCEEDED) self.runCmd("thread step-in", RUN_SUCCEEDED) self.runCmd("thread step-out", RUN_SUCCEEDED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py b/lldb/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py index a65882d3fa4..f2126e9ffd5 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py @@ -5,14 +5,15 @@ Test the MemoryCache L1 flush. 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 * import lldbsuite.test.lldbutil as lldbutil + class MemoryCacheTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,17 +32,18 @@ class MemoryCacheTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() after the variables are assigned values. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # Read a chunk of memory containing &my_ints[0]. The number of bytes read # must be greater than m_L2_cache_line_byte_size to make sure the L1 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py index 6cdf5bf48e9..ddbe6409cb8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py @@ -5,14 +5,15 @@ Test the 'memory find' command. from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test.decorators import * + class MemoryFindTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,31 +31,40 @@ class MemoryFindTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() aftre the variables are assigned values. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # Test the memory find commands. - self.expect('memory find -s "in const" `stringdata` `stringdata+(int)strlen(stringdata)`', - substrs = ['data found at location: 0x', '69 6e 20 63', 'in const']) - - self.expect('memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[15]`', - substrs = ['data found at location: 0x', '22 33 44 55 66']) - - self.expect('memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[2]`', - substrs = ['data not found within the range.']) + self.expect( + 'memory find -s "in const" `stringdata` `stringdata+(int)strlen(stringdata)`', + substrs=[ + 'data found at location: 0x', + '69 6e 20 63', + 'in const']) + + self.expect( + 'memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[15]`', + substrs=[ + 'data found at location: 0x', + '22 33 44 55 66']) + + self.expect( + 'memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[2]`', + substrs=['data not found within the range.']) self.expect('memory find -s "nothere" `stringdata` `stringdata+5`', - substrs = ['data not found within the range.']) + substrs=['data not found within the range.']) self.expect('memory find -s "nothere" `stringdata` `stringdata+10`', - substrs = ['data not found within the range.']) + substrs=['data not found within the range.']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py index 7410650ad65..9d4e44c96bb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py @@ -5,13 +5,14 @@ Test the 'memory read' command. from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class MemoryReadTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,17 +30,18 @@ class MemoryReadTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() aftre the variables are assigned values. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # Test the memory read commands. @@ -61,39 +63,58 @@ class MemoryReadTestCase(TestBase): # 0x7fff5fbff9a4: {0x00000000} # 0x7fff5fbff9a8: {0x0ec0bf27} # 0x7fff5fbff9ac: {0x215db505} - self.runCmd("memory read --format uint32_t[] --size 4 --count 4 `&argc`") + self.runCmd( + "memory read --format uint32_t[] --size 4 --count 4 `&argc`") lines = self.res.GetOutput().splitlines() for i in range(4): if i == 0: # Verify that the printout for argc is correct. - self.assertTrue(argc == int(lines[i].split(':')[1].strip(' {}'), 0)) + self.assertTrue( + argc == int( + lines[i].split(':')[1].strip(' {}'), 0)) addr = int(lines[i].split(':')[0], 0) # Verify that the printout for addr is incremented correctly. - self.assertTrue(addr == (address + i*4)) + self.assertTrue(addr == (address + i * 4)) # (lldb) memory read --format char[] --size 7 --count 1 `&my_string` # 0x7fff5fbff990: {abcdefg} - self.expect("memory read --format char[] --size 7 --count 1 `&my_string`", - substrs = ['abcdefg']) + self.expect( + "memory read --format char[] --size 7 --count 1 `&my_string`", + substrs=['abcdefg']) # (lldb) memory read --format 'hex float' --size 16 `&argc` - # 0x7fff5fbff5b0: error: unsupported byte size (16) for hex float format - self.expect("memory read --format 'hex float' --size 16 `&argc`", - substrs = ['unsupported byte size (16) for hex float format']) + # 0x7fff5fbff5b0: error: unsupported byte size (16) for hex float + # format + self.expect( + "memory read --format 'hex float' --size 16 `&argc`", + substrs=['unsupported byte size (16) for hex float format']) - self.expect("memory read --format 'float' --count 1 --size 8 `&my_double`", - substrs = ['1234.']) + self.expect( + "memory read --format 'float' --count 1 --size 8 `&my_double`", + substrs=['1234.']) # (lldb) memory read --format 'float' --count 1 --size 20 `&my_double` # 0x7fff5fbff598: error: unsupported byte size (20) for float format - self.expect("memory read --format 'float' --count 1 --size 20 `&my_double`", - substrs = ['unsupported byte size (20) for float format']) + self.expect( + "memory read --format 'float' --count 1 --size 20 `&my_double`", + substrs=['unsupported byte size (20) for float format']) self.expect('memory read --type int --count 5 `&my_ints[0]`', - substrs=['(int) 0x', '2','4','6','8','10']) - - self.expect('memory read --type int --count 5 --format hex `&my_ints[0]`', - substrs=['(int) 0x', '0x','0a']) - - self.expect('memory read --type int --count 5 --offset 5 `&my_ints[0]`', - substrs=['(int) 0x', '12', '14','16','18', '20']) + substrs=['(int) 0x', '2', '4', '6', '8', '10']) + + self.expect( + 'memory read --type int --count 5 --format hex `&my_ints[0]`', + substrs=[ + '(int) 0x', + '0x', + '0a']) + + self.expect( + 'memory read --type int --count 5 --offset 5 `&my_ints[0]`', + substrs=[ + '(int) 0x', + '12', + '14', + '16', + '18', + '20']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py b/lldb/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py index 7d959ec504c..9cdd7158516 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py @@ -5,13 +5,14 @@ Test that commands do not try and hold on to stale CommandInterpreters in a mult 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 MultipleDebuggersCommandsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,28 +22,33 @@ class MultipleDebuggersCommandsTestCase(TestBase): """Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario""" source_init_files = False magic_text = "The following commands may relate to 'env'" - + debugger_1 = lldb.SBDebugger.Create(source_init_files) interpreter_1 = debugger_1.GetCommandInterpreter() - + retobj = lldb.SBCommandReturnObject() interpreter_1.HandleCommand("apropos env", retobj) - self.assertTrue(magic_text in str(retobj), "[interpreter_1]: the output does not contain the correct words") - - if self.TraceOn(): print(str(retobj)) - + self.assertTrue( + magic_text in str(retobj), + "[interpreter_1]: the output does not contain the correct words") + + if self.TraceOn(): + print(str(retobj)) + lldb.SBDebugger.Destroy(debugger_1) - + # now do this again with a different debugger - we shouldn't crash - + debugger_2 = lldb.SBDebugger.Create(source_init_files) interpreter_2 = debugger_2.GetCommandInterpreter() - + retobj = lldb.SBCommandReturnObject() interpreter_2.HandleCommand("apropos env", retobj) - self.assertTrue(magic_text in str(retobj), "[interpreter_2]: the output does not contain the correct words") - - if self.TraceOn(): print(str(retobj)) - + self.assertTrue( + magic_text in str(retobj), + "[interpreter_2]: the output does not contain the correct words") + + if self.TraceOn(): + print(str(retobj)) + lldb.SBDebugger.Destroy(debugger_2) - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py b/lldb/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py index 6a74ddb727d..86c5e41b093 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py @@ -5,13 +5,14 @@ Test that an alias can reference other aliases without crashing. from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NestedAliasTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,17 +30,18 @@ class NestedAliasTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() aftre the variables are assigned values. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom aliases in order to have a # clean slate for the next test case. @@ -54,15 +56,38 @@ class NestedAliasTestCase(TestBase): self.runCmd('command alias read memory read -f A') self.runCmd('command alias rd read -c 3') - - self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef']) - self.expect('rd `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef']) - self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadfeed'], matching=False) + self.expect( + 'memory read -f A -c 3 `&my_ptr[0]`', + substrs=[ + 'deadbeef', + 'main.cpp:', + 'feedbeef']) + self.expect( + 'rd `&my_ptr[0]`', + substrs=[ + 'deadbeef', + 'main.cpp:', + 'feedbeef']) + + self.expect( + 'memory read -f A -c 3 `&my_ptr[0]`', + substrs=['deadfeed'], + matching=False) self.expect('rd `&my_ptr[0]`', substrs=['deadfeed'], matching=False) self.runCmd('command alias fo frame variable -O --') self.runCmd('command alias foself fo self') - - self.expect('help foself', substrs=['--show-all-children', '--raw-output'], matching=False) - self.expect('help foself', substrs=['Show variables for the current', 'stack frame.'], matching=True) + + self.expect( + 'help foself', + substrs=[ + '--show-all-children', + '--raw-output'], + matching=False) + self.expect( + 'help foself', + substrs=[ + 'Show variables for the current', + 'stack frame.'], + matching=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py b/lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py index 5c53cfaf912..bbaba956acf 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py @@ -4,11 +4,11 @@ from out of scope to in scope when stopped at the breakpoint.""" from __future__ import print_function - import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NonOverlappingIndexVariableCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -16,7 +16,8 @@ class NonOverlappingIndexVariableCase(TestBase): def setUp(self): TestBase.setUp(self) self.source = 'main.cpp' - self.line_to_break = line_number(self.source, '// Set breakpoint here.') + self.line_to_break = line_number( + self.source, '// Set breakpoint here.') # rdar://problem/9890530 def test_eval_index_variable(self): @@ -26,14 +27,19 @@ class NonOverlappingIndexVariableCase(TestBase): exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.source, self.line_to_break, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.source, + self.line_to_break, + num_expected_locations=1, + loc_exact=True) 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']) self.runCmd('frame variable i') self.runCmd('expr i') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py b/lldb/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py index 7a6c98d92c3..be89e36b5ce 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py @@ -4,24 +4,28 @@ Test that using a non-existent architecture name does not crash LLDB. from __future__ import print_function - import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NoSuchArchTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): + def test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") - # Check that passing an invalid arch via the command-line fails but doesn't crash - self.expect("target crete --arch nothingtoseehere %s" % (exe), error=True) + # Check that passing an invalid arch via the command-line fails but + # doesn't crash + self.expect( + "target crete --arch nothingtoseehere %s" % + (exe), error=True) - # Check that passing an invalid arch via the SB API fails but doesn't crash - target = self.dbg.CreateTargetWithFileAndArch(exe,"nothingtoseehere") + # Check that passing an invalid arch via the SB API fails but doesn't + # crash + target = self.dbg.CreateTargetWithFileAndArch(exe, "nothingtoseehere") self.assertFalse(target.IsValid(), "This target should not be valid") # Now just create the target with the default arch and check it's fine diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py b/lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py index 0fdc43bb9fe..93eac1ecd10 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py @@ -7,7 +7,6 @@ foreign-architecture object files. from __future__ import print_function - import os.path import re @@ -16,6 +15,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestImageListMultiArchitecture(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -35,7 +35,11 @@ class TestImageListMultiArchitecture(TestBase): } for image_name in images: - file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "bin", image_name)) + file_name = os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "bin", + image_name)) expected_triple_and_arch_regex = images[image_name] self.runCmd("file {}".format(file_name)) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py b/lldb/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py index db577dc5bac..7fc9a743d32 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py @@ -4,7 +4,6 @@ Test some lldb command abbreviations. from __future__ import print_function - import lldb import os import time @@ -12,25 +11,26 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestPaths(TestBase): mydir = TestBase.compute_mydir(__file__) @no_debug_info_test - def test_paths (self): + def test_paths(self): '''Test to make sure no file names are set in the lldb.SBFileSpec objects returned by lldb.SBHostOS.GetLLDBPath() for paths that are directories''' - dir_path_types = [lldb.ePathTypeLLDBShlibDir, - lldb.ePathTypeSupportExecutableDir, - lldb.ePathTypeHeaderDir, - lldb.ePathTypePythonDir, - lldb.ePathTypeLLDBSystemPlugins, - lldb.ePathTypeLLDBUserPlugins, - lldb.ePathTypeLLDBTempSystemDir] - + dir_path_types = [lldb.ePathTypeLLDBShlibDir, + lldb.ePathTypeSupportExecutableDir, + lldb.ePathTypeHeaderDir, + lldb.ePathTypePythonDir, + lldb.ePathTypeLLDBSystemPlugins, + lldb.ePathTypeLLDBUserPlugins, + lldb.ePathTypeLLDBTempSystemDir] + for path_type in dir_path_types: - f = lldb.SBHostOS.GetLLDBPath(path_type); + f = lldb.SBHostOS.GetLLDBPath(path_type) # No directory path types should have the filename set - self.assertTrue (f.GetFilename() == None); + self.assertTrue(f.GetFilename() is None) @no_debug_info_test def test_directory_doesnt_end_with_slash(self): @@ -41,9 +41,12 @@ class TestPaths(TestBase): @skipUnlessPlatform(["windows"]) @no_debug_info_test - def test_windows_double_slash (self): + def test_windows_double_slash(self): '''Test to check the path with double slash is handled correctly ''' # Create a path and see if lldb gets the directory and file right - fspec = lldb.SBFileSpec("C:\\dummy1\\dummy2//unknown_file", True); - self.assertEqual(os.path.normpath(fspec.GetDirectory()), os.path.normpath("C:/dummy1/dummy2")); - self.assertEqual(fspec.GetFilename(), "unknown_file"); + fspec = lldb.SBFileSpec("C:\\dummy1\\dummy2//unknown_file", True) + self.assertEqual( + os.path.normpath( + fspec.GetDirectory()), + os.path.normpath("C:/dummy1/dummy2")) + self.assertEqual(fspec.GetFilename(), "unknown_file") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py b/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py index 9599f83d6a5..302201a9256 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py @@ -5,13 +5,14 @@ Test some lldb platform commands. 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 PlatformCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,45 +24,58 @@ class PlatformCommandTestCase(TestBase): @no_debug_info_test def test_list(self): self.expect("platform list", - patterns = ['^Available platforms:']) + patterns=['^Available platforms:']) @no_debug_info_test def test_process_list(self): self.expect("platform process list", - substrs = ['PID', 'TRIPLE', 'NAME']) + substrs=['PID', 'TRIPLE', 'NAME']) @no_debug_info_test def test_process_info_with_no_arg(self): """This is expected to fail and to return a proper error message.""" self.expect("platform process info", error=True, - substrs = ['one or more process id(s) must be specified']) + substrs=['one or more process id(s) must be specified']) @no_debug_info_test def test_status(self): - self.expect("platform status", - substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname']) + self.expect( + "platform status", + substrs=[ + 'Platform', + 'Triple', + 'OS Version', + 'Kernel', + 'Hostname']) @no_debug_info_test def test_shell(self): """ Test that the platform shell command can invoke ls. """ triple = self.dbg.GetSelectedPlatform().GetTriple() if re.match(".*-.*-windows", triple): - self.expect("platform shell dir c:\\", substrs = ["Windows", "Program Files"]) + self.expect( + "platform shell dir c:\\", substrs=[ + "Windows", "Program Files"]) elif re.match(".*-.*-.*-android", triple): - self.expect("platform shell ls /", substrs = ["cache", "dev", "system"]) + self.expect( + "platform shell ls /", + substrs=[ + "cache", + "dev", + "system"]) else: - self.expect("platform shell ls /", substrs = ["dev", "tmp", "usr"]) + self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"]) @no_debug_info_test def test_shell_builtin(self): """ Test a shell built-in command (echo) """ self.expect("platform shell echo hello lldb", - substrs = ["hello lldb"]) + substrs=["hello lldb"]) - #FIXME: re-enable once platform shell -t can specify the desired timeout + # FIXME: re-enable once platform shell -t can specify the desired timeout @no_debug_info_test def test_shell_timeout(self): """ Test a shell built-in command (sleep) that times out """ self.skipTest("due to taking too long to complete.") - self.expect("platform shell sleep 15", error=True, - substrs = ["error: timed out waiting for shell command to complete"]) + self.expect("platform shell sleep 15", error=True, substrs=[ + "error: timed out waiting for shell command to complete"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py index 619ed7afe32..9341ff97e6f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py @@ -5,20 +5,23 @@ Test that plugins that load commands work correctly. 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 PluginCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfNoSBHeaders - @skipIfHostIncompatibleWithRemote # Requires a compatible arch and platform to link against the host's built lldb lib. + # Requires a compatible arch and platform to link against the host's built + # lldb lib. + @skipIfHostIncompatibleWithRemote @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @no_debug_info_test def test_load_plugin(self): @@ -37,23 +40,26 @@ class PluginCommandTestCase(TestBase): retobj = lldb.SBCommandReturnObject() - retval = debugger.GetCommandInterpreter().HandleCommand("plugin load %s" % plugin_lib_name, retobj) + retval = debugger.GetCommandInterpreter().HandleCommand( + "plugin load %s" % plugin_lib_name, retobj) retobj.Clear() - retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_command child abc def ghi",retobj) + retval = debugger.GetCommandInterpreter().HandleCommand( + "plugin_loaded_command child abc def ghi", retobj) if self.TraceOn(): print(retobj.GetOutput()) - self.expect(retobj,substrs = ['abc def ghi'], exe=False) + self.expect(retobj, substrs=['abc def ghi'], exe=False) retobj.Clear() # check that abbreviations work correctly in plugin commands. - retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_ ch abc def ghi",retobj) + retval = debugger.GetCommandInterpreter().HandleCommand( + "plugin_loaded_ ch abc def ghi", retobj) if self.TraceOn(): print(retobj.GetOutput()) - self.expect(retobj,substrs = ['abc def ghi'], exe=False) + self.expect(retobj, substrs=['abc def ghi'], exe=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py index ebd96d9d4c0..9a5d320dce5 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py @@ -5,13 +5,14 @@ Test that the Python operating system plugin works correctly from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class PluginPythonOSPlugin(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,9 +32,11 @@ class PluginPythonOSPlugin(TestBase): registers = frame.GetRegisters().GetValueAtIndex(0) reg_value = thread.GetThreadID() + 1 for reg in registers: - self.assertTrue(reg.GetValueAsUnsigned() == reg_value, "Verify the registers contains the correct value") + self.assertTrue( + reg.GetValueAsUnsigned() == reg_value, + "Verify the registers contains the correct value") reg_value = reg_value + 1 - + def run_python_os_funcionality(self): """Test that the Python operating system plugin works correctly""" @@ -47,52 +50,76 @@ class PluginPythonOSPlugin(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - # Set breakpoints inside and outside methods that take pointers to the containing struct. - lldbutil.run_break_set_by_source_regexp (self, "// Set breakpoint here") + # Set breakpoints inside and outside methods that take pointers to the + # containing struct. + lldbutil.run_break_set_by_source_regexp(self, "// Set breakpoint here") - # Register our shared libraries for remote targets so they get automatically uploaded + # Register our shared libraries for remote targets so they get + # automatically uploaded arguments = None - environment = None + environment = None # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (arguments, environment, self.get_process_working_directory()) + process = target.LaunchSimple( + arguments, environment, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - # Make sure there are no OS plug-in created thread when we first stop at our breakpoint in main - thread = process.GetThreadByID(0x111111111); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x111111111 before we load the python OS plug-in"); - thread = process.GetThreadByID(0x222222222); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x222222222 before we load the python OS plug-in"); - thread = process.GetThreadByID(0x333333333); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x333333333 before we load the python OS plug-in"); - + # Make sure there are no OS plug-in created thread when we first stop + # at our breakpoint in main + thread = process.GetThreadByID(0x111111111) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x111111111 before we load the python OS plug-in") + thread = process.GetThreadByID(0x222222222) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x222222222 before we load the python OS plug-in") + thread = process.GetThreadByID(0x333333333) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x333333333 before we load the python OS plug-in") # Now load the python OS plug-in which should update the thread list and we should have - # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, 0x333333333 + # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, + # 0x333333333 command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path self.dbg.HandleCommand(command) # Verify our OS plug-in threads showed up - thread = process.GetThreadByID(0x111111111); - self.assertTrue (thread.IsValid(), "Make sure there is a thread 0x111111111 after we load the python OS plug-in"); + thread = process.GetThreadByID(0x111111111) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x111111111 after we load the python OS plug-in") self.verify_os_thread_registers(thread) - thread = process.GetThreadByID(0x222222222); - self.assertTrue (thread.IsValid(), "Make sure there is a thread 0x222222222 after we load the python OS plug-in"); + thread = process.GetThreadByID(0x222222222) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x222222222 after we load the python OS plug-in") self.verify_os_thread_registers(thread) - thread = process.GetThreadByID(0x333333333); - self.assertTrue (thread.IsValid(), "Make sure there is a thread 0x333333333 after we load the python OS plug-in"); + thread = process.GetThreadByID(0x333333333) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x333333333 after we load the python OS plug-in") self.verify_os_thread_registers(thread) - - # Now clear the OS plug-in path to make the OS plug-in created threads dissappear - self.dbg.HandleCommand("settings clear target.process.python-os-plugin-path") - + + # Now clear the OS plug-in path to make the OS plug-in created threads + # dissappear + self.dbg.HandleCommand( + "settings clear target.process.python-os-plugin-path") + # Verify the threads are gone after unloading the python OS plug-in - thread = process.GetThreadByID(0x111111111); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x111111111 after we unload the python OS plug-in"); - thread = process.GetThreadByID(0x222222222); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x222222222 after we unload the python OS plug-in"); - thread = process.GetThreadByID(0x333333333); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x333333333 after we unload the python OS plug-in"); + thread = process.GetThreadByID(0x111111111) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x111111111 after we unload the python OS plug-in") + thread = process.GetThreadByID(0x222222222) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x222222222 after we unload the python OS plug-in") + thread = process.GetThreadByID(0x333333333) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x333333333 after we unload the python OS plug-in") def run_python_os_step(self): """Test that the Python operating system plugin works correctly and allows single stepping of a virtual thread that is backed by a real thread""" @@ -107,44 +134,64 @@ class PluginPythonOSPlugin(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - # Set breakpoints inside and outside methods that take pointers to the containing struct. - lldbutil.run_break_set_by_source_regexp (self, "// Set breakpoint here") + # Set breakpoints inside and outside methods that take pointers to the + # containing struct. + lldbutil.run_break_set_by_source_regexp(self, "// Set breakpoint here") - # Register our shared libraries for remote targets so they get automatically uploaded + # Register our shared libraries for remote targets so they get + # automatically uploaded arguments = None - environment = None + environment = None # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (arguments, environment, self.get_process_working_directory()) + process = target.LaunchSimple( + arguments, environment, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - # Make sure there are no OS plug-in created thread when we first stop at our breakpoint in main - thread = process.GetThreadByID(0x111111111); - self.assertFalse (thread.IsValid(), "Make sure there is no thread 0x111111111 before we load the python OS plug-in"); - + # Make sure there are no OS plug-in created thread when we first stop + # at our breakpoint in main + thread = process.GetThreadByID(0x111111111) + self.assertFalse( + thread.IsValid(), + "Make sure there is no thread 0x111111111 before we load the python OS plug-in") # Now load the python OS plug-in which should update the thread list and we should have - # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, 0x333333333 + # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, + # 0x333333333 command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path self.dbg.HandleCommand(command) # Verify our OS plug-in threads showed up - thread = process.GetThreadByID(0x111111111); - self.assertTrue (thread.IsValid(), "Make sure there is a thread 0x111111111 after we load the python OS plug-in"); + thread = process.GetThreadByID(0x111111111) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x111111111 after we load the python OS plug-in") frame = thread.GetFrameAtIndex(0) - self.assertTrue(frame.IsValid(), "Make sure we get a frame from thread 0x111111111") + self.assertTrue( + frame.IsValid(), + "Make sure we get a frame from thread 0x111111111") line_entry = frame.GetLineEntry() - self.assertTrue(line_entry.GetFileSpec().GetFilename() == 'main.c', "Make sure we stopped on line 5 in main.c") - self.assertTrue(line_entry.GetLine() == 5, "Make sure we stopped on line 5 in main.c") + self.assertTrue( + line_entry.GetFileSpec().GetFilename() == 'main.c', + "Make sure we stopped on line 5 in main.c") + self.assertTrue( + line_entry.GetLine() == 5, + "Make sure we stopped on line 5 in main.c") - # Now single step thread 0x111111111 and make sure it does what we need it to + # Now single step thread 0x111111111 and make sure it does what we need + # it to thread.StepOver() - + frame = thread.GetFrameAtIndex(0) - self.assertTrue(frame.IsValid(), "Make sure we get a frame from thread 0x111111111") + self.assertTrue( + frame.IsValid(), + "Make sure we get a frame from thread 0x111111111") line_entry = frame.GetLineEntry() - - self.assertTrue(line_entry.GetFileSpec().GetFilename() == 'main.c', "Make sure we stepped from line 5 to line 6 in main.c") - self.assertTrue(line_entry.GetLine() == 6, "Make sure we stepped from line 5 to line 6 in main.c") + + self.assertTrue( + line_entry.GetFileSpec().GetFilename() == 'main.c', + "Make sure we stepped from line 5 to line 6 in main.c") + self.assertTrue(line_entry.GetLine() == 6, + "Make sure we stepped from line 5 to line 6 in main.c") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py index 536092e40b3..394c24b4a88 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py @@ -3,21 +3,22 @@ import lldb import struct + class OperatingSystemPlugIn(object): """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class""" - + def __init__(self, process): '''Initialization needs a valid.SBProcess object. - + This plug-in will get created after a live process is valid and has stopped for the first time.''' self.process = None self.registers = None self.threads = None - if type(process) is lldb.SBProcess and process.IsValid(): + if isinstance(process, lldb.SBProcess) and process.IsValid(): self.process = process - self.threads = None # Will be an dictionary containing info for each thread - + self.threads = None # Will be an dictionary containing info for each thread + def get_target(self): # NOTE: Don't use "lldb.target" when trying to get your target as the "lldb.target" # tracks the current target in the LLDB command interpreter which isn't the @@ -26,11 +27,16 @@ class OperatingSystemPlugIn(object): def create_thread(self, tid, context): if tid == 0x444444444: - thread_info = { 'tid' : tid, 'name' : 'four' , 'queue' : 'queue4', 'state' : 'stopped', 'stop_reason' : 'none' } + thread_info = { + 'tid': tid, + 'name': 'four', + 'queue': 'queue4', + 'state': 'stopped', + 'stop_reason': 'none'} self.threads.append(thread_info) return thread_info return None - + def get_thread_info(self): if not self.threads: # The sample dictionary below shows the values that can be returned for a thread @@ -48,43 +54,75 @@ class OperatingSystemPlugIn(object): # Specifying this key/value pair for a thread will avoid a call to get_register_data() # and can be used when your registers are in a thread context structure that is contiguous # in memory. Don't specify this if your register layout in memory doesn't match the layout - # described by the dictionary returned from a call to the get_register_info() method. - self.threads = [ - { 'tid' : 0x111111111, 'name' : 'one' , 'queue' : 'queue1', 'state' : 'stopped', 'stop_reason' : 'breakpoint'}, - { 'tid' : 0x222222222, 'name' : 'two' , 'queue' : 'queue2', 'state' : 'stopped', 'stop_reason' : 'none' }, - { 'tid' : 0x333333333, 'name' : 'three', 'queue' : 'queue3', 'state' : 'stopped', 'stop_reason' : 'trace' } - ] + # described by the dictionary returned from a call to the + # get_register_info() method. + self.threads = [{'tid': 0x111111111, + 'name': 'one', + 'queue': 'queue1', + 'state': 'stopped', + 'stop_reason': 'breakpoint'}, + {'tid': 0x222222222, + 'name': 'two', + 'queue': 'queue2', + 'state': 'stopped', + 'stop_reason': 'none'}, + {'tid': 0x333333333, + 'name': 'three', + 'queue': 'queue3', + 'state': 'stopped', + 'stop_reason': 'trace'}] return self.threads - + def get_register_info(self): - if self.registers == None: - self.registers = dict() + if self.registers is None: + self.registers = dict() self.registers['sets'] = ['GPR'] self.registers['registers'] = [ - { 'name':'rax' , 'bitsize' : 64, 'offset' : 0, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 0, 'dwarf' : 0}, - { 'name':'rbx' , 'bitsize' : 64, 'offset' : 8, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 3, 'dwarf' : 3}, - { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 2, 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', }, - { 'name':'rdx' , 'bitsize' : 64, 'offset' : 24, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 1, 'dwarf' : 1, 'generic':'arg3', 'alt-name':'arg3', }, - { 'name':'rdi' , 'bitsize' : 64, 'offset' : 32, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 5, 'dwarf' : 5, 'generic':'arg1', 'alt-name':'arg1', }, - { 'name':'rsi' , 'bitsize' : 64, 'offset' : 40, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 4, 'dwarf' : 4, 'generic':'arg2', 'alt-name':'arg2', }, - { 'name':'rbp' , 'bitsize' : 64, 'offset' : 48, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 6, 'dwarf' : 6, 'generic':'fp' , 'alt-name':'fp', }, - { 'name':'rsp' , 'bitsize' : 64, 'offset' : 56, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 7, 'dwarf' : 7, 'generic':'sp' , 'alt-name':'sp', }, - { 'name':'r8' , 'bitsize' : 64, 'offset' : 64, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 8, 'dwarf' : 8, 'generic':'arg5', 'alt-name':'arg5', }, - { 'name':'r9' , 'bitsize' : 64, 'offset' : 72, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 9, 'dwarf' : 9, 'generic':'arg6', 'alt-name':'arg6', }, - { 'name':'r10' , 'bitsize' : 64, 'offset' : 80, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 10, 'dwarf' : 10}, - { 'name':'r11' , 'bitsize' : 64, 'offset' : 88, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 11, 'dwarf' : 11}, - { 'name':'r12' , 'bitsize' : 64, 'offset' : 96, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 12, 'dwarf' : 12}, - { 'name':'r13' , 'bitsize' : 64, 'offset' : 104, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 13, 'dwarf' : 13}, - { 'name':'r14' , 'bitsize' : 64, 'offset' : 112, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 14, 'dwarf' : 14}, - { 'name':'r15' , 'bitsize' : 64, 'offset' : 120, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 15, 'dwarf' : 15}, - { 'name':'rip' , 'bitsize' : 64, 'offset' : 128, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 16, 'dwarf' : 16, 'generic':'pc', 'alt-name':'pc' }, - { 'name':'rflags' , 'bitsize' : 64, 'offset' : 136, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'generic':'flags', 'alt-name':'flags' }, - { 'name':'cs' , 'bitsize' : 64, 'offset' : 144, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - { 'name':'fs' , 'bitsize' : 64, 'offset' : 152, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - { 'name':'gs' , 'bitsize' : 64, 'offset' : 160, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - ] + {'name': 'rax', 'bitsize': 64, 'offset': 0, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 0, 'dwarf': 0}, + {'name': 'rbx', 'bitsize': 64, 'offset': 8, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 3, 'dwarf': 3}, + {'name': 'rcx', 'bitsize': 64, 'offset': 16, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 2, 'dwarf': 2, 'generic': 'arg4', 'alt-name': 'arg4', }, + {'name': 'rdx', 'bitsize': 64, 'offset': 24, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 1, 'dwarf': 1, 'generic': 'arg3', 'alt-name': 'arg3', }, + {'name': 'rdi', 'bitsize': 64, 'offset': 32, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 5, 'dwarf': 5, 'generic': 'arg1', 'alt-name': 'arg1', }, + {'name': 'rsi', 'bitsize': 64, 'offset': 40, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 4, 'dwarf': 4, 'generic': 'arg2', 'alt-name': 'arg2', }, + {'name': 'rbp', 'bitsize': 64, 'offset': 48, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 6, 'dwarf': 6, 'generic': 'fp', 'alt-name': 'fp', }, + {'name': 'rsp', 'bitsize': 64, 'offset': 56, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 7, 'dwarf': 7, 'generic': 'sp', 'alt-name': 'sp', }, + {'name': 'r8', 'bitsize': 64, 'offset': 64, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 8, 'dwarf': 8, 'generic': 'arg5', 'alt-name': 'arg5', }, + {'name': 'r9', 'bitsize': 64, 'offset': 72, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 9, 'dwarf': 9, 'generic': 'arg6', 'alt-name': 'arg6', }, + {'name': 'r10', 'bitsize': 64, 'offset': 80, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 10, 'dwarf': 10}, + {'name': 'r11', 'bitsize': 64, 'offset': 88, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 11, 'dwarf': 11}, + {'name': 'r12', 'bitsize': 64, 'offset': 96, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 12, 'dwarf': 12}, + {'name': 'r13', 'bitsize': 64, 'offset': 104, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 13, 'dwarf': 13}, + {'name': 'r14', 'bitsize': 64, 'offset': 112, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 14, 'dwarf': 14}, + {'name': 'r15', 'bitsize': 64, 'offset': 120, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 15, 'dwarf': 15}, + {'name': 'rip', 'bitsize': 64, 'offset': 128, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 16, 'dwarf': 16, 'generic': 'pc', 'alt-name': 'pc'}, + {'name': 'rflags', 'bitsize': 64, 'offset': 136, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'generic': 'flags', 'alt-name': 'flags'}, + {'name': 'cs', 'bitsize': 64, 'offset': 144, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + {'name': 'fs', 'bitsize': 64, 'offset': 152, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + {'name': 'gs', 'bitsize': 64, 'offset': 160, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + ] return self.registers - + def get_register_data(self, tid): - return struct.pack('21Q',tid + 1,tid + 2,tid + 3,tid + 4,tid + 5,tid + 6,tid + 7,tid + 8,tid + 9,tid + 10,tid + 11,tid + 12,tid + 13,tid + 14,tid + 15,tid + 16,tid + 17,tid + 18,tid + 19,tid + 20,tid + 21); - + return struct.pack( + '21Q', + tid + 1, + tid + 2, + tid + 3, + tid + 4, + tid + 5, + tid + 6, + tid + 7, + tid + 8, + tid + 9, + tid + 10, + tid + 11, + tid + 12, + tid + 13, + tid + 14, + tid + 15, + tid + 16, + tid + 17, + tid + 18, + tid + 19, + tid + 20, + tid + 21) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py index 7a9435d44ed..438538ca922 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py @@ -3,21 +3,22 @@ import lldb import struct + class OperatingSystemPlugIn(object): """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class""" - + def __init__(self, process): '''Initialization needs a valid.SBProcess object. - + This plug-in will get created after a live process is valid and has stopped for the first time.''' self.process = None self.registers = None self.threads = None - if type(process) is lldb.SBProcess and process.IsValid(): + if isinstance(process, lldb.SBProcess) and process.IsValid(): self.process = process - self.threads = None # Will be an dictionary containing info for each thread - + self.threads = None # Will be an dictionary containing info for each thread + def get_target(self): # NOTE: Don't use "lldb.target" when trying to get your target as the "lldb.target" # tracks the current target in the LLDB command interpreter which isn't the @@ -26,11 +27,16 @@ class OperatingSystemPlugIn(object): def create_thread(self, tid, context): if tid == 0x444444444: - thread_info = { 'tid' : tid, 'name' : 'four' , 'queue' : 'queue4', 'state' : 'stopped', 'stop_reason' : 'none' } + thread_info = { + 'tid': tid, + 'name': 'four', + 'queue': 'queue4', + 'state': 'stopped', + 'stop_reason': 'none'} self.threads.append(thread_info) return thread_info return None - + def get_thread_info(self): if not self.threads: # The sample dictionary below shows the values that can be returned for a thread @@ -48,41 +54,63 @@ class OperatingSystemPlugIn(object): # Specifying this key/value pair for a thread will avoid a call to get_register_data() # and can be used when your registers are in a thread context structure that is contiguous # in memory. Don't specify this if your register layout in memory doesn't match the layout - # described by the dictionary returned from a call to the get_register_info() method. + # described by the dictionary returned from a call to the + # get_register_info() method. self.threads = [ - { 'tid' : 0x111111111, 'core' : 0 } - ] + {'tid': 0x111111111, 'core': 0} + ] return self.threads - + def get_register_info(self): - if self.registers == None: - self.registers = dict() + if self.registers is None: + self.registers = dict() self.registers['sets'] = ['GPR'] self.registers['registers'] = [ - { 'name':'rax' , 'bitsize' : 64, 'offset' : 0, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 0, 'dwarf' : 0}, - { 'name':'rbx' , 'bitsize' : 64, 'offset' : 8, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 3, 'dwarf' : 3}, - { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 2, 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', }, - { 'name':'rdx' , 'bitsize' : 64, 'offset' : 24, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 1, 'dwarf' : 1, 'generic':'arg3', 'alt-name':'arg3', }, - { 'name':'rdi' , 'bitsize' : 64, 'offset' : 32, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 5, 'dwarf' : 5, 'generic':'arg1', 'alt-name':'arg1', }, - { 'name':'rsi' , 'bitsize' : 64, 'offset' : 40, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 4, 'dwarf' : 4, 'generic':'arg2', 'alt-name':'arg2', }, - { 'name':'rbp' , 'bitsize' : 64, 'offset' : 48, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 6, 'dwarf' : 6, 'generic':'fp' , 'alt-name':'fp', }, - { 'name':'rsp' , 'bitsize' : 64, 'offset' : 56, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 7, 'dwarf' : 7, 'generic':'sp' , 'alt-name':'sp', }, - { 'name':'r8' , 'bitsize' : 64, 'offset' : 64, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 8, 'dwarf' : 8, 'generic':'arg5', 'alt-name':'arg5', }, - { 'name':'r9' , 'bitsize' : 64, 'offset' : 72, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 9, 'dwarf' : 9, 'generic':'arg6', 'alt-name':'arg6', }, - { 'name':'r10' , 'bitsize' : 64, 'offset' : 80, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 10, 'dwarf' : 10}, - { 'name':'r11' , 'bitsize' : 64, 'offset' : 88, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 11, 'dwarf' : 11}, - { 'name':'r12' , 'bitsize' : 64, 'offset' : 96, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 12, 'dwarf' : 12}, - { 'name':'r13' , 'bitsize' : 64, 'offset' : 104, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 13, 'dwarf' : 13}, - { 'name':'r14' , 'bitsize' : 64, 'offset' : 112, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 14, 'dwarf' : 14}, - { 'name':'r15' , 'bitsize' : 64, 'offset' : 120, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 15, 'dwarf' : 15}, - { 'name':'rip' , 'bitsize' : 64, 'offset' : 128, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 16, 'dwarf' : 16, 'generic':'pc', 'alt-name':'pc' }, - { 'name':'rflags' , 'bitsize' : 64, 'offset' : 136, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'generic':'flags', 'alt-name':'flags' }, - { 'name':'cs' , 'bitsize' : 64, 'offset' : 144, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - { 'name':'fs' , 'bitsize' : 64, 'offset' : 152, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - { 'name':'gs' , 'bitsize' : 64, 'offset' : 160, 'encoding':'uint' , 'format':'hex' , 'set': 0 }, - ] + {'name': 'rax', 'bitsize': 64, 'offset': 0, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 0, 'dwarf': 0}, + {'name': 'rbx', 'bitsize': 64, 'offset': 8, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 3, 'dwarf': 3}, + {'name': 'rcx', 'bitsize': 64, 'offset': 16, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 2, 'dwarf': 2, 'generic': 'arg4', 'alt-name': 'arg4', }, + {'name': 'rdx', 'bitsize': 64, 'offset': 24, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 1, 'dwarf': 1, 'generic': 'arg3', 'alt-name': 'arg3', }, + {'name': 'rdi', 'bitsize': 64, 'offset': 32, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 5, 'dwarf': 5, 'generic': 'arg1', 'alt-name': 'arg1', }, + {'name': 'rsi', 'bitsize': 64, 'offset': 40, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 4, 'dwarf': 4, 'generic': 'arg2', 'alt-name': 'arg2', }, + {'name': 'rbp', 'bitsize': 64, 'offset': 48, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 6, 'dwarf': 6, 'generic': 'fp', 'alt-name': 'fp', }, + {'name': 'rsp', 'bitsize': 64, 'offset': 56, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 7, 'dwarf': 7, 'generic': 'sp', 'alt-name': 'sp', }, + {'name': 'r8', 'bitsize': 64, 'offset': 64, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 8, 'dwarf': 8, 'generic': 'arg5', 'alt-name': 'arg5', }, + {'name': 'r9', 'bitsize': 64, 'offset': 72, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 9, 'dwarf': 9, 'generic': 'arg6', 'alt-name': 'arg6', }, + {'name': 'r10', 'bitsize': 64, 'offset': 80, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 10, 'dwarf': 10}, + {'name': 'r11', 'bitsize': 64, 'offset': 88, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 11, 'dwarf': 11}, + {'name': 'r12', 'bitsize': 64, 'offset': 96, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 12, 'dwarf': 12}, + {'name': 'r13', 'bitsize': 64, 'offset': 104, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 13, 'dwarf': 13}, + {'name': 'r14', 'bitsize': 64, 'offset': 112, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 14, 'dwarf': 14}, + {'name': 'r15', 'bitsize': 64, 'offset': 120, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 15, 'dwarf': 15}, + {'name': 'rip', 'bitsize': 64, 'offset': 128, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 16, 'dwarf': 16, 'generic': 'pc', 'alt-name': 'pc'}, + {'name': 'rflags', 'bitsize': 64, 'offset': 136, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'generic': 'flags', 'alt-name': 'flags'}, + {'name': 'cs', 'bitsize': 64, 'offset': 144, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + {'name': 'fs', 'bitsize': 64, 'offset': 152, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + {'name': 'gs', 'bitsize': 64, 'offset': 160, 'encoding': 'uint', 'format': 'hex', 'set': 0}, + ] return self.registers - + def get_register_data(self, tid): - return struct.pack('21Q',tid + 1,tid + 2,tid + 3,tid + 4,tid + 5,tid + 6,tid + 7,tid + 8,tid + 9,tid + 10,tid + 11,tid + 12,tid + 13,tid + 14,tid + 15,tid + 16,tid + 17,tid + 18,tid + 19,tid + 20,tid + 21); - + return struct.pack( + '21Q', + tid + 1, + tid + 2, + tid + 3, + tid + 4, + tid + 5, + tid + 6, + tid + 7, + tid + 8, + tid + 9, + tid + 10, + tid + 11, + tid + 12, + tid + 13, + tid + 14, + tid + 15, + tid + 16, + tid + 17, + tid + 18, + tid + 19, + tid + 20, + tid + 21) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py index 3c650639aeb..197a0378d99 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py @@ -12,18 +12,19 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LinuxCoreTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) - _i386_pid = 32306 + _i386_pid = 32306 _x86_64_pid = 32259 - _s390x_pid = 1045 + _s390x_pid = 1045 - _i386_regions = 4 + _i386_regions = 4 _x86_64_regions = 5 - _s390x_regions = 2 + _s390x_regions = 2 def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" @@ -33,8 +34,9 @@ class LinuxCoreTestCase(TestBase): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("x86_64", self._x86_64_pid, self._x86_64_regions) - # This seems to hang on non-s390x platforms for some reason. Disabling for now. - @skipIf(archs=no_match(['s390x'])) + # This seems to hang on non-s390x platforms for some reason. Disabling + # for now. + @skipIf(archs=no_match(['s390x'])) def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("s390x", self._s390x_pid, self._s390x_regions) @@ -43,7 +45,7 @@ class LinuxCoreTestCase(TestBase): """Test that we read the information from the core correctly even if we have a running process with the same PID around""" try: - shutil.copyfile("x86_64.out", "x86_64-pid.out") + shutil.copyfile("x86_64.out", "x86_64-pid.out") shutil.copyfile("x86_64.core", "x86_64-pid.core") with open("x86_64-pid.core", "r+b") as f: # These are offsets into the NT_PRSTATUS and NT_PRPSINFO structures in the note @@ -51,9 +53,14 @@ class LinuxCoreTestCase(TestBase): # as well. (Notes can be viewed with readelf --notes.) for pid_offset in [0x1c4, 0x320]: f.seek(pid_offset) - self.assertEqual(struct.unpack("<I", f.read(4))[0], self._x86_64_pid) - - # We insert our own pid, and make sure the test still works. + self.assertEqual( + struct.unpack( + "<I", + f.read(4))[0], + self._x86_64_pid) + + # We insert our own pid, and make sure the test still + # works. f.seek(pid_offset) f.write(struct.pack("<I", os.getpid())) self.do_test("x86_64-pid", os.getpid(), self._x86_64_regions) @@ -72,10 +79,15 @@ class LinuxCoreTestCase(TestBase): altframe = altprocess.GetSelectedThread().GetFrameAtIndex(0) self.assertEqual(altframe.GetFunctionName(), "_start") - self.assertEqual(altframe.GetLineEntry().GetLine(), line_number("altmain.c", "Frame _start")) + self.assertEqual( + altframe.GetLineEntry().GetLine(), + line_number( + "altmain.c", + "Frame _start")) error = lldb.SBError() - F = altprocess.ReadCStringFromMemory(altframe.FindVariable("F").GetValueAsUnsigned(), 256, error) + F = altprocess.ReadCStringFromMemory( + altframe.FindVariable("F").GetValueAsUnsigned(), 256, error) self.assertTrue(error.Success()) self.assertEqual(F, "_start") @@ -90,33 +102,40 @@ class LinuxCoreTestCase(TestBase): region = lldb.SBMemoryRegionInfo() # Check we have the right number of regions. - self.assertEqual(region_list.GetSize(), region_count); + self.assertEqual(region_list.GetSize(), region_count) # Check that getting a region beyond the last in the list fails. - self.assertFalse(region_list.GetMemoryRegionAtIndex(region_count, region)); + self.assertFalse( + region_list.GetMemoryRegionAtIndex( + region_count, region)) # Check each region is valid. for i in range(region_list.GetSize()): # Check we can actually get this region. self.assertTrue(region_list.GetMemoryRegionAtIndex(i, region)) - #Every region in the list should be mapped. + # Every region in the list should be mapped. self.assertTrue(region.IsMapped()) - # Test the address at the start of a region returns it's enclosing region. + # Test the address at the start of a region returns it's enclosing + # region. begin_address = region.GetRegionBase() region_at_begin = lldb.SBMemoryRegionInfo() error = process.GetMemoryRegionInfo(begin_address, region_at_begin) self.assertEqual(region, region_at_begin) - # Test an address in the middle of a region returns it's enclosing region. - middle_address = (region.GetRegionBase() + region.GetRegionEnd()) / 2l + # Test an address in the middle of a region returns it's enclosing + # region. + middle_address = (region.GetRegionBase() + + region.GetRegionEnd()) / 2 region_at_middle = lldb.SBMemoryRegionInfo() - error = process.GetMemoryRegionInfo(middle_address, region_at_middle) + error = process.GetMemoryRegionInfo( + middle_address, region_at_middle) self.assertEqual(region, region_at_middle) - # Test the address at the end of a region returns it's enclosing region. - end_address = region.GetRegionEnd() - 1l + # Test the address at the end of a region returns it's enclosing + # region. + end_address = region.GetRegionEnd() - 1 region_at_end = lldb.SBMemoryRegionInfo() error = process.GetMemoryRegionInfo(end_address, region_at_end) self.assertEqual(region, region_at_end) @@ -124,18 +143,24 @@ class LinuxCoreTestCase(TestBase): # Check that quering the end address does not return this region but # the next one. next_region = lldb.SBMemoryRegionInfo() - error = process.GetMemoryRegionInfo(region.GetRegionEnd(), next_region) + error = process.GetMemoryRegionInfo( + region.GetRegionEnd(), next_region) self.assertNotEqual(region, next_region) - self.assertEqual(region.GetRegionEnd(), next_region.GetRegionBase()) + self.assertEqual( + region.GetRegionEnd(), + next_region.GetRegionBase()) # Check that query beyond the last region returns an unmapped region # that ends at LLDB_INVALID_ADDRESS last_region = lldb.SBMemoryRegionInfo() region_list.GetMemoryRegionAtIndex(region_count - 1, last_region) end_region = lldb.SBMemoryRegionInfo() - error = process.GetMemoryRegionInfo(last_region.GetRegionEnd(), end_region) + error = process.GetMemoryRegionInfo( + last_region.GetRegionEnd(), end_region) self.assertFalse(end_region.IsMapped()) - self.assertEqual(last_region.GetRegionEnd(), end_region.GetRegionBase()) + self.assertEqual( + last_region.GetRegionEnd(), + end_region.GetRegionBase()) self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS) def do_test(self, filename, pid, region_count): @@ -155,8 +180,10 @@ class LinuxCoreTestCase(TestBase): self.assertTrue(frame) self.assertEqual(frame.GetFunctionName(), backtrace[i]) self.assertEqual(frame.GetLineEntry().GetLine(), - line_number("main.c", "Frame " + backtrace[i])) - self.assertEqual(frame.FindVariable("F").GetValueAsUnsigned(), ord(backtrace[i][0])) + line_number("main.c", "Frame " + backtrace[i])) + self.assertEqual( + frame.FindVariable("F").GetValueAsUnsigned(), ord( + backtrace[i][0])) self.check_memory_regions(process, region_count) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py index 89d1974b670..8c375f7d862 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py @@ -11,6 +11,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class MiniDumpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -35,12 +36,13 @@ class MiniDumpTestCase(TestBase): self.dbg.CreateTarget("") self.target = self.dbg.GetSelectedTarget() self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp") - # This process crashed due to an access violation (0xc0000005) in its one and only thread. + # This process crashed due to an access violation (0xc0000005) in its + # one and only thread. self.assertEqual(self.process.GetNumThreads(), 1) thread = self.process.GetThreadAtIndex(0) self.assertEqual(thread.GetStopReason(), lldb.eStopReasonException) - stop_description = thread.GetStopDescription(256); - self.assertTrue("0xc0000005" in stop_description); + stop_description = thread.GetStopDescription(256) + self.assertTrue("0xc0000005" in stop_description) @skipUnlessWindows # for now mini-dump debugging is limited to Windows hosts @no_debug_info_test @@ -72,7 +74,8 @@ class MiniDumpTestCase(TestBase): # Set a breakpoint and capture a mini dump. target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByName("bar") - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertEqual(process.GetState(), lldb.eStateStopped) self.assertTrue(process.SaveCore(core)) self.assertTrue(os.path.isfile(core)) @@ -83,7 +86,7 @@ class MiniDumpTestCase(TestBase): process = target.LoadCore(core) thread = process.GetThreadAtIndex(0) - expected_stack = { 0: 'bar', 1: 'foo', 2: 'main' } + expected_stack = {0: 'bar', 1: 'foo', 2: 'main'} self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack)) for index, name in iteritems(expected_stack): frame = thread.GetFrameAtIndex(index) @@ -108,7 +111,8 @@ class MiniDumpTestCase(TestBase): # Set a breakpoint and capture a mini dump. target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByName("bar") - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertEqual(process.GetState(), lldb.eStateStopped) self.assertTrue(process.SaveCore(core)) self.assertTrue(os.path.isfile(core)) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py index 08debab538f..d68871a34fb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py @@ -16,6 +16,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class Wow64MiniDumpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -66,7 +67,8 @@ class Wow64MiniDumpTestCase(TestBase): # In the dump, none of the threads are stopped, so we cannot use # lldbutil.get_stopped_thread. thread = process.GetThreadAtIndex(0) - # The crash is in main, so there should be at least one frame on the stack. + # The crash is in main, so there should be at least one frame on the + # stack. self.assertGreaterEqual(thread.GetNumFrames(), 1) frame = thread.GetFrameAtIndex(0) self.assertTrue(frame.IsValid()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py index e4eb302d83d..6a366b69d93 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -5,8 +5,8 @@ Test process attach. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -14,6 +14,7 @@ from lldbsuite.test import lldbutil exe_name = "ProcessAttach" # Must match Makefile + class ProcessAttachTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py index 3d1d7fdc790..071f5d57c78 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py @@ -5,7 +5,6 @@ Test denied process attach. from __future__ import print_function - import os import time import lldb @@ -15,6 +14,7 @@ from lldbsuite.test import lldbutil exe_name = 'AttachDenied' # Must match Makefile + class AttachDeniedTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,8 +28,11 @@ class AttachDeniedTestCase(TestBase): # Use a file as a synchronization point between test and inferior. pid_file_path = lldbutil.append_to_process_working_directory( - "pid_file_%d" % (int(time.time()))) - self.addTearDownHook(lambda: self.run_platform_command("rm %s" % (pid_file_path))) + "pid_file_%d" % (int(time.time()))) + self.addTearDownHook( + lambda: self.run_platform_command( + "rm %s" % + (pid_file_path))) # Spawn a new process popen = self.spawnSubprocess(exe, [pid_file_path]) @@ -38,5 +41,5 @@ class AttachDeniedTestCase(TestBase): pid = lldbutil.wait_for_file_on_target(self, pid_file_path) self.expect('process attach -p ' + pid, - startstr = 'error: attach failed:', - error = True) + startstr='error: attach failed:', + error=True) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py index c20d66aa3ab..00b4d415340 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py @@ -3,7 +3,6 @@ from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * @@ -21,8 +20,8 @@ class ChangeProcessGroupTestCase(TestBase): # Find the line number to break for main.c. self.line = line_number('main.c', '// Set breakpoint here') - @skipIfFreeBSD # Times out on FreeBSD llvm.org/pr23731 - @skipIfWindows # setpgid call does not exist on Windows + @skipIfFreeBSD # Times out on FreeBSD llvm.org/pr23731 + @skipIfWindows # setpgid call does not exist on Windows @expectedFailureAndroid("http://llvm.org/pr23762", api_levels=[16]) def test_setpgid(self): self.build() @@ -30,8 +29,11 @@ class ChangeProcessGroupTestCase(TestBase): # Use a file as a synchronization point between test and inferior. pid_file_path = lldbutil.append_to_process_working_directory( - "pid_file_%d" % (int(time.time()))) - self.addTearDownHook(lambda: self.run_platform_command("rm %s" % (pid_file_path))) + "pid_file_%d" % (int(time.time()))) + self.addTearDownHook( + lambda: self.run_platform_command( + "rm %s" % + (pid_file_path))) popen = self.spawnSubprocess(exe, [pid_file_path]) self.addTearDownHook(self.cleanupSubprocesses) @@ -57,19 +59,20 @@ class ChangeProcessGroupTestCase(TestBase): self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # set a breakpoint just before the setpgid() call - lldbutil.run_break_set_by_file_and_line(self, 'main.c', self.line, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, 'main.c', self.line, num_expected_locations=-1) thread = process.GetSelectedThread() # release the child from its loop value = thread.GetSelectedFrame().EvaluateExpression("release_child_flag = 1") - self.assertTrue(value.IsValid() and value.GetValueAsUnsigned(0) == 1); + self.assertTrue(value.IsValid() and value.GetValueAsUnsigned(0) == 1) process.Continue() # make sure the child's process group id is different from its pid value = thread.GetSelectedFrame().EvaluateExpression("(int)getpgid(0)") self.assertTrue(value.IsValid()) - self.assertNotEqual(value.GetValueAsUnsigned(0), int(pid)); + self.assertNotEqual(value.GetValueAsUnsigned(0), int(pid)) # step over the setpgid() call thread.StepOver() @@ -79,7 +82,7 @@ class ChangeProcessGroupTestCase(TestBase): # this also checks that we are still in full control of the child value = thread.GetSelectedFrame().EvaluateExpression("(int)getpgid(0)") self.assertTrue(value.IsValid()) - self.assertEqual(value.GetValueAsUnsigned(0), int(pid)); + self.assertEqual(value.GetValueAsUnsigned(0), int(pid)) # run to completion process.Continue() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py index 5998edb3c7e..5929a352b61 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py @@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil import six + class ProcessLaunchTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,12 +30,12 @@ class ProcessLaunchTestCase(TestBase): TestBase.tearDown(self) @not_remote_testsuite_ready - def test_io (self): + def test_io(self): """Test that process launch I/O redirection flags work properly.""" - self.build () - exe = os.path.join (os.getcwd(), "a.out") + self.build() + exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out" ]) + patterns=["Current executable set to .*a.out"]) in_file = "input-file.txt" out_file = "output-test.out" @@ -42,23 +43,24 @@ class ProcessLaunchTestCase(TestBase): # Make sure the output files do not exist before launching the process try: - os.remove (out_file) + os.remove(out_file) except OSError: pass try: - os.remove (err_file) + os.remove(err_file) except OSError: pass - launch_command = "process launch -i " + in_file + " -o " + out_file + " -e " + err_file + launch_command = "process launch -i " + \ + in_file + " -o " + out_file + " -e " + err_file if lldb.remote_platform: self.runCmd('platform put-file "{local}" "{remote}"'.format( local=in_file, remote=in_file)) - self.expect (launch_command, - patterns = [ "Process .* launched: .*a.out" ]) + self.expect(launch_command, + patterns=["Process .* launched: .*a.out"]) if lldb.remote_platform: self.runCmd('platform get-file "{remote}" "{local}"'.format( @@ -71,33 +73,33 @@ class ProcessLaunchTestCase(TestBase): # Check to see if the 'stdout' file was created try: - out_f = open (out_file) + out_f = open(out_file) except IOError: success = False err_msg = err_msg + " ERROR: stdout file was not created.\n" else: # Check to see if the 'stdout' file contains the right output - line = out_f.readline (); + line = out_f.readline() if line != "This should go to stdout.\n": success = False err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n" - out_f.close(); + out_f.close() # Try to delete the 'stdout' file try: - os.remove (out_file) + os.remove(out_file) except OSError: pass # Check to see if the 'stderr' file was created try: - err_f = open (err_file) + err_f = open(err_file) except IOError: success = False err_msg = err_msg + " ERROR: stderr file was not created.\n" else: # Check to see if the 'stderr' file contains the right output - line = err_f.readline () + line = err_f.readline() if line != "This should go to stderr.\n": success = False err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n\ @@ -106,23 +108,24 @@ class ProcessLaunchTestCase(TestBase): # Try to delete the 'stderr' file try: - os.remove (err_file) + os.remove(err_file) except OSError: pass if not success: - self.fail (err_msg) + self.fail(err_msg) # rdar://problem/9056462 - # The process launch flag '-w' for setting the current working directory not working? + # The process launch flag '-w' for setting the current working directory + # not working? @not_remote_testsuite_ready @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20265") - def test_set_working_dir (self): + def test_set_working_dir(self): """Test that '-w dir' sets the working dir when running the inferior.""" - d = {'CXX_SOURCES' : 'print_cwd.cpp'} + d = {'CXX_SOURCES': 'print_cwd.cpp'} self.build(dictionary=d) self.setTearDownCleanup(d) - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe) mywd = 'my_working_dir' @@ -135,26 +138,26 @@ class ProcessLaunchTestCase(TestBase): # Make sure the output files do not exist before launching the process try: - os.remove (out_file_path) - os.remove (err_file_path) + os.remove(out_file_path) + os.remove(err_file_path) except OSError: pass # Check that we get an error when we have a nonexisting path - launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path + 'z', - out_file_path, - err_file_path) + launch_command = "process launch -w %s -o %s -e %s" % ( + my_working_dir_path + 'z', out_file_path, err_file_path) - self.expect(launch_command, error=True, - patterns = ["error:.* No such file or directory: %sz" % my_working_dir_path]) + self.expect( + launch_command, error=True, patterns=[ + "error:.* No such file or directory: %sz" % + my_working_dir_path]) # Really launch the process - launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path, - out_file_path, - err_file_path) + launch_command = "process launch -w %s -o %s -e %s" % ( + my_working_dir_path, out_file_path, err_file_path) self.expect(launch_command, - patterns = [ "Process .* launched: .*a.out" ]) + patterns=["Process .* launched: .*a.out"]) success = True err_msg = "" @@ -167,13 +170,13 @@ class ProcessLaunchTestCase(TestBase): err_msg = err_msg + "ERROR: stdout file was not created.\n" else: # Check to see if the 'stdout' file contains the right output - line = out_f.readline(); + line = out_f.readline() if self.TraceOn(): print("line:", line) if not re.search(mywd, line): success = False err_msg = err_msg + "The current working directory was not set correctly.\n" - out_f.close(); + out_f.close() # Try to delete the 'stdout' and 'stderr' files try: @@ -186,24 +189,31 @@ class ProcessLaunchTestCase(TestBase): if not success: self.fail(err_msg) - def test_environment_with_special_char (self): + def test_environment_with_special_char(self): """Test that environment variables containing '*' and '}' are handled correctly by the inferior.""" source = 'print_env.cpp' - d = {'CXX_SOURCES' : source} + d = {'CXX_SOURCES': source} self.build(dictionary=d) self.setTearDownCleanup(d) - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") evil_var = 'INIT*MIDDLE}TAIL' target = self.dbg.CreateTarget(exe) main_source_spec = lldb.SBFileSpec(source) - breakpoint = target.BreakpointCreateBySourceRegex('// Set breakpoint here.', main_source_spec) - - process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) - self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) - - threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) + breakpoint = target.BreakpointCreateBySourceRegex( + '// Set breakpoint here.', main_source_spec) + + process = target.LaunchSimple(None, + ['EVIL=' + evil_var], + self.get_process_working_directory()) + self.assertEqual( + process.GetState(), + lldb.eStateStopped, + PROCESS_STOPPED) + + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) self.assertEqual(len(threads), 1) frame = threads[0].GetFrameAtIndex(0) sbvalue = frame.EvaluateExpression("evil") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py index 1c01e2138c2..ee1f82b14f7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py @@ -4,12 +4,14 @@ Test saving a core file (or mini dump). 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 ProcessSaveCoreTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,7 +24,8 @@ class ProcessSaveCoreTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") core = os.path.join(os.getcwd(), "core.dmp") target = self.dbg.CreateTarget(exe) - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertNotEqual(process.GetState(), lldb.eStateStopped) error = process.SaveCore(core) self.assertTrue(error.Fail()) @@ -37,7 +40,8 @@ class ProcessSaveCoreTestCase(TestBase): try: target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByName("bar") - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertEqual(process.GetState(), lldb.eStateStopped) self.assertTrue(process.SaveCore(core)) self.assertTrue(os.path.isfile(core)) @@ -47,8 +51,13 @@ class ProcessSaveCoreTestCase(TestBase): # the executable in the module list. target = self.dbg.CreateTarget(None) process = target.LoadCore(core) - files = [target.GetModuleAtIndex(i).GetFileSpec() for i in range(0, target.GetNumModules())] - paths = [os.path.join(f.GetDirectory(), f.GetFilename()) for f in files] + files = [ + target.GetModuleAtIndex(i).GetFileSpec() for i in range( + 0, target.GetNumModules())] + paths = [ + os.path.join( + f.GetDirectory(), + f.GetFilename()) for f in files] self.assertTrue(exe in paths) finally: @@ -56,5 +65,3 @@ class ProcessSaveCoreTestCase(TestBase): self.assertTrue(self.dbg.DeleteTarget(target)) if (os.path.isfile(core)): os.unlink(core) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py b/lldb/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py index 81db42d8e3c..5085b8cce99 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py @@ -10,6 +10,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestPtrRefs(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,24 +21,29 @@ class TestPtrRefs(TestBase): self.build() exe_name = 'a.out' exe = os.path.join(os.getcwd(), exe_name) - + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - main_file_spec = lldb.SBFileSpec ('main.c') - breakpoint = target.BreakpointCreateBySourceRegex('break', main_file_spec) + main_file_spec = lldb.SBFileSpec('main.c') + breakpoint = target.BreakpointCreateBySourceRegex( + 'break', main_file_spec) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint condition") - frame = thread.GetFrameAtIndex(0) + frame = thread.GetFrameAtIndex(0) self.dbg.HandleCommand("script import lldb.macosx.heap") - self.expect("ptr_refs my_ptr", substrs=["malloc", "stack"]); + self.expect("ptr_refs my_ptr", substrs=["malloc", "stack"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py b/lldb/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py index fcb493bc9d9..5b72d383f14 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py @@ -5,12 +5,13 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class ValueObjectRecursionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,14 +27,15 @@ class ValueObjectRecursionTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +49,21 @@ class ValueObjectRecursionTestCase(TestBase): root = self.frame().FindVariable("root") child = root.GetChildAtIndex(1) if self.TraceOn(): - print(root) - print(child) - for i in range(0,15000): - child = child.GetChildAtIndex(1) + print(root) + print(child) + for i in range(0, 15000): + child = child.GetChildAtIndex(1) if self.TraceOn(): - print(child) - self.assertTrue(child.IsValid(),"could not retrieve the deep ValueObject") - self.assertTrue(child.GetChildAtIndex(0).IsValid(),"the deep ValueObject has no value") - self.assertTrue(child.GetChildAtIndex(0).GetValueAsUnsigned() != 0,"the deep ValueObject has a zero value") - self.assertTrue(child.GetChildAtIndex(1).GetValueAsUnsigned() != 0, "the deep ValueObject has no next") + print(child) + self.assertTrue( + child.IsValid(), + "could not retrieve the deep ValueObject") + self.assertTrue( + child.GetChildAtIndex(0).IsValid(), + "the deep ValueObject has no value") + self.assertTrue( + child.GetChildAtIndex(0).GetValueAsUnsigned() != 0, + "the deep ValueObject has a zero value") + self.assertTrue( + child.GetChildAtIndex(1).GetValueAsUnsigned() != 0, + "the deep ValueObject has no next") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py b/lldb/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py index 21de3ab7cc3..3f9535a220c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py @@ -5,14 +5,16 @@ Test the 'register' command. from __future__ import print_function - -import os, sys, time +import os +import sys +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class RegisterCommandsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -36,19 +38,24 @@ class RegisterCommandsTestCase(TestBase): self.log_enable("registers") self.expect("register read -a", MISSING_EXPECTED_REGISTERS, - substrs = ['registers were unavailable'], matching = False) + substrs=['registers were unavailable'], matching=False) if self.getArchitecture() in ['amd64', 'i386', 'x86_64']: self.runCmd("register read xmm0") - self.runCmd("register read ymm15") # may be available + self.runCmd("register read ymm15") # may be available elif self.getArchitecture() in ['arm']: self.runCmd("register read s0") - self.runCmd("register read q15") # may be available + self.runCmd("register read q15") # may be available - self.expect("register read -s 3", substrs = ['invalid register set index: 3'], error = True) + self.expect( + "register read -s 3", + substrs=['invalid register set index: 3'], + error=True) @skipIfiOSSimulator - @skipIfTargetAndroid(archs=["i386"]) # Writing of mxcsr register fails, presumably due to a kernel/hardware problem + # Writing of mxcsr register fails, presumably due to a kernel/hardware + # problem + @skipIfTargetAndroid(archs=["i386"]) @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64'])) def test_fp_register_write(self): """Test commands that write to registers, in particular floating-point registers.""" @@ -56,8 +63,9 @@ class RegisterCommandsTestCase(TestBase): self.fp_register_write() @skipIfiOSSimulator - @expectedFailureAndroid(archs=["i386"]) # "register read fstat" always return 0xffff - @skipIfFreeBSD #llvm.org/pr25057 + # "register read fstat" always return 0xffff + @expectedFailureAndroid(archs=["i386"]) + @skipIfFreeBSD # llvm.org/pr25057 @skipIf(archs=no_match(['amd64', 'i386', 'x86_64'])) def test_fp_special_purpose_register_read(self): """Test commands that read fpu special purpose registers.""" @@ -78,12 +86,16 @@ class RegisterCommandsTestCase(TestBase): gpr = "r0" vector = "q0" - self.expect("expr/x $%s" % gpr, substrs = ['unsigned int', ' = 0x']) - self.expect("expr $%s" % vector, substrs = ['vector_type']) - self.expect("expr (unsigned int)$%s[0]" % vector, substrs = ['unsigned int']) + self.expect("expr/x $%s" % gpr, substrs=['unsigned int', ' = 0x']) + self.expect("expr $%s" % vector, substrs=['vector_type']) + self.expect( + "expr (unsigned int)$%s[0]" % + vector, substrs=['unsigned int']) if self.getArchitecture() in ['amd64', 'x86_64']: - self.expect("expr -- ($rax & 0xffffffff) == $eax", substrs = ['true']) + self.expect( + "expr -- ($rax & 0xffffffff) == $eax", + substrs=['true']) @skipIfiOSSimulator @skipIf(archs=no_match(['amd64', 'x86_64'])) @@ -112,13 +124,14 @@ class RegisterCommandsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main(). - lldbutil.run_break_set_by_symbol (self, "main", num_expected_locations=-1) + lldbutil.run_break_set_by_symbol( + self, "main", 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']) # platform specific logging of the specified category def log_enable(self, category): @@ -126,7 +139,7 @@ class RegisterCommandsTestCase(TestBase): # platform as logging is host side. self.platform = "" if sys.platform.startswith("darwin"): - self.platform = "" # TODO: add support for "log enable darwin registers" + self.platform = "" # TODO: add support for "log enable darwin registers" if sys.platform.startswith("freebsd"): self.platform = "freebsd" @@ -139,7 +152,14 @@ class RegisterCommandsTestCase(TestBase): if self.platform != "": self.log_file = os.path.join(os.getcwd(), 'TestRegisters.log') - self.runCmd("log enable " + self.platform + " " + str(category) + " registers -v -f " + self.log_file, RUN_SUCCEEDED) + self.runCmd( + "log enable " + + self.platform + + " " + + str(category) + + " registers -v -f " + + self.log_file, + RUN_SUCCEEDED) if not self.has_teardown: def remove_log(self): if os.path.exists(self.log_file): @@ -147,15 +167,24 @@ class RegisterCommandsTestCase(TestBase): self.has_teardown = True self.addTearDownHook(remove_log) - def write_and_read(self, frame, register, new_value, must_exist = True): + def write_and_read(self, frame, register, new_value, must_exist=True): value = frame.FindValue(register, lldb.eValueTypeRegister) if must_exist: - self.assertTrue(value.IsValid(), "finding a value for register " + register) + self.assertTrue( + value.IsValid(), + "finding a value for register " + + register) elif not value.IsValid(): - return # If register doesn't exist, skip this test + return # If register doesn't exist, skip this test self.runCmd("register write " + register + " \'" + new_value + "\'") - self.expect("register read " + register, substrs = [register + ' = ', new_value]) + self.expect( + "register read " + + register, + substrs=[ + register + + ' = ', + new_value]) def fp_special_purpose_register_read(self): exe = os.path.join(os.getcwd(), "a.out") @@ -165,12 +194,14 @@ class RegisterCommandsTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Launch the process and stop. - self.expect ("run", PROCESS_STOPPED, substrs = ['stopped']) + self.expect("run", PROCESS_STOPPED, substrs=['stopped']) # Check stop reason; Should be either signal SIGTRAP or EXC_BREAKPOINT output = self.res.GetOutput() matched = False - substrs = ['stop reason = EXC_BREAKPOINT', 'stop reason = signal SIGTRAP'] + substrs = [ + 'stop reason = EXC_BREAKPOINT', + 'stop reason = signal SIGTRAP'] for str1 in substrs: matched = output.find(str1) != -1 with recording(self, False) as sbuf: @@ -202,30 +233,39 @@ class RegisterCommandsTestCase(TestBase): reg_value_ftag_initial = value.GetValueAsUnsigned(error, 0) self.assertTrue(error.Success(), "reading a value for ftag") - fstat_top_pointer_initial = (reg_value_fstat_initial & 0x3800)>>11 + fstat_top_pointer_initial = (reg_value_fstat_initial & 0x3800) >> 11 # Execute 'si' aka 'thread step-inst' instruction 5 times and with # every execution verify the value of fstat and ftag registers - for x in range(0,5): - # step into the next instruction to push a value on 'st' register stack - self.runCmd ("si", RUN_SUCCEEDED) + for x in range(0, 5): + # step into the next instruction to push a value on 'st' register + # stack + self.runCmd("si", RUN_SUCCEEDED) - # Verify fstat and save it to be used for verification in next execution of 'si' command + # Verify fstat and save it to be used for verification in next + # execution of 'si' command if not (reg_value_fstat_initial & 0x3800): - self.expect("register read fstat", - substrs = ['fstat' + ' = ', str("0x%0.4x" %((reg_value_fstat_initial & ~(0x3800))| 0x3800))]) - reg_value_fstat_initial = ((reg_value_fstat_initial & ~(0x3800))| 0x3800) + self.expect("register read fstat", substrs=[ + 'fstat' + ' = ', str("0x%0.4x" % ((reg_value_fstat_initial & ~(0x3800)) | 0x3800))]) + reg_value_fstat_initial = ( + (reg_value_fstat_initial & ~(0x3800)) | 0x3800) fstat_top_pointer_initial = 7 - else : - self.expect("register read fstat", - substrs = ['fstat' + ' = ', str("0x%0.4x" % (reg_value_fstat_initial - 0x0800))]) + else: + self.expect("register read fstat", substrs=[ + 'fstat' + ' = ', str("0x%0.4x" % (reg_value_fstat_initial - 0x0800))]) reg_value_fstat_initial = (reg_value_fstat_initial - 0x0800) fstat_top_pointer_initial -= 1 - # Verify ftag and save it to be used for verification in next execution of 'si' command - self.expect("register read ftag", - substrs = ['ftag' + ' = ', str("0x%0.2x" % (reg_value_ftag_initial | (1<< fstat_top_pointer_initial)))]) - reg_value_ftag_initial = reg_value_ftag_initial | (1<< fstat_top_pointer_initial) + # Verify ftag and save it to be used for verification in next + # execution of 'si' command + self.expect( + "register read ftag", substrs=[ + 'ftag' + ' = ', str( + "0x%0.2x" % + (reg_value_ftag_initial | ( + 1 << fstat_top_pointer_initial)))]) + reg_value_ftag_initial = reg_value_ftag_initial | ( + 1 << fstat_top_pointer_initial) def fp_register_write(self): exe = os.path.join(os.getcwd(), "a.out") @@ -234,13 +274,17 @@ class RegisterCommandsTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - lldbutil.run_break_set_by_symbol (self, "main", num_expected_locations=-1) + lldbutil.run_break_set_by_symbol( + self, "main", num_expected_locations=-1) # 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()) process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) + self.assertTrue( + process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid(), "current thread is valid") @@ -251,12 +295,12 @@ class RegisterCommandsTestCase(TestBase): if self.getArchitecture() in ['amd64', 'i386', 'x86_64']: reg_list = [ # reg value must-have - ("fcw", "0x0000ff0e", False), - ("fsw", "0x0000ff0e", False), - ("ftw", "0x0000ff0e", False), - ("ip", "0x0000ff0e", False), - ("dp", "0x0000ff0e", False), - ("mxcsr", "0x0000ff0e", False), + ("fcw", "0x0000ff0e", False), + ("fsw", "0x0000ff0e", False), + ("ftw", "0x0000ff0e", False), + ("ip", "0x0000ff0e", False), + ("dp", "0x0000ff0e", False), + ("mxcsr", "0x0000ff0e", False), ("mxcsrmask", "0x0000ff0e", False), ] @@ -266,31 +310,52 @@ class RegisterCommandsTestCase(TestBase): elif currentFrame.FindRegister("stmm0").IsValid(): st0regname = "stmm0" if st0regname is not None: - # reg value must-have - reg_list.append((st0regname, "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00}", True)) - reg_list.append(("xmm0", "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f}", True)) - reg_list.append(("xmm15", "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f}", False)) + # reg value + # must-have + reg_list.append( + (st0regname, "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00}", True)) + reg_list.append( + ("xmm0", + "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f}", + True)) + reg_list.append( + ("xmm15", + "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f}", + False)) elif self.getArchitecture() in ['arm']: reg_list = [ - # reg value must-have - ("fpscr", "0xfbf79f9f", True), - ("s0", "1.25", True), - ("s31", "0.75", True), - ("d1", "123", True), - ("d17", "987", False), - ("q1", "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f}", True), - ("q14", "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f}", False), + # reg value + # must-have + ("fpscr", "0xfbf79f9f", True), + ("s0", "1.25", True), + ("s31", "0.75", True), + ("d1", "123", True), + ("d17", "987", False), + ("q1", "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x2f 0x2f}", True), + ("q14", + "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f}", + False), ] for (reg, val, must) in reg_list: self.write_and_read(currentFrame, reg, val, must) if self.getArchitecture() in ['amd64', 'i386', 'x86_64']: - self.runCmd("register write " + st0regname + " \"{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}\"") - self.expect("register read " + st0regname + " --format f", substrs = [st0regname + ' = 0']) - - has_avx = False - registerSets = currentFrame.GetRegisters() # Returns an SBValueList. + self.runCmd( + "register write " + + st0regname + + " \"{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}\"") + self.expect( + "register read " + + st0regname + + " --format f", + substrs=[ + st0regname + + ' = 0']) + + has_avx = False + # Returns an SBValueList. + registerSets = currentFrame.GetRegisters() for registerSet in registerSets: if 'advanced vector extensions' in registerSet.GetName().lower(): has_avx = True @@ -300,7 +365,7 @@ class RegisterCommandsTestCase(TestBase): new_value = "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0c 0x0d 0x0e 0x0f}" self.write_and_read(currentFrame, "ymm0", new_value) self.write_and_read(currentFrame, "ymm7", new_value) - self.expect("expr $ymm0", substrs = ['vector_type']) + self.expect("expr $ymm0", substrs=['vector_type']) else: self.runCmd("register read ymm0") @@ -308,22 +373,24 @@ class RegisterCommandsTestCase(TestBase): """Test convenience registers.""" self.common_setup() - # The command "register read -a" does output a derived register like eax... + # The command "register read -a" does output a derived register like + # eax... self.expect("register read -a", matching=True, - substrs = ['eax']) + substrs=['eax']) # ...however, the vanilla "register read" command should not output derived registers like eax. self.expect("register read", matching=False, - substrs = ['eax']) - + substrs=['eax']) + # Test reading of rax and eax. self.expect("register read rax eax", - substrs = ['rax = 0x', 'eax = 0x']) + substrs=['rax = 0x', 'eax = 0x']) - # Now write rax with a unique bit pattern and test that eax indeed represents the lower half of rax. + # Now write rax with a unique bit pattern and test that eax indeed + # represents the lower half of rax. self.runCmd("register write rax 0x1234567887654321") self.expect("register read rax 0x1234567887654321", - substrs = ['0x1234567887654321']) + substrs=['0x1234567887654321']) def convenience_registers_with_process_attach(self, test_16bit_regs): """Test convenience registers after a 'process attach'.""" @@ -343,8 +410,8 @@ class RegisterCommandsTestCase(TestBase): if self.getArchitecture() in ['amd64', 'x86_64']: self.expect("expr -- ($rax & 0xffffffff) == $eax", - substrs = ['true']) + substrs=['true']) if test_16bit_regs: self.expect("expr -- $ax == (($ah << 8) | $al)", - substrs = ['true']) + substrs=['true']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py b/lldb/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py index 8636abadd10..20d64b38f0c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py @@ -4,7 +4,6 @@ Test that argdumper is a viable launching strategy. from __future__ import print_function - import lldb import os import time @@ -12,45 +11,51 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestRerun(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): + def test(self): self.build() - exe = os.path.join (os.getcwd(), "a.out") - + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("target create %s" % exe) - + # Create the target target = self.dbg.CreateTarget(exe) - + # Create any breakpoints we need - breakpoint = target.BreakpointCreateBySourceRegex ('break here', lldb.SBFileSpec ("main.cpp", False)) + breakpoint = target.BreakpointCreateBySourceRegex( + 'break here', lldb.SBFileSpec("main.cpp", False)) self.assertTrue(breakpoint, VALID_BREAKPOINT) self.runCmd("process launch 1 2 3") process = self.process() - thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) - self.assertIsNotNone(thread, "Process should be stopped at a breakpoint in main") + thread = lldbutil.get_one_thread_stopped_at_breakpoint( + process, breakpoint) + self.assertIsNotNone( + thread, "Process should be stopped at a breakpoint in main") self.assertTrue(thread.IsValid(), "Stopped thread is not valid") self.expect("frame variable argv[1]", substrs=['1']) self.expect("frame variable argv[2]", substrs=['2']) self.expect("frame variable argv[3]", substrs=['3']) - + # Let program exit self.runCmd("continue") - + # Re-run with no args and make sure we still run with 1 2 3 as arguments as # they should have been stored in "target.run-args" self.runCmd("process launch") process = self.process() - thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) + thread = lldbutil.get_one_thread_stopped_at_breakpoint( + process, breakpoint) - self.assertIsNotNone(thread, "Process should be stopped at a breakpoint in main"); + self.assertIsNotNone( + thread, "Process should be stopped at a breakpoint in main") self.assertTrue(thread.IsValid(), "Stopped thread is not valid") self.expect("frame variable argv[1]", substrs=['1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index 81d93294b5a..71edcdfd95e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -5,21 +5,33 @@ Test getting return-values correctly when stepping out 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 ReturnValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["macosx","freebsd"], archs=["i386"]) - @expectedFailureAll(oslist=["linux"], compiler="clang", compiler_version=["<=", "3.6"], archs=["i386"]) - @expectedFailureAll(bugnumber="llvm.org/pr25785", hostoslist=["windows"], compiler="gcc", archs=["i386"], triple='.*-android') + @expectedFailureAll(oslist=["macosx", "freebsd"], archs=["i386"]) + @expectedFailureAll( + oslist=["linux"], + compiler="clang", + compiler_version=[ + "<=", + "3.6"], + archs=["i386"]) + @expectedFailureAll( + bugnumber="llvm.org/pr25785", + hostoslist=["windows"], + compiler="gcc", + archs=["i386"], + triple='.*-android') @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @add_test_categories(['pyapi']) def test_with_python(self): @@ -35,7 +47,8 @@ class ReturnValueTestCase(TestBase): self.assertTrue(inner_sint_bkpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) @@ -44,168 +57,178 @@ class ReturnValueTestCase(TestBase): STOPPED_DUE_TO_BREAKPOINT) # Now finish, and make sure the return value is correct. - thread = lldbutil.get_stopped_thread (self.process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + self.process, lldb.eStopReasonBreakpoint) # inner_sint returns the variable value, so capture that here: - in_int = thread.GetFrameAtIndex(0).FindVariable ("value").GetValueAsSigned(error) - self.assertTrue (error.Success()) + in_int = thread.GetFrameAtIndex(0).FindVariable( + "value").GetValueAsSigned(error) + self.assertTrue(error.Success()) - thread.StepOut(); + thread.StepOut() - self.assertTrue (self.process.GetState() == lldb.eStateStopped) - self.assertTrue (thread.GetStopReason() == lldb.eStopReasonPlanComplete) + self.assertTrue(self.process.GetState() == lldb.eStateStopped) + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() - self.assertTrue (fun_name == "outer_sint") + self.assertTrue(fun_name == "outer_sint") return_value = thread.GetStopReturnValue() - self.assertTrue (return_value.IsValid()) + self.assertTrue(return_value.IsValid()) ret_int = return_value.GetValueAsSigned(error) - self.assertTrue (error.Success()) - self.assertTrue (in_int == ret_int) + self.assertTrue(error.Success()) + self.assertTrue(in_int == ret_int) - # Run again and we will stop in inner_sint the second time outer_sint is called. - #Then test stepping out two frames at once: + # Run again and we will stop in inner_sint the second time outer_sint is called. + # Then test stepping out two frames at once: self.process.Continue() - thread_list = lldbutil.get_threads_stopped_at_breakpoint (self.process, inner_sint_bkpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + self.process, inner_sint_bkpt) self.assertTrue(len(thread_list) == 1) thread = thread_list[0] # We are done with the inner_sint breakpoint: - self.target.BreakpointDelete (inner_sint_bkpt.GetID()) + self.target.BreakpointDelete(inner_sint_bkpt.GetID()) frame = thread.GetFrameAtIndex(1) - fun_name = frame.GetFunctionName () - self.assertTrue (fun_name == "outer_sint") - in_int = frame.FindVariable ("value").GetValueAsSigned(error) - self.assertTrue (error.Success()) + fun_name = frame.GetFunctionName() + self.assertTrue(fun_name == "outer_sint") + in_int = frame.FindVariable("value").GetValueAsSigned(error) + self.assertTrue(error.Success()) - thread.StepOutOfFrame (frame) + thread.StepOutOfFrame(frame) - self.assertTrue (self.process.GetState() == lldb.eStateStopped) - self.assertTrue (thread.GetStopReason() == lldb.eStopReasonPlanComplete) + self.assertTrue(self.process.GetState() == lldb.eStateStopped) + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() - self.assertTrue (fun_name == "main") + self.assertTrue(fun_name == "main") ret_value = thread.GetStopReturnValue() - self.assertTrue (return_value.IsValid()) - ret_int = ret_value.GetValueAsSigned (error) - self.assertTrue (error.Success()) - self.assertTrue (2 * in_int == ret_int) - + self.assertTrue(return_value.IsValid()) + ret_int = ret_value.GetValueAsSigned(error) + self.assertTrue(error.Success()) + self.assertTrue(2 * in_int == ret_int) + # Now try some simple returns that have different types: - inner_float_bkpt = self.target.BreakpointCreateByName("inner_float", exe) + inner_float_bkpt = self.target.BreakpointCreateByName( + "inner_float", exe) self.assertTrue(inner_float_bkpt, VALID_BREAKPOINT) self.process.Continue() - thread_list = lldbutil.get_threads_stopped_at_breakpoint (self.process, inner_float_bkpt) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + self.process, inner_float_bkpt) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - self.target.BreakpointDelete (inner_float_bkpt.GetID()) + self.target.BreakpointDelete(inner_float_bkpt.GetID()) frame = thread.GetFrameAtIndex(0) - in_value = frame.FindVariable ("value") - in_float = float (in_value.GetValue()) + in_value = frame.FindVariable("value") + in_float = float(in_value.GetValue()) thread.StepOut() - self.assertTrue (self.process.GetState() == lldb.eStateStopped) - self.assertTrue (thread.GetStopReason() == lldb.eStopReasonPlanComplete) + self.assertTrue(self.process.GetState() == lldb.eStateStopped) + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() - self.assertTrue (fun_name == "outer_float") + self.assertTrue(fun_name == "outer_float") return_value = thread.GetStopReturnValue() - self.assertTrue (return_value.IsValid()) - return_float = float (return_value.GetValue()) + self.assertTrue(return_value.IsValid()) + return_float = float(return_value.GetValue()) self.assertTrue(in_float == return_float) - self.return_and_test_struct_value ("return_one_int") - self.return_and_test_struct_value ("return_two_int") - self.return_and_test_struct_value ("return_three_int") - self.return_and_test_struct_value ("return_four_int") - self.return_and_test_struct_value ("return_five_int") - - self.return_and_test_struct_value ("return_two_double") - self.return_and_test_struct_value ("return_one_double_two_float") - self.return_and_test_struct_value ("return_one_int_one_float_one_int") - - self.return_and_test_struct_value ("return_one_pointer") - self.return_and_test_struct_value ("return_two_pointer") - self.return_and_test_struct_value ("return_one_float_one_pointer") - self.return_and_test_struct_value ("return_one_int_one_pointer") - self.return_and_test_struct_value ("return_three_short_one_float") - - self.return_and_test_struct_value ("return_one_int_one_double") - self.return_and_test_struct_value ("return_one_int_one_double_one_int") - self.return_and_test_struct_value ("return_one_short_one_double_one_short") - self.return_and_test_struct_value ("return_one_float_one_int_one_float") - self.return_and_test_struct_value ("return_two_float") - # I am leaving out the packed test until we have a way to tell CLANG + self.return_and_test_struct_value("return_one_int") + self.return_and_test_struct_value("return_two_int") + self.return_and_test_struct_value("return_three_int") + self.return_and_test_struct_value("return_four_int") + self.return_and_test_struct_value("return_five_int") + + self.return_and_test_struct_value("return_two_double") + self.return_and_test_struct_value("return_one_double_two_float") + self.return_and_test_struct_value("return_one_int_one_float_one_int") + + self.return_and_test_struct_value("return_one_pointer") + self.return_and_test_struct_value("return_two_pointer") + self.return_and_test_struct_value("return_one_float_one_pointer") + self.return_and_test_struct_value("return_one_int_one_pointer") + self.return_and_test_struct_value("return_three_short_one_float") + + self.return_and_test_struct_value("return_one_int_one_double") + self.return_and_test_struct_value("return_one_int_one_double_one_int") + self.return_and_test_struct_value( + "return_one_short_one_double_one_short") + self.return_and_test_struct_value("return_one_float_one_int_one_float") + self.return_and_test_struct_value("return_two_float") + # I am leaving out the packed test until we have a way to tell CLANG # about alignment when reading DWARF for packed types. #self.return_and_test_struct_value ("return_one_int_one_double_packed") - self.return_and_test_struct_value ("return_one_int_one_long") + self.return_and_test_struct_value("return_one_int_one_long") # icc and gcc don't support this extension. if self.getCompiler().endswith('clang'): - self.return_and_test_struct_value ("return_vector_size_float32_8") - self.return_and_test_struct_value ("return_vector_size_float32_16") - self.return_and_test_struct_value ("return_vector_size_float32_32") - self.return_and_test_struct_value ("return_ext_vector_size_float32_2") - self.return_and_test_struct_value ("return_ext_vector_size_float32_4") - self.return_and_test_struct_value ("return_ext_vector_size_float32_8") - - def return_and_test_struct_value (self, func_name): + self.return_and_test_struct_value("return_vector_size_float32_8") + self.return_and_test_struct_value("return_vector_size_float32_16") + self.return_and_test_struct_value("return_vector_size_float32_32") + self.return_and_test_struct_value( + "return_ext_vector_size_float32_2") + self.return_and_test_struct_value( + "return_ext_vector_size_float32_4") + self.return_and_test_struct_value( + "return_ext_vector_size_float32_8") + + def return_and_test_struct_value(self, func_name): """Pass in the name of the function to return from - takes in value, returns value.""" - + # Set the breakpoint, run to it, finish out. - bkpt = self.target.BreakpointCreateByName (func_name) - self.assertTrue (bkpt.GetNumResolvedLocations() > 0) + bkpt = self.target.BreakpointCreateByName(func_name) + self.assertTrue(bkpt.GetNumResolvedLocations() > 0) - self.process.Continue () + self.process.Continue() - thread_list = lldbutil.get_threads_stopped_at_breakpoint (self.process, bkpt) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + self.process, bkpt) - self.assertTrue (len(thread_list) == 1) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] - self.target.BreakpointDelete (bkpt.GetID()) + self.target.BreakpointDelete(bkpt.GetID()) + + in_value = thread.GetFrameAtIndex(0).FindVariable("value") - in_value = thread.GetFrameAtIndex(0).FindVariable ("value") - - self.assertTrue (in_value.IsValid()) + self.assertTrue(in_value.IsValid()) num_in_children = in_value.GetNumChildren() # This is a little hokey, but if we don't get all the children now, then # once we've stepped we won't be able to get them? - + for idx in range(0, num_in_children): - in_child = in_value.GetChildAtIndex (idx) + in_child = in_value.GetChildAtIndex(idx) in_child_str = in_child.GetValue() thread.StepOut() - - self.assertTrue (self.process.GetState() == lldb.eStateStopped) - self.assertTrue (thread.GetStopReason() == lldb.eStopReasonPlanComplete) + + self.assertTrue(self.process.GetState() == lldb.eStateStopped) + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) # Assuming all these functions step out to main. Could figure out the caller dynamically # if that would add something to the test. frame = thread.GetFrameAtIndex(0) fun_name = frame.GetFunctionName() - self.assertTrue (fun_name == "main") + self.assertTrue(fun_name == "main") frame = thread.GetFrameAtIndex(0) ret_value = thread.GetStopReturnValue() - self.assertTrue (ret_value.IsValid()) + self.assertTrue(ret_value.IsValid()) num_ret_children = ret_value.GetNumChildren() - self.assertTrue (num_in_children == num_ret_children) + self.assertTrue(num_in_children == num_ret_children) for idx in range(0, num_ret_children): in_child = in_value.GetChildAtIndex(idx) ret_child = ret_value.GetChildAtIndex(idx) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py index 294aa672515..2fc31a4e78a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py @@ -5,13 +5,14 @@ Set the contents of variables and registers using raw data 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 SetDataTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,41 +24,48 @@ class SetDataTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - self.runCmd("br s -p First"); - self.runCmd("br s -p Second"); + self.runCmd("br s -p First") + self.runCmd("br s -p Second") self.runCmd("run", RUN_SUCCEEDED) self.expect("p myFoo.x", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['2']) + substrs=['2']) process = self.dbg.GetSelectedTarget().GetProcess() frame = process.GetSelectedThread().GetFrameAtIndex(0) x = frame.FindVariable("myFoo").GetChildMemberWithName("x") - my_data = lldb.SBData.CreateDataFromSInt32Array(lldb.eByteOrderLittle, 8, [4]) + my_data = lldb.SBData.CreateDataFromSInt32Array( + lldb.eByteOrderLittle, 8, [4]) err = lldb.SBError() - self.assertTrue (x.SetData(my_data, err)) + self.assertTrue(x.SetData(my_data, err)) self.runCmd("continue") self.expect("p myFoo.x", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['4']) + substrs=['4']) frame = process.GetSelectedThread().GetFrameAtIndex(0) x = frame.FindVariable("string") if process.GetAddressByteSize() == 8: - my_data = lldb.SBData.CreateDataFromUInt64Array(process.GetByteOrder(), 8, [0]) + my_data = lldb.SBData.CreateDataFromUInt64Array( + process.GetByteOrder(), 8, [0]) else: - my_data = lldb.SBData.CreateDataFromUInt32Array(process.GetByteOrder(), 4, [0]) - + my_data = lldb.SBData.CreateDataFromUInt32Array( + process.GetByteOrder(), 4, [0]) + err = lldb.SBError() - self.assertTrue (x.SetData(my_data, err)) + self.assertTrue(x.SetData(my_data, err)) - self.expect("fr var -d run-target string", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['NSString *', 'nil']) + self.expect( + "fr var -d run-target string", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'NSString *', + 'nil']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py index 1da4d701a59..0a2756d87fb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py @@ -3,8 +3,9 @@ from __future__ import print_function - -import os, time, signal +import os +import time +import signal import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -21,8 +22,10 @@ class SendSignalTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number('main.c', 'Put breakpoint here') - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23318: does not report running state") - @skipIfWindows # Windows does not support signals + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr23318: does not report running state") + @skipIfWindows # Windows does not support signals def test_with_run_command(self): """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process.""" self.build() @@ -57,14 +60,17 @@ class SendSignalTestCase(TestBase): self.runCmd("process handle -n False -p True -s True SIGUSR1") - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertTrue(thread.IsValid(), "We hit the first breakpoint.") # After resuming the process, send it a SIGUSR1 signal. self.setAsync(True) - self.assertTrue(process_listener.IsValid(), "Got a good process listener") + self.assertTrue( + process_listener.IsValid(), + "Got a good process listener") # Disable our breakpoint, we don't want to hit it anymore... breakpoint.SetEnabled(False) @@ -88,9 +94,12 @@ class SendSignalTestCase(TestBase): self.assertTrue(len(threads) == 1, "One thread stopped for a signal.") thread = threads[0] - self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") - self.assertTrue(thread.GetStopReasonDataAtIndex(0) == lldbutil.get_signal_number('SIGUSR1'), - "The stop signal was SIGUSR1") + self.assertTrue( + thread.GetStopReasonDataCount() >= 1, + "There was data in the event.") + self.assertTrue( + thread.GetStopReasonDataAtIndex(0) == lldbutil.get_signal_number('SIGUSR1'), + "The stop signal was SIGUSR1") def match_state(self, process_listener, expected_state): num_seconds = 5 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py index d8dbb7f6893..16681fdbcde 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py @@ -3,7 +3,6 @@ from __future__ import print_function - import os import re @@ -17,9 +16,11 @@ class HandleSegvTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # signals do not exist on Windows + @skipIfWindows # signals do not exist on Windows @skipIfDarwin - @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") + @expectedFailureAll( + oslist=['freebsd'], + bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") def test_inferior_handle_sigsegv(self): self.build() exe = os.path.join(os.getcwd(), "a.out") @@ -29,15 +30,21 @@ class HandleSegvTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # launch - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) self.assertEqual(process.GetState(), lldb.eStateStopped) signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSEGV") thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) - self.assertTrue(thread and thread.IsValid(), "Thread should be stopped due to a signal") - self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") - self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, "The stop signal was SIGSEGV") + self.assertTrue( + thread and thread.IsValid(), + "Thread should be stopped due to a signal") + self.assertTrue( + thread.GetStopReasonDataCount() >= 1, + "There was data in the event.") + self.assertEqual(thread.GetStopReasonDataAtIndex(0), + signo, "The stop signal was SIGSEGV") # Continue until we exit. process.Continue() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py index 2c30f69d7b2..efadea51f66 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py @@ -3,7 +3,6 @@ from __future__ import print_function - import os import lldb import re @@ -13,7 +12,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -@skipIfWindows # signals do not exist on Windows +@skipIfWindows # signals do not exist on Windows class RaiseTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,9 +20,10 @@ class RaiseTestCase(TestBase): def test_sigstop(self): self.build() self.signal_test('SIGSTOP', False) - # passing of SIGSTOP is not correctly handled, so not testing that scenario: https://llvm.org/bugs/show_bug.cgi?id=23574 + # passing of SIGSTOP is not correctly handled, so not testing that + # scenario: https://llvm.org/bugs/show_bug.cgi?id=23574 - @skipIfDarwin # darwin does not support real time signals + @skipIfDarwin # darwin does not support real time signals @skipIfTargetAndroid() def test_sigsigrtmin(self): self.build() @@ -31,20 +31,25 @@ class RaiseTestCase(TestBase): def launch(self, target, signal): # launch the process, do not stop at entry point. - process = target.LaunchSimple([signal], None, self.get_process_working_directory()) + process = target.LaunchSimple( + [signal], None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) self.assertEqual(process.GetState(), lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "Thread should be stopped due to a breakpoint") + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) + self.assertTrue( + thread.IsValid(), + "Thread should be stopped due to a breakpoint") return process def set_handle(self, signal, pass_signal, stop_at_signal, notify_signal): return_obj = lldb.SBCommandReturnObject() self.dbg.GetCommandInterpreter().HandleCommand( - "process handle %s -p %s -s %s -n %s" % (signal, pass_signal, stop_at_signal, notify_signal), - return_obj) - self.assertTrue (return_obj.Succeeded() == True, "Setting signal handling failed") - + "process handle %s -p %s -s %s -n %s" % + (signal, pass_signal, stop_at_signal, notify_signal), return_obj) + self.assertTrue( + return_obj.Succeeded(), + "Setting signal handling failed") def signal_test(self, signal, test_passing): """Test that we handle inferior raising signals""" @@ -61,9 +66,12 @@ class RaiseTestCase(TestBase): # retrieve default signal disposition return_obj = lldb.SBCommandReturnObject() - self.dbg.GetCommandInterpreter().HandleCommand("process handle %s " % signal, return_obj) - match = re.match('NAME *PASS *STOP *NOTIFY.*(false|true) *(false|true) *(false|true)', - return_obj.GetOutput(), re.IGNORECASE | re.DOTALL) + self.dbg.GetCommandInterpreter().HandleCommand( + "process handle %s " % signal, return_obj) + match = re.match( + 'NAME *PASS *STOP *NOTIFY.*(false|true) *(false|true) *(false|true)', + return_obj.GetOutput(), + re.IGNORECASE | re.DOTALL) if not match: self.fail('Unable to retrieve default signal disposition.') default_pass = match.group(1) @@ -75,10 +83,14 @@ class RaiseTestCase(TestBase): process.Continue() self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) - self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal") - self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") + self.assertTrue( + thread.IsValid(), + "Thread should be stopped due to a signal") + self.assertTrue( + thread.GetStopReasonDataCount() >= 1, + "There was data in the event.") self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, - "The stop signal was %s" % signal) + "The stop signal was %s" % signal) # Continue until we exit. process.Continue() @@ -88,18 +100,27 @@ class RaiseTestCase(TestBase): # launch again process = self.launch(target, signal) - # Make sure we do not stop at the signal. We should still get the notification. + # Make sure we do not stop at the signal. We should still get the + # notification. self.set_handle(signal, "false", "false", "true") - self.expect("process continue", substrs=["stopped and restarted", signal]) + self.expect( + "process continue", + substrs=[ + "stopped and restarted", + signal]) self.assertEqual(process.GetState(), lldb.eStateExited) self.assertEqual(process.GetExitStatus(), 0) # launch again process = self.launch(target, signal) - # Make sure we do not stop at the signal, and we do not get the notification. + # Make sure we do not stop at the signal, and we do not get the + # notification. self.set_handle(signal, "false", "false", "false") - self.expect("process continue", substrs=["stopped and restarted"], matching=False) + self.expect( + "process continue", + substrs=["stopped and restarted"], + matching=False) self.assertEqual(process.GetState(), lldb.eStateExited) self.assertEqual(process.GetExitStatus(), 0) @@ -116,11 +137,17 @@ class RaiseTestCase(TestBase): process.Continue() self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) - self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal") - self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") - self.assertEqual(thread.GetStopReasonDataAtIndex(0), - process.GetUnixSignals().GetSignalNumberFromName(signal), - "The stop signal was %s" % signal) + self.assertTrue( + thread.IsValid(), + "Thread should be stopped due to a signal") + self.assertTrue( + thread.GetStopReasonDataCount() >= 1, + "There was data in the event.") + self.assertEqual( + thread.GetStopReasonDataAtIndex(0), + process.GetUnixSignals().GetSignalNumberFromName(signal), + "The stop signal was %s" % + signal) # Continue until we exit. The process should receive the signal. process.Continue() @@ -133,7 +160,11 @@ class RaiseTestCase(TestBase): # Make sure we do not stop at the signal. We should still get the notification. Process # should receive the signal. self.set_handle(signal, "true", "false", "true") - self.expect("process continue", substrs=["stopped and restarted", signal]) + self.expect( + "process continue", + substrs=[ + "stopped and restarted", + signal]) self.assertEqual(process.GetState(), lldb.eStateExited) self.assertEqual(process.GetExitStatus(), signo) @@ -143,14 +174,20 @@ class RaiseTestCase(TestBase): # Make sure we do not stop at the signal, and we do not get the notification. Process # should receive the signal. self.set_handle(signal, "true", "false", "false") - self.expect("process continue", substrs=["stopped and restarted"], matching=False) + self.expect( + "process continue", + substrs=["stopped and restarted"], + matching=False) self.assertEqual(process.GetState(), lldb.eStateExited) self.assertEqual(process.GetExitStatus(), signo) # reset signal handling to default self.set_handle(signal, default_pass, default_stop, default_notify) - @expectedFailureAll(oslist=["linux"]+getDarwinOSTriples(), bugnumber="llvm.org/pr20231") + @expectedFailureAll( + oslist=["linux"] + + getDarwinOSTriples(), + bugnumber="llvm.org/pr20231") def test_restart_bug(self): """Test that we catch a signal in the edge case where the process receives it while we are about to interrupt it""" @@ -167,16 +204,16 @@ class RaiseTestCase(TestBase): self.dbg.SetAsync(True) error = lldb.SBError() listener = lldb.SBListener("my listener") - process = target.Launch (listener, - ["SIGSTOP"], # argv - None, # envp - None, # stdin_path - None, # stdout_path - None, # stderr_path - None, # working directory - 0, # launch flags - False, # Stop at entry - error) # error + process = target.Launch(listener, + ["SIGSTOP"], # argv + None, # envp + None, # stdin_path + None, # stdout_path + None, # stderr_path + None, # working directory + 0, # launch flags + False, # Stop at entry + error) # error self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) @@ -187,12 +224,18 @@ class RaiseTestCase(TestBase): # The last WaitForEvent call will time out after 2 seconds. while listener.WaitForEvent(2, event): if self.TraceOn(): - print("Process changing state to:", self.dbg.StateAsCString(process.GetStateFromEvent(event))) + print( + "Process changing state to:", + self.dbg.StateAsCString( + process.GetStateFromEvent(event))) # now the process should be stopped - self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)), 1, - "A thread should be stopped at breakpoint") + self.assertEqual( + process.GetState(), + lldb.eStateStopped, + PROCESS_STOPPED) + self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint( + process, bkpt)), 1, "A thread should be stopped at breakpoint") # Remove all breakpoints. This makes sure we don't have to single-step over them when we # resume the process below @@ -200,23 +243,32 @@ class RaiseTestCase(TestBase): # resume the process and immediately try to set another breakpoint. When using the remote # stub, this will trigger a request to stop the process just as it is about to stop - # naturally due to a SIGSTOP signal it raises. Make sure we do not lose this signal. + # naturally due to a SIGSTOP signal it raises. Make sure we do not lose + # this signal. process.Continue() - self.assertTrue(target.BreakpointCreateByName("handler").IsValid(), VALID_BREAKPOINT) + self.assertTrue(target.BreakpointCreateByName( + "handler").IsValid(), VALID_BREAKPOINT) # Clear the events again while listener.WaitForEvent(2, event): if self.TraceOn(): - print("Process changing state to:", self.dbg.StateAsCString(process.GetStateFromEvent(event))) + print( + "Process changing state to:", + self.dbg.StateAsCString( + process.GetStateFromEvent(event))) # The process should be stopped due to a signal self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) - self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal") - self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") + self.assertTrue( + thread.IsValid(), + "Thread should be stopped due to a signal") + self.assertTrue( + thread.GetStopReasonDataCount() >= 1, + "There was data in the event.") signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSTOP") self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, - "The stop signal was %s" % signal) + "The stop signal was %s" % signal) # We are done process.Kill() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py b/lldb/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py index 6f5882636cb..ad08c6a9e95 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py @@ -5,13 +5,13 @@ Test the lldb command line takes a filename with single quote chars. from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SingleQuoteInCommandLineTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +27,9 @@ class SingleQuoteInCommandLineTestCase(TestBase): except: pass - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") @no_debug_info_test def test_lldb_invocation_with_single_quote_in_filename(self): """Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it.""" @@ -39,7 +41,9 @@ class SingleQuoteInCommandLineTestCase(TestBase): prompt = "(lldb) " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s "%s"' % (lldbtest_config.lldbExec, self.lldbOption, self.myexe)) + self.child = pexpect.spawn( + '%s %s "%s"' % + (lldbtest_config.lldbExec, self.lldbOption, self.myexe)) child = self.child child.setecho(True) # Turn on logging for input/output to/from the child. @@ -58,7 +62,7 @@ class SingleQuoteInCommandLineTestCase(TestBase): # stop further logging. child.logfile_send = None child.logfile_read = None - + with open('child_send.txt', 'r') as fs: if self.TraceOn(): print("\n\nContents of child_send.txt:") @@ -70,4 +74,4 @@ class SingleQuoteInCommandLineTestCase(TestBase): print(from_child) self.expect(from_child, exe=False, - substrs = ["Current executable set to"]) + substrs=["Current executable set to"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py b/lldb/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py index 8b9c91217de..b0b2e609ba6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py @@ -5,7 +5,6 @@ Test thread step-in, step-over and step-out work with the "Avoid no debug" optio from __future__ import print_function - import os import re import sys @@ -15,6 +14,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ReturnValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,8 +27,15 @@ class ReturnValueTestCase(TestBase): self.do_step_out_past_nodebug() @add_test_categories(['pyapi']) - @decorators.expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr28549") - @decorators.expectedFailureAll(compiler="clang", compiler_version=[">=", "3.9"], archs=["i386"], bugnumber="llvm.org/pr28549") + @decorators.expectedFailureAll( + compiler="gcc", bugnumber="llvm.org/pr28549") + @decorators.expectedFailureAll( + compiler="clang", + compiler_version=[ + ">=", + "3.9"], + archs=["i386"], + bugnumber="llvm.org/pr28549") def test_step_over_with_python(self): """Test stepping over using avoid-no-debug with dwarf.""" self.build() @@ -36,82 +43,111 @@ class ReturnValueTestCase(TestBase): self.do_step_over_past_nodebug() @add_test_categories(['pyapi']) - @decorators.expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr28549") - @decorators.expectedFailureAll(compiler="clang", compiler_version=[">=", "3.9"], archs=["i386"], bugnumber="llvm.org/pr28549") + @decorators.expectedFailureAll( + compiler="gcc", bugnumber="llvm.org/pr28549") + @decorators.expectedFailureAll( + compiler="clang", + compiler_version=[ + ">=", + "3.9"], + archs=["i386"], + bugnumber="llvm.org/pr28549") def test_step_in_with_python(self): """Test stepping in using avoid-no-debug with dwarf.""" self.build() self.get_to_starting_point() self.do_step_in_past_nodebug() - def setUp (self): + def setUp(self): TestBase.setUp(self) self.main_source = "with-debug.c" self.main_source_spec = lldb.SBFileSpec("with-debug.c") - self.dbg.HandleCommand ("settings set target.process.thread.step-out-avoid-nodebug true") + self.dbg.HandleCommand( + "settings set target.process.thread.step-out-avoid-nodebug true") - def tearDown (self): - self.dbg.HandleCommand ("settings set target.process.thread.step-out-avoid-nodebug false") + def tearDown(self): + self.dbg.HandleCommand( + "settings set target.process.thread.step-out-avoid-nodebug false") TestBase.tearDown(self) - def hit_correct_line (self, pattern): - target_line = line_number (self.main_source, pattern) - self.assertTrue (target_line != 0, "Could not find source pattern " + pattern) + def hit_correct_line(self, pattern): + target_line = line_number(self.main_source, pattern) + self.assertTrue( + target_line != 0, + "Could not find source pattern " + + pattern) cur_line = self.thread.frames[0].GetLineEntry().GetLine() - self.assertTrue (cur_line == target_line, "Stepped to line %d instead of expected %d with pattern '%s'."%(cur_line, target_line, pattern)) - - def hit_correct_function (self, pattern): + self.assertTrue( + cur_line == target_line, + "Stepped to line %d instead of expected %d with pattern '%s'." % + (cur_line, + target_line, + pattern)) + + def hit_correct_function(self, pattern): name = self.thread.frames[0].GetFunctionName() - self.assertTrue (pattern in name, "Got to '%s' not the expected function '%s'."%(name, pattern)) + self.assertTrue( + pattern in name, "Got to '%s' not the expected function '%s'." % + (name, pattern)) - def get_to_starting_point (self): + def get_to_starting_point(self): exe = os.path.join(os.getcwd(), "a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - inner_bkpt = self.target.BreakpointCreateBySourceRegex("Stop here and step out of me", self.main_source_spec) + inner_bkpt = self.target.BreakpointCreateBySourceRegex( + "Stop here and step out of me", self.main_source_spec) self.assertTrue(inner_bkpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory()) + self.process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) # Now finish, and make sure the return value is correct. - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, inner_bkpt) + threads = lldbutil.get_threads_stopped_at_breakpoint( + self.process, inner_bkpt) self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.") self.thread = threads[0] def do_step_out_past_nodebug(self): # The first step out takes us to the called_from_nodebug frame, just to make sure setting - # step-out-avoid-nodebug doesn't change the behavior in frames with debug info. + # step-out-avoid-nodebug doesn't change the behavior in frames with + # debug info. self.thread.StepOut() - self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)") + self.hit_correct_line( + "intermediate_return_value = called_from_nodebug_actual(some_value)") self.thread.StepOut() - self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)") + self.hit_correct_line( + "int return_value = no_debug_caller(5, called_from_nodebug)") - def do_step_over_past_nodebug (self): + def do_step_over_past_nodebug(self): self.thread.StepOver() - self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)") + self.hit_correct_line( + "intermediate_return_value = called_from_nodebug_actual(some_value)") self.thread.StepOver() - self.hit_correct_line ("return intermediate_return_value") + self.hit_correct_line("return intermediate_return_value") self.thread.StepOver() # Note, lldb doesn't follow gdb's distinction between "step-out" and "step-over/step-in" # when exiting a frame. In all cases we leave the pc at the point where we exited the # frame. In gdb, step-over/step-in move to the end of the line they stepped out to. # If we ever change this we will need to fix this test. - self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)") + self.hit_correct_line( + "int return_value = no_debug_caller(5, called_from_nodebug)") - def do_step_in_past_nodebug (self): + def do_step_in_past_nodebug(self): self.thread.StepInto() - self.hit_correct_line ("intermediate_return_value = called_from_nodebug_actual(some_value)") + self.hit_correct_line( + "intermediate_return_value = called_from_nodebug_actual(some_value)") self.thread.StepInto() - self.hit_correct_line ("return intermediate_return_value") + self.hit_correct_line("return intermediate_return_value") self.thread.StepInto() # Note, lldb doesn't follow gdb's distinction between "step-out" and "step-over/step-in" # when exiting a frame. In all cases we leave the pc at the point where we exited the # frame. In gdb, step-over/step-in move to the end of the line they stepped out to. # If we ever change this we will need to fix this test. - self.hit_correct_line ("int return_value = no_debug_caller(5, called_from_nodebug)") + self.hit_correct_line( + "int return_value = no_debug_caller(5, called_from_nodebug)") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py index 93f846a0687..3d23f644554 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py @@ -5,13 +5,13 @@ Test lldb target stop-hook command. from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StopHookCmdTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,9 +20,15 @@ class StopHookCmdTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers inside main.cpp. - self.begl = line_number('main.cpp', '// Set breakpoint here to test target stop-hook.') - self.endl = line_number('main.cpp', '// End of the line range for which stop-hook is to be run.') - self.line = line_number('main.cpp', '// Another breakpoint which is outside of the stop-hook range.') + self.begl = line_number( + 'main.cpp', + '// Set breakpoint here to test target stop-hook.') + self.endl = line_number( + 'main.cpp', + '// End of the line range for which stop-hook is to be run.') + self.line = line_number( + 'main.cpp', + '// Another breakpoint which is outside of the stop-hook range.') @no_debug_info_test def test_not_crashing_if_no_target(self): @@ -35,32 +41,37 @@ class StopHookCmdTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.begl, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.begl, num_expected_locations=1, loc_exact=True) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) - self.runCmd("target stop-hook add -f main.cpp -l %d -e %d -o 'expr ptr'" % (self.begl, self.endl)) + self.runCmd( + "target stop-hook add -f main.cpp -l %d -e %d -o 'expr ptr'" % + (self.begl, self.endl)) self.expect('target stop-hook list', 'Stop Hook added successfully', - substrs = ['State: enabled', - 'expr ptr']) + substrs=['State: enabled', + 'expr ptr']) self.runCmd('target stop-hook disable') self.expect('target stop-hook list', 'Stop Hook disabled successfully', - substrs = ['State: disabled', - 'expr ptr']) + substrs=['State: disabled', + 'expr ptr']) self.runCmd('target stop-hook enable') self.expect('target stop-hook list', 'Stop Hook enabled successfully', - substrs = ['State: enabled', - 'expr ptr']) + substrs=['State: enabled', + 'expr ptr']) self.runCmd("settings set auto-confirm true") - self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm")) + self.addTearDownHook( + lambda: self.runCmd("settings clear auto-confirm")) self.runCmd('target stop-hook delete') self.expect('target stop-hook list', 'Stop Hook deleted successfully', - substrs = ['No stop hooks.']) + substrs=['No stop hooks.']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py index c42c1e56388..fa5c6de0565 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py @@ -5,7 +5,6 @@ Test lldb target stop-hook mechanism to see whether it fires off correctly . from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * @@ -13,6 +12,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import configuration from lldbsuite.test import lldbutil + class StopHookMechanismTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,14 +21,24 @@ class StopHookMechanismTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers inside main.cpp. - self.begl = line_number('main.cpp', '// Set breakpoint here to test target stop-hook.') - self.endl = line_number('main.cpp', '// End of the line range for which stop-hook is to be run.') - self.correct_step_line = line_number ('main.cpp', '// We should stop here after stepping.') - self.line = line_number('main.cpp', '// Another breakpoint which is outside of the stop-hook range.') + self.begl = line_number( + 'main.cpp', + '// Set breakpoint here to test target stop-hook.') + self.endl = line_number( + 'main.cpp', + '// End of the line range for which stop-hook is to be run.') + self.correct_step_line = line_number( + 'main.cpp', '// We should stop here after stepping.') + self.line = line_number( + 'main.cpp', + '// Another breakpoint which is outside of the stop-hook range.') - @skipIfFreeBSD # llvm.org/pr15037 - @expectedFlakeyLinux('llvm.org/pr15037') # stop-hooks sometimes fail to fire on Linux - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr15037 + # stop-hooks sometimes fail to fire on Linux + @expectedFlakeyLinux('llvm.org/pr15037') + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") def test(self): """Test the stop-hook mechanism.""" self.build() @@ -40,7 +50,8 @@ class StopHookMechanismTestCase(TestBase): add_prompt1 = "> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (lldbtest_config.lldbExec, self.lldbOption)) + self.child = pexpect.spawn('%s %s' % + (lldbtest_config.lldbExec, self.lldbOption)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): @@ -48,11 +59,17 @@ class StopHookMechanismTestCase(TestBase): if lldb.remote_platform: child.expect_exact(prompt) - child.sendline('platform select %s' % lldb.remote_platform.GetName()) + child.sendline( + 'platform select %s' % + lldb.remote_platform.GetName()) child.expect_exact(prompt) - child.sendline('platform connect %s' % configuration.lldb_platform_url) + child.sendline( + 'platform connect %s' % + configuration.lldb_platform_url) child.expect_exact(prompt) - child.sendline('platform settings -w %s' % configuration.lldb_platform_working_dir) + child.sendline( + 'platform settings -w %s' % + configuration.lldb_platform_working_dir) child.expect_exact(prompt) child.sendline('target create %s' % exe) @@ -63,7 +80,9 @@ class StopHookMechanismTestCase(TestBase): child.expect_exact(prompt) child.sendline('breakpoint set -f main.cpp -l %d' % self.line) child.expect_exact(prompt) - child.sendline('target stop-hook add -f main.cpp -l %d -e %d' % (self.begl, self.endl)) + child.sendline( + 'target stop-hook add -f main.cpp -l %d -e %d' % + (self.begl, self.endl)) child.expect_exact(add_prompt) child.expect_exact(add_prompt1) child.sendline('expr ptr') @@ -72,10 +91,12 @@ class StopHookMechanismTestCase(TestBase): child.expect_exact(prompt) child.sendline('target stop-hook list') - # Now run the program, expect to stop at the first breakpoint which is within the stop-hook range. + # Now run the program, expect to stop at the first breakpoint which is + # within the stop-hook range. child.expect_exact(prompt) child.sendline('run') - # Make sure we see the stop hook text from the stop of the process from the run hitting the first breakpoint + # Make sure we see the stop hook text from the stop of the process from + # the run hitting the first breakpoint child.expect_exact('(void *) $') child.expect_exact(prompt) child.sendline('thread step-over') @@ -91,13 +112,16 @@ class StopHookMechanismTestCase(TestBase): print('expecting "%s"' % at_line) child.expect_exact(at_line) - # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range. + # Now continue the inferior, we'll stop at another breakpoint which is + # outside the stop-hook range. child.sendline('process continue') - child.expect_exact('// Another breakpoint which is outside of the stop-hook range.') - #self.DebugPExpect(child) + child.expect_exact( + '// Another breakpoint which is outside of the stop-hook range.') + # self.DebugPExpect(child) child.sendline('thread step-over') - child.expect_exact('// Another breakpoint which is outside of the stop-hook range.') - #self.DebugPExpect(child) + child.expect_exact( + '// Another breakpoint which is outside of the stop-hook range.') + # self.DebugPExpect(child) # Verify that the 'Stop Hooks' mechanism is NOT BEING fired off. self.expect(child.before, exe=False, matching=False, - substrs = ['(void *) $']) + substrs=['(void *) $']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py index 57395832dc2..3a18877ef2d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py @@ -5,14 +5,15 @@ Test that lldb stop-hook works for multiple threads. 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 configuration from lldbsuite.test import lldbutil + class StopHookForMultipleThreadsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,15 +24,22 @@ class StopHookForMultipleThreadsTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.first_stop = line_number(self.source, '// Set break point at this line, and add a stop-hook.') - self.thread_function = line_number(self.source, '// Break here to test that the stop-hook mechanism works for multiple threads.') - # Build dictionary to have unique executable names for each test method. + self.first_stop = line_number( + self.source, '// Set break point at this line, and add a stop-hook.') + self.thread_function = line_number( + self.source, + '// Break here to test that the stop-hook mechanism works for multiple threads.') + # Build dictionary to have unique executable names for each test + # method. self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} @expectedFlakeyFreeBSD("llvm.org/pr15037") - @expectedFlakeyLinux("llvm.org/pr15037") # stop hooks sometimes fail to fire on Linux - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + # stop hooks sometimes fail to fire on Linux + @expectedFlakeyLinux("llvm.org/pr15037") + @expectedFailureAll( + hostoslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") def test_stop_hook_multiple_threads(self): """Test that lldb stop-hook works for multiple threads.""" self.build(dictionary=self.d) @@ -42,7 +50,8 @@ class StopHookForMultipleThreadsTestCase(TestBase): prompt = "(lldb) " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (lldbtest_config.lldbExec, self.lldbOption)) + self.child = pexpect.spawn('%s %s' % + (lldbtest_config.lldbExec, self.lldbOption)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): @@ -50,11 +59,17 @@ class StopHookForMultipleThreadsTestCase(TestBase): if lldb.remote_platform: child.expect_exact(prompt) - child.sendline('platform select %s' % lldb.remote_platform.GetName()) + child.sendline( + 'platform select %s' % + lldb.remote_platform.GetName()) child.expect_exact(prompt) - child.sendline('platform connect %s' % configuration.lldb_platform_url) + child.sendline( + 'platform connect %s' % + configuration.lldb_platform_url) child.expect_exact(prompt) - child.sendline('platform settings -w %s' % configuration.lldb_platform_working_dir) + child.sendline( + 'platform settings -w %s' % + configuration.lldb_platform_working_dir) child.expect_exact(prompt) child.sendline('target create %s' % exe) @@ -63,17 +78,23 @@ class StopHookForMultipleThreadsTestCase(TestBase): child.expect_exact(prompt) child.sendline('breakpoint set -f main.cpp -l %d' % self.first_stop) child.expect_exact(prompt) - child.sendline('breakpoint set -f main.cpp -l %d' % self.thread_function) + child.sendline( + 'breakpoint set -f main.cpp -l %d' % + self.thread_function) child.expect_exact(prompt) - # Now run the program, expect to stop at the first breakpoint which is within the stop-hook range. + # Now run the program, expect to stop at the first breakpoint which is + # within the stop-hook range. child.sendline('run') - child.expect_exact("Process") # 'Process 2415 launched', 'Process 2415 stopped' + # 'Process 2415 launched', 'Process 2415 stopped' + child.expect_exact("Process") child.expect_exact(prompt) - child.sendline('target stop-hook add -o "frame variable --show-globals g_val"') - child.expect_exact("Stop hook") # 'Stop hook #1 added.' + child.sendline( + 'target stop-hook add -o "frame variable --show-globals g_val"') + child.expect_exact("Stop hook") # 'Stop hook #1 added.' child.expect_exact(prompt) - # Continue and expect to find the output emitted by the firing of our stop hook. + # Continue and expect to find the output emitted by the firing of our + # stop hook. child.sendline('continue') child.expect_exact('(uint32_t) ::g_val = ') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py b/lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py index 126f6e4dab8..7d2900d6171 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py @@ -5,13 +5,13 @@ Test some target commands: create, list, select, variable. from __future__ import print_function - import lldb import sys from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class targetCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -80,17 +80,19 @@ class targetCommandTestCase(TestBase): # We will start from (index + 1) .... base = int(match.group(1), 10) + 1 #print("base is:", base) - break; + break self.runCmd("target create " + exe_a, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.runCmd("target create " + exe_b, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, 'b.c', self.line_b, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, 'b.c', self.line_b, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) self.runCmd("target create " + exe_c, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, 'c.c', self.line_c, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, 'c.c', self.line_c, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) self.runCmd("target list") @@ -100,13 +102,13 @@ class targetCommandTestCase(TestBase): self.runCmd("target select %d" % (base + 2)) self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['c.c:%d' % self.line_c, - 'stop reason = breakpoint']) + substrs=['c.c:%d' % self.line_c, + 'stop reason = breakpoint']) self.runCmd("target select %d" % (base + 1)) self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['b.c:%d' % self.line_b, - 'stop reason = breakpoint']) + substrs=['b.c:%d' % self.line_b, + 'stop reason = breakpoint']) self.runCmd("target list") @@ -114,89 +116,160 @@ class targetCommandTestCase(TestBase): """Exercise 'target variable' command before and after starting the inferior.""" self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) - self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["my_global_char", "'X'"]) - self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_global_str', '"abc"']) - self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_static_int', '228']) + self.expect( + "target variable my_global_char", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "my_global_char", + "'X'"]) + self.expect( + "target variable my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_global_str', + '"abc"']) + self.expect( + "target variable my_static_int", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_static_int', + '228']) self.expect("target variable my_global_str_ptr", matching=False, - substrs = ['"abc"']) + substrs=['"abc"']) self.expect("target variable *my_global_str_ptr", matching=True, - substrs = ['"abc"']) - self.expect("target variable *my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['a']) + substrs=['"abc"']) + self.expect( + "target variable *my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=['a']) self.runCmd("b main") self.runCmd("run") - - self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_global_str', '"abc"']) - self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_static_int', '228']) + + self.expect( + "target variable my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_global_str', + '"abc"']) + self.expect( + "target variable my_static_int", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_static_int', + '228']) self.expect("target variable my_global_str_ptr", matching=False, - substrs = ['"abc"']) + substrs=['"abc"']) self.expect("target variable *my_global_str_ptr", matching=True, - substrs = ['"abc"']) - self.expect("target variable *my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['a']) - self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["my_global_char", "'X'"]) + substrs=['"abc"']) + self.expect( + "target variable *my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=['a']) + self.expect( + "target variable my_global_char", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "my_global_char", + "'X'"]) self.runCmd("c") # rdar://problem/9763907 # 'target variable' command fails if the target program has been run - self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_global_str', '"abc"']) - self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_static_int', '228']) + self.expect( + "target variable my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_global_str', + '"abc"']) + self.expect( + "target variable my_static_int", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_static_int', + '228']) self.expect("target variable my_global_str_ptr", matching=False, - substrs = ['"abc"']) + substrs=['"abc"']) self.expect("target variable *my_global_str_ptr", matching=True, - substrs = ['"abc"']) - self.expect("target variable *my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['a']) - self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["my_global_char", "'X'"]) + substrs=['"abc"']) + self.expect( + "target variable *my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=['a']) + self.expect( + "target variable my_global_char", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "my_global_char", + "'X'"]) def do_target_variable_command_no_fail(self, exe_name): """Exercise 'target variable' command before and after starting the inferior.""" self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) - self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["my_global_char", "'X'"]) - self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_global_str', '"abc"']) - self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_static_int', '228']) + self.expect( + "target variable my_global_char", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "my_global_char", + "'X'"]) + self.expect( + "target variable my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_global_str', + '"abc"']) + self.expect( + "target variable my_static_int", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_static_int', + '228']) self.expect("target variable my_global_str_ptr", matching=False, - substrs = ['"abc"']) + substrs=['"abc"']) self.expect("target variable *my_global_str_ptr", matching=True, - substrs = ['"abc"']) - self.expect("target variable *my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['a']) + substrs=['"abc"']) + self.expect( + "target variable *my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=['a']) self.runCmd("b main") self.runCmd("run") - + # New feature: you don't need to specify the variable(s) to 'target vaiable'. - # It will find all the global and static variables in the current compile unit. + # It will find all the global and static variables in the current + # compile unit. self.expect("target variable", - substrs = ['my_global_char', - 'my_global_str', - 'my_global_str_ptr', - 'my_static_int']) - - self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_global_str', '"abc"']) - self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['my_static_int', '228']) + substrs=['my_global_char', + 'my_global_str', + 'my_global_str_ptr', + 'my_static_int']) + + self.expect( + "target variable my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_global_str', + '"abc"']) + self.expect( + "target variable my_static_int", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + 'my_static_int', + '228']) self.expect("target variable my_global_str_ptr", matching=False, - substrs = ['"abc"']) + substrs=['"abc"']) self.expect("target variable *my_global_str_ptr", matching=True, - substrs = ['"abc"']) - self.expect("target variable *my_global_str", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['a']) - self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["my_global_char", "'X'"]) + substrs=['"abc"']) + self.expect( + "target variable *my_global_str", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=['a']) + self.expect( + "target variable my_global_char", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "my_global_char", + "'X'"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/TestNumThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/TestNumThreads.py index 8184ddcfbf4..094c8670596 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/TestNumThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/TestNumThreads.py @@ -5,12 +5,13 @@ Test number of threads. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class NumberOfThreadsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,18 +29,23 @@ class NumberOfThreadsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 location. - 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) # The breakpoint list should show 3 locations. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.line]) # Run the program. self.runCmd("run", RUN_SUCCEEDED) # Stopped once. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Get the target process target = self.dbg.GetSelectedTarget() @@ -50,4 +56,6 @@ class NumberOfThreadsTestCase(TestBase): # Using std::thread may involve extra threads, so we assert that there are # at least 4 rather than exactly 4. - self.assertTrue(num_threads >= 4, 'Number of expected threads and actual threads do not match.') + self.assertTrue( + num_threads >= 4, + 'Number of expected threads and actual threads do not match.') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py index 902adacb2ab..ba5094f6de3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py @@ -2,13 +2,15 @@ Test regression for Bug 25251. """ -import os, time +import os +import time import unittest2 import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class BreakpointAfterJoinTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -17,11 +19,13 @@ class BreakpointAfterJoinTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number for our breakpoint. - self.breakpoint = line_number('ParallelTask.cpp', '// Set breakpoint here') - - @skipIfTargetAndroid(archs=["arm"]) # The android-arm compiler can't compile the inferior - # because of an issue around std::future. - # TODO: Change the test to don't depend on std::future<T> + self.breakpoint = line_number( + 'ParallelTask.cpp', '// Set breakpoint here') + + # The android-arm compiler can't compile the inferior + @skipIfTargetAndroid(archs=["arm"]) + # because of an issue around std::future. + # TODO: Change the test to don't depend on std::future<T> def test(self): """Test breakpoint handling after a thread join.""" self.build(dictionary=self.getBuildFlags()) @@ -30,23 +34,28 @@ class BreakpointAfterJoinTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint - lldbutil.run_break_set_by_file_and_line (self, "ParallelTask.cpp", self.breakpoint, num_expected_locations=-1) + lldbutil.run_break_set_by_file_and_line( + self, "ParallelTask.cpp", self.breakpoint, num_expected_locations=-1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'ParallelTask.cpp', line = %d, exact_match = 0" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'ParallelTask.cpp', line = %d, exact_match = 0" % + self.breakpoint]) # Run the program. 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']) # This should not result in a segmentation fault self.expect("thread backtrace all", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint 1."]) + substrs=["stop reason = breakpoint 1."]) # Run to completion self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py index 8ef0fb0a000..34634c37a7f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py @@ -5,13 +5,14 @@ Test number of threads. 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 BreakpointAfterJoinTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,9 +23,15 @@ class BreakpointAfterJoinTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") def test(self): """Test breakpoint handling after a thread join.""" self.build(dictionary=self.getBuildFlags()) @@ -33,19 +40,24 @@ class BreakpointAfterJoinTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.breakpoint]) # Run the program. 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']) # Get the target process target = self.dbg.GetSelectedTarget() @@ -59,12 +71,15 @@ class BreakpointAfterJoinTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see at least six threads - self.assertTrue(num_threads >= 6, 'Number of expected threads and actual threads do not match.') + self.assertTrue( + num_threads >= 6, + 'Number of expected threads and actual threads do not match.') # Make sure all threads are stopped for i in range(0, num_threads): - self.assertTrue(process.GetThreadAtIndex(i).IsStopped(), - "Thread {0} didn't stop during breakpoint.".format(i)) + self.assertTrue( + process.GetThreadAtIndex(i).IsStopped(), + "Thread {0} didn't stop during breakpoint.".format(i)) # Run to completion self.runCmd("continue") @@ -75,4 +90,6 @@ class BreakpointAfterJoinTestCase(TestBase): self.runCmd("process status") # At this point, the inferior process should have exited. - self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue( + process.GetState() == lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py index bafff4c63f0..d470e1a46bd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py @@ -12,13 +12,12 @@ class ConcurrentBreakpointDelayBreakpointOneSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_breakpoint_delay_breakpoint_one_signal(self): """Test two threads that trigger a breakpoint (one with a 1 second delay) and one signal thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_delay_breakpoint_threads=1, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py index 5d31f9a402f..5b88f7e38c8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py @@ -12,12 +12,11 @@ class ConcurrentBreakpointOneDelayBreakpointThreads(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_breakpoint_one_delay_breakpoint_threads(self): """Test threads that trigger a breakpoint where one thread has a 1 second delay. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_delay_breakpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py index 8cba670d6b9..b48ff4bf04a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py @@ -8,18 +8,18 @@ from lldbsuite.test.lldbtest import TestBase @skipIfWindows -class ConcurrentBreakpointsDelayedBreakpointOneWatchpoint(ConcurrentEventsBase): +class ConcurrentBreakpointsDelayedBreakpointOneWatchpoint( + ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_breakpoints_delayed_breakpoint_one_watchpoint(self): """Test a breakpoint, a delayed breakpoint, and one watchpoint thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_delay_breakpoint_threads=1, num_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py index a24399347ae..827a5dcd343 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py @@ -12,11 +12,10 @@ class ConcurrentCrashWithBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_crash_with_break(self): """ Test a thread that crashes while another thread hits a breakpoint.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_crash_threads=1, num_breakpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py index a6da4a8b001..4d9d758f323 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py @@ -12,11 +12,10 @@ class ConcurrentCrashWithSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_crash_with_signal(self): """ Test a thread that crashes while another thread generates a signal.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_crash_threads=1, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py index 9c45f9592e8..db7b40ea454 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py @@ -12,12 +12,11 @@ class ConcurrentCrashWithWatchpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_crash_with_watchpoint(self): """ Test a thread that crashes while another thread hits a watchpoint.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_crash_threads=1, num_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py index 093eb156297..44faf408760 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py @@ -12,9 +12,10 @@ class ConcurrentCrashWithWatchpointBreakpointSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_crash_with_watchpoint_breakpoint_signal(self): """ Test a thread that crashes while other threads generate a signal and hit a watchpoint and breakpoint. """ self.build(dictionary=self.getBuildFlags()) @@ -22,5 +23,3 @@ class ConcurrentCrashWithWatchpointBreakpointSignal(ConcurrentEventsBase): num_breakpoint_threads=1, num_signal_threads=1, num_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py index 37d8f24de0d..5f69e5615eb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py @@ -12,11 +12,12 @@ class ConcurrentDelaySignalBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_delay_signal_break(self): """Test (1-second delay) signal and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_breakpoint_threads=1, num_delay_signal_threads=1) - - + self.do_thread_actions( + num_breakpoint_threads=1, + num_delay_signal_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py index 1d52d6a6df9..0118f584c1b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py @@ -12,12 +12,13 @@ class ConcurrentDelaySignalWatch(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_delay_signal_watch(self): """Test a watchpoint and a (1 second delay) signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_delay_signal_threads=1, num_watchpoint_threads=1) - - + self.do_thread_actions( + num_delay_signal_threads=1, + num_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py index 9f7b91c7fa4..79d04d1ca63 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py @@ -12,12 +12,13 @@ class ConcurrentDelayWatchBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_delay_watch_break(self): """Test (1-second delay) watchpoint and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_breakpoint_threads=1, num_delay_watchpoint_threads=1) - - + self.do_thread_actions( + num_breakpoint_threads=1, + num_delay_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py index 0d36ce663db..8018ee30748 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py @@ -12,13 +12,12 @@ class ConcurrentDelayedCrashWithBreakpointSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_delayed_crash_with_breakpoint_signal(self): """ Test a thread with a delayed crash while other threads generate a signal and hit a breakpoint. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_delay_crash_threads=1, num_breakpoint_threads=1, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py index 2397c4117f0..552e9424bad 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py @@ -12,14 +12,13 @@ class ConcurrentDelayedCrashWithBreakpointWatchpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_delayed_crash_with_breakpoint_watchpoint(self): """ Test a thread with a delayed crash while other threads hit a watchpoint and a breakpoint. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_delay_crash_threads=1, num_breakpoint_threads=1, num_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py index af55e0b067b..3f221b19752 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py @@ -12,11 +12,12 @@ class ConcurrentManyBreakpoints(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_many_breakpoints(self): """Test 100 breakpoints from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=100) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py index 89b494d489b..a6c4a0082f3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py @@ -12,12 +12,12 @@ class ConcurrentManyCrash(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_many_crash(self): """Test 100 threads that cause a segfault.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_crash_threads=100) - - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py index 1c07a12de60..5dcf52178b7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py @@ -12,11 +12,12 @@ class ConcurrentManySignals(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_many_signals(self): """Test 100 signals from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_signal_threads=100) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py index 48fddac5e93..9d2d0ffc2a6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py @@ -12,11 +12,12 @@ class ConcurrentManyWatchpoints(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_many_watchpoints(self): """Test 100 watchpoints from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=100) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py index 79926feb7cf..a538c1b5243 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py @@ -12,14 +12,12 @@ class ConcurrentNWatchNBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_n_watch_n_break(self): """Test with 5 watchpoint and breakpoint threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=5, num_breakpoint_threads=5) - - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py index 8d863ef131d..7937126cbbf 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py @@ -12,11 +12,10 @@ class ConcurrentSignalBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_break(self): """Test signal and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py index 442b52f0311..33ebcc97520 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py @@ -12,12 +12,12 @@ class ConcurrentSignalDelayBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_delay_break(self): """Test signal and a (1 second delay) breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_delay_breakpoint_threads=1, num_signal_threads=1) - - - + self.do_thread_actions( + num_delay_breakpoint_threads=1, + num_signal_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py index 92d40c1fe3b..4f797730b00 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py @@ -12,13 +12,13 @@ class ConcurrentSignalDelayWatch(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_delay_watch(self): """Test a (1 second delay) watchpoint and a signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_signal_threads=1, num_delay_watchpoint_threads=1) - - - + self.do_thread_actions( + num_signal_threads=1, + num_delay_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py index 4c3aaba2943..861273a1701 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py @@ -12,14 +12,13 @@ class ConcurrentSignalNWatchNBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_n_watch_n_break(self): """Test one signal thread with 5 watchpoint and breakpoint threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_signal_threads=1, num_watchpoint_threads=5, num_breakpoint_threads=5) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py index bc019e29bd0..8aadd318e9b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py @@ -12,12 +12,11 @@ class ConcurrentSignalWatch(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_watch(self): """Test a watchpoint and a signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_signal_threads=1, num_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py index a0bf925f564..025e10bf931 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py @@ -12,14 +12,13 @@ class ConcurrentSignalWatchBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_signal_watch_break(self): """Test a signal/watchpoint/breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_signal_threads=1, num_watchpoint_threads=1, num_breakpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py index ecd8061cca2..24012365b8d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py @@ -12,11 +12,10 @@ class ConcurrentTwoBreakpointThreads(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_breakpoint_threads(self): """Test two threads that trigger a breakpoint. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=2) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py index 2814cab1362..56435026253 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py @@ -12,11 +12,12 @@ class ConcurrentTwoBreakpointsOneDelaySignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_breakpoints_one_delay_signal(self): """Test two threads that trigger a breakpoint and one (1 second delay) signal thread. """ self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_breakpoint_threads=2, num_delay_signal_threads=1) - - + self.do_thread_actions( + num_breakpoint_threads=2, + num_delay_signal_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py index 2513e61fd4e..bd9f5cd4ca7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py @@ -12,11 +12,10 @@ class ConcurrentTwoBreakpointsOneSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + @skipIfFreeBSD # timing out on buildbot + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_breakpoints_one_signal(self): """Test two threads that trigger a breakpoint and one signal thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=2, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py index c3444459109..6d2c8ef6cbc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py @@ -12,12 +12,13 @@ class ConcurrentTwoBreakpointsOneWatchpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_breakpoints_one_watchpoint(self): """Test two threads that trigger a breakpoint and one watchpoint thread. """ self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_breakpoint_threads=2, num_watchpoint_threads=1) - - + self.do_thread_actions( + num_breakpoint_threads=2, + num_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py index 60b538d43cf..7742f00aeed 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py @@ -12,12 +12,11 @@ class ConcurrentTwoWatchpointThreads(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_watchpoint_threads(self): """Test two threads that trigger a watchpoint. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=2) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py index 9e448d607d6..d1be67cad31 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py @@ -12,12 +12,13 @@ class ConcurrentTwoWatchpointsOneBreakpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_watchpoints_one_breakpoint(self): """Test two threads that trigger a watchpoint and one breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_watchpoint_threads=2, num_breakpoint_threads=1) - - + self.do_thread_actions( + num_watchpoint_threads=2, + num_breakpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py index 60faf1bbb3f..b1b6fbc82f2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py @@ -12,12 +12,13 @@ class ConcurrentTwoWatchpointsOneDelayBreakpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_watchpoints_one_delay_breakpoint(self): """Test two threads that trigger a watchpoint and one (1 second delay) breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_watchpoint_threads=2, num_delay_breakpoint_threads=1) - - + self.do_thread_actions( + num_watchpoint_threads=2, + num_delay_breakpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py index 070fd64e583..39e77a2052a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py @@ -12,12 +12,11 @@ class ConcurrentTwoWatchpointsOneSignal(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_two_watchpoints_one_signal(self): """Test two threads that trigger a watchpoint and one signal thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=2, num_signal_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py index c678e0053cb..7537490eaa4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py @@ -12,12 +12,13 @@ class ConcurrentWatchBreak(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_watch_break(self): """Test watchpoint and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_breakpoint_threads=1, num_watchpoint_threads=1) - - + self.do_thread_actions( + num_breakpoint_threads=1, + num_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py index 909ba7a78af..d5af2ce4770 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py @@ -12,12 +12,13 @@ class ConcurrentWatchBreakDelay(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_watch_break_delay(self): """Test watchpoint and a (1 second delay) breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - self.do_thread_actions(num_delay_breakpoint_threads=1, num_watchpoint_threads=1) - - + self.do_thread_actions( + num_delay_breakpoint_threads=1, + num_watchpoint_threads=1) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py index 52c55244f43..79fc70f888f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py @@ -12,14 +12,13 @@ class ConcurrentWatchpointDelayWatchpointOneBreakpoint(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_watchpoint_delay_watchpoint_one_breakpoint(self): """Test two threads that trigger a watchpoint (one with a 1 second delay) and one breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=1, num_delay_watchpoint_threads=1, num_breakpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py index 71ebcc1e509..2b3d422c066 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py @@ -12,13 +12,12 @@ class ConcurrentWatchpointWithDelayWatchpointThreads(ConcurrentEventsBase): mydir = ConcurrentEventsBase.compute_mydir(__file__) - @skipIfFreeBSD # timing out on buildbot + @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. + # Atomic sequences are not supported yet for MIPS in LLDB. + @expectedFailureAll(triple='^mips') def test_watchpoint_with_delay_watchpoint_threads(self): """Test two threads that trigger a watchpoint where one thread has a 1 second delay. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=1, num_delay_watchpoint_threads=1) - - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py index edd1e885ca9..a9a8aa31e37 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py @@ -5,13 +5,13 @@ Test that step-inst over a crash behaves correctly. from __future__ import print_function - import os import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class CreateDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,8 +22,12 @@ class CreateDuringStepTestCase(TestBase): @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @expectedFailureAndroid("llvm.org/pr24497", archs=['arm', 'aarch64']) - @expectedFailureAll(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr24497") - @expectedFailureAll(triple = re.compile('^mips')) # IO error due to breakpoint at invalid address + @expectedFailureAll( + oslist=["linux"], + archs=["arm"], + bugnumber="llvm.org/pr24497") + # IO error due to breakpoint at invalid address + @expectedFailureAll(triple=re.compile('^mips')) def test_step_inst_with(self): """Test thread creation during step-inst handling.""" self.build(dictionary=self.getBuildFlags()) @@ -32,21 +36,34 @@ class CreateDuringStepTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") - self.bp_num = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + self.bp_num = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # Run the program. - process = target.LaunchSimple(None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) # The stop reason should be breakpoint. - self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertEqual( + process.GetState(), + lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertTrue(thread.IsValid(), STOPPED_DUE_TO_BREAKPOINT) # Keep stepping until the inferior crashes while process.GetState() == lldb.eStateStopped and not lldbutil.is_thread_crashed(self, thread): thread.StepInstruction(False) - self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) - self.assertTrue(lldbutil.is_thread_crashed(self, thread), "Thread has crashed") + self.assertEqual( + process.GetState(), + lldb.eStateStopped, + PROCESS_STOPPED) + self.assertTrue( + lldbutil.is_thread_crashed( + self, + thread), + "Thread has crashed") process.Kill() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py index 1cb97355395..fb6208a0d3e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py @@ -5,31 +5,33 @@ Test thread creation after process attach. 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 CreateAfterAttachTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD # Hangs. May be the same as Linux issue llvm.org/pr16229 but - # not yet investigated. Revisit once required functionality - # is implemented for FreeBSD. - @skipIfWindows # Occasionally hangs on Windows, may be same as other issues. + @skipIfFreeBSD # Hangs. May be the same as Linux issue llvm.org/pr16229 but + # not yet investigated. Revisit once required functionality + # is implemented for FreeBSD. + # Occasionally hangs on Windows, may be same as other issues. + @skipIfWindows @skipIfiOSSimulator def test_create_after_attach_with_popen(self): """Test thread creation after process attach.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.create_after_attach(use_fork=False) - @skipIfFreeBSD # Hangs. Revisit once required functionality is implemented - # for FreeBSD. + @skipIfFreeBSD # Hangs. Revisit once required functionality is implemented + # for FreeBSD. @skipIfRemote - @skipIfWindows # Windows doesn't have fork. + @skipIfWindows # Windows doesn't have fork. @skipIfiOSSimulator def test_create_after_attach_with_fork(self): """Test thread creation after process attach.""" @@ -66,13 +68,16 @@ class CreateAfterAttachTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) # This should create a breakpoint in the second child thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_2, num_expected_locations=1) # This should create a breakpoint in the first child thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_3, num_expected_locations=1) # Note: With std::thread, we cannot rely on particular thread numbers. Using # std::thread may cause the program to spin up a thread pool (and it does on @@ -83,10 +88,10 @@ class CreateAfterAttachTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - '* thread #', - 'main', - 'stop reason = breakpoint']) + substrs=['stopped', + '* thread #', + 'main', + 'stop reason = breakpoint']) # Change a variable to escape the loop self.runCmd("expression main_thread_continue = 1") @@ -96,10 +101,10 @@ class CreateAfterAttachTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - '* thread #', - 'thread_2_func', - 'stop reason = breakpoint']) + substrs=['stopped', + '* thread #', + 'thread_2_func', + 'stop reason = breakpoint']) # Change a variable to escape the loop self.runCmd("expression child_thread_continue = 1") @@ -110,13 +115,15 @@ class CreateAfterAttachTestCase(TestBase): # The stop reason of the thread should be breakpoint. # Thread 3 may or may not have already exited. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - '* thread #', - 'thread_1_func', - 'stop reason = breakpoint']) + substrs=['stopped', + '* thread #', + 'thread_1_func', + 'stop reason = breakpoint']) # Run to completion self.runCmd("continue") # At this point, the inferior process should have exited. - self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue( + process.GetState() == lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py index 9401826e304..02f6a1aca41 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py @@ -5,43 +5,74 @@ Test number of threads. 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 CreateDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_inst(self): """Test thread creation during step-inst handling.""" self.build(dictionary=self.getBuildFlags()) - self.create_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step') - - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + self.create_during_step_base( + "thread step-inst -m all-threads", + 'stop reason = instruction step') + + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_over(self): """Test thread creation during step-over handling.""" self.build(dictionary=self.getBuildFlags()) - self.create_during_step_base("thread step-over -m all-threads", 'stop reason = step over') - - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + self.create_during_step_base( + "thread step-over -m all-threads", + 'stop reason = step over') + + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_in(self): """Test thread creation during step-in handling.""" self.build(dictionary=self.getBuildFlags()) - self.create_during_step_base("thread step-in -m all-threads", 'stop reason = step in') + self.create_during_step_base( + "thread step-in -m all-threads", + 'stop reason = step in') def setUp(self): # Call super's setUp(). @@ -56,19 +87,24 @@ class CreateDuringStepTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the stepping thread. - self.bp_num = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + self.bp_num = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, locations = 1" % + self.breakpoint]) # Run the program. 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']) # Get the target process target = self.dbg.GetSelectedTarget() @@ -78,15 +114,21 @@ class CreateDuringStepTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see only two threads - self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match.') + self.assertTrue( + num_threads == 2, + 'Number of expected threads and actual threads do not match.') # Get the thread objects thread1 = process.GetThreadAtIndex(0) thread2 = process.GetThreadAtIndex(1) # Make sure both threads are stopped - self.assertTrue(thread1.IsStopped(), "Thread 1 didn't stop during breakpoint") - self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint") + self.assertTrue( + thread1.IsStopped(), + "Thread 1 didn't stop during breakpoint") + self.assertTrue( + thread2.IsStopped(), + "Thread 2 didn't stop during breakpoint") # Find the thread that is stopped at the breakpoint stepping_thread = None @@ -95,7 +137,10 @@ class CreateDuringStepTestCase(TestBase): if expected_bp_desc in thread.GetStopDescription(100): stepping_thread = thread break - self.assertTrue(stepping_thread != None, "unable to find thread stopped at %s" % expected_bp_desc) + self.assertTrue( + stepping_thread is not None, + "unable to find thread stopped at %s" % + expected_bp_desc) current_line = self.breakpoint # Keep stepping until we've reached our designated continue point while current_line != self.continuepoint: @@ -108,21 +153,31 @@ class CreateDuringStepTestCase(TestBase): current_line = frame.GetLineEntry().GetLine() # Make sure we're still where we thought we were - self.assertTrue(current_line >= self.breakpoint, "Stepped to unexpected line, " + str(current_line)) - self.assertTrue(current_line <= self.continuepoint, "Stepped to unexpected line, " + str(current_line)) + self.assertTrue( + current_line >= self.breakpoint, + "Stepped to unexpected line, " + + str(current_line)) + self.assertTrue( + current_line <= self.continuepoint, + "Stepped to unexpected line, " + + str(current_line)) # Update the number of threads num_threads = process.GetNumThreads() # Check to see that we increased the number of threads as expected - self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match after thread exit.') + self.assertTrue( + num_threads == 3, + 'Number of expected threads and actual threads do not match after thread exit.') self.expect("thread list", 'Process state is stopped due to step', - substrs = ['stopped', - step_stop_reason]) + substrs=['stopped', + step_stop_reason]) # Run to completion self.runCmd("process continue") # At this point, the inferior process should have exited. - self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue( + process.GetState() == lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py index 2c394263d36..3b0d102c6cb 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py @@ -5,13 +5,14 @@ Test number of threads. 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 ExitDuringBreakpointTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,10 +23,18 @@ class ExitDuringBreakpointTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test(self): """Test thread exit during breakpoint handling.""" self.build(dictionary=self.getBuildFlags()) @@ -33,19 +42,24 @@ class ExitDuringBreakpointTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, locations = 1" % + self.breakpoint]) # Run the program. 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']) # Get the target process target = self.dbg.GetSelectedTarget() @@ -59,7 +73,9 @@ class ExitDuringBreakpointTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see at least five threads - self.assertTrue(num_threads >= 5, 'Number of expected threads and actual threads do not match.') + self.assertTrue( + num_threads >= 5, + 'Number of expected threads and actual threads do not match.') # Get the thread objects thread1 = process.GetThreadAtIndex(0) @@ -69,14 +85,26 @@ class ExitDuringBreakpointTestCase(TestBase): thread5 = process.GetThreadAtIndex(4) # Make sure all threads are stopped - self.assertTrue(thread1.IsStopped(), "Thread 1 didn't stop during breakpoint") - self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint") - self.assertTrue(thread3.IsStopped(), "Thread 3 didn't stop during breakpoint") - self.assertTrue(thread4.IsStopped(), "Thread 4 didn't stop during breakpoint") - self.assertTrue(thread5.IsStopped(), "Thread 5 didn't stop during breakpoint") + self.assertTrue( + thread1.IsStopped(), + "Thread 1 didn't stop during breakpoint") + self.assertTrue( + thread2.IsStopped(), + "Thread 2 didn't stop during breakpoint") + self.assertTrue( + thread3.IsStopped(), + "Thread 3 didn't stop during breakpoint") + self.assertTrue( + thread4.IsStopped(), + "Thread 4 didn't stop during breakpoint") + self.assertTrue( + thread5.IsStopped(), + "Thread 5 didn't stop during breakpoint") # Run to completion self.runCmd("continue") # At this point, the inferior process should have exited. - self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue( + process.GetState() == lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py index af4a022ed0c..c27bd2d3e4d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py @@ -5,34 +5,41 @@ Test number of threads. 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 ExitDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfFreeBSD # llvm.org/pr21411: test is hanging def test(self): """Test thread exit during step handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step') + self.exit_during_step_base( + "thread step-inst -m all-threads", + 'stop reason = instruction step') - @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfFreeBSD # llvm.org/pr21411: test is hanging def test_step_over(self): """Test thread exit during step-over handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-over -m all-threads", 'stop reason = step over') + self.exit_during_step_base( + "thread step-over -m all-threads", + 'stop reason = step over') - @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfFreeBSD # llvm.org/pr21411: test is hanging def test_step_in(self): """Test thread exit during step-in handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in') + self.exit_during_step_base( + "thread step-in -m all-threads", + 'stop reason = step in') def setUp(self): # Call super's setUp(). @@ -47,19 +54,24 @@ class ExitDuringStepTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - self.bp_num = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + self.bp_num = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.breakpoint]) # Run the program. 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']) # Get the target process target = self.dbg.GetSelectedTarget() @@ -67,14 +79,23 @@ class ExitDuringStepTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see all three threads - self.assertGreaterEqual(num_threads, 3, 'Number of expected threads and actual threads do not match.') + self.assertGreaterEqual( + num_threads, + 3, + 'Number of expected threads and actual threads do not match.') - stepping_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, self.bp_num) - self.assertIsNotNone(stepping_thread, "Could not find a thread stopped at the breakpoint") + stepping_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id( + process, self.bp_num) + self.assertIsNotNone( + stepping_thread, + "Could not find a thread stopped at the breakpoint") current_line = self.breakpoint stepping_frame = stepping_thread.GetFrameAtIndex(0) - self.assertEqual(current_line, stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.") + self.assertEqual( + current_line, + stepping_frame.GetLineEntry().GetLine(), + "Starting line for stepping doesn't match breakpoint line.") # Keep stepping until we've reached our designated continue point while current_line != self.continuepoint: @@ -90,8 +111,16 @@ class ExitDuringStepTestCase(TestBase): current_line = frame.GetLineEntry().GetLine() - self.assertGreaterEqual(current_line, self.breakpoint, "Stepped to unexpected line, " + str(current_line)) - self.assertLessEqual(current_line, self.continuepoint, "Stepped to unexpected line, " + str(current_line)) + self.assertGreaterEqual( + current_line, + self.breakpoint, + "Stepped to unexpected line, " + + str(current_line)) + self.assertLessEqual( + current_line, + self.continuepoint, + "Stepped to unexpected line, " + + str(current_line)) self.runCmd("thread list") @@ -99,11 +128,14 @@ class ExitDuringStepTestCase(TestBase): new_num_threads = process.GetNumThreads() # Check to see that we reduced the number of threads as expected - self.assertEqual(new_num_threads, num_threads-1, 'Number of threads did not reduce by 1 after thread exit.') + self.assertEqual( + new_num_threads, + num_threads - 1, + 'Number of threads did not reduce by 1 after thread exit.') self.expect("thread list", 'Process state is stopped due to step', - substrs = ['stopped', - step_stop_reason]) + substrs=['stopped', + step_stop_reason]) # Run to completion self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py index 4c55bcd982a..26ee5d4084e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -5,13 +5,14 @@ Test jumping to different places. 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 ThreadJumpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,31 +30,50 @@ class ThreadJumpTestCase(TestBase): self.mark4 = line_number('main.cpp', '// 4th marker') self.mark5 = line_number('other.cpp', '// other marker') - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.mark3, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.mark3, num_expected_locations=1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint 1. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1", - substrs=['stopped', 'main.cpp:{}'.format(self.mark3), 'stop reason = breakpoint 1']) + self.expect( + "thread list", + STOPPED_DUE_TO_BREAKPOINT + " 1", + substrs=[ + 'stopped', + 'main.cpp:{}'.format( + self.mark3), + 'stop reason = breakpoint 1']) - self.do_min_test(self.mark3, self.mark1, "i", "4"); # Try the int path, force it to return 'a' - self.do_min_test(self.mark3, self.mark2, "i", "5"); # Try the int path, force it to return 'b' - self.do_min_test(self.mark4, self.mark1, "j", "7"); # Try the double path, force it to return 'a' - self.do_min_test(self.mark4, self.mark2, "j", "8"); # Try the double path, force it to return 'b' + # Try the int path, force it to return 'a' + self.do_min_test(self.mark3, self.mark1, "i", "4") + # Try the int path, force it to return 'b' + self.do_min_test(self.mark3, self.mark2, "i", "5") + # Try the double path, force it to return 'a' + self.do_min_test(self.mark4, self.mark1, "j", "7") + # Try the double path, force it to return 'b' + self.do_min_test(self.mark4, self.mark2, "j", "8") # Try jumping to another function in a different file. - self.runCmd("thread jump --file other.cpp --line %i --force" % self.mark5) + self.runCmd( + "thread jump --file other.cpp --line %i --force" % + self.mark5) self.expect("process status", - substrs = ["at other.cpp:%i" % self.mark5]) + substrs=["at other.cpp:%i" % self.mark5]) # Try jumping to another function (without forcing) - self.expect("j main.cpp:%i" % self.mark1, COMMAND_FAILED_AS_EXPECTED, error = True, - substrs = ["error"]) - + self.expect( + "j main.cpp:%i" % + self.mark1, + COMMAND_FAILED_AS_EXPECTED, + error=True, + substrs=["error"]) + def do_min_test(self, start, jump, var, value): - self.runCmd("j %i" % start) # jump to the start marker + # jump to the start marker + self.runCmd("j %i" % start) self.runCmd("thread step-in") # step into the min fn - self.runCmd("j %i" % jump) # jump to the branch we're interested in + # jump to the branch we're interested in + self.runCmd("j %i" % jump) self.runCmd("thread step-out") # return out self.runCmd("thread step-over") # assign to the global - self.expect("expr %s" % var, substrs = [value]) # check it + self.expect("expr %s" % var, substrs=[value]) # check it diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py index d4b1eb32a9a..7f542d442ac 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -5,13 +5,14 @@ Test number of threads. 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 MultipleBreakpointTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,10 +23,18 @@ class MultipleBreakpointTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test(self): """Test simultaneous breakpoints in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -33,11 +42,16 @@ class MultipleBreakpointTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, locations = 1" % + self.breakpoint]) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -45,8 +59,8 @@ class MultipleBreakpointTestCase(TestBase): # The stop reason of the thread should be breakpoint. # The breakpoint may be hit in either thread 2 or thread 3. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # Get the target process target = self.dbg.GetSelectedTarget() @@ -56,7 +70,9 @@ class MultipleBreakpointTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see all three threads - self.assertTrue(num_threads >= 3, 'Number of expected threads and actual threads do not match.') + self.assertTrue( + num_threads >= 3, + 'Number of expected threads and actual threads do not match.') # Get the thread objects thread1 = process.GetThreadAtIndex(0) @@ -64,9 +80,15 @@ class MultipleBreakpointTestCase(TestBase): thread3 = process.GetThreadAtIndex(2) # Make sure both threads are stopped - self.assertTrue(thread1.IsStopped(), "Primary thread didn't stop during breakpoint") - self.assertTrue(thread2.IsStopped(), "Secondary thread didn't stop during breakpoint") - self.assertTrue(thread3.IsStopped(), "Tertiary thread didn't stop during breakpoint") + self.assertTrue( + thread1.IsStopped(), + "Primary thread didn't stop during breakpoint") + self.assertTrue( + thread2.IsStopped(), + "Secondary thread didn't stop during breakpoint") + self.assertTrue( + thread3.IsStopped(), + "Tertiary thread didn't stop during breakpoint") # Delete the first breakpoint then continue self.runCmd("breakpoint delete 1") @@ -75,4 +97,6 @@ class MultipleBreakpointTestCase(TestBase): self.runCmd("continue") # At this point, the inferior process should have exited. - self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue( + process.GetState() == lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 5afb57bf4ba..c3604783d89 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -5,28 +5,37 @@ Test thread states. from __future__ import print_function - import unittest2 -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 ThreadStateTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr15824 thread states not properly maintained") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18190 thread states not properly maintained") def test_state_after_breakpoint(self): """Test thread state after breakpoint.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.thread_state_after_breakpoint_test() - @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly - @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr23669") + @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly + @expectedFailureAll( + oslist=lldbplatformutil.getDarwinOSTriples(), + bugnumber="llvm.org/pr23669") @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr15824") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660") def test_state_after_continue(self): @@ -34,24 +43,31 @@ class ThreadStateTestCase(TestBase): self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.thread_state_after_continue_test() - @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly + @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly @expectedFailureDarwin('llvm.org/pr23669') @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660") - @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained + # thread states not properly maintained + @unittest2.expectedFailure("llvm.org/pr16712") def test_state_after_expression(self): """Test thread state after expression.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.thread_state_after_expression_test() - @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + # thread states not properly maintained + @unittest2.expectedFailure("llvm.org/pr16712") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_process_interrupt(self): """Test process interrupt.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.process_interrupt_test() - @unittest2.expectedFailure("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + # thread states not properly maintained + @unittest2.expectedFailure("llvm.org/pr15824") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_process_state(self): """Test thread states (comprehensive).""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -70,7 +86,8 @@ class ThreadStateTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - bp = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) + bp = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -79,12 +96,16 @@ class ThreadStateTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) # Make sure the thread is in the stopped state. - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 1.") + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' during breakpoint 1.") + self.assertFalse(thread.IsSuspended(), + "Thread state is \'suspended\' during breakpoint 1.") # Kill the process self.runCmd("process kill") @@ -92,8 +113,12 @@ class ThreadStateTestCase(TestBase): def wait_for_running_event(self, process): listener = self.dbg.GetListener() if lldb.remote_platform: - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateConnected]) - lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateConnected]) + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) def thread_state_after_continue_test(self): """Test thread state after continue.""" @@ -101,8 +126,10 @@ class ThreadStateTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_2, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -111,17 +138,23 @@ class ThreadStateTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) - # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. + # Continue, the inferior will go into an infinite loop waiting for + # 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") self.wait_for_running_event(process) # Check the thread state. It should be running. - self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' when it should be running.") + self.assertFalse( + thread.IsStopped(), + "Thread state is \'stopped\' when it should be running.") + self.assertFalse( + thread.IsSuspended(), + "Thread state is \'suspended\' when it should be running.") # Go back to synchronous interactions self.dbg.SetAsync(False) @@ -135,8 +168,10 @@ class ThreadStateTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_2, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -145,27 +180,32 @@ class ThreadStateTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) # Get the inferior out of its loop self.runCmd("expression g_test = 1") # Check the thread state - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' after expression evaluation.") + self.assertFalse( + thread.IsSuspended(), + "Thread state is \'suspended\' after expression evaluation.") # Let the process run to completion self.runCmd("process continue") - def process_interrupt_test(self): """Test process interrupt and continue.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -174,10 +214,12 @@ class ThreadStateTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) - # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. + # Continue, the inferior will go into an infinite loop waiting for + # 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") self.wait_for_running_event(process) @@ -202,8 +244,10 @@ class ThreadStateTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_2, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -211,21 +255,30 @@ class ThreadStateTestCase(TestBase): # Get the target process target = self.dbg.GetSelectedTarget() process = target.GetProcess() - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) # Make sure the thread is in the stopped state. - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 1.") - - # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' during breakpoint 1.") + self.assertFalse(thread.IsSuspended(), + "Thread state is \'suspended\' during breakpoint 1.") + + # Continue, the inferior will go into an infinite loop waiting for + # 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") self.wait_for_running_event(process) # Check the thread state. It should be running. - self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' when it should be running.") + self.assertFalse( + thread.IsStopped(), + "Thread state is \'stopped\' when it should be running.") + self.assertFalse( + thread.IsSuspended(), + "Thread state is \'suspended\' when it should be running.") # Go back to synchronous interactions self.dbg.SetAsync(False) @@ -236,15 +289,22 @@ class ThreadStateTestCase(TestBase): self.assertEqual(thread.GetState(), lldb.eStopReasonSignal) # Check the thread state - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after process stop.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after process stop.") + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' after process stop.") + self.assertFalse(thread.IsSuspended(), + "Thread state is \'suspended\' after process stop.") # Get the inferior out of its loop self.runCmd("expression g_test = 1") # Check the thread state - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' after expression evaluation.") + self.assertFalse( + thread.IsSuspended(), + "Thread state is \'suspended\' after expression evaluation.") self.assertEqual(thread.GetState(), lldb.eStopReasonSignal) @@ -254,8 +314,11 @@ class ThreadStateTestCase(TestBase): self.assertEqual(thread.GetState(), lldb.eStopReasonBreakpoint) # Make sure both threads are stopped - self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 2.") - self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 2.") + self.assertTrue( + thread.IsStopped(), + "Thread state isn't \'stopped\' during breakpoint 2.") + self.assertFalse(thread.IsSuspended(), + "Thread state is \'suspended\' during breakpoint 2.") # Run to completion self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py index 735ee80d624..f043013b90c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py @@ -5,38 +5,54 @@ Test stepping out from a function in a multi-threaded program. 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 ThreadStepOutTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18066 inferior does not exit") + # Test occasionally times out on the Linux build bot + @skipIfLinux + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr18066 inferior does not exit") @expectedFailureAll(oslist=["windows"]) def test_step_single_thread(self): """Test thread step out on one thread via command interpreter. """ self.build(dictionary=self.getBuildFlags()) self.step_out_test(self.step_out_single_thread_with_cmd) - @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + # Test occasionally times out on the Linux build bot + @skipIfLinux + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") @expectedFailureAll(oslist=["windows"]) def test_step_all_threads(self): """Test thread step out on all threads via command interpreter. """ self.build(dictionary=self.getBuildFlags()) self.step_out_test(self.step_out_all_threads_with_cmd) - @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") - @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + # Test occasionally times out on the Linux build bot + @skipIfLinux + @expectedFailureAll( + oslist=["linux"], + bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll( + oslist=["freebsd"], + bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24681") def test_python(self): """Test thread step out on one thread via Python API (dwarf).""" @@ -48,43 +64,63 @@ class ThreadStepOutTestCase(TestBase): TestBase.setUp(self) # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - if "gcc" in self.getCompiler() or self.isIntelCompiler(): - self.step_out_destination = line_number('main.cpp', '// Expect to stop here after step-out (icc and gcc)') + if "gcc" in self.getCompiler() or self.isIntelCompiler(): + self.step_out_destination = line_number( + 'main.cpp', '// Expect to stop here after step-out (icc and gcc)') else: - self.step_out_destination = line_number('main.cpp', '// Expect to stop here after step-out (clang)') + self.step_out_destination = line_number( + 'main.cpp', '// Expect to stop here after step-out (clang)') def step_out_single_thread_with_cmd(self): self.step_out_with_cmd("this-thread") - self.expect("thread backtrace all", "Thread location after step out is correct", - substrs = ["main.cpp:%d" % self.step_out_destination, - "main.cpp:%d" % self.breakpoint]) + self.expect( + "thread backtrace all", + "Thread location after step out is correct", + substrs=[ + "main.cpp:%d" % + self.step_out_destination, + "main.cpp:%d" % + self.breakpoint]) def step_out_all_threads_with_cmd(self): self.step_out_with_cmd("all-threads") - self.expect("thread backtrace all", "Thread location after step out is correct", - substrs = ["main.cpp:%d" % self.step_out_destination]) + self.expect( + "thread backtrace all", + "Thread location after step out is correct", + substrs=[ + "main.cpp:%d" % + self.step_out_destination]) def step_out_with_cmd(self, run_mode): self.runCmd("thread select %d" % self.step_out_thread.GetIndexID()) self.runCmd("thread step-out -m %s" % run_mode) self.expect("process status", "Expected stop reason to be step-out", - substrs = ["stop reason = step out"]) + substrs=["stop reason = step out"]) - self.expect("thread list", "Selected thread did not change during step-out", - substrs = ["* thread #%d" % self.step_out_thread.GetIndexID()]) + self.expect( + "thread list", + "Selected thread did not change during step-out", + substrs=[ + "* thread #%d" % + self.step_out_thread.GetIndexID()]) def step_out_with_python(self): self.step_out_thread.StepOut() reason = self.step_out_thread.GetStopReason() - self.assertEqual(lldb.eStopReasonPlanComplete, reason, - "Expected thread stop reason 'plancomplete', but got '%s'" % lldbutil.stop_reason_to_str(reason)) + self.assertEqual( + lldb.eStopReasonPlanComplete, + reason, + "Expected thread stop reason 'plancomplete', but got '%s'" % + lldbutil.stop_reason_to_str(reason)) # Verify location after stepping out frame = self.step_out_thread.GetFrameAtIndex(0) desc = lldbutil.get_description(frame.GetLineEntry()) expect = "main.cpp:%d" % self.step_out_destination - self.assertTrue(expect in desc, "Expected %s but thread stopped at %s" % (expect, desc)) + self.assertTrue( + expect in desc, "Expected %s but thread stopped at %s" % + (expect, desc)) def step_out_test(self, step_out_func): """Test single thread step out of a function.""" @@ -92,11 +128,16 @@ class ThreadStepOutTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.breakpoint, num_expected_locations=1) # The breakpoint list should show 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.breakpoint]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.breakpoint]) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -107,7 +148,10 @@ class ThreadStepOutTestCase(TestBase): # Get the number of threads, ensure we see all three. num_threads = self.inferior_process.GetNumThreads() - self.assertEqual(num_threads, 3, 'Number of expected threads and actual threads do not match.') + self.assertEqual( + num_threads, + 3, + 'Number of expected threads and actual threads do not match.') (breakpoint_threads, other_threads) = ([], []) lldbutil.sort_stopped_threads(self.inferior_process, @@ -115,10 +159,12 @@ class ThreadStepOutTestCase(TestBase): other_threads=other_threads) while len(breakpoint_threads) < 2: - self.runCmd("thread continue %s" % " ".join([str(x.GetIndexID()) for x in other_threads])) - lldbutil.sort_stopped_threads(self.inferior_process, - breakpoint_threads=breakpoint_threads, - other_threads=other_threads) + self.runCmd("thread continue %s" % + " ".join([str(x.GetIndexID()) for x in other_threads])) + lldbutil.sort_stopped_threads( + self.inferior_process, + breakpoint_threads=breakpoint_threads, + other_threads=other_threads) self.step_out_thread = breakpoint_threads[0] @@ -129,4 +175,5 @@ class ThreadStepOutTestCase(TestBase): self.runCmd("continue") # At this point, the inferior process should have exited. - self.assertTrue(self.inferior_process.GetState() == lldb.eStateExited, PROCESS_EXITED) + self.assertTrue(self.inferior_process.GetState() == + lldb.eStateExited, PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py index 2ba6f2e57f2..deedc4b7507 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py @@ -5,12 +5,13 @@ Test number of threads. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class ThreadExitTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,17 +32,28 @@ class ThreadExitTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 location. - bp1_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - bp2_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) - bp3_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) - bp4_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_4, num_expected_locations=1) + bp1_id = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_1, num_expected_locations=1) + bp2_id = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_2, num_expected_locations=1) + bp3_id = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_3, num_expected_locations=1) + bp4_id = lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.break_4, num_expected_locations=1) # The breakpoint list should show 1 locations. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_1, - "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_2, - "3: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_3, - "4: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_4]) + self.expect( + "breakpoint list -f", + "Breakpoint location shown correctly", + substrs=[ + "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.break_1, + "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.break_2, + "3: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.break_3, + "4: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % + self.break_4]) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -49,39 +61,59 @@ class ThreadExitTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp1_id) - self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 1") + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id( + process, bp1_id) + self.assertIsNotNone(stopped_thread, + "Process is not stopped at breakpoint 1") # Get the number of threads num_threads = process.GetNumThreads() - self.assertGreaterEqual(num_threads, 2, 'Number of expected threads and actual threads do not match at breakpoint 1.') + self.assertGreaterEqual( + num_threads, + 2, + 'Number of expected threads and actual threads do not match at breakpoint 1.') # Run to the second breakpoint self.runCmd("continue") - stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp2_id) - self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 2") + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id( + process, bp2_id) + self.assertIsNotNone(stopped_thread, + "Process is not stopped at breakpoint 2") # Update the number of threads new_num_threads = process.GetNumThreads() - self.assertEqual(new_num_threads, num_threads+1, 'Number of expected threads did not increase by 1 at bp 2.') + self.assertEqual( + new_num_threads, + num_threads + 1, + 'Number of expected threads did not increase by 1 at bp 2.') # Run to the third breakpoint self.runCmd("continue") - stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp3_id) - self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 3") + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id( + process, bp3_id) + self.assertIsNotNone(stopped_thread, + "Process is not stopped at breakpoint 3") # Update the number of threads new_num_threads = process.GetNumThreads() - self.assertEqual(new_num_threads, num_threads, 'Number of expected threads is not equal to original number of threads at bp 3.') + self.assertEqual( + new_num_threads, + num_threads, + 'Number of expected threads is not equal to original number of threads at bp 3.') # Run to the fourth breakpoint self.runCmd("continue") - stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp4_id) - self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 4") + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id( + process, bp4_id) + self.assertIsNotNone(stopped_thread, + "Process is not stopped at breakpoint 4") # Update the number of threads new_num_threads = process.GetNumThreads() - self.assertEqual(new_num_threads, num_threads-1, 'Number of expected threads did not decrease by 1 at bp 4.') + self.assertEqual( + new_num_threads, + num_threads - 1, + 'Number of expected threads did not decrease by 1 at bp 4.') # Run to completion self.runCmd("continue") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py index 12bacabd0d7..0377b0c0a80 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py @@ -5,14 +5,15 @@ Test that we obey thread conditioned breakpoints. 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 ThreadSpecificBreakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,24 +31,42 @@ class ThreadSpecificBreakTestCase(TestBase): # This test works by setting a breakpoint in a function conditioned to stop only on # the main thread, and then calling this function on a secondary thread, joining, # and then calling again on the main thread. If the thread specific breakpoint works - # then it should not be hit on the secondary thread, only on the main thread. - - main_source_spec = lldb.SBFileSpec ("main.cpp") - - main_breakpoint = target.BreakpointCreateBySourceRegex("Set main breakpoint here", main_source_spec); - thread_breakpoint = target.BreakpointCreateBySourceRegex("Set thread-specific breakpoint here", main_source_spec) - - self.assertTrue(main_breakpoint.IsValid(), "Failed to set main breakpoint.") - self.assertGreater(main_breakpoint.GetNumLocations(), 0, "main breakpoint has no locations associated with it.") - self.assertTrue(thread_breakpoint.IsValid(), "Failed to set thread breakpoint.") - self.assertGreater(thread_breakpoint.GetNumLocations(), 0, "thread breakpoint has no locations associated with it.") - - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + # then it should not be hit on the secondary thread, only on the main + # thread. + + main_source_spec = lldb.SBFileSpec("main.cpp") + + main_breakpoint = target.BreakpointCreateBySourceRegex( + "Set main breakpoint here", main_source_spec) + thread_breakpoint = target.BreakpointCreateBySourceRegex( + "Set thread-specific breakpoint here", main_source_spec) + + self.assertTrue( + main_breakpoint.IsValid(), + "Failed to set main breakpoint.") + self.assertGreater( + main_breakpoint.GetNumLocations(), + 0, + "main breakpoint has no locations associated with it.") + self.assertTrue( + thread_breakpoint.IsValid(), + "Failed to set thread breakpoint.") + self.assertGreater( + thread_breakpoint.GetNumLocations(), + 0, + "thread breakpoint has no locations associated with it.") + + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - stopped_threads = lldbutil.get_threads_stopped_at_breakpoint(process, main_breakpoint) - self.assertEqual(len(stopped_threads), 1, "main breakpoint stopped at unexpected number of threads") + stopped_threads = lldbutil.get_threads_stopped_at_breakpoint( + process, main_breakpoint) + self.assertEqual( + len(stopped_threads), + 1, + "main breakpoint stopped at unexpected number of threads") main_thread = stopped_threads[0] main_thread_id = main_thread.GetThreadID() @@ -58,7 +77,17 @@ class ThreadSpecificBreakTestCase(TestBase): process.Continue() next_stop_state = process.GetState() - self.assertEqual(next_stop_state, lldb.eStateStopped, "We should have stopped at the thread breakpoint.") - stopped_threads = lldbutil.get_threads_stopped_at_breakpoint(process, thread_breakpoint) - self.assertEqual(len(stopped_threads), 1, "thread breakpoint stopped at unexpected number of threads") - self.assertEqual(stopped_threads[0].GetThreadID(), main_thread_id, "thread breakpoint stopped at the wrong thread") + self.assertEqual( + next_stop_state, + lldb.eStateStopped, + "We should have stopped at the thread breakpoint.") + stopped_threads = lldbutil.get_threads_stopped_at_breakpoint( + process, thread_breakpoint) + self.assertEqual( + len(stopped_threads), + 1, + "thread breakpoint stopped at unexpected number of threads") + self.assertEqual( + stopped_threads[0].GetThreadID(), + main_thread_id, + "thread breakpoint stopped at the wrong thread") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py index ec5719d730d..da9ba59f992 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py @@ -6,20 +6,23 @@ conditioned breakpoints simultaneously 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 ThreadSpecificBreakPlusConditionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIf(oslist=['windows', 'freebsd']) # test frequently times out or hangs - @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522') # hits break in another thread in testrun + # test frequently times out or hangs + @skipIf(oslist=['windows', 'freebsd']) + # hits break in another thread in testrun + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522') @add_test_categories(['pyapi']) def test_python(self): """Test that we obey thread conditioned breakpoints.""" @@ -29,18 +32,24 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - main_source_spec = lldb.SBFileSpec ("main.cpp") + main_source_spec = lldb.SBFileSpec("main.cpp") - # Set a breakpoint in the thread body, and make it active for only the first thread. - break_thread_body = target.BreakpointCreateBySourceRegex ("Break here in thread body.", main_source_spec) - self.assertTrue (break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0, "Failed to set thread body breakpoint.") + # Set a breakpoint in the thread body, and make it active for only the + # first thread. + break_thread_body = target.BreakpointCreateBySourceRegex( + "Break here in thread body.", main_source_spec) + self.assertTrue( + break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0, + "Failed to set thread body breakpoint.") - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, break_thread_body) - + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, break_thread_body) + victim_thread = threads[0] # Pick one of the threads, and change the breakpoint so it ONLY stops for this thread, @@ -51,14 +60,18 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase): frame = victim_thread.GetFrameAtIndex(0) value = frame.FindVariable("my_value").GetValueAsSigned(0) - self.assertTrue (value > 0 and value < 11, "Got a reasonable value for my_value.") + self.assertTrue( + value > 0 and value < 11, + "Got a reasonable value for my_value.") - cond_string = "my_value != %d"%(value) + cond_string = "my_value != %d" % (value) break_thread_body.SetThreadID(victim_thread.GetThreadID()) - break_thread_body.SetCondition (cond_string) + break_thread_body.SetCondition(cond_string) process.Continue() next_stop_state = process.GetState() - self.assertTrue (next_stop_state == lldb.eStateExited, "We should have not hit the breakpoint again.") + self.assertTrue( + next_stop_state == lldb.eStateExited, + "We should have not hit the breakpoint again.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py index 44fa9cedc86..241c49897ef 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py @@ -2,25 +2,29 @@ Tests basic ThreadSanitizer support (detecting a data race). """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanBasicTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() def setUp(self): # Call super's setUp(). @@ -29,26 +33,33 @@ class TsanBasicTestCase(TestBase): self.line_thread1 = line_number('main.c', '// thread1 line') self.line_thread2 = line_number('main.c', '// thread2 line') - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # the stop reason of the thread should be breakpoint. self.expect("thread list", "A data race should be detected", - substrs = ['stopped', 'stop reason = Data race detected']) + substrs=['stopped', 'stop reason = Data race detected']) - self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + self.assertEqual( + self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonInstrumentation) # test that the TSan dylib is present - self.expect("image lookup -n __tsan_get_current_report", "__tsan_get_current_report should be present", - substrs = ['1 match found']) + self.expect( + "image lookup -n __tsan_get_current_report", + "__tsan_get_current_report should be present", + substrs=['1 match found']) # We should be stopped in __tsan_on_report process = self.dbg.GetSelectedTarget().process @@ -56,7 +67,8 @@ class TsanBasicTestCase(TestBase): frame = thread.GetSelectedFrame() self.assertTrue("__tsan_on_report" in frame.GetFunctionName()) - # The stopped thread backtrace should contain either line1 or line2 from main.c. + # The stopped thread backtrace should contain either line1 or line2 + # from main.c. found = False for i in range(0, thread.GetNumFrames()): frame = thread.GetFrameAtIndex(i) @@ -67,8 +79,13 @@ class TsanBasicTestCase(TestBase): found = True self.assertTrue(found) - self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", - substrs = ["instrumentation_class", "description", "mops"]) + self.expect( + "thread info -s", + "The extended stop info should contain the TSan provided fields", + substrs=[ + "instrumentation_class", + "description", + "mops"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) @@ -77,10 +94,12 @@ class TsanBasicTestCase(TestBase): self.assertEqual(data["issue_type"], "data-race") self.assertEqual(len(data["mops"]), 2) - backtraces = thread.GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeAddressSanitizer) + backtraces = thread.GetStopReasonExtendedBacktraces( + lldb.eInstrumentationRuntimeTypeAddressSanitizer) self.assertEqual(backtraces.GetSize(), 0) - backtraces = thread.GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer) + backtraces = thread.GetStopReasonExtendedBacktraces( + lldb.eInstrumentationRuntimeTypeThreadSanitizer) self.assertTrue(backtraces.GetSize() >= 2) # First backtrace is a memory operation @@ -111,8 +130,8 @@ class TsanBasicTestCase(TestBase): # the stop reason of the thread should be a SIGABRT. self.expect("thread list", "We should be stopped due a SIGABRT", - substrs = ['stopped', 'stop reason = signal SIGABRT']) + substrs=['stopped', 'stop reason = signal SIGABRT']) # test that we're in pthread_kill now (TSan abort the process) self.expect("thread list", "We should be stopped in pthread_kill", - substrs = ['pthread_kill']) + substrs=['pthread_kill']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py index 230ff982da0..8aa75d22e97 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py @@ -2,47 +2,59 @@ Tests that TSan correctly reports the filename and line number of a racy global C++ variable. """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanCPPGlobalLocationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() def setUp(self): # Call super's setUp(). TestBase.setUp(self) - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # the stop reason of the thread should be breakpoint. self.expect("thread list", "A data race should be detected", - substrs = ['stopped', 'stop reason = Data race detected']) + substrs=['stopped', 'stop reason = Data race detected']) - self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", - substrs = ["instrumentation_class", "description", "mops"]) + self.expect( + "thread info -s", + "The extended stop info should contain the TSan provided fields", + substrs=[ + "instrumentation_class", + "description", + "mops"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) @@ -51,4 +63,8 @@ class TsanCPPGlobalLocationTestCase(TestBase): self.assertEqual(data["issue_type"], "data-race") self.assertTrue(data["location_filename"].endswith("/main.cpp")) - self.assertEqual(data["location_line"], line_number('main.cpp', '// global variable')) + self.assertEqual( + data["location_line"], + line_number( + 'main.cpp', + '// global variable')) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py index b268c46fead..cec74eeaf44 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py @@ -2,53 +2,69 @@ Tests that TSan correctly reports the filename and line number of a racy global variable. """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanGlobalLocationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() def setUp(self): # Call super's setUp(). TestBase.setUp(self) - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # the stop reason of the thread should be breakpoint. self.expect("thread list", "A data race should be detected", - substrs = ['stopped', 'stop reason = Data race detected']) + substrs=['stopped', 'stop reason = Data race detected']) - self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", - substrs = ["instrumentation_class", "description", "mops"]) + self.expect( + "thread info -s", + "The extended stop info should contain the TSan provided fields", + substrs=[ + "instrumentation_class", + "description", + "mops"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) data = json.loads(json_line) self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") self.assertEqual(data["issue_type"], "data-race") - + self.assertTrue(data["location_filename"].endswith("/main.c")) - self.assertEqual(data["location_line"], line_number('main.c', '// global variable')) + self.assertEqual( + data["location_line"], + line_number( + 'main.c', + '// global variable')) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py index c22501141cc..b9baaf89b05 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py @@ -2,33 +2,39 @@ Test ThreadSanitizer when multiple different issues are found. """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanMultipleTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() def setUp(self): # Call super's setUp(). TestBase.setUp(self) - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("env TSAN_OPTIONS=abort_on_error=0") @@ -36,34 +42,46 @@ class TsanMultipleTestCase(TestBase): stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") report_count = 0 - while self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() == lldb.eStopReasonInstrumentation: + while self.dbg.GetSelectedTarget().process.GetSelectedThread( + ).GetStopReason() == lldb.eStopReasonInstrumentation: report_count += 1 - stop_description = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopDescription(100) + stop_description = self.dbg.GetSelectedTarget( + ).process.GetSelectedThread().GetStopDescription(100) self.assertTrue( - (stop_description == "Data race detected") or - (stop_description == "Use of deallocated memory detected") or - (stop_description == "Thread leak detected") or - (stop_description == "Use of an uninitialized or destroyed mutex detected") or - (stop_description == "Unlock of an unlocked mutex (or by a wrong thread) detected") + (stop_description == "Data race detected") or + (stop_description == "Use of deallocated memory detected") or + (stop_description == "Thread leak detected") or + (stop_description == "Use of an uninitialized or destroyed mutex detected") or + (stop_description == "Unlock of an unlocked mutex (or by a wrong thread) detected") ) - self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", - substrs = ["instrumentation_class", "description", "mops"]) + self.expect( + "thread info -s", + "The extended stop info should contain the TSan provided fields", + substrs=[ + "instrumentation_class", + "description", + "mops"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) data = json.loads(json_line) self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") - backtraces = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer) + backtraces = self.dbg.GetSelectedTarget().process.GetSelectedThread( + ).GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer) self.assertTrue(backtraces.GetSize() >= 1) self.runCmd("continue") - self.assertEqual(self.dbg.GetSelectedTarget().process.GetState(), lldb.eStateExited, PROCESS_EXITED) + self.assertEqual( + self.dbg.GetSelectedTarget().process.GetState(), + lldb.eStateExited, + PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py index ed620093c1f..45e5dbf9b30 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py @@ -2,39 +2,48 @@ Tests ThreadSanitizer's support to detect a leaked thread. """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanThreadLeakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # the stop reason of the thread should be breakpoint. self.expect("thread list", "A thread leak should be detected", - substrs = ['stopped', 'stop reason = Thread leak detected']) + substrs=['stopped', 'stop reason = Thread leak detected']) - self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + self.assertEqual( + self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonInstrumentation) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py index c7905bcb1c1..abcf1f4eca0 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py @@ -2,51 +2,66 @@ Tests that TSan and LLDB have correct thread numbers. """ -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil import json + class TsanThreadNumbersTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") - @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default + @expectedFailureAll( + oslist=["linux"], + bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") + @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt @skipUnlessThreadSanitizer - def test (self): - self.build () - self.tsan_tests () + def test(self): + self.build() + self.tsan_tests() def setUp(self): # Call super's setUp(). TestBase.setUp(self) - def tsan_tests (self): - exe = os.path.join (os.getcwd(), "a.out") - self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + def tsan_tests(self): + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) self.runCmd("run") stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() if stop_reason == lldb.eStopReasonExec: - # On OS X 10.10 and older, we need to re-exec to enable interceptors. + # On OS X 10.10 and older, we need to re-exec to enable + # interceptors. self.runCmd("continue") # the stop reason of the thread should be breakpoint. self.expect("thread list", "A data race should be detected", - substrs = ['stopped', 'stop reason = Data race detected']) + substrs=['stopped', 'stop reason = Data race detected']) - self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + self.assertEqual( + self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), + lldb.eStopReasonInstrumentation) - report_thread_id = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetIndexID() + report_thread_id = self.dbg.GetSelectedTarget( + ).process.GetSelectedThread().GetIndexID() - self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", - substrs = ["instrumentation_class", "description", "mops"]) + self.expect( + "thread info -s", + "The extended stop info should contain the TSan provided fields", + substrs=[ + "instrumentation_class", + "description", + "mops"]) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) @@ -59,10 +74,15 @@ class TsanThreadNumbersTestCase(TestBase): other_thread_id = data["mops"][1]["thread_id"] self.assertTrue(other_thread_id != report_thread_id) - other_thread = self.dbg.GetSelectedTarget().process.GetThreadByIndexID(other_thread_id) + other_thread = self.dbg.GetSelectedTarget( + ).process.GetThreadByIndexID(other_thread_id) self.assertTrue(other_thread.IsValid()) self.runCmd("thread select %d" % other_thread_id) - self.expect("thread backtrace", "The other thread should be stopped in f1 or f2", - substrs = ["a.out", "main.c"]) + self.expect( + "thread backtrace", + "The other thread should be stopped in f1 or f2", + substrs=[ + "a.out", + "main.c"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py b/lldb/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py index cebba1b4c57..f4268f5bfa9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py @@ -5,14 +5,15 @@ Test lldb command aliases. from __future__ import print_function - import unittest2 -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 LaunchInTerminalTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,18 +25,26 @@ class LaunchInTerminalTestCase(TestBase): @expectedFailureDarwin("llvm.org/pr25484") # If the test is being run under sudo, the spawned terminal won't retain that elevated # privilege so it can't open the socket to talk back to the test case - @unittest2.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, "test cannot be run as root") + @unittest2.skipIf(hasattr(os, 'geteuid') and os.geteuid() + == 0, "test cannot be run as root") # Do we need to disable this test if the testsuite is being run on a remote system? - # This env var is only defined when the shell is running in a local mac terminal window - @unittest2.skipUnless('TERM_PROGRAM' in os.environ, "test must be run on local system") + # This env var is only defined when the shell is running in a local mac + # terminal window + @unittest2.skipUnless( + 'TERM_PROGRAM' in os.environ, + "test must be run on local system") @no_debug_info_test - def test_launch_in_terminal (self): + def test_launch_in_terminal(self): exe = "/bin/ls" target = self.dbg.CreateTarget(exe) launch_info = lldb.SBLaunchInfo(["-lAF", "/tmp/"]) - launch_info.SetLaunchFlags(lldb.eLaunchFlagLaunchInTTY | lldb.eLaunchFlagCloseTTYOnExit) + launch_info.SetLaunchFlags( + lldb.eLaunchFlagLaunchInTTY | lldb.eLaunchFlagCloseTTYOnExit) error = lldb.SBError() - process = target.Launch (launch_info, error) - self.assertTrue(error.Success(), "Make sure launch happened successfully in a terminal window") - # Running in synchronous mode our process should have run and already exited by the time target.Launch() returns + process = target.Launch(launch_info, error) + self.assertTrue( + error.Success(), + "Make sure launch happened successfully in a terminal window") + # Running in synchronous mode our process should have run and already + # exited by the time target.Launch() returns self.assertTrue(process.GetState() == lldb.eStateExited) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py b/lldb/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py index 2bf10204ea6..8d6311e42b9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py @@ -5,32 +5,37 @@ Check that types only get completed when necessary. 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 TypeCompletionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(compiler="icc", bugnumber="often fails with 'NameAndAddress should be valid.") - # Fails with gcc 4.8.1 with llvm.org/pr15301 LLDB prints incorrect sizes of STL containers + @expectedFailureAll( + compiler="icc", + bugnumber="often fails with 'NameAndAddress should be valid.") + # Fails with gcc 4.8.1 with llvm.org/pr15301 LLDB prints incorrect sizes + # of STL containers def test_with_run_command(self): """Check that types only get completed when necessary.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "// Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "// Set break point at this line.") 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']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -42,68 +47,112 @@ class TypeCompletionTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertFalse(p_type.IsTypeComplete(), 'vector<T> complete but it should not be') + self.assertFalse( + p_type.IsTypeComplete(), + 'vector<T> complete but it should not be') self.runCmd("continue") - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertFalse(p_type.IsTypeComplete(), 'vector<T> complete but it should not be') + self.assertFalse( + p_type.IsTypeComplete(), + 'vector<T> complete but it should not be') self.runCmd("continue") self.runCmd("frame variable p --show-types") - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertTrue(p_type.IsTypeComplete(), 'vector<T> should now be complete') + self.assertTrue( + p_type.IsTypeComplete(), + 'vector<T> should now be complete') name_address_type = p_type.GetTemplateArgumentType(0) - self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid') - self.assertFalse(name_address_type.IsTypeComplete(), 'NameAndAddress complete but it should not be') + self.assertTrue( + name_address_type.IsValid(), + 'NameAndAddress should be valid') + self.assertFalse( + name_address_type.IsTypeComplete(), + 'NameAndAddress complete but it should not be') self.runCmd("continue") self.runCmd("frame variable guy --show-types") - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertTrue(p_type.IsTypeComplete(), 'vector<T> should now be complete') + self.assertTrue( + p_type.IsTypeComplete(), + 'vector<T> should now be complete') name_address_type = p_type.GetTemplateArgumentType(0) - self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid') - self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress should now be complete') + self.assertTrue( + name_address_type.IsValid(), + 'NameAndAddress should be valid') + self.assertTrue( + name_address_type.IsTypeComplete(), + 'NameAndAddress should now be complete') field0 = name_address_type.GetFieldAtIndex(0) - self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid') + self.assertTrue( + field0.IsValid(), + 'NameAndAddress::m_name should be valid') string = field0.GetType().GetPointeeType() self.assertTrue(string.IsValid(), 'CustomString should be valid') - self.assertFalse(string.IsTypeComplete(), 'CustomString complete but it should not be') + self.assertFalse(string.IsTypeComplete(), + 'CustomString complete but it should not be') self.runCmd("continue") - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertTrue(p_type.IsTypeComplete(), 'vector<T> should now be complete') + self.assertTrue( + p_type.IsTypeComplete(), + 'vector<T> should now be complete') name_address_type = p_type.GetTemplateArgumentType(0) - self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid') - self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress should now be complete') + self.assertTrue( + name_address_type.IsValid(), + 'NameAndAddress should be valid') + self.assertTrue( + name_address_type.IsTypeComplete(), + 'NameAndAddress should now be complete') field0 = name_address_type.GetFieldAtIndex(0) - self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid') + self.assertTrue( + field0.IsValid(), + 'NameAndAddress::m_name should be valid') string = field0.GetType().GetPointeeType() self.assertTrue(string.IsValid(), 'CustomString should be valid') - self.assertFalse(string.IsTypeComplete(), 'CustomString complete but it should not be') + self.assertFalse(string.IsTypeComplete(), + 'CustomString complete but it should not be') self.runCmd('type category enable -l c++', check=False) self.runCmd('frame variable guy --show-types --ptr-depth=1') - p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p') + p_vector = self.dbg.GetSelectedTarget().GetProcess( + ).GetSelectedThread().GetSelectedFrame().FindVariable('p') p_type = p_vector.GetType() - self.assertTrue(p_type.IsTypeComplete(), 'vector<T> should now be complete') + self.assertTrue( + p_type.IsTypeComplete(), + 'vector<T> should now be complete') name_address_type = p_type.GetTemplateArgumentType(0) - self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid') - self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress should now be complete') + self.assertTrue( + name_address_type.IsValid(), + 'NameAndAddress should be valid') + self.assertTrue( + name_address_type.IsTypeComplete(), + 'NameAndAddress should now be complete') field0 = name_address_type.GetFieldAtIndex(0) - self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid') + self.assertTrue( + field0.IsValid(), + 'NameAndAddress::m_name should be valid') string = field0.GetType().GetPointeeType() self.assertTrue(string.IsValid(), 'CustomString should be valid') - self.assertTrue(string.IsTypeComplete(), 'CustomString should now be complete') + self.assertTrue( + string.IsTypeComplete(), + 'CustomString should now be complete') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py index 774eb437b78..0c415480de8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py @@ -5,14 +5,15 @@ Test type lookup command. from __future__ import print_function - import datetime -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 TypeLookupTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,17 +30,22 @@ class TypeLookupTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 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']) - - self.expect('type lookup NoSuchType', substrs=['@interface'], matching=False) + substrs=['stopped', + 'stop reason = breakpoint']) + + self.expect( + 'type lookup NoSuchType', + substrs=['@interface'], + matching=False) self.expect('type lookup NSURL', substrs=['NSURL']) self.expect('type lookup NSArray', substrs=['NSArray']) self.expect('type lookup NSObject', substrs=['NSObject', 'isa']) - self.expect('type lookup PleaseDontBeARealTypeThatExists', substrs=["no type was found matching 'PleaseDontBeARealTypeThatExists'"]) + self.expect('type lookup PleaseDontBeARealTypeThatExists', substrs=[ + "no type was found matching 'PleaseDontBeARealTypeThatExists'"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py index e17d5d36d39..a855be7536c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py @@ -5,20 +5,20 @@ Test that we can backtrace correctly from Non ABI functions on the stack 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 EHFrameBasedUnwind(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessPlatform(['linux']) @skipIf(archs=["aarch64", "arm", "i386", "i686"]) - def test (self): + def test(self): """Test that we can backtrace correctly from Non ABI functions on the stack""" self.build() self.setTearDownCleanup() @@ -28,9 +28,10 @@ class EHFrameBasedUnwind(TestBase): self.assertTrue(target, VALID_TARGET) - lldbutil.run_break_set_by_symbol (self, "func") + lldbutil.run_break_set_by_symbol(self, "func") - process = target.LaunchSimple (["abc", "xyz"], None, self.get_process_working_directory()) + process = target.LaunchSimple( + ["abc", "xyz"], None, self.get_process_working_directory()) if not process: self.fail("SBTarget.Launch() failed") @@ -42,10 +43,10 @@ class EHFrameBasedUnwind(TestBase): stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, - substrs = ['(int)argc=3']) + substrs=['(int)argc=3']) self.runCmd("thread step-inst") stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, - substrs = ['(int)argc=3']) + substrs=['(int)argc=3']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py index 62c6c16080a..e5c9c907727 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py @@ -5,18 +5,19 @@ Test that we can backtrace correctly with 'noreturn' functions on the stack 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 NoreturnUnwind(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # clang-cl does not support gcc style attributes. - def test (self): + @skipIfWindows # clang-cl does not support gcc style attributes. + def test(self): """Test that we can backtrace correctly with 'noreturn' functions on the stack""" self.build() self.setTearDownCleanup() @@ -25,7 +26,8 @@ class NoreturnUnwind(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - 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") @@ -55,22 +57,27 @@ class NoreturnUnwind(TestBase): self.fail("Unable to find abort() in backtrace.") func_c_frame_number = abort_frame_number + 1 - if thread.GetFrameAtIndex (func_c_frame_number).GetFunctionName() != "func_c": + if thread.GetFrameAtIndex( + func_c_frame_number).GetFunctionName() != "func_c": self.fail("Did not find func_c() above abort().") # This depends on whether we see the func_b inlined function in the backtrace # or not. I'm not interested in testing that aspect of the backtrace here # right now. - if thread.GetFrameAtIndex (func_c_frame_number + 1).GetFunctionName() == "func_b": + if thread.GetFrameAtIndex( + func_c_frame_number + + 1).GetFunctionName() == "func_b": func_a_frame_number = func_c_frame_number + 2 else: func_a_frame_number = func_c_frame_number + 1 - if thread.GetFrameAtIndex (func_a_frame_number).GetFunctionName() != "func_a": + if thread.GetFrameAtIndex( + func_a_frame_number).GetFunctionName() != "func_a": self.fail("Did not find func_a() above func_c().") main_frame_number = func_a_frame_number + 1 - if thread.GetFrameAtIndex (main_frame_number).GetFunctionName() != "main": + if thread.GetFrameAtIndex( + main_frame_number).GetFunctionName() != "main": self.fail("Did not find main() above func_a().") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py index d2b36412f1f..e35bb966c91 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py @@ -5,20 +5,21 @@ Test that we can backtrace correctly with 'sigtramp' functions on the stack 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 SigtrampUnwind(TestBase): mydir = TestBase.compute_mydir(__file__) # On different platforms the "_sigtramp" and "__kill" frames are likely to be different. # This test could probably be adapted to run on linux/*bsd easily enough. @skipUnlessDarwin - def test (self): + def test(self): """Test that we can backtrace correctly with _sigtramp on the stack""" self.build() self.setTearDownCleanup() @@ -27,10 +28,11 @@ class SigtrampUnwind(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) + lldbutil.run_break_set_by_file_and_line(self, "main.c", line_number( + 'main.c', '// Set breakpoint here'), num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.c", line_number('main.c', '// Set breakpoint here'), num_expected_locations=1) - - 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") @@ -40,10 +42,20 @@ class SigtrampUnwind(TestBase): "instead the actual state is: '%s'" % lldbutil.state_type_to_str(process.GetState())) - self.expect("pro handle -n false -p true -s false SIGUSR1", "Have lldb pass SIGUSR1 signals", - substrs = ["SIGUSR1", "true", "false", "false"]) - - lldbutil.run_break_set_by_symbol (self, "handler", num_expected_locations=1, module_name="a.out") + self.expect( + "pro handle -n false -p true -s false SIGUSR1", + "Have lldb pass SIGUSR1 signals", + substrs=[ + "SIGUSR1", + "true", + "false", + "false"]) + + lldbutil.run_break_set_by_symbol( + self, + "handler", + num_expected_locations=1, + module_name="a.out") self.runCmd("continue") @@ -69,14 +81,14 @@ class SigtrampUnwind(TestBase): for f in thread.frames: print(" %d %s" % (f.GetFrameID(), f.GetFunctionName())) - if found_handler == False: + if not found_handler: self.fail("Unable to find handler() in backtrace.") - if found_sigtramp == False: + if not found_sigtramp: self.fail("Unable to find _sigtramp() in backtrace.") - if found_kill == False: + if not found_kill: self.fail("Unable to find kill() in backtrace.") - if found_main == False: + if not found_main: self.fail("Unable to find main() in backtrace.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py index 20532c6fc67..2416128d2ef 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py @@ -13,9 +13,9 @@ after escaping some special characters). from __future__ import print_function - import unittest2 -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -23,10 +23,11 @@ from lldbsuite.test import lldbutil test_source_dirs = ["."] + class StandardUnwindTest(TestBase): mydir = TestBase.compute_mydir(__file__) - def standard_unwind_tests (self): + def standard_unwind_tests(self): # The following variables have to be defined for each architecture and OS we testing for: # base_function_names: List of function names where we accept that the stack unwinding is # correct if they are on the stack. It should include the bottom most @@ -36,20 +37,27 @@ class StandardUnwindTest(TestBase): # instruction by instruction for any reason. (A valid reason is if # it is impossible to step through a function instruction by # instruction because it is special for some reason.) For these - # functions we will immediately do a step-out when we hit them. + # functions we will immediately do a step-out when we hit them. triple = self.dbg.GetSelectedPlatform().GetTriple() if re.match("arm-.*-.*-android", triple): base_function_names = [ "_start", # Base function on the stack "__memcpy_base", # Function reached by a fall through from the previous function - "__memcpy_base_aligned", # Function reached by a fall through from the previous function + "__memcpy_base_aligned", + # Function reached by a fall through from the previous function ] no_step_function_names = [ - "__sync_fetch_and_add_4", # Calls into a special SO where we can't set a breakpoint - "pthread_mutex_lock", # Uses ldrex and strex what interferes with the software single stepping - "pthread_mutex_unlock", # Uses ldrex and strex what interferes with the software single stepping - "pthread_once", # Uses ldrex and strex what interferes with the software single stepping + "__sync_fetch_and_add_4", # Calls into a special SO where we can't set a breakpoint + "pthread_mutex_lock", + # Uses ldrex and strex what interferes with the software single + # stepping + "pthread_mutex_unlock", + # Uses ldrex and strex what interferes with the software single + # stepping + "pthread_once", + # Uses ldrex and strex what interferes with the software single + # stepping ] elif re.match("aarch64-.*-.*-android", triple): base_function_names = [ @@ -57,11 +65,21 @@ class StandardUnwindTest(TestBase): ] no_step_function_names = [ None, - "__cxa_guard_acquire", # Uses ldxr and stxr what interferes with the software single stepping - "__cxa_guard_release", # Uses ldxr and stxr what interferes with the software single stepping - "pthread_mutex_lock", # Uses ldxr and stxr what interferes with the software single stepping - "pthread_mutex_unlock", # Uses ldxr and stxr what interferes with the software single stepping - "pthread_once", # Uses ldxr and stxr what interferes with the software single stepping + "__cxa_guard_acquire", + # Uses ldxr and stxr what interferes with the software single + # stepping + "__cxa_guard_release", + # Uses ldxr and stxr what interferes with the software single + # stepping + "pthread_mutex_lock", + # Uses ldxr and stxr what interferes with the software single + # stepping + "pthread_mutex_unlock", + # Uses ldxr and stxr what interferes with the software single + # stepping + "pthread_once", + # Uses ldxr and stxr what interferes with the software single + # stepping ] else: self.skipTest("No expectations for the current architecture") @@ -72,17 +90,23 @@ class StandardUnwindTest(TestBase): target.BreakpointCreateByName("main") - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process is not None, "SBTarget.Launch() failed") - self.assertEqual(process.GetState(), lldb.eStateStopped, "The process didn't hit main") + self.assertEqual( + process.GetState(), + lldb.eStateStopped, + "The process didn't hit main") index = 0 while process.GetState() == lldb.eStateStopped: index += 1 if process.GetNumThreads() > 1: # In case of a multi threaded inferior if one of the thread is stopped in a blocking - # syscall and we try to step it then SBThread::StepInstruction() will block forever - self.skipTest("Multi threaded inferiors are not supported by this test") + # syscall and we try to step it then + # SBThread::StepInstruction() will block forever + self.skipTest( + "Multi threaded inferiors are not supported by this test") thread = process.GetThreadAtIndex(0) @@ -97,9 +121,11 @@ class StandardUnwindTest(TestBase): if f.GetFunctionName() in base_function_names: found_main = True break - self.assertTrue(found_main, "Main function isn't found on the backtrace") + self.assertTrue(found_main, + "Main function isn't found on the backtrace") - if thread.GetFrameAtIndex(0).GetFunctionName() in no_step_function_names: + if thread.GetFrameAtIndex( + 0).GetFunctionName() in no_step_function_names: thread.StepOut() else: thread.StepInstruction(False) @@ -113,13 +139,16 @@ for d in test_source_dirs: dirname = os.path.join(os.path.dirname(__file__), d) for root, _, files in os.walk(dirname): - test_source_files = test_source_files | set(os.path.abspath(os.path.join(root, f)) for f in files) + test_source_files = test_source_files | set( + os.path.abspath(os.path.join(root, f)) for f in files) # Generate test cases based on the collected source files for f in test_source_files: if f.endswith(".cpp") or f.endswith(".c"): @add_test_categories(["dwarf"]) - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") def test_function_dwarf(self, f=f): if f.endswith(".cpp"): d = {'CXX_SOURCES': f} @@ -143,4 +172,7 @@ for f in test_source_files: test_name = test_name.replace(c, '_') test_function_dwarf.__name__ = test_name - setattr(StandardUnwindTest, test_function_dwarf.__name__, test_function_dwarf) + setattr( + StandardUnwindTest, + test_function_dwarf.__name__, + test_function_dwarf) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py b/lldb/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py index cbea7d22cc4..8e3ab853e27 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py @@ -5,13 +5,14 @@ Verify that the hash computing logic for ValueObject's values can't crash us. 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 ValueMD5CrashTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -28,26 +29,27 @@ class ValueMD5CrashTestCase(TestBase): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) value = self.frame().FindVariable("a") value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) - + v = value.GetValue() type_name = value.GetTypeName() self.assertTrue(type_name == "B *", "a is a B*") - + self.runCmd("next") self.runCmd("process kill") - + # now the process is dead, and value needs updating v = value.GetValue() - + # if we are here, instead of crashed, the test succeeded diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py index 933f21a90bb..6a68730e08e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py @@ -5,14 +5,15 @@ Test lldb watchpoint that uses '-s size' to watch a pointed location with size. 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 HelloWatchLocationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,18 +24,31 @@ class HelloWatchLocationTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # This is for verifying that watch location works. - self.violating_func = "do_bad_thing_with_location"; - # Build dictionary to have unique executable names for each test method. + self.violating_func = "do_bad_thing_with_location" + # Build dictionary to have unique executable names for each test + # method. self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(triple = re.compile('^mips')) # Most of the MIPS boards provide only one H/W watchpoints, and S/W watchpoints are not supported yet - @expectedFailureAll(archs=['s390x']) # SystemZ also currently supports only one H/W watchpoint - @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27795") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Most of the MIPS boards provide only one H/W watchpoints, and S/W + # watchpoints are not supported yet + @expectedFailureAll(triple=re.compile('^mips')) + # SystemZ also currently supports only one H/W watchpoint + @expectedFailureAll(archs=['s390x']) + @expectedFailureAll( + oslist=["linux"], + archs=[ + "arm", + "aarch64"], + bugnumber="llvm.org/pr27795") @skipIfDarwin def test_hello_watchlocation(self): """Test watching a location with '-s size' option.""" @@ -44,7 +58,8 @@ class HelloWatchLocationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1, loc_exact=False) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1, loc_exact=False) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -52,48 +67,56 @@ class HelloWatchLocationTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint pointed to by 'g_char_ptr'. - self.expect("watchpoint set expression -w write -s 1 -- g_char_ptr", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 1', 'type = w']) + self.expect( + "watchpoint set expression -w write -s 1 -- g_char_ptr", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 1', + 'type = w']) # Get a hold of the watchpoint id just created, it is used later on to # match the watchpoint id which is expected to be fired. - match = re.match("Watchpoint created: Watchpoint (.*):", self.res.GetOutput().splitlines()[0]) + match = re.match( + "Watchpoint created: Watchpoint (.*):", + self.res.GetOutput().splitlines()[0]) if match: expected_wp_id = int(match.group(1), 0) else: - self.fail("Grokking watchpoint id faailed!") + self.fail("Grokking watchpoint id faailed!") self.runCmd("expr unsigned val = *g_char_ptr; val") self.expect(self.res.GetOutput().splitlines()[0], exe=False, - endstr = ' = 0') + endstr=' = 0') self.runCmd("watchpoint set expression -w write -s 4 -- &threads[0]") # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but # only once. The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', - 'stop reason = watchpoint %d' % expected_wp_id]) + substrs=['stopped', + 'stop reason = watchpoint %d' % expected_wp_id]) - # Switch to the thread stopped due to watchpoint and issue some commands. + # Switch to the thread stopped due to watchpoint and issue some + # commands. self.switch_to_thread_with_stop_reason(lldb.eStopReasonWatchpoint) self.runCmd("thread backtrace") self.expect("frame info", - substrs = [self.violating_func]) + substrs=[self.violating_func]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) self.runCmd("thread backtrace all") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py index 5214c7f5e08..c74452fd375 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py @@ -5,16 +5,17 @@ Test my first lldb watchpoint. 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 HelloWatchpointTestCase(TestBase): - def getCategories (self): + def getCategories(self): return ['basic_process'] mydir = TestBase.compute_mydir(__file__) @@ -25,14 +26,19 @@ class HelloWatchpointTestCase(TestBase): # Our simple source filename. self.source = 'main.c' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') + self.decl = line_number(self.source, + '// Watchpoint variable declaration.') self.exe_name = 'a.out' self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_hello_watchpoint_using_watchpoint_set(self): """Test a simple sequence of watchpoint creation and watchpoint hit.""" self.build(dictionary=self.d) @@ -42,7 +48,8 @@ class HelloWatchpointTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -50,36 +57,45 @@ class HelloWatchpointTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. # There should be only one watchpoint hit (see main.c). - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but # only once. The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', - 'stop reason = watchpoint']) + substrs=['stopped', + 'stop reason = watchpoint']) self.runCmd("process continue") # Don't expect the read of 'global' to trigger a stop exception. process = self.dbg.GetSelectedTarget().GetProcess() if process.GetState() == lldb.eStateStopped: - self.assertFalse(lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint)) + self.assertFalse( + lldbutil.get_stopped_thread( + process, lldb.eStopReasonWatchpoint)) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py index af8306c9a20..78273d6ec69 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py @@ -5,28 +5,35 @@ Test that lldb watchpoint works for multiple threads. 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 WatchpointForMultipleThreadsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchpoint_multiple_threads(self): """Test that lldb watchpoint works for multiple threads.""" self.build() self.setTearDownCleanup() self.hello_multiple_threads() - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchpoint_multiple_threads_wp_set_and_then_delete(self): """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires.""" self.build() @@ -39,14 +46,21 @@ class WatchpointForMultipleThreadsTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.first_stop = line_number(self.source, '// Set break point at this line') + self.first_stop = line_number( + self.source, '// Set break point at this line') def hello_multiple_threads(self): """Test that lldb watchpoint works for multiple threads.""" - self.runCmd("file %s" % os.path.join(os.getcwd(), 'a.out'), CURRENT_EXECUTABLE_SET) + self.runCmd( + "file %s" % + os.path.join( + os.getcwd(), + 'a.out'), + CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.first_stop, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.first_stop, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -54,17 +68,22 @@ class WatchpointForMultipleThreadsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for variable 'g_val'. - self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w']) + self.expect( + "watchpoint set variable -w write g_val", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) while True: self.runCmd("process continue") @@ -80,14 +99,20 @@ class WatchpointForMultipleThreadsTestCase(TestBase): # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) def hello_multiple_threads_wp_set_and_then_delete(self): """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires.""" - self.runCmd("file %s" % os.path.join(os.getcwd(), 'a.out'), CURRENT_EXECUTABLE_SET) + self.runCmd( + "file %s" % + os.path.join( + os.getcwd(), + 'a.out'), + CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.first_stop, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.first_stop, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -95,17 +120,22 @@ class WatchpointForMultipleThreadsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for variable 'g_val'. - self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w']) + self.expect( + "watchpoint set variable -w write g_val", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) watchpoint_stops = 0 while True: @@ -120,13 +150,17 @@ class WatchpointForMultipleThreadsTestCase(TestBase): self.runCmd("thread backtrace all") watchpoint_stops += 1 if watchpoint_stops > 1: - self.fail("Watchpoint hits not supposed to exceed 1 by design!") - # Good, we verified that the watchpoint works! Now delete the watchpoint. + self.fail( + "Watchpoint hits not supposed to exceed 1 by design!") + # Good, we verified that the watchpoint works! Now delete the + # watchpoint. if self.TraceOn(): - print("watchpoint_stops=%d at the moment we delete the watchpoint" % watchpoint_stops) + print( + "watchpoint_stops=%d at the moment we delete the watchpoint" % + watchpoint_stops) self.runCmd("watchpoint delete 1") self.expect("watchpoint list -v", - substrs = ['No watchpoints currently set.']) + substrs=['No watchpoints currently set.']) continue else: self.fail("The stop reason should be either break or watchpoint") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py index 22011f11352..f1d7acfcc5e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py @@ -3,7 +3,6 @@ from __future__ import print_function - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -17,10 +16,19 @@ class TestStepOverWatchpoint(TestBase): def getCategories(self): return ['basic_process'] - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=['aarch64', 'arm'], bugnumber="llvm.org/pr26031") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=[ + 'aarch64', + 'arm'], + bugnumber="llvm.org/pr26031") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test(self): """Test stepping over watchpoints.""" self.build() @@ -73,9 +81,10 @@ class TestStepOverWatchpoint(TestBase): lldb.eValueTypeVariableGlobal) self.assertTrue(write_value, "Failed to find write value.") - # Most of the MIPS boards provide only one H/W watchpoints, and S/W watchpoints are not supported yet + # Most of the MIPS boards provide only one H/W watchpoints, and S/W + # watchpoints are not supported yet arch = self.getArchitecture() - if re.match("^mips",arch): + if re.match("^mips", arch): self.runCmd("watchpoint delete 1") # resolve_location=True, read=False, write=True diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py index 21f1fb68426..d3074149763 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py @@ -5,13 +5,14 @@ Test that a variable watchpoint should only hit when in scope. from __future__ import print_function - import unittest2 -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class WatchedVariableHitWhenInScopeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -20,7 +21,7 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): # This test depends on not tracking watchpoint expression hits if we have # left the watchpoint scope. We will provide such an ability at some point # but the way this was done was incorrect, and it is unclear that for the - # most part that's not what folks mostly want, so we have to provide a + # most part that's not what folks mostly want, so we have to provide a # clearer API to express this. # @@ -42,7 +43,8 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped in main. - lldbutil.run_break_set_by_symbol (self, "main", num_expected_locations=-1) + lldbutil.run_break_set_by_symbol( + self, "main", num_expected_locations=-1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -50,34 +52,34 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a watchpoint for 'c.a'. # There should be only one watchpoint hit (see main.c). self.expect("watchpoint set variable c.a", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w']) + substrs=['Watchpoint created', 'size = 4', 'type = w']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but # only once. The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', - 'stop reason = watchpoint']) + substrs=['stopped', + 'stop reason = watchpoint']) self.runCmd("process continue") # Don't expect the read of 'global' to trigger a stop exception. # The process status should be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py index 4ce05af96e2..7a9904c53f8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py @@ -5,13 +5,14 @@ Test watchpoint list, enable, disable, and delete commands. 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 WatchpointCommandsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,27 +23,37 @@ class WatchpointCommandsTestCase(TestBase): # Our simple source filename. self.source = 'main.c' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') - self.line2 = line_number(self.source, '// Set 2nd break point for disable_then_enable test case.') + self.line = line_number( + self.source, '// Set break point at this line.') + self.line2 = line_number( + self.source, + '// Set 2nd break point for disable_then_enable test case.') # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') - # Build dictionary to have unique executable names for each test method. + self.decl = line_number(self.source, + '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test + # method. self.exe_name = self.testMethodName self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_rw_watchpoint(self): """Test read_write watchpoint and expect to stop two times.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - + exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -50,60 +61,72 @@ class WatchpointCommandsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a read_write-type watchpoint for 'global'. # There should be two watchpoint hits (see main.c). - self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w read_write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = rw', + '%s:%d' % + (self.source, + self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['Number of supported hardware watchpoints:', - 'hit_count = 0']) + substrs=['Number of supported hardware watchpoints:', + 'hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (read_write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (read_write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) self.runCmd("process continue") # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 2. self.expect("watchpoint list -v", - substrs = ['hit_count = 2']) - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + substrs=['hit_count = 2']) + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_rw_watchpoint_delete(self): """Test delete watchpoint and expect not to stop for watchpoint.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - + exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -111,19 +134,27 @@ class WatchpointCommandsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a read_write-type watchpoint for 'global'. # There should be two watchpoint hits (see main.c). - self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) - - # Delete the watchpoint immediately, but set auto-confirm to true first. + self.expect( + "watchpoint set variable -w read_write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = rw', + '%s:%d' % + (self.source, + self.decl)]) + + # Delete the watchpoint immediately, but set auto-confirm to true + # first. self.runCmd("settings set auto-confirm true") self.expect("watchpoint delete", - substrs = ['All watchpoints removed.']) + substrs=['All watchpoints removed.']) # Restore the original setting of auto-confirm. self.runCmd("settings clear auto-confirm") @@ -135,21 +166,26 @@ class WatchpointCommandsTestCase(TestBase): # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + substrs=['exited']) + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_rw_watchpoint_set_ignore_count(self): """Test watchpoint ignore count and expect to not to stop at all.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - + exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -157,49 +193,61 @@ class WatchpointCommandsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a read_write-type watchpoint for 'global'. # There should be two watchpoint hits (see main.c). - self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w read_write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = rw', + '%s:%d' % + (self.source, + self.decl)]) # Set the ignore count of the watchpoint immediately. self.expect("watchpoint ignore -i 2", - substrs = ['All watchpoints ignored.']) + substrs=['All watchpoints ignored.']) # Use the '-v' option to do verbose listing of the watchpoint. # Expect to find an ignore_count of 2. self.expect("watchpoint list -v", - substrs = ['hit_count = 0', 'ignore_count = 2']) + substrs=['hit_count = 0', 'ignore_count = 2']) self.runCmd("process continue") # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) # Use the '-v' option to do verbose listing of the watchpoint. # Expect to find a hit_count of 2 as well. self.expect("watchpoint list -v", - substrs = ['hit_count = 2', 'ignore_count = 2']) - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + substrs=['hit_count = 2', 'ignore_count = 2']) + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_rw_disable_after_first_stop(self): """Test read_write watchpoint but disable it after the first stop.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - + exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -207,49 +255,60 @@ class WatchpointCommandsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a read_write-type watchpoint for 'global'. # There should be two watchpoint hits (see main.c). - self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w read_write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = rw', + '%s:%d' % + (self.source, + self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['state = enabled', 'hit_count = 0']) + substrs=['state = enabled', 'hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (read_write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) # Before continuing, we'll disable the watchpoint, which means we won't # stop again after this. self.runCmd("watchpoint disable") self.expect("watchpoint list -v", - substrs = ['state = disabled', 'hit_count = 1']) + substrs=['state = disabled', 'hit_count = 1']) self.runCmd("process continue") # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + substrs=['hit_count = 1']) + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_rw_disable_then_enable(self): """Test read_write watchpoint, disable initially, then enable it.""" self.build(dictionary=self.d) @@ -259,8 +318,10 @@ class WatchpointCommandsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, None, self.line2, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line2, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -268,14 +329,21 @@ class WatchpointCommandsTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a read_write-type watchpoint for 'global'. # There should be two watchpoint hits (see main.c). - self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w read_write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = rw', + '%s:%d' % + (self.source, + self.decl)]) # Immediately, we disable the watchpoint. We won't be stopping due to a # watchpoint after this. @@ -284,36 +352,36 @@ class WatchpointCommandsTestCase(TestBase): # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['state = disabled', 'hit_count = 0']) + substrs=['state = disabled', 'hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the breakpoint. self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stop reason = breakpoint']) + substrs=['stop reason = breakpoint']) # Before continuing, we'll enable the watchpoint, which means we will # stop again after this. self.runCmd("watchpoint enable") self.expect("watchpoint list -v", - substrs = ['state = enabled', 'hit_count = 0']) + substrs=['state = enabled', 'hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (read_write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) self.runCmd("process continue") # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py index ee276dd5687..5b89f14dd85 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py @@ -5,13 +5,14 @@ Test 'watchpoint command'. 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 WatchpointLLDBCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,26 +23,36 @@ class WatchpointLLDBCommandTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') - # Build dictionary to have unique executable names for each test method. + self.decl = line_number(self.source, + '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test + # method. self.exe_name = 'a%d.out' % self.test_number self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - + exe = os.path.join(os.getcwd(), self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -49,44 +60,58 @@ class WatchpointLLDBCommandTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) self.runCmd('watchpoint command add 1 -o "expr -- cookie = 777"') # List the watchpoint command we just added. self.expect("watchpoint command list 1", - substrs = ['expr -- cookie = 777']) + substrs=['expr -- cookie = 777']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) # Check that the watchpoint snapshoting mechanism is working. self.expect("watchpoint list -v", - substrs = ['old value:', ' = 0', - 'new value:', ' = 1']) + substrs=['old value:', ' = 0', + 'new value:', ' = 1']) - # The watchpoint command "forced" our global variable 'cookie' to become 777. + # The watchpoint command "forced" our global variable 'cookie' to + # become 777. self.expect("frame variable --show-globals cookie", - substrs = ['(int32_t)', 'cookie = 777']) - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + substrs=['(int32_t)', 'cookie = 777']) + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchpoint_command_can_disable_a_watchpoint(self): """Test that 'watchpoint command' action can disable a watchpoint after it is triggered.""" self.build(dictionary=self.d) @@ -96,7 +121,8 @@ class WatchpointLLDBCommandTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -104,39 +130,46 @@ class WatchpointLLDBCommandTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) self.runCmd('watchpoint command add 1 -o "watchpoint disable 1"') # List the watchpoint command we just added. self.expect("watchpoint command list 1", - substrs = ['watchpoint disable 1']) + substrs=['watchpoint disable 1']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) # Check that the watchpoint has been disabled. self.expect("watchpoint list -v", - substrs = ['disabled']) + substrs=['disabled']) self.runCmd("process continue") # There should be no more watchpoint hit and the process status should # be 'exited'. self.expect("process status", - substrs = ['exited']) + substrs=['exited']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py index f6ea4fc1686..494ea2e4a54 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py @@ -5,13 +5,14 @@ Test 'watchpoint command'. 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 WatchpointPythonCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,17 +23,26 @@ class WatchpointPythonCommandTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') - # Build dictionary to have unique executable names for each test method. + self.decl = line_number(self.source, + '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test + # method. self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") + @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) @@ -42,7 +52,8 @@ class WatchpointPythonCommandTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, # startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % # (self.source, self.line))# @@ -53,46 +64,62 @@ class WatchpointPythonCommandTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) - - self.runCmd('watchpoint command add -s python 1 -o \'frame.EvaluateExpression("cookie = 777")\'') + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) + + self.runCmd( + 'watchpoint command add -s python 1 -o \'frame.EvaluateExpression("cookie = 777")\'') # List the watchpoint command we just added. self.expect("watchpoint command list 1", - substrs = ['frame.EvaluateExpression', 'cookie = 777']) + substrs=['frame.EvaluateExpression', 'cookie = 777']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) # Check that the watchpoint snapshoting mechanism is working. self.expect("watchpoint list -v", - substrs = ['old value:', ' = 0', - 'new value:', ' = 1']) + substrs=['old value:', ' = 0', + 'new value:', ' = 1']) - # The watchpoint command "forced" our global variable 'cookie' to become 777. + # The watchpoint command "forced" our global variable 'cookie' to + # become 777. self.expect("frame variable --show-globals cookie", - substrs = ['(int32_t)', 'cookie = 777']) - - @skipIfFreeBSD # timing out on buildbot - @expectedFailureAll(bugnumber="llvm.org/pr28055: continue in watchpoint commands disables the watchpoint") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") + substrs=['(int32_t)', 'cookie = 777']) + + @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll( + bugnumber="llvm.org/pr28055: continue in watchpoint commands disables the watchpoint") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") def test_continue_in_watchpoint_command(self): """Test continue in a watchpoint command.""" self.build(dictionary=self.d) @@ -102,7 +129,8 @@ class WatchpointPythonCommandTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, # startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % # (self.source, self.line))# @@ -113,31 +141,39 @@ class WatchpointPythonCommandTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) cmd_script_file = os.path.join(os.getcwd(), "watchpoint_command.py") - self.runCmd("command script import '%s'"%(cmd_script_file)) + self.runCmd("command script import '%s'" % (cmd_script_file)) - self.runCmd('watchpoint command add -F watchpoint_command.watchpoint_command') + self.runCmd( + 'watchpoint command add -F watchpoint_command.watchpoint_command') # List the watchpoint command we just added. self.expect("watchpoint command list 1", - substrs = ['watchpoint_command.watchpoint_command']) + substrs=['watchpoint_command.watchpoint_command']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) # We should have hit the watchpoint once, set cookie to 888, then continued to the # second hit and set it to 999 self.expect("frame variable --show-globals cookie", - substrs = ['(int32_t)', 'cookie = 999']) + substrs=['(int32_t)', 'cookie = 999']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py index 575a5160d21..ae5913a500e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py @@ -1,7 +1,9 @@ import lldb num_hits = 0 -def watchpoint_command (frame, wp, dict): + + +def watchpoint_command(frame, wp, dict): global num_hits if num_hits == 0: print ("I stopped the first time") @@ -9,6 +11,5 @@ def watchpoint_command (frame, wp, dict): num_hits += 1 frame.thread.process.Continue() else: - print ("I stopped the %d time"%(num_hits)) + print ("I stopped the %d time" % (num_hits)) frame.EvaluateExpression("cookie = 999") - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py index 64e01e5cb93..5a16856149b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py @@ -5,13 +5,14 @@ Test watchpoint modify command to set condition on a watchpoint. 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 WatchpointConditionCmdTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,16 +23,25 @@ class WatchpointConditionCmdTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') - # Build dictionary to have unique executable names for each test method. + self.decl = line_number(self.source, + '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test + # method. self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchpoint_cond(self): """Test watchpoint condition.""" self.build(dictionary=self.d) @@ -41,7 +51,8 @@ class WatchpointConditionCmdTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -49,32 +60,39 @@ class WatchpointConditionCmdTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint for 'global'. # With a condition of 'global==5'. - self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + self.expect( + "watchpoint set variable -w write global", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 4', + 'type = w', + '%s:%d' % + (self.source, + self.decl)]) self.runCmd("watchpoint modify -c 'global==5'") # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0', 'global==5']) + substrs=['hit_count = 0', 'global==5']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type). # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) + substrs=['stop reason = watchpoint']) self.expect("frame variable --show-globals global", - substrs = ['(int32_t)', 'global = 5']) + substrs=['(int32_t)', 'global = 5']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 2. self.expect("watchpoint list -v", - substrs = ['hit_count = 5']) + substrs=['hit_count = 5']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py index f8435befae5..02180a127a8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.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 TestWatchpointEvents (TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,51 +22,65 @@ class TestWatchpointEvents (TestBase): self.main_source = "main.c" @add_test_categories(['pyapi']) - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=["aarch64"], + bugnumber="llvm.org/pr27710") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_with_python_api(self): """Test that adding, deleting and modifying watchpoints sends the appropriate events.""" self.build() - + exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - self.main_source_spec = lldb.SBFileSpec (self.main_source) + self.main_source_spec = lldb.SBFileSpec(self.main_source) - break_in_main = target.BreakpointCreateBySourceRegex ('// Put a breakpoint here.', self.main_source_spec) + break_in_main = target.BreakpointCreateBySourceRegex( + '// Put a breakpoint here.', self.main_source_spec) self.assertTrue(break_in_main, VALID_BREAKPOINT) # 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()) self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint (process, break_in_main) + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, break_in_main) if len(threads) != 1: - self.fail ("Failed to stop at first breakpoint in main.") + self.fail("Failed to stop at first breakpoint in main.") thread = threads[0] frame = thread.GetFrameAtIndex(0) - local_var = frame.FindVariable ("local_var") - self.assertTrue (local_var.IsValid()) + local_var = frame.FindVariable("local_var") + self.assertTrue(local_var.IsValid()) self.listener = lldb.SBListener("com.lldb.testsuite_listener") self.target_bcast = target.GetBroadcaster() - self.target_bcast.AddListener (self.listener, lldb.SBTarget.eBroadcastBitWatchpointChanged) - self.listener.StartListeningForEvents (self.target_bcast, lldb.SBTarget.eBroadcastBitWatchpointChanged) + self.target_bcast.AddListener( + self.listener, lldb.SBTarget.eBroadcastBitWatchpointChanged) + self.listener.StartListeningForEvents( + self.target_bcast, lldb.SBTarget.eBroadcastBitWatchpointChanged) error = lldb.SBError() local_watch = local_var.Watch(True, False, True, error) if not error.Success(): - self.fail ("Failed to make watchpoint for local_var: %s"%(error.GetCString())) + self.fail( + "Failed to make watchpoint for local_var: %s" % + (error.GetCString())) self.GetWatchpointEvent(lldb.eWatchpointEventTypeAdded) - # Now change some of the features of this watchpoint and make sure we get events: + # Now change some of the features of this watchpoint and make sure we + # get events: local_watch.SetEnabled(False) self.GetWatchpointEvent(lldb.eWatchpointEventTypeDisabled) @@ -79,19 +94,27 @@ class TestWatchpointEvents (TestBase): local_watch.SetCondition(condition) self.GetWatchpointEvent(lldb.eWatchpointEventTypeConditionChanged) - self.assertTrue(local_watch.GetCondition() == condition, 'make sure watchpoint condition is "' + condition + '"'); - - def GetWatchpointEvent (self, event_type): + self.assertTrue(local_watch.GetCondition() == condition, + 'make sure watchpoint condition is "' + condition + '"') + + def GetWatchpointEvent(self, event_type): # We added a watchpoint so we should get a watchpoint added event. event = lldb.SBEvent() - success = self.listener.WaitForEvent (1, event) - self.assertTrue(success == True, "Successfully got watchpoint event") - self.assertTrue (lldb.SBWatchpoint.EventIsWatchpointEvent(event), "Event is a watchpoint event.") - found_type = lldb.SBWatchpoint.GetWatchpointEventTypeFromEvent (event) - self.assertTrue (found_type == event_type, "Event is not correct type, expected: %d, found: %d"%(event_type, found_type)) + success = self.listener.WaitForEvent(1, event) + self.assertTrue(success, "Successfully got watchpoint event") + self.assertTrue( + lldb.SBWatchpoint.EventIsWatchpointEvent(event), + "Event is a watchpoint event.") + found_type = lldb.SBWatchpoint.GetWatchpointEventTypeFromEvent(event) + self.assertTrue( + found_type == event_type, + "Event is not correct type, expected: %d, found: %d" % + (event_type, + found_type)) # There shouldn't be another event waiting around: - found_event = self.listener.PeekAtNextEventForBroadcasterWithType (self.target_bcast, lldb.SBTarget.eBroadcastBitBreakpointChanged, event) + found_event = self.listener.PeekAtNextEventForBroadcasterWithType( + self.target_bcast, lldb.SBTarget.eBroadcastBitBreakpointChanged, event) if found_event: print("Found an event I didn't expect: ", event) - self.assertTrue (not found_event, "Only one event per change.") + self.assertTrue(not found_event, "Only one event per change.") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py index c66ddb51288..3f301fd9f1a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py @@ -5,25 +5,29 @@ Test displayed value of a vector variable while doing watchpoint operations 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 TestValueOfVectorVariableTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_value_of_vector_variable_using_watchpoint_set(self): """Test verify displayed value of vector variable.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) self.value_of_vector_variable_with_watchpoint_set() - + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -39,10 +43,12 @@ class TestValueOfVectorVariableTestCase(TestBase): # Set break to get a frame self.runCmd("b main") - + # Run the program. self.runCmd("run", RUN_SUCCEEDED) # Value of a vector variable should be displayed correctly - self.expect("watchpoint set variable global_vector", WATCHPOINT_CREATED, - substrs = ['new value: (1, 2, 3, 4)']) + self.expect( + "watchpoint set variable global_vector", + WATCHPOINT_CREATED, + substrs=['new value: (1, 2, 3, 4)']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py index 735a5678c4f..1a94276c58e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py @@ -5,13 +5,14 @@ Test lldb watchpoint that uses 'watchpoint set -w write -s size' to watch a poin 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 WatchLocationUsingWatchpointSetTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,14 +23,24 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # This is for verifying that watch location works. - self.violating_func = "do_bad_thing_with_location"; - # Build dictionary to have unique executable names for each test method. - - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["linux"], archs=['aarch64', 'arm'], bugnumber="llvm.org/pr26031") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + self.violating_func = "do_bad_thing_with_location" + # Build dictionary to have unique executable names for each test + # method. + + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["linux"], + archs=[ + 'aarch64', + 'arm'], + bugnumber="llvm.org/pr26031") + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_watchlocation_using_watchpoint_set(self): """Test watching a location with 'watchpoint set expression -w write -s size' option.""" self.build() @@ -39,7 +50,8 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -47,45 +59,52 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Now let's set a write-type watchpoint pointed to by 'g_char_ptr' and # with offset as 7. # The main.cpp, by design, misbehaves by not following the agreed upon # protocol of only accessing the allowable index range of [0, 6]. - self.expect("watchpoint set expression -w write -s 1 -- g_char_ptr + 7", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 1', 'type = w']) + self.expect( + "watchpoint set expression -w write -s 1 -- g_char_ptr + 7", + WATCHPOINT_CREATED, + substrs=[ + 'Watchpoint created', + 'size = 1', + 'type = w']) self.runCmd("expr unsigned val = g_char_ptr[7]; val") self.expect(self.res.GetOutput().splitlines()[0], exe=False, - endstr = ' = 0') + endstr=' = 0') # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. self.expect("watchpoint list -v", - substrs = ['hit_count = 0']) + substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but # only once. The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', - 'stop reason = watchpoint', - self.violating_func]) + substrs=['stopped', + 'stop reason = watchpoint', + self.violating_func]) - # Switch to the thread stopped due to watchpoint and issue some commands. + # Switch to the thread stopped due to watchpoint and issue some + # commands. self.switch_to_thread_with_stop_reason(lldb.eStopReasonWatchpoint) self.runCmd("thread backtrace") self.runCmd("expr unsigned val = g_char_ptr[7]; val") self.expect(self.res.GetOutput().splitlines()[0], exe=False, - endstr = ' = 99') + endstr=' = 99') # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be the same as the number of threads that # stopped on a watchpoint. - threads = lldbutil.get_stopped_threads(self.process(), lldb.eStopReasonWatchpoint) + threads = lldbutil.get_stopped_threads( + self.process(), lldb.eStopReasonWatchpoint) self.expect("watchpoint list -v", - substrs = ['hit_count = %d' % len(threads)]) + substrs=['hit_count = %d' % len(threads)]) self.runCmd("thread backtrace all") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py index 43597ec28f5..269b7c9b44e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py @@ -5,13 +5,14 @@ Test error cases for the 'watchpoint set' command to make sure it errors out whe from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil + class WatchpointSetErrorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,8 +23,10 @@ class WatchpointSetErrorTestCase(TestBase): # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') - # Build dictionary to have unique executable names for each test method. + self.line = line_number( + self.source, '// Set break point at this line.') + # Build dictionary to have unique executable names for each test + # method. @expectedFailureAll(oslist=["windows"]) def test_error_cases_with_watchpoint_set(self): @@ -35,7 +38,8 @@ class WatchpointSetErrorTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line( + self, None, self.line, num_expected_locations=1) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -43,27 +47,29 @@ class WatchpointSetErrorTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Try some error conditions: # 'watchpoint set' is now a multiword command. self.expect("watchpoint set", - substrs = ['The following subcommands are supported:', - 'expression', - 'variable']) + substrs=['The following subcommands are supported:', + 'expression', + 'variable']) self.runCmd("watchpoint set variable -w read_write", check=False) # 'watchpoint set expression' with '-w' or '-s' specified now needs # an option terminator and a raw expression after that. self.expect("watchpoint set expression -w write --", error=True, - startstr = 'error: ') + startstr='error: ') # It's an error if the expression did not evaluate to an address. - self.expect("watchpoint set expression MyAggregateDataType", error=True, - startstr = 'error: expression did not evaluate to an address') + self.expect( + "watchpoint set expression MyAggregateDataType", + error=True, + startstr='error: expression did not evaluate to an address') # Wrong size parameter is an error. self.expect("watchpoint set variable -s -128", error=True, - substrs = ['invalid enumeration value']) + substrs=['invalid enumeration value']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py index 55e36649ce1..e342e34667f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py @@ -7,12 +7,14 @@ when they are packed in a 8-byte region. 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 WatchpointSizeTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -29,23 +31,35 @@ class WatchpointSizeTestCase(TestBase): self.exe_name = 'a.out' self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_byte_size_watchpoints_with_byte_selection(self): """Test to selectively watch different bytes in a 8-byte array.""" self.run_watchpoint_size_test('byteArray', 8, '1') - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_two_byte_watchpoints_with_word_selection(self): """Test to selectively watch different words in an 8-byte word array.""" self.run_watchpoint_size_test('wordArray', 4, '2') - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ + # Watchpoints not supported + @expectedFailureAndroid(archs=['arm', 'aarch64']) + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) def test_four_byte_watchpoints_with_dword_selection(self): """Test to selectively watch two double words in an 8-byte dword array.""" self.run_watchpoint_size_test('dwordArray', 2, '4') @@ -61,8 +75,8 @@ class WatchpointSizeTestCase(TestBase): loc_line = line_number('main.c', '// About to write ' + arrayName) # Set a breakpoint on the line detected above. - lldbutil.run_break_set_by_file_and_line (self, "main.c",loc_line, - num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.c", loc_line, num_expected_locations=1, loc_exact=True) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -71,46 +85,55 @@ class WatchpointSizeTestCase(TestBase): # We should be stopped again due to the breakpoint. # 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']) # Set a read_write type watchpoint arrayName - watch_loc=arrayName+"[" + str(i) + "]" - self.expect("watchpoint set variable -w read_write " + watch_loc, + watch_loc = arrayName + "[" + str(i) + "]" + self.expect( + "watchpoint set variable -w read_write " + + watch_loc, WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = ' + watchsize, 'type = rw']) + substrs=[ + 'Watchpoint created', + 'size = ' + + watchsize, + 'type = rw']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. - self.expect("watchpoint list -v", substrs = ['hit_count = 0']) + self.expect("watchpoint list -v", substrs=['hit_count = 0']) self.runCmd("process continue") # We should be stopped due to the watchpoint. # The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', 'stop reason = watchpoint']) + substrs=['stopped', 'stop reason = watchpoint']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", - substrs = ['hit_count = 1']) + substrs=['hit_count = 1']) self.runCmd("process continue") # We should be stopped due to the watchpoint. # The stop reason of the thread should be watchpoint. self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', 'stop reason = watchpoint']) + substrs=['stopped', 'stop reason = watchpoint']) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. # Verify hit_count has been updated after value has been read. self.expect("watchpoint list -v", - substrs = ['hit_count = 2']) + substrs=['hit_count = 2']) - # Delete the watchpoint immediately, but set auto-confirm to true first. + # Delete the watchpoint immediately, but set auto-confirm to true + # first. self.runCmd("settings set auto-confirm true") - self.expect("watchpoint delete", substrs = ['All watchpoints removed.']) + self.expect( + "watchpoint delete", + substrs=['All watchpoints removed.']) # Restore the original setting of auto-confirm. self.runCmd("settings clear auto-confirm") |