From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: =?UTF-8?q?***=20This=20commit=20represents=20a=20complete=20refor?= =?UTF-8?q?matting=20of=20the=20LLDB=20source=20code=20***=20to=20conform?= =?UTF-8?q?=20to=20clang-format=E2=80=99s=20LLVM=20style.=20=20This=20kind?= =?UTF-8?q?=20of=20mass=20change=20has=20***=20two=20obvious=20implication?= =?UTF-8?q?s:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751 --- .../TestPublicAPIHeaders.py | 36 ++++++++++------ .../lldbsuite/test/api/listeners/TestListener.py | 38 ++++++++++++----- .../multiple-debuggers/TestMultipleDebuggers.py | 21 +++++++--- .../test/api/multithreaded/TestMultithreaded.py | 48 ++++++++++++++-------- 4 files changed, 97 insertions(+), 46 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/api') diff --git a/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py b/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py index 0ed2df3..0b202a0 100644 --- a/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py +++ b/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py @@ -6,12 +6,13 @@ should compile and link with the LLDB framework.""" from __future__ import print_function - -import os, re +import os +import re from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class SBDirCheckerCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,7 +31,8 @@ class SBDirCheckerCase(TestBase): if not (self.platformIsDarwin() and self.getArchitecture() == "x86_64"): self.skipTest("This test is only for LLDB.framework built 64-bit") if self.getArchitecture() == "i386": - self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.") + self.skipTest( + "LLDB is 64-bit and cannot be linked to 32-bit test program.") # Generate main.cpp, build it, and execute. self.generate_main_cpp() @@ -43,7 +45,8 @@ class SBDirCheckerCase(TestBase): with open(temp, 'r') as f: content = f.read() - public_api_dir = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API") + public_api_dir = os.path.join( + os.environ["LLDB_SRC"], "include", "lldb", "API") # Look under the include/lldb/API directory and add #include statements # for all the SB API headers. @@ -51,10 +54,11 @@ class SBDirCheckerCase(TestBase): # For different platforms, the include statement can vary. if self.platformIsDarwin(): include_stmt = "'#include <%s>' % os.path.join('LLDB', header)" - if self.getPlatform() == "freebsd" or self.getPlatform() == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': + if self.getPlatform() == "freebsd" or self.getPlatform( + ) == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)" - list = [eval(include_stmt) for header in public_headers if (header.startswith("SB") and - header.endswith(".h"))] + list = [eval(include_stmt) for header in public_headers if ( + header.startswith("SB") and header.endswith(".h"))] includes = '\n'.join(list) new_content = content.replace('%include_SB_APIs%', includes) src = os.path.join(os.getcwd(), self.source) @@ -69,21 +73,27 @@ class SBDirCheckerCase(TestBase): exe = os.path.join(os.getcwd(), exe_name) self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET) - self.line_to_break = line_number(self.source, '// Set breakpoint here.') + self.line_to_break = line_number( + self.source, '// Set breakpoint here.') - env_cmd = "settings set target.env-vars %s=%s" %(self.dylibPath, self.getLLDBLibraryEnvVal()) + env_cmd = "settings set target.env-vars %s=%s" % ( + self.dylibPath, self.getLLDBLibraryEnvVal()) if self.TraceOn(): print("Set environment to: ", env_cmd) self.runCmd(env_cmd) - self.addTearDownHook(lambda: self.dbg.HandleCommand("settings remove target.env-vars %s" % self.dylibPath)) + self.addTearDownHook( + lambda: self.dbg.HandleCommand( + "settings remove target.env-vars %s" % + self.dylibPath)) - lldbutil.run_break_set_by_file_and_line (self, self.source, self.line_to_break, num_expected_locations = -1) + lldbutil.run_break_set_by_file_and_line( + self, self.source, self.line_to_break, 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']) self.runCmd('frame variable') diff --git a/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py b/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py index bd8c204..65232f0 100644 --- a/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py +++ b/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py @@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil import six + class ListenToModuleLoadedEvents (TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,14 +25,17 @@ class ListenToModuleLoadedEvents (TestBase): TestBase.setUp(self) self.build() - def test_receiving_breakpoint_added (self): + def test_receiving_breakpoint_added(self): """Test that we get breakpoint added events, waiting on event classes on the debugger""" my_listener = lldb.SBListener("test_listener") - - my_listener.StartListeningForEventClass(self.dbg, lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitBreakpointChanged) - exe = os.path.join (os.getcwd(), "a.out") + my_listener.StartListeningForEventClass( + self.dbg, + lldb.SBTarget.GetBroadcasterClassName(), + lldb.SBTarget.eBroadcastBitBreakpointChanged) + + exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -39,17 +43,29 @@ class ListenToModuleLoadedEvents (TestBase): event = lldb.SBEvent() my_listener.WaitForEvent(1, event) - + self.assertTrue(event.IsValid(), "Got a valid event.") - self.assertTrue(lldb.SBBreakpoint.EventIsBreakpointEvent(event), "It is a breakpoint event.") - self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") - self.assertTrue(bkpt == lldb.SBBreakpoint.GetBreakpointFromEvent(event), "It is our breakpoint.") + self.assertTrue( + lldb.SBBreakpoint.EventIsBreakpointEvent(event), + "It is a breakpoint event.") + self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent( + event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") + self.assertTrue( + bkpt == lldb.SBBreakpoint.GetBreakpointFromEvent(event), + "It is our breakpoint.") # Now make sure if we stop listening for events we don't get them: - my_listener.StopListeningForEventClass(self.dbg, lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitBreakpointChanged) - my_listener.StopListeningForEvents(target.GetBroadcaster(), lldb.SBTarget.eBroadcastBitBreakpointChanged) + my_listener.StopListeningForEventClass( + self.dbg, + lldb.SBTarget.GetBroadcasterClassName(), + lldb.SBTarget.eBroadcastBitBreakpointChanged) + my_listener.StopListeningForEvents( + target.GetBroadcaster(), + lldb.SBTarget.eBroadcastBitBreakpointChanged) bkpt2 = target.BreakpointCreateByName("main") my_listener.WaitForEvent(1, event) - self.assertTrue(not event.IsValid(), "We don't get events we aren't listening to.") + self.assertTrue( + not event.IsValid(), + "We don't get events we aren't listening to.") diff --git a/lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py b/lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py index ca2b986..ca8a69c 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py +++ b/lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py @@ -3,8 +3,8 @@ from __future__ import print_function - -import os, re +import os +import re import subprocess import lldb @@ -12,16 +12,24 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestMultipleSimultaneousDebuggers(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfNoSBHeaders @expectedFlakeyDarwin() - @expectedFailureAll(archs="i[3-6]86", bugnumber="multi-process-driver.cpp creates an x64 target") - @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr20282") + @expectedFailureAll( + archs="i[3-6]86", + bugnumber="multi-process-driver.cpp creates an x64 target") + @expectedFailureAll( + oslist=[ + "windows", + "linux", + "freebsd"], + bugnumber="llvm.org/pr20282") def test_multiple_debuggers(self): - env = {self.dylibPath : self.getLLDBLibraryEnvVal()} + env = {self.dylibPath: self.getLLDBLibraryEnvVal()} self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver") self.buildDriver('multi-process-driver.cpp', self.driver_exe) @@ -41,4 +49,5 @@ class TestMultipleSimultaneousDebuggers(TestBase): check_call([self.driver_exe, self.inferior_exe], env=env) else: with open(os.devnull, 'w') as fnull: - check_call([self.driver_exe, self.inferior_exe], env=env, stdout=fnull, stderr=fnull) + check_call([self.driver_exe, self.inferior_exe], + env=env, stdout=fnull, stderr=fnull) diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py index 7959bb7..970c251 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -5,19 +5,22 @@ from __future__ import print_function # __package__ = "lldbsuite.test" -import os, re +import os +import re from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil import subprocess + class SBBreakpointCallbackCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfRemote @skipIfNoSBHeaders - @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) + # clang-cl does not support throw or catch (llvm.org/pr24538) + @skipIfWindows def test_breakpoint_callback(self): """Test the that SBBreakpoint callback is invoked when a breakpoint is hit. """ self.build_and_test('driver.cpp test_breakpoint_callback.cpp', @@ -25,40 +28,52 @@ class SBBreakpointCallbackCase(TestBase): @skipIfRemote @skipIfNoSBHeaders - @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) + # clang-cl does not support throw or catch (llvm.org/pr24538) + @skipIfWindows @expectedFlakeyFreeBSD def test_sb_api_listener_event_description(self): """ Test the description of an SBListener breakpoint event is valid.""" - self.build_and_test('driver.cpp listener_test.cpp test_listener_event_description.cpp', - 'test_listener_event_description') + self.build_and_test( + 'driver.cpp listener_test.cpp test_listener_event_description.cpp', + 'test_listener_event_description') pass @skipIfRemote @skipIfNoSBHeaders - @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) + # clang-cl does not support throw or catch (llvm.org/pr24538) + @skipIfWindows @expectedFlakeyFreeBSD - @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"]) + @expectedFailureAll( + "llvm.org/pr23139", + oslist=["linux"], + compiler="gcc", + compiler_version=[ + ">=", + "4.9"], + archs=["x86_64"]) def test_sb_api_listener_event_process_state(self): """ Test that a registered SBListener receives events when a process changes state. """ - self.build_and_test('driver.cpp listener_test.cpp test_listener_event_process_state.cpp', - 'test_listener_event_process_state') + self.build_and_test( + 'driver.cpp listener_test.cpp test_listener_event_process_state.cpp', + 'test_listener_event_process_state') pass - @skipIfRemote @skipIfNoSBHeaders - @skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538) + # clang-cl does not support throw or catch (llvm.org/pr24538) + @skipIfWindows @expectedFlakeyFreeBSD @expectedFailureAll(oslist=["linux"]) def test_sb_api_listener_resume(self): """ Test that a process can be resumed from a non-main thread. """ - self.build_and_test('driver.cpp listener_test.cpp test_listener_resume.cpp', - 'test_listener_resume') + self.build_and_test( + 'driver.cpp listener_test.cpp test_listener_resume.cpp', + 'test_listener_resume') pass - def build_and_test(self, sources, test_name, args = None): + def build_and_test(self, sources, test_name, args=None): """ Build LLDB test from sources, and run expecting 0 exit code """ # These tests link against host lldb API. @@ -66,7 +81,8 @@ class SBBreakpointCallbackCase(TestBase): # because remote is disabled, we can assume that the os is the same # still need to check architecture if self.getLldbArchitecture() != self.getArchitecture(): - self.skipTest("This test is only run if the target arch is the same as the lldb binary arch") + self.skipTest( + "This test is only run if the target arch is the same as the lldb binary arch") self.inferior = 'inferior_program' self.buildProgram('inferior.cpp', self.inferior) @@ -79,7 +95,7 @@ class SBBreakpointCallbackCase(TestBase): self.signBinary(test_exe) exe = [test_exe, self.inferior] - env = {self.dylibPath : self.getLLDBLibraryEnvVal()} + env = {self.dylibPath: self.getLLDBLibraryEnvVal()} if self.TraceOn(): print("Running test %s" % " ".join(exe)) check_call(exe, env=env) -- cgit v1.1