From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: *** This commit represents a complete reformatting of the LLDB source code *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: 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 --- .../add-dsym/TestAddDsymMidExecutionCommand.py | 14 +- .../apple_types/TestAppleTypesIsProduced.py | 10 +- .../macosx/indirect_symbol/TestIndirectSymbols.py | 94 ++++-- .../test/macosx/nslog/TestDarwinNSLogOutput.py | 5 +- .../lldbsuite/test/macosx/order/TestOrderFile.py | 7 +- .../lldbsuite/test/macosx/queues/TestQueues.py | 367 ++++++++++++++------- .../macosx/safe-to-func-call/TestSafeFuncCalls.py | 47 +-- .../test/macosx/universal/TestUniversal.py | 73 ++-- 8 files changed, 391 insertions(+), 226 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/macosx') diff --git a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py index f4f6e313a1f..ec20ee2a24c 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py @@ -3,14 +3,15 @@ from __future__ import print_function - -import os, time +import os +import time import lldb import sys from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class AddDsymMidExecutionCommandCase(TestBase): @@ -21,7 +22,7 @@ class AddDsymMidExecutionCommandCase(TestBase): TestBase.setUp(self) self.source = 'main.c' - @no_debug_info_test # Prevent the genaration of the dwarf version of this test + @no_debug_info_test # Prevent the genaration of the dwarf version of this test def test_add_dsym_mid_execution(self): """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary.""" self.buildDsym(clean=True) @@ -30,11 +31,12 @@ class AddDsymMidExecutionCommandCase(TestBase): self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - main_bp = self.target.BreakpointCreateByName ("main", "a.out") + main_bp = self.target.BreakpointCreateByName("main", "a.out") self.assertTrue(main_bp, VALID_BREAKPOINT) self.runCmd("settings set target.disable-aslr false") - 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) # The stop reason of the thread should be breakpoint. @@ -44,4 +46,4 @@ class AddDsymMidExecutionCommandCase(TestBase): self.runCmd("add-dsym hide.app/Contents/a.out.dSYM") self.expect("frame select", - substrs = ['a.out`main at main.c']) + substrs=['a.out`main at main.c']) diff --git a/lldb/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py b/lldb/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py index afd933dc211..ff1ca2a9381 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py @@ -5,19 +5,20 @@ Test that clang produces the __apple accelerator tables, for example, __apple_ty 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 from lldbsuite.test.lldbutil import symbol_type_to_str + class AppleTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - #rdar://problem/11166975 + # rdar://problem/11166975 @skipUnlessDarwin def test_debug_info_for_apple_types(self): """Test that __apple_types section does get produced by clang.""" @@ -27,7 +28,8 @@ class AppleTypesTestCase(TestBase): self.build() if self.debug_info == "dsym": - exe = os.path.join(os.getcwd(), "a.out.dSYM/Contents/Resources/DWARF/a.out") + exe = os.path.join(os.getcwd(), + "a.out.dSYM/Contents/Resources/DWARF/a.out") else: exe = os.path.join(os.getcwd(), "main.o") diff --git a/lldb/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py b/lldb/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py index f8b884003ad..e717e2ecdd9 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.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 TestIndirectFunctions(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,60 +31,83 @@ class TestIndirectFunctions(TestBase): 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) - break1 = target.BreakpointCreateBySourceRegex ("Set breakpoint here to step in indirect.", self.main_source_spec) + break1 = target.BreakpointCreateBySourceRegex( + "Set breakpoint here to step in indirect.", self.main_source_spec) self.assertTrue(break1, VALID_BREAKPOINT) - break2 = target.BreakpointCreateBySourceRegex ("Set breakpoint here to step in reexported.", self.main_source_spec) + break2 = target.BreakpointCreateBySourceRegex( + "Set breakpoint here to step in reexported.", self.main_source_spec) self.assertTrue(break2, 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, break1) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") thread = threads[0] - # Now do a step-into, and we should end up in the hidden target of this indirect function. + # Now do a step-into, and we should end up in the hidden target of this + # indirect function. thread.StepInto() curr_function = thread.GetFrameAtIndex(0).GetFunctionName() - self.assertTrue (curr_function == "call_through_indirect_hidden", "Stepped into indirect symbols.") - - # Now set a breakpoint using the indirect symbol name, and make sure we get to that: - break_indirect = target.BreakpointCreateByName ("call_through_indirect"); - self.assertTrue (break_indirect, VALID_BREAKPOINT) - - # Now continue should take us to the second call through the indirect symbol: - - threads = lldbutil.continue_to_breakpoint (process, break_indirect) - self.assertTrue (len(threads) == 1, "Stopped at breakpoint in indirect function.") + self.assertTrue( + curr_function == "call_through_indirect_hidden", + "Stepped into indirect symbols.") + + # Now set a breakpoint using the indirect symbol name, and make sure we + # get to that: + break_indirect = target.BreakpointCreateByName("call_through_indirect") + self.assertTrue(break_indirect, VALID_BREAKPOINT) + + # Now continue should take us to the second call through the indirect + # symbol: + + threads = lldbutil.continue_to_breakpoint(process, break_indirect) + self.assertTrue( + len(threads) == 1, + "Stopped at breakpoint in indirect function.") curr_function = thread.GetFrameAtIndex(0).GetFunctionName() - self.assertTrue (curr_function == "call_through_indirect_hidden", "Stepped into indirect symbols.") + self.assertTrue( + curr_function == "call_through_indirect_hidden", + "Stepped into indirect symbols.") # Delete this breakpoint so it won't get in the way: - target.BreakpointDelete (break_indirect.GetID()) + target.BreakpointDelete(break_indirect.GetID()) - # Now continue to the site of the first re-exported function call in main: - threads = lldbutil.continue_to_breakpoint (process, break2) + # Now continue to the site of the first re-exported function call in + # main: + threads = lldbutil.continue_to_breakpoint(process, break2) - # This is stepping Into through a re-exported symbol to an indirect symbol: + # This is stepping Into through a re-exported symbol to an indirect + # symbol: thread.StepInto() curr_function = thread.GetFrameAtIndex(0).GetFunctionName() - self.assertTrue (curr_function == "call_through_indirect_hidden", "Stepped into indirect symbols.") - - # And the last bit is to set a breakpoint on the re-exported symbol and make sure we are again in out target function. - break_reexported = target.BreakpointCreateByName ("reexport_to_indirect"); - self.assertTrue (break_reexported, VALID_BREAKPOINT) - - # Now continue should take us to the second call through the indirect symbol: - - threads = lldbutil.continue_to_breakpoint (process, break_reexported) - self.assertTrue (len(threads) == 1, "Stopped at breakpoint in reexported function target.") + self.assertTrue( + curr_function == "call_through_indirect_hidden", + "Stepped into indirect symbols.") + + # And the last bit is to set a breakpoint on the re-exported symbol and + # make sure we are again in out target function. + break_reexported = target.BreakpointCreateByName( + "reexport_to_indirect") + self.assertTrue(break_reexported, VALID_BREAKPOINT) + + # Now continue should take us to the second call through the indirect + # symbol: + + threads = lldbutil.continue_to_breakpoint(process, break_reexported) + self.assertTrue( + len(threads) == 1, + "Stopped at breakpoint in reexported function target.") curr_function = thread.GetFrameAtIndex(0).GetFunctionName() - self.assertTrue (curr_function == "call_through_indirect_hidden", "Stepped into indirect symbols.") + self.assertTrue( + curr_function == "call_through_indirect_hidden", + "Stepped into indirect symbols.") diff --git a/lldb/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py b/lldb/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py index 15d25bb713a..1e9596785f9 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py @@ -18,6 +18,7 @@ from lldbsuite.test import decorators from lldbsuite.test import lldbtest from lldbsuite.test import lldbtest_config + @decorators.skipUnlessDarwin class DarwinNSLogOutputTestCase(lldbtest.TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -125,7 +126,9 @@ class DarwinNSLogOutputTestCase(lldbtest.TestBase): ]) self.assertIsNotNone(self.child.match) self.assertGreater(len(self.child.match.groups()), 0) - self.assertEqual("This is a message from NSLog", self.child.match.group(1)) + self.assertEqual( + "This is a message from NSLog", + self.child.match.group(1)) def test_nslog_output_is_suppressed_with_env_var(self): """Test that NSLog() output does not show up with the ignore env var.""" diff --git a/lldb/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py b/lldb/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py index db2e071914c..a70878f73e2 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py @@ -5,14 +5,15 @@ Test that debug symbols have the correct order as specified by the order file. 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 OrderFileTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,7 +31,7 @@ class OrderFileTestCase(TestBase): output = self.res.GetOutput() mo_f3 = re.search("Code +.+f3", output) mo_f1 = re.search("Code +.+f1", output) - + # Match objects for f3 and f1 must exist and f3 must come before f1. self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), "Symbols have correct order by the order file") diff --git a/lldb/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/lldb/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py index 81384cb7e76..2d86f860d52 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py @@ -3,20 +3,21 @@ 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 TestQueues(TestBase): mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin - @add_test_categories(['pyapi']) + @add_test_categories(['pyapi']) def test_with_python_api(self): """Test queues inspection SB APIs.""" self.build() @@ -30,16 +31,34 @@ class TestQueues(TestBase): self.main_source = "main.c" def check_queue_for_valid_queue_id(self, queue): - self.assertTrue(queue.GetQueueID() != 0, "Check queue %s for valid QueueID (got 0x%x)" % (queue.GetName(), queue.GetQueueID())) - - def check_running_and_pending_items_on_queue(self, queue, expected_running, expected_pending): - self.assertTrue(queue.GetNumPendingItems() == expected_pending, "queue %s should have %d pending items, instead has %d pending items" % (queue.GetName(), expected_pending, (queue.GetNumPendingItems()))) - self.assertTrue(queue.GetNumRunningItems() == expected_running, "queue %s should have %d running items, instead has %d running items" % (queue.GetName(), expected_running, (queue.GetNumRunningItems()))) + self.assertTrue( + queue.GetQueueID() != 0, "Check queue %s for valid QueueID (got 0x%x)" % + (queue.GetName(), queue.GetQueueID())) + + def check_running_and_pending_items_on_queue( + self, queue, expected_running, expected_pending): + self.assertTrue( + queue.GetNumPendingItems() == expected_pending, + "queue %s should have %d pending items, instead has %d pending items" % + (queue.GetName(), + expected_pending, + (queue.GetNumPendingItems()))) + self.assertTrue( + queue.GetNumRunningItems() == expected_running, + "queue %s should have %d running items, instead has %d running items" % + (queue.GetName(), + expected_running, + (queue.GetNumRunningItems()))) def check_number_of_threads_owned_by_queue(self, queue, number_threads): - self.assertTrue(queue.GetNumThreads() == number_threads, "queue %s should have %d thread executing, but has %d" % (queue.GetName(), number_threads, queue.GetNumThreads())) - - def check_queue_kind (self, queue, kind): + self.assertTrue( + queue.GetNumThreads() == number_threads, + "queue %s should have %d thread executing, but has %d" % + (queue.GetName(), + number_threads, + queue.GetNumThreads())) + + def check_queue_kind(self, queue, kind): expected_kind_string = "Unknown" if kind == lldb.eQueueKindSerial: expected_kind_string = "Serial queue" @@ -50,15 +69,39 @@ class TestQueues(TestBase): actual_kind_string = "Serial queue" if queue.GetKind() == lldb.eQueueKindConcurrent: actual_kind_string = "Concurrent queue" - self.assertTrue(queue.GetKind() == kind, "queue %s is expected to be a %s but it is actually a %s" % (queue.GetName(), expected_kind_string, actual_kind_string)) + self.assertTrue( + queue.GetKind() == kind, + "queue %s is expected to be a %s but it is actually a %s" % + (queue.GetName(), + expected_kind_string, + actual_kind_string)) def check_queues_threads_match_queue(self, queue): for idx in range(0, queue.GetNumThreads()): t = queue.GetThreadAtIndex(idx) - self.assertTrue(t.IsValid(), "Queue %s's thread #%d must be valid" % (queue.GetName(), idx)) - self.assertTrue(t.GetQueueID() == queue.GetQueueID(), "Queue %s has a QueueID of %d but its thread #%d has a QueueID of %d" % (queue.GetName(), queue.GetQueueID(), idx, t.GetQueueID())) - self.assertTrue(t.GetQueueName() == queue.GetName(), "Queue %s has a QueueName of %s but its thread #%d has a QueueName of %s" % (queue.GetName(), queue.GetName(), idx, t.GetQueueName())) - self.assertTrue(t.GetQueue().GetQueueID() == queue.GetQueueID(), "Thread #%d's Queue's QueueID of %d is not the same as the QueueID of its owning queue %d" % (idx, t.GetQueue().GetQueueID(), queue.GetQueueID())) + self.assertTrue( + t.IsValid(), "Queue %s's thread #%d must be valid" % + (queue.GetName(), idx)) + self.assertTrue( + t.GetQueueID() == queue.GetQueueID(), + "Queue %s has a QueueID of %d but its thread #%d has a QueueID of %d" % + (queue.GetName(), + queue.GetQueueID(), + idx, + t.GetQueueID())) + self.assertTrue( + t.GetQueueName() == queue.GetName(), + "Queue %s has a QueueName of %s but its thread #%d has a QueueName of %s" % + (queue.GetName(), + queue.GetName(), + idx, + t.GetQueueName())) + self.assertTrue( + t.GetQueue().GetQueueID() == queue.GetQueueID(), + "Thread #%d's Queue's QueueID of %d is not the same as the QueueID of its owning queue %d" % + (idx, + t.GetQueue().GetQueueID(), + queue.GetQueueID())) def queues(self): """Test queues inspection SB APIs without libBacktraceRecording.""" @@ -66,53 +109,58 @@ class TestQueues(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - self.main_source_spec = lldb.SBFileSpec (self.main_source) - break1 = target.BreakpointCreateByName ("stopper", 'a.out') + self.main_source_spec = lldb.SBFileSpec(self.main_source) + break1 = target.BreakpointCreateByName("stopper", 'a.out') self.assertTrue(break1, 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) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, break1) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") queue_submittor_1 = lldb.SBQueue() queue_performer_1 = lldb.SBQueue() queue_performer_2 = lldb.SBQueue() queue_performer_3 = lldb.SBQueue() - for idx in range (0, process.GetNumQueues()): - q = process.GetQueueAtIndex(idx) - if q.GetName() == "com.apple.work_submittor_1": - queue_submittor_1 = q - if q.GetName() == "com.apple.work_performer_1": - queue_performer_1 = q - if q.GetName() == "com.apple.work_performer_2": - queue_performer_2 = q - if q.GetName() == "com.apple.work_performer_3": - queue_performer_3 = q - - self.assertTrue(queue_submittor_1.IsValid() and queue_performer_1.IsValid() and queue_performer_2.IsValid() and queue_performer_3.IsValid(), "Got all four expected queues: %s %s %s %s" % (queue_submittor_1.IsValid(), queue_performer_1.IsValid(), queue_performer_2.IsValid(), queue_performer_3.IsValid())) - - self.check_queue_for_valid_queue_id (queue_submittor_1) - self.check_queue_for_valid_queue_id (queue_performer_1) - self.check_queue_for_valid_queue_id (queue_performer_2) - self.check_queue_for_valid_queue_id (queue_performer_3) - - self.check_number_of_threads_owned_by_queue (queue_submittor_1, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_1, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_2, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_3, 4) - - self.check_queue_kind (queue_submittor_1, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_1, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_2, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_3, lldb.eQueueKindConcurrent) - - self.check_queues_threads_match_queue (queue_submittor_1) - self.check_queues_threads_match_queue (queue_performer_1) - self.check_queues_threads_match_queue (queue_performer_2) - self.check_queues_threads_match_queue (queue_performer_3) - - + for idx in range(0, process.GetNumQueues()): + q = process.GetQueueAtIndex(idx) + if q.GetName() == "com.apple.work_submittor_1": + queue_submittor_1 = q + if q.GetName() == "com.apple.work_performer_1": + queue_performer_1 = q + if q.GetName() == "com.apple.work_performer_2": + queue_performer_2 = q + if q.GetName() == "com.apple.work_performer_3": + queue_performer_3 = q + + self.assertTrue( + queue_submittor_1.IsValid() and queue_performer_1.IsValid() and queue_performer_2.IsValid() and queue_performer_3.IsValid(), + "Got all four expected queues: %s %s %s %s" % + (queue_submittor_1.IsValid(), + queue_performer_1.IsValid(), + queue_performer_2.IsValid(), + queue_performer_3.IsValid())) + + self.check_queue_for_valid_queue_id(queue_submittor_1) + self.check_queue_for_valid_queue_id(queue_performer_1) + self.check_queue_for_valid_queue_id(queue_performer_2) + self.check_queue_for_valid_queue_id(queue_performer_3) + + self.check_number_of_threads_owned_by_queue(queue_submittor_1, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_1, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_2, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_3, 4) + + self.check_queue_kind(queue_submittor_1, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_1, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_2, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_3, lldb.eQueueKindConcurrent) + + self.check_queues_threads_match_queue(queue_submittor_1) + self.check_queues_threads_match_queue(queue_performer_1) + self.check_queues_threads_match_queue(queue_performer_2) + self.check_queues_threads_match_queue(queue_performer_3) # We have threads running with all the different dispatch QoS service # levels - find those threads and check that we can get the correct @@ -135,109 +183,172 @@ class TestQueues(TestBase): if th.GetName() == "background QoS": background_thread = th - self.assertTrue(user_initiated_thread.IsValid(), "Found user initiated QoS thread") - self.assertTrue(user_interactive_thread.IsValid(), "Found user interactive QoS thread") + self.assertTrue( + user_initiated_thread.IsValid(), + "Found user initiated QoS thread") + self.assertTrue( + user_interactive_thread.IsValid(), + "Found user interactive QoS thread") self.assertTrue(utility_thread.IsValid(), "Found utility QoS thread") - self.assertTrue(unspecified_thread.IsValid(), "Found unspecified QoS thread") - self.assertTrue(background_thread.IsValid(), "Found background QoS thread") + self.assertTrue( + unspecified_thread.IsValid(), + "Found unspecified QoS thread") + self.assertTrue( + background_thread.IsValid(), + "Found background QoS thread") stream = lldb.SBStream() - self.assertTrue(user_initiated_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for user initiated QoS thread") - self.assertTrue(stream.GetData() == "User Initiated", "user initiated QoS thread name is valid") + self.assertTrue( + user_initiated_thread.GetInfoItemByPathAsString( + "requested_qos.printable_name", + stream), + "Get QoS printable string for user initiated QoS thread") + self.assertTrue( + stream.GetData() == "User Initiated", + "user initiated QoS thread name is valid") stream.Clear() - self.assertTrue(user_interactive_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for user interactive QoS thread") - self.assertTrue(stream.GetData() == "User Interactive", "user interactive QoS thread name is valid") + self.assertTrue( + user_interactive_thread.GetInfoItemByPathAsString( + "requested_qos.printable_name", + stream), + "Get QoS printable string for user interactive QoS thread") + self.assertTrue( + stream.GetData() == "User Interactive", + "user interactive QoS thread name is valid") stream.Clear() - self.assertTrue(utility_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for utility QoS thread") - self.assertTrue(stream.GetData() == "Utility", "utility QoS thread name is valid") + self.assertTrue( + utility_thread.GetInfoItemByPathAsString( + "requested_qos.printable_name", + stream), + "Get QoS printable string for utility QoS thread") + self.assertTrue( + stream.GetData() == "Utility", + "utility QoS thread name is valid") stream.Clear() - self.assertTrue(unspecified_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for unspecified QoS thread") - self.assertTrue(stream.GetData() == "User Initiated", "unspecified QoS thread name is valid") + self.assertTrue( + unspecified_thread.GetInfoItemByPathAsString( + "requested_qos.printable_name", + stream), + "Get QoS printable string for unspecified QoS thread") + self.assertTrue( + stream.GetData() == "User Initiated", + "unspecified QoS thread name is valid") stream.Clear() - self.assertTrue(background_thread.GetInfoItemByPathAsString("requested_qos.printable_name", stream), "Get QoS printable string for background QoS thread") - self.assertTrue(stream.GetData() == "Background", "background QoS thread name is valid") + self.assertTrue( + background_thread.GetInfoItemByPathAsString( + "requested_qos.printable_name", + stream), + "Get QoS printable string for background QoS thread") + self.assertTrue( + stream.GetData() == "Background", + "background QoS thread name is valid") def queues_with_libBacktraceRecording(self): """Test queues inspection SB APIs with libBacktraceRecording present.""" exe = os.path.join(os.getcwd(), "a.out") - if not os.path.isfile('/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib'): - self.skipTest ("Skipped because libBacktraceRecording.dylib was present on the system.") - - if not os.path.isfile('/usr/lib/system/introspection/libdispatch.dylib'): - self.skipTest ("Skipped because introspection libdispatch dylib is not present.") - + if not os.path.isfile( + '/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib'): + self.skipTest( + "Skipped because libBacktraceRecording.dylib was present on the system.") + + if not os.path.isfile( + '/usr/lib/system/introspection/libdispatch.dylib'): + self.skipTest( + "Skipped because introspection libdispatch dylib is not present.") + 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) - break1 = target.BreakpointCreateByName ("stopper", 'a.out') + break1 = target.BreakpointCreateByName("stopper", 'a.out') self.assertTrue(break1, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, ['DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib', 'DYLD_LIBRARY_PATH=/usr/lib/system/introspection'], self.get_process_working_directory()) + process = target.LaunchSimple( + None, + [ + 'DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib', + 'DYLD_LIBRARY_PATH=/usr/lib/system/introspection'], + 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, break1) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib") - libbtr_module = target.FindModule (libbtr_module_filespec) + libbtr_module = target.FindModule(libbtr_module_filespec) if not libbtr_module.IsValid(): - self.skipTest ("Skipped because libBacktraceRecording.dylib was not loaded into the process.") + self.skipTest( + "Skipped because libBacktraceRecording.dylib was not loaded into the process.") - self.assertTrue(process.GetNumQueues() >= 4, "Found the correct number of queues.") + self.assertTrue( + process.GetNumQueues() >= 4, + "Found the correct number of queues.") queue_submittor_1 = lldb.SBQueue() queue_performer_1 = lldb.SBQueue() queue_performer_2 = lldb.SBQueue() queue_performer_3 = lldb.SBQueue() - for idx in range (0, process.GetNumQueues()): - q = process.GetQueueAtIndex(idx) - if q.GetName() == "com.apple.work_submittor_1": - queue_submittor_1 = q - if q.GetName() == "com.apple.work_performer_1": - queue_performer_1 = q - if q.GetName() == "com.apple.work_performer_2": - queue_performer_2 = q - if q.GetName() == "com.apple.work_performer_3": - queue_performer_3 = q - - self.assertTrue(queue_submittor_1.IsValid() and queue_performer_1.IsValid() and queue_performer_2.IsValid() and queue_performer_3.IsValid(), "Got all four expected queues: %s %s %s %s" % (queue_submittor_1.IsValid(), queue_performer_1.IsValid(), queue_performer_2.IsValid(), queue_performer_3.IsValid())) - - self.check_queue_for_valid_queue_id (queue_submittor_1) - self.check_queue_for_valid_queue_id (queue_performer_1) - self.check_queue_for_valid_queue_id (queue_performer_2) - self.check_queue_for_valid_queue_id (queue_performer_3) - - self.check_running_and_pending_items_on_queue (queue_submittor_1, 1, 0) - self.check_running_and_pending_items_on_queue (queue_performer_1, 1, 3) - self.check_running_and_pending_items_on_queue (queue_performer_2, 1, 9999) - self.check_running_and_pending_items_on_queue (queue_performer_3, 4, 0) - - self.check_number_of_threads_owned_by_queue (queue_submittor_1, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_1, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_2, 1) - self.check_number_of_threads_owned_by_queue (queue_performer_3, 4) - - self.check_queue_kind (queue_submittor_1, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_1, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_2, lldb.eQueueKindSerial) - self.check_queue_kind (queue_performer_3, lldb.eQueueKindConcurrent) - - - self.check_queues_threads_match_queue (queue_submittor_1) - self.check_queues_threads_match_queue (queue_performer_1) - self.check_queues_threads_match_queue (queue_performer_2) - self.check_queues_threads_match_queue (queue_performer_3) - - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).IsValid(), "queue 2's pending item #0 is valid") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol().GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") - self.assertTrue(queue_performer_2.GetNumPendingItems() == 9999, "verify that queue 2 still has 9999 pending items") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).IsValid(), "queue 2's pending item #9998 is valid") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol().GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9999).IsValid() == False, "queue 2's pending item #9999 is invalid") + for idx in range(0, process.GetNumQueues()): + q = process.GetQueueAtIndex(idx) + if q.GetName() == "com.apple.work_submittor_1": + queue_submittor_1 = q + if q.GetName() == "com.apple.work_performer_1": + queue_performer_1 = q + if q.GetName() == "com.apple.work_performer_2": + queue_performer_2 = q + if q.GetName() == "com.apple.work_performer_3": + queue_performer_3 = q + + self.assertTrue( + queue_submittor_1.IsValid() and queue_performer_1.IsValid() and queue_performer_2.IsValid() and queue_performer_3.IsValid(), + "Got all four expected queues: %s %s %s %s" % + (queue_submittor_1.IsValid(), + queue_performer_1.IsValid(), + queue_performer_2.IsValid(), + queue_performer_3.IsValid())) + + self.check_queue_for_valid_queue_id(queue_submittor_1) + self.check_queue_for_valid_queue_id(queue_performer_1) + self.check_queue_for_valid_queue_id(queue_performer_2) + self.check_queue_for_valid_queue_id(queue_performer_3) + + self.check_running_and_pending_items_on_queue(queue_submittor_1, 1, 0) + self.check_running_and_pending_items_on_queue(queue_performer_1, 1, 3) + self.check_running_and_pending_items_on_queue( + queue_performer_2, 1, 9999) + self.check_running_and_pending_items_on_queue(queue_performer_3, 4, 0) + + self.check_number_of_threads_owned_by_queue(queue_submittor_1, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_1, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_2, 1) + self.check_number_of_threads_owned_by_queue(queue_performer_3, 4) + + self.check_queue_kind(queue_submittor_1, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_1, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_2, lldb.eQueueKindSerial) + self.check_queue_kind(queue_performer_3, lldb.eQueueKindConcurrent) + + self.check_queues_threads_match_queue(queue_submittor_1) + self.check_queues_threads_match_queue(queue_performer_1) + self.check_queues_threads_match_queue(queue_performer_2) + self.check_queues_threads_match_queue(queue_performer_3) + + self.assertTrue(queue_performer_2.GetPendingItemAtIndex( + 0).IsValid(), "queue 2's pending item #0 is valid") + self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol( + ).GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") + self.assertTrue( + queue_performer_2.GetNumPendingItems() == 9999, + "verify that queue 2 still has 9999 pending items") + self.assertTrue(queue_performer_2.GetPendingItemAtIndex( + 9998).IsValid(), "queue 2's pending item #9998 is valid") + self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol( + ).GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") + self.assertTrue(queue_performer_2.GetPendingItemAtIndex( + 9999).IsValid() == False, "queue 2's pending item #9999 is invalid") diff --git a/lldb/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py b/lldb/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py index 4e2dfb0eeb6..096064896ea 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.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 TestSafeFuncCalls(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -29,36 +30,44 @@ class TestSafeFuncCalls(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - self.main_source_spec = lldb.SBFileSpec (self.main_source) - break1 = target.BreakpointCreateByName ("stopper", 'a.out') + self.main_source_spec = lldb.SBFileSpec(self.main_source) + break1 = target.BreakpointCreateByName("stopper", 'a.out') self.assertTrue(break1, 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) - threads = lldbutil.get_threads_stopped_at_breakpoint (process, break1) + threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: - self.fail ("Failed to stop at breakpoint 1.") + self.fail("Failed to stop at breakpoint 1.") self.check_number_of_threads(process) main_thread = lldb.SBThread() select_thread = lldb.SBThread() - for idx in range (0, process.GetNumThreads()): - t = process.GetThreadAtIndex (idx) + for idx in range(0, process.GetNumThreads()): + t = process.GetThreadAtIndex(idx) if t.GetName() == "main thread": main_thread = t if t.GetName() == "select thread": select_thread = t - self.assertTrue(main_thread.IsValid() and select_thread.IsValid(), "Got both expected threads") + self.assertTrue( + main_thread.IsValid() and select_thread.IsValid(), + "Got both expected threads") - self.safe_to_call_func_on_main_thread (main_thread) - self.safe_to_call_func_on_select_thread (select_thread) + self.safe_to_call_func_on_main_thread(main_thread) + self.safe_to_call_func_on_select_thread(select_thread) def check_number_of_threads(self, process): - self.assertTrue(process.GetNumThreads() == 2, "Check that the process has two threads when sitting at the stopper() breakpoint") - - def safe_to_call_func_on_main_thread (self, main_thread): - self.assertTrue(main_thread.SafeToCallFunctions() == True, "It is safe to call functions on the main thread") - - def safe_to_call_func_on_select_thread (self, select_thread): - self.assertTrue(select_thread.SafeToCallFunctions() == False, "It is not safe to call functions on the select thread") + self.assertTrue( + process.GetNumThreads() == 2, + "Check that the process has two threads when sitting at the stopper() breakpoint") + + def safe_to_call_func_on_main_thread(self, main_thread): + self.assertTrue(main_thread.SafeToCallFunctions(), + "It is safe to call functions on the main thread") + + def safe_to_call_func_on_select_thread(self, select_thread): + self.assertTrue( + select_thread.SafeToCallFunctions() == False, + "It is not safe to call functions on the select thread") diff --git a/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py b/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py index 70a83ea9079..988611935c1 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py +++ b/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py @@ -3,14 +3,15 @@ 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 UniversalTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,12 +20,12 @@ class UniversalTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). - self.line = line_number('main.c', '// Set break point at this line.') + self.line = line_number('main.c', '// Set break point at this line.') @add_test_categories(['pyapi']) @skipUnlessDarwin - @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in ['i386', 'x86_64'], - "requires i386 or x86_64") + @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in [ + 'i386', 'x86_64'], "requires i386 or x86_64") def test_sbdebugger_create_target_with_file_and_target_triple(self): """Test the SBDebugger.CreateTargetWithFileAndTargetTriple() API.""" # Invoke the default build rule. @@ -34,16 +35,18 @@ class UniversalTestCase(TestBase): exe = os.path.join(os.getcwd(), "testit") # Create a target by the debugger. - target = self.dbg.CreateTargetWithFileAndTargetTriple(exe, "i386-apple-macosx") + target = self.dbg.CreateTargetWithFileAndTargetTriple( + exe, "i386-apple-macosx") self.assertTrue(target, VALID_TARGET) # 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) @skipUnlessDarwin - @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in ['i386', 'x86_64'], - "requires i386 or x86_64") + @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in [ + 'i386', 'x86_64'], "requires i386 or x86_64") def test_process_launch_for_universal(self): """Test process launch of a universal binary.""" from lldbsuite.test.lldbutil import print_registers @@ -56,11 +59,12 @@ class UniversalTestCase(TestBase): # By default, x86_64 is assumed if no architecture is specified. self.expect("file " + exe, CURRENT_EXECUTABLE_SET, - startstr = "Current executable set to ", - substrs = ["testit' (x86_64)."]) + startstr="Current executable set to ", + substrs=["testit' (x86_64)."]) # Break inside the main. - 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) # We should be able to launch the x86_64 executable. self.runCmd("run", RUN_SUCCEEDED) @@ -75,17 +79,18 @@ class UniversalTestCase(TestBase): frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, - substrs = ['Name: rax']) + substrs=['Name: rax']) self.runCmd("continue") # Now specify i386 as the architecture for "testit". self.expect("file -a i386 " + exe, CURRENT_EXECUTABLE_SET, - startstr = "Current executable set to ", - substrs = ["testit' (i386)."]) + startstr="Current executable set to ", + substrs=["testit' (i386)."]) # Break inside the main. - 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) # We should be able to launch the i386 executable as well. self.runCmd("run", RUN_SUCCEEDED) @@ -97,24 +102,26 @@ class UniversalTestCase(TestBase): "32-bit process launched") pointerSize = self.invoke(process, 'GetAddressByteSize') - self.assertTrue(pointerSize == 4, - "AddressByteSize of 32-bit process should be 4, got %d instead." % pointerSize) + self.assertTrue( + pointerSize == 4, + "AddressByteSize of 32-bit process should be 4, got %d instead." % + pointerSize) frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, - substrs = ['Name: eax']) + substrs=['Name: eax']) self.runCmd("continue") - @skipUnlessDarwin - @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in ['i386', 'x86_64'], - "requires i386 or x86_64") + @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in [ + 'i386', 'x86_64'], "requires i386 or x86_64") def test_process_attach_with_wrong_arch(self): """Test that when we attach to a binary from the wrong fork of a universal binary, we fix up the ABI correctly.""" # Now keep the architecture at 32 bit, but switch the binary we launch to - # 64 bit, and make sure on attach we switch to the correct architecture. + # 64 bit, and make sure on attach we switch to the correct + # architecture. # Invoke the default build rule. self.build() @@ -122,23 +129,27 @@ class UniversalTestCase(TestBase): # Note that "testit" is a universal binary. exe = os.path.join(os.getcwd(), "testit") - # Create a target by the debugger. - target = self.dbg.CreateTargetWithFileAndTargetTriple(exe, "i386-apple-macosx") + target = self.dbg.CreateTargetWithFileAndTargetTriple( + exe, "i386-apple-macosx") self.assertTrue(target, VALID_TARGET) pointer_size = target.GetAddressByteSize() self.assertTrue(pointer_size == 4, "Initially we were 32 bit.") - bkpt = target.BreakpointCreateBySourceRegex("sleep", lldb.SBFileSpec("main.c")) - self.assertTrue (bkpt.IsValid(), "Valid breakpoint") - self.assertTrue(bkpt.GetNumLocations() >= 1, "Our main breakpoint has locations.") + bkpt = target.BreakpointCreateBySourceRegex( + "sleep", lldb.SBFileSpec("main.c")) + self.assertTrue(bkpt.IsValid(), "Valid breakpoint") + self.assertTrue( + bkpt.GetNumLocations() >= 1, + "Our main breakpoint has locations.") popen = self.spawnSubprocess(exe, ["keep_waiting"]) self.addTearDownHook(self.cleanupSubprocesses) error = lldb.SBError() empty_listener = lldb.SBListener() - process = target.AttachToProcessWithID(empty_listener, popen.pid, error) + process = target.AttachToProcessWithID( + empty_listener, popen.pid, error) self.assertTrue(error.Success(), "Attached to process.") pointer_size = target.GetAddressByteSize() @@ -153,4 +164,6 @@ class UniversalTestCase(TestBase): threads = lldbutil.continue_to_breakpoint(process, bkpt) self.assertTrue(len(threads) == 1) thread = threads[0] - self.assertTrue(thread.GetNumFrames() > 1, "We were able to backtrace.") + self.assertTrue( + thread.GetNumFrames() > 1, + "We were able to backtrace.") -- cgit v1.2.3