From 60de0c4536ed0e10274b25eb903e23e57a7f77bb Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 27 Jun 2019 16:45:23 +0000 Subject: [PATCH 001/616] Add a sanity check to the domain socket tests. rdar://problem/52062631 llvm-svn: 364562 (cherry picked from commit 3b4a667854e0615d321a31752a6caa9f9e632c70) --- lldb/unittests/Host/SocketTest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/unittests/Host/SocketTest.cpp b/lldb/unittests/Host/SocketTest.cpp index 0d1851e5c0268..4e897975e5d61 100644 --- a/lldb/unittests/Host/SocketTest.cpp +++ b/lldb/unittests/Host/SocketTest.cpp @@ -93,6 +93,8 @@ TEST_F(SocketTest, DomainListenConnectAccept) { std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path); ASSERT_FALSE(EC); llvm::sys::path::append(Path, "test"); + // If this fails, $TMPDIR is too long to hold a domain socket. + EXPECT_LE(Path.size(), 107u); std::unique_ptr socket_a_up; std::unique_ptr socket_b_up; @@ -194,6 +196,8 @@ TEST_F(SocketTest, DomainGetConnectURI) { llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", domain_path); ASSERT_FALSE(EC); llvm::sys::path::append(domain_path, "test"); + // If this fails, $TMPDIR is too long to hold a domain socket. + EXPECT_LE(domain_path.size(), 107u); std::unique_ptr socket_a_up; std::unique_ptr socket_b_up; @@ -208,4 +212,4 @@ TEST_F(SocketTest, DomainGetConnectURI) { EXPECT_EQ(scheme, "unix-connect"); EXPECT_EQ(path, domain_path); } -#endif \ No newline at end of file +#endif From 3fef5174320f967b3fce4ba22363d0de29aa9915 Mon Sep 17 00:00:00 2001 From: Ali Tamur Date: Fri, 28 Jun 2019 00:11:26 +0000 Subject: [PATCH 002/616] Fixing a couple of wrong logical operator bugs. llvm-svn: 364614 (cherry picked from commit 9a89d657b1a51ce8d1b8b1e32b836319fb7c2a3e) --- .../DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h | 2 +- .../Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h index 67734a3c3a5b0..eb31c40916c93 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -240,7 +240,7 @@ class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader { image_infos_addr = LLDB_INVALID_ADDRESS; } - bool IsValid() const { return version >= 1 || version <= 2; } + bool IsValid() const { return version >= 1 && version <= 2; } }; void RegisterNotificationCallbacks(); diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h index 77c8209b4f537..00b2ebf373d83 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -121,7 +121,7 @@ class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoaderDarwin { dyldImageLoadAddress = LLDB_INVALID_ADDRESS; } - bool IsValid() const { return version >= 1 || version <= 6; } + bool IsValid() const { return version >= 1 && version <= 6; } }; static lldb::ByteOrder GetByteOrderFromMagic(uint32_t magic); From 8d3255a2a97db96e50c26829496f9161723c3967 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 28 Jun 2019 17:57:19 +0000 Subject: [PATCH 003/616] Make sure the thread list is updated before you set the stop reason on a thread. When talking to some older gdb-remote stubs, We were getting a stop reason from the stop reply packet and setting it on the relevant thread before we updated the full stop list. That would get discarded when the full list was updated. Also, if you already have a thread list when you go to see if there is an Operating System plugin, and you do indeed load a new OS plugin, you have to re-fetch the thread list or it will only show the raw threads. Differential Revision: https://reviews.llvm.org/D62887 llvm-svn: 364666 (cherry picked from commit 8864b4360aabfd3a99c396a8b31c9ec1644702a1) --- .../TestRecognizeBreakpoint.py | 139 ++++++++++++++++++ .../gdb_remote_client/gdbclientutils.py | 5 + .../gdb_remote_client/operating_system_2.py | 62 ++++++++ .../Process/gdb-remote/ProcessGDBRemote.cpp | 17 ++- lldb/source/Target/Process.cpp | 10 +- 5 files changed, 225 insertions(+), 8 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system_2.py diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py new file mode 100644 index 0000000000000..c112c58862581 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -0,0 +1,139 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestRecognizeBreakpoint(GDBRemoteTestBase): + """ This tests the case where the gdb-remote server doesn't support any + of the thread-info packets, and just tells which thread got the stop + signal with: + T05thread:01; + There was a bug in lldb that we would set the stop reason from this + packet too early - before we had updated the thread list. So when we + later updated the thread list, we would throw away this info. Normally + we would be able to reconstruct it from the thread info, but not if the + stub doesn't support it """ + + def test(self): + class MyResponder(MockGDBServerResponder): + def __init__(self): + MockGDBServerResponder.__init__(self) + self.thread_info_count = 0 + self.after_cont = False + self.current_thread = 0 + + def cont(self): + # Simulate process stopping due to a breakpoint: + self.after_cont = True + return "T05thread:01;" + + def vCont(self, packet): + self.after_cont = True + return "T05thread:01;" + + def haltReason(self): + return "T02thread:01;" + + def threadStopInfo(self, num): + return "" + + def QThreadSuffixSupported(self): + return "" + + def QListThreadsInStopReply(self): + return "" + + def setBreakpoint(self, packet): + return "OK" + + def qfThreadInfo(self): + return "m1" + + def qsThreadInfo(self): + if (self.thread_info_count % 2) == 0: + str = "m2" + else: + str = "l" + self.thread_info_count += 1 + return str + + def readRegisters(self): + if self.after_cont and self.current_thread == 1: + return "c01e990080ffffff" + else: + return "badcfe10325476980" + + def readRegister(self, regno): + return "" + + def qXferRead(self, obj, annex, offset, length): + if annex == "target.xml": + return """ + + i386:x86-64 + + + + """, False + else: + return None, False + + def selectThread(self, op, thread): + if op != 'g': + return '' + + self.current_thread = thread + return "OK" + + def other (self, packet): + if packet == "vCont?": + return "vCont;c;C;s;S" + return '' + + python_os_plugin_path = os.path.join(self.getSourceDir(), + 'operating_system_2.py') + command ="settings set target.process.python-os-plugin-path '{}'".format( + python_os_plugin_path) + self.runCmd(command) + + self.server.responder = MyResponder() + target = self.dbg.CreateTarget("") + process = self.connect(target) + + bkpt = target.BreakpointCreateByAddress(0xffffff8000991ec0) + self.assertEqual(bkpt.GetNumLocations(), 1, "Fake breakpoint was resolved.") + + # Get the initial stop, and we should have two threads. + num_threads = len(process.threads) + self.assertEqual(num_threads, 2, "Got two threads") + + thread_0 = process.threads[0] + self.assertEqual(thread_0.GetStopReason(), 1, "Thread_0 stopped for no reason") + self.assertEqual(thread_0.GetName(), "one", "Thread_0 is called one") + + thread_1 = process.threads[1] + self.assertEqual(thread_1.GetStopReason(), 5, "Thread_0 stopped for SIGSTOP") + self.assertEqual(thread_1.GetName(), "two", "Thread_0 is called two") + + # Now continue and we will fake hitting a breakpoint. + process.Continue() + + self.assertEqual(process.GetState(),lldb.eStateStopped, "Process is stopped") + num_threads = len(process.threads) + + num_threads = len(process.threads) + self.assertEqual(num_threads, 2, "Got two threads") + + thread_0 = process.threads[0] + self.assertEqual(thread_0.GetStopReason(), 1, "Thread_0 stopped for no reason") + self.assertEqual(thread_0.GetName(), "one", "Thread_0 is called one") + + thread_1 = process.threads[1] + self.assertEqual(thread_1.GetStopReason(), 3, "Thread_0 stopped for SIGTRAP") + self.assertEqual(thread_1.GetName(), "three", "Thread_0 is called three") + + self.assertTrue(thread_1.IsValid(), "Thread_1 is valid") + self.assertEqual(thread_1.GetStopReason(), lldb.eStopReasonBreakpoint, "Stopped at breakpoint") + diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py index fb8f61bdf8c4e..f0875c9c9953e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py @@ -103,6 +103,8 @@ def respond(self, packet): return self.interrupt() if packet == "c": return self.cont() + if packet.startswith("vCont;c"): + return self.vCont(packet) if packet[0] == "g": return self.readRegisters() if packet[0] == "G": @@ -168,6 +170,9 @@ def interrupt(self): def cont(self): raise self.UnexpectedPacketException() + def vCont(self, packet): + raise self.UnexpectedPacketException() + def readRegisters(self): return "00000000" * self.registerCount diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system_2.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system_2.py new file mode 100644 index 0000000000000..d8ebed610da4d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system_2.py @@ -0,0 +1,62 @@ +import lldb +import struct + + +class OperatingSystemPlugIn(object): + """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class + This version stops once with threads 0x111 and 0x222, then stops a second time with threads + 0x111 and 0x333.""" + + 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 + self.times_called = 0 + if isinstance(process, lldb.SBProcess) and process.IsValid(): + self.process = process + self.threads = None # Will be an dictionary containing info for each thread + + def get_target(self): + return self.process.target + + def get_thread_info(self): + self.times_called += 1 + + if self.times_called == 1: + self.threads = [{ + 'tid': 0x111, + 'name': 'one', + 'queue': 'queue1', + 'state': 'stopped', + 'stop_reason': 'none', + 'core': 1 + }, { + 'tid': 0x222, + 'name': 'two', + 'queue': 'queue2', + 'state': 'stopped', + 'stop_reason': 'none', + 'core': 0 + }] + else: + self.threads = [{ + 'tid': 0x111, + 'name': 'one', + 'queue': 'queue1', + 'state': 'stopped', + 'stop_reason': 'none', + 'core': 1 + }, { + 'tid': 0x333, + 'name': 'three', + 'queue': 'queue3', + 'state': 'stopped', + 'stop_reason': 'none', + 'core': 0 + }] + return self.threads + diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index cfac0b1ec9c8d..0501e205ca749 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2423,6 +2423,15 @@ void ProcessGDBRemote::RefreshStateAfterStop() { // Scope for the lock { + // Check to see if SetThreadStopInfo() filled in m_thread_ids? + if (m_thread_ids.empty()) { + // No, we need to fetch the thread list manually + UpdateThreadIDList(); + } + // We might set some stop info's so make sure the thread list is up to + // date before we do that or we might overwrite what was computed here. + UpdateThreadListIfNeeded(); + // Lock the thread stack while we access it std::lock_guard guard(m_last_stop_packet_mutex); // Get the number of stop packets on the stack @@ -2437,13 +2446,7 @@ void ProcessGDBRemote::RefreshStateAfterStop() { // Clear the thread stop stack m_stop_packet_stack.clear(); } - - // Check to see if SetThreadStopInfo() filled in m_thread_ids? - if (m_thread_ids.empty()) { - // No, we need to fetch the thread list manually - UpdateThreadIDList(); - } - + // If we have queried for a default thread id if (m_initial_tid != LLDB_INVALID_THREAD_ID) { m_thread_list.SetSelectedThreadByID(m_initial_tid); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index ef755e66b7c4b..9e87f04ff0dd7 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3019,8 +3019,16 @@ void Process::CompleteAttach() { } } - if (!m_os_up) + if (!m_os_up) { LoadOperatingSystemPlugin(false); + if (m_os_up) { + // Somebody might have gotten threads before now, but we need to force the + // update after we've loaded the OperatingSystem plugin or it won't get a + // chance to process the threads. + m_thread_list.Clear(); + UpdateThreadListIfNeeded(); + } + } // Figure out which one is the executable, and set that in our target: const ModuleList &target_modules = GetTarget().GetImages(); std::lock_guard guard(target_modules.GetMutex()); From 90e3c430ed650cfb3afbfbca853220e6b4fb71dc Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 28 Jun 2019 18:14:27 +0000 Subject: [PATCH 004/616] [GDBRemote] Remove code that flushes GDB remote packets The arbitrary timeout when flushing GDB remote packets caused non-determinism and flakiness between test runs. I suspect it is what's causing the flakiness of the reproducer tests on GreenDragon, and want to see if removing it causes that to go away. This change was originally introduced in r197579 to discard a `$T02thread:01;#4` that QEMU was sending. If anybody knows how to test that this continues working after removing this code, I'd love to hear it. llvm-svn: 364669 (cherry picked from commit 9db6073381da617bea6c117d02fd0b0d30d33c4b) --- .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 9797184026e06..0d6b45a2286b0 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -115,13 +115,6 @@ bool GDBRemoteCommunicationClient::HandshakeWithServer(Status *error_ptr) { // Start the read thread after we send the handshake ack since if we fail to // send the handshake ack, there is no reason to continue... if (SendAck()) { - // Wait for any responses that might have been queued up in the remote - // GDB server and flush them all - StringExtractorGDBRemote response; - PacketResult packet_result = PacketResult::Success; - while (packet_result == PacketResult::Success) - packet_result = ReadPacket(response, milliseconds(10), false); - // The return value from QueryNoAckModeSupported() is true if the packet // was sent and _any_ response (including UNIMPLEMENTED) was received), or // false if no response was received. This quickly tells us if we have a From eebed7cd13811f3c948b91f0c3f9e683e3f54eaa Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 28 Jun 2019 21:40:05 +0000 Subject: [PATCH 005/616] Get the expression parser to handle missing weak symbols. MachO only for this patch. Differential Revision: https://reviews.llvm.org/D63914 llvm-svn: 364686 (cherry picked from commit f2128b28cdb73d0ccfa2cbf508e8f9d8dc9f8eb5) --- .../include/lldb/Expression/IRExecutionUnit.h | 12 ++- lldb/include/lldb/Symbol/Symbol.h | 7 +- lldb/include/lldb/lldb-enumerations.h | 2 + .../expression_command/weak_symbols/Makefile | 26 ++++++ .../weak_symbols/TestWeakSymbols.py | 83 +++++++++++++++++ .../expression_command/weak_symbols/dylib.c | 14 +++ .../expression_command/weak_symbols/dylib.h | 8 ++ .../expression_command/weak_symbols/main.c | 23 +++++ .../weak_symbols/module.modulemap | 3 + lldb/source/Expression/IRExecutionUnit.cpp | 91 ++++++++++++++----- lldb/source/Expression/IRInterpreter.cpp | 5 +- .../ExpressionParser/Clang/IRForTarget.cpp | 18 ++-- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 2 + lldb/source/Symbol/Symbol.cpp | 15 ++- 14 files changed, 269 insertions(+), 40 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/TestWeakSymbols.py create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.c create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.h create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/main.c create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/module.modulemap diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h index 37f31358e4e0f..beff44db9d5ed 100644 --- a/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -101,7 +101,7 @@ class IRExecutionUnit : public std::enable_shared_from_this, lldb::ModuleSP GetJITModule(); - lldb::addr_t FindSymbol(ConstString name); + lldb::addr_t FindSymbol(ConstString name, bool &missing_weak); void GetStaticInitializers(std::vector &static_initializers); @@ -226,7 +226,8 @@ class IRExecutionUnit : public std::enable_shared_from_this, const std::vector &C_specs); lldb::addr_t FindInSymbols(const std::vector &specs, - const lldb_private::SymbolContext &sc); + const lldb_private::SymbolContext &sc, + bool &symbol_was_missing_weak); lldb::addr_t FindInRuntimes(const std::vector &specs, const lldb_private::SymbolContext &sc); @@ -301,6 +302,13 @@ class IRExecutionUnit : public std::enable_shared_from_this, size_t Size) override {} uint64_t getSymbolAddress(const std::string &Name) override; + + // Find the address of the symbol Name. If Name is a missing weak symbol + // then missing_weak will be true. + uint64_t GetSymbolAddressAndPresence(const std::string &Name, + bool &missing_weak); + + llvm::JITSymbol findSymbol(const std::string &Name) override; void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true) override; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index d36629773c74b..1cbc2f5492f4e 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -165,6 +165,10 @@ class Symbol : public SymbolContextScope { bool IsTrampoline() const; bool IsIndirect() const; + + bool IsWeak() const { return m_is_weak; } + + void SetIsWeak (bool b) { m_is_weak = b; } bool GetByteSizeIsValid() const { return m_size_is_valid; } @@ -250,7 +254,8 @@ class Symbol : public SymbolContextScope { m_contains_linker_annotations : 1, // The symbol name contains linker // annotations, which are optional when // doing name lookups - m_type : 7; + m_is_weak : 1, + m_type : 6; // Values from the lldb::SymbolType enum. Mangled m_mangled; // uniqued symbol name/mangled name pair AddressRange m_addr_range; // Contains the value, or the section offset // address when the value is an address in a diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 9d2d9ba305065..f9830c04bc39f 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -592,6 +592,8 @@ enum CommandArgumentType { }; // Symbol types +// Symbol holds the SymbolType in a 6-bit field (m_type), so if you get over 63 +// entries you will have to resize that field. enum SymbolType { eSymbolTypeAny = 0, eSymbolTypeInvalid = 0, diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/Makefile new file mode 100644 index 0000000000000..7c70b509fe737 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/Makefile @@ -0,0 +1,26 @@ +LEVEL = ../../make +CFLAGS_EXTRAS += -std=c99 +LD_FLAGS := -dynamiclib +include $(LEVEL)/Makefile.rules + +all: a.out dylib missing + +dylib: dylib.o + $(CC) $(LD_FLAGS) -o libdylib.dylib dylib.o + +missing: dylib2.o + mkdir hidden + $(CC) $(LD_FLAGS) -o hidden/libdylib.dylib dylib2.o + +a.out: main.o dylib missing + $(CC) $(CFLAGS) -L. -ldylib main.o + +dylib.o: dylib.h $(SRCDIR)/dylib.c + $(CC) -DHAS_THEM $(CFLAGS) -c $(SRCDIR)/dylib.c + +dylib2.o: dylib.h $(SRCDIR)/dylib.c + $(CC) $(CFLAGS) -c $(SRCDIR)/dylib.c -o dylib2.o + +main.o: dylib.h $(SRCDIR)/main.c + $(CC) $(CFLAGS) -c $(SRCDIR)/main.c -fmodules + diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/TestWeakSymbols.py b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/TestWeakSymbols.py new file mode 100644 index 0000000000000..a5d7a4b7e6a2d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/TestWeakSymbols.py @@ -0,0 +1,83 @@ +""" +Test that we can compile expressions referring to +absent weak symbols from a dylib. +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +from lldbsuite.test import decorators +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class TestWeakSymbolsInExpressions(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + @decorators.skipUnlessDarwin + def test_weak_symbol_in_expr(self): + """Tests that we can refer to weak symbols in expressions.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.do_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def run_weak_var_check (self, weak_varname, present): + # The expression will modify present_weak_int to signify which branch + # was taken. Set it to so we don't get confused by a previous run. + value = self.target.FindFirstGlobalVariable("present_weak_int") + value.SetValueFromCString("0") + if present: + correct_value = 10 + else: + correct_value = 20 + + # Note, I'm adding the "; 10" at the end of the expression to work around + # the bug that expressions with no result currently return False for Success()... + expr = "if (&" + weak_varname + " != NULL) { present_weak_int = 10; } else { present_weak_int = 20;}; 10" + result = self.frame.EvaluateExpression(expr) + self.assertTrue(result.GetError().Success(), "absent_weak_int expr failed: %s"%(result.GetError().GetCString())) + self.assertEqual(value.GetValueAsSigned(), correct_value, "Didn't change present_weak_int correctly.") + + def do_test(self): + hidden_dir = os.path.join(self.getBuildDir(), "hidden") + + launch_info = lldb.SBLaunchInfo(None) + launch_info.SetWorkingDirectory(self.getBuildDir()) + # We have to point to the hidden directory to pick up the + # version of the dylib without the weak symbols: + env_expr = self.platformContext.shlib_environment_var + "=" + hidden_dir + launch_info.SetEnvironmentEntries([env_expr], True) + + (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", self.main_source_file, + launch_info = launch_info) + # First we have to import the Dylib module so we get the type info + # for the weak symbol. We need to add the source dir to the module + # search paths, and then run @import to introduce it into the expression + # context: + self.dbg.HandleCommand("settings set target.clang-module-search-paths " + self.getSourceDir()) + + self.frame = thread.frames[0] + self.assertTrue(self.frame.IsValid(), "Got a good frame") + options = lldb.SBExpressionOptions() + options.SetLanguage(lldb.eLanguageTypeObjC) + result = self.frame.EvaluateExpression("@import Dylib", options) + + # Now run an expression that references an absent weak symbol: + self.run_weak_var_check("absent_weak_int", False) + self.run_weak_var_check("absent_weak_function", False) + + # Make sure we can do the same thing with present weak symbols + self.run_weak_var_check("present_weak_int", True) + self.run_weak_var_check("present_weak_function", True) diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.c b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.c new file mode 100644 index 0000000000000..dc513e5c5fb52 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.c @@ -0,0 +1,14 @@ +#include "dylib.h" + +int present_weak_int = 10; +int present_weak_function() +{ + return present_weak_int; +} + +#if defined HAS_THEM +int absent_weak_int = 10; +int absent_weak_function() { + return absent_weak_int; +} +#endif diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.h b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.h new file mode 100644 index 0000000000000..f668ec0a78476 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/dylib.h @@ -0,0 +1,8 @@ +extern int absent_weak_int __attribute__((weak_import)); + +extern int present_weak_int __attribute__((weak_import)); + +extern int absent_weak_function() __attribute__((weak_import)); + +extern int present_weak_function() __attribute__((weak_import)); + diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/main.c b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/main.c new file mode 100644 index 0000000000000..5ea257bae5b9c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/main.c @@ -0,0 +1,23 @@ +#include "dylib.h" +#include + +int +doSomething() +{ + // Set a breakpoint here. + if (&absent_weak_int != NULL) + printf("In absent_weak_int: %d\n", absent_weak_int); + if (absent_weak_function != NULL) + printf("In absent_weak_func: %p\n", absent_weak_function); + if (&present_weak_int != NULL) + printf("In present_weak_int: %d\n", present_weak_int); + if (present_weak_function != NULL) + printf("In present_weak_func: %p\n", present_weak_function); + +} + +int +main() +{ + return doSomething(); +} diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/module.modulemap b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/module.modulemap new file mode 100644 index 0000000000000..6f7671400bc33 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/weak_symbols/module.modulemap @@ -0,0 +1,3 @@ +module Dylib { + header "dylib.h" +} diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 160f586b2f4c5..da7496604b4f2 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -774,7 +774,9 @@ void IRExecutionUnit::CollectFallbackNames( lldb::addr_t IRExecutionUnit::FindInSymbols( const std::vector &specs, - const lldb_private::SymbolContext &sc) { + const lldb_private::SymbolContext &sc, + bool &symbol_was_missing_weak) { + symbol_was_missing_weak = false; Target *target = sc.target_sp.get(); if (!target) { @@ -794,11 +796,20 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( const lldb_private::SymbolContext &sc) -> lldb::addr_t { load_address = LLDB_INVALID_ADDRESS; - for (size_t si = 0, se = sc_list.GetSize(); si < se; ++si) { - SymbolContext candidate_sc; - - sc_list.GetContextAtIndex(si, candidate_sc); - + if (sc_list.GetSize() == 0) + return false; + + // missing_weak_symbol will be true only if we found only weak undefined + // references to this symbol. + bool symbol_was_missing_weak = true; + for (auto candidate_sc : sc_list.SymbolContexts()) { + // Only symbols can be weak undefined: + if (!candidate_sc.symbol) + symbol_was_missing_weak = false; + else if (candidate_sc.symbol->GetType() != lldb::eSymbolTypeUndefined + || !candidate_sc.symbol->IsWeak()) + symbol_was_missing_weak = false; + const bool is_external = (candidate_sc.function) || (candidate_sc.symbol && candidate_sc.symbol->IsExternal()); @@ -835,6 +846,13 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( } } + // You test the address of a weak symbol against NULL to see if it is + // present. So we should return 0 for a missing weak symbol. + if (symbol_was_missing_weak) { + load_address = 0; + return true; + } + return false; }; @@ -930,31 +948,37 @@ lldb::addr_t IRExecutionUnit::FindInUserDefinedSymbols( } lldb::addr_t -IRExecutionUnit::FindSymbol(lldb_private::ConstString name) { +IRExecutionUnit::FindSymbol(lldb_private::ConstString name, bool &missing_weak) { std::vector candidate_C_names; std::vector candidate_CPlusPlus_names; CollectCandidateCNames(candidate_C_names, name); + + lldb::addr_t ret = FindInSymbols(candidate_C_names, m_sym_ctx, missing_weak); + if (ret != LLDB_INVALID_ADDRESS) + return ret; + + // If we find the symbol in runtimes or user defined symbols it can't be + // a missing weak symbol. + missing_weak = false; + ret = FindInRuntimes(candidate_C_names, m_sym_ctx); + if (ret != LLDB_INVALID_ADDRESS) + return ret; - lldb::addr_t ret = FindInSymbols(candidate_C_names, m_sym_ctx); - if (ret == LLDB_INVALID_ADDRESS) - ret = FindInRuntimes(candidate_C_names, m_sym_ctx); - - if (ret == LLDB_INVALID_ADDRESS) - ret = FindInUserDefinedSymbols(candidate_C_names, m_sym_ctx); + ret = FindInUserDefinedSymbols(candidate_C_names, m_sym_ctx); + if (ret != LLDB_INVALID_ADDRESS) + return ret; - if (ret == LLDB_INVALID_ADDRESS) { - CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names, - m_sym_ctx); - ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx); - } + CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names, + m_sym_ctx); + ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx, missing_weak); + if (ret != LLDB_INVALID_ADDRESS) + return ret; - if (ret == LLDB_INVALID_ADDRESS) { - std::vector candidate_fallback_names; + std::vector candidate_fallback_names; - CollectFallbackNames(candidate_fallback_names, candidate_C_names); - ret = FindInSymbols(candidate_fallback_names, m_sym_ctx); - } + CollectFallbackNames(candidate_fallback_names, candidate_C_names); + ret = FindInSymbols(candidate_fallback_names, m_sym_ctx, missing_weak); return ret; } @@ -989,13 +1013,32 @@ void IRExecutionUnit::GetStaticInitializers( } } +llvm::JITSymbol +IRExecutionUnit::MemoryManager::findSymbol(const std::string &Name) { + bool missing_weak = false; + uint64_t addr = GetSymbolAddressAndPresence(Name, missing_weak); + // This is a weak symbol: + if (missing_weak) + return llvm::JITSymbol(addr, + llvm::JITSymbolFlags::Exported | llvm::JITSymbolFlags::Weak); + else + return llvm::JITSymbol(addr, llvm::JITSymbolFlags::Exported); +} + uint64_t IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) { + bool missing_weak = false; + return GetSymbolAddressAndPresence(Name, missing_weak); +} + +uint64_t +IRExecutionUnit::MemoryManager::GetSymbolAddressAndPresence( + const std::string &Name, bool &missing_weak) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); ConstString name_cs(Name.c_str()); - lldb::addr_t ret = m_parent.FindSymbol(name_cs); + lldb::addr_t ret = m_parent.FindSymbol(name_cs, missing_weak); if (ret == LLDB_INVALID_ADDRESS) { if (log) diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 24a3cd24fdd27..5a9814d15362d 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -233,8 +233,9 @@ class InterpreterStackFrame { case Value::FunctionVal: if (const Function *constant_func = dyn_cast(constant)) { lldb_private::ConstString name(constant_func->getName()); - lldb::addr_t addr = m_execution_unit.FindSymbol(name); - if (addr == LLDB_INVALID_ADDRESS) + bool missing_weak = false; + lldb::addr_t addr = m_execution_unit.FindSymbol(name, missing_weak); + if (addr == LLDB_INVALID_ADDRESS || missing_weak) return false; value = APInt(m_target_data.getPointerSizeInBits(), addr); return true; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index f083b92e3d627..07acb2e1030f3 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -433,9 +433,11 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str, static lldb_private::ConstString g_CFStringCreateWithBytes_str( "CFStringCreateWithBytes"); + bool missing_weak = false; CFStringCreateWithBytes_addr = - m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str); - if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS) { + m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str, + missing_weak); + if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) { if (log) log->PutCString("Couldn't find CFStringCreateWithBytes in the target"); @@ -857,9 +859,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) { if (!m_sel_registerName) { lldb::addr_t sel_registerName_addr; + bool missing_weak = false; static lldb_private::ConstString g_sel_registerName_str("sel_registerName"); - sel_registerName_addr = m_execution_unit.FindSymbol(g_sel_registerName_str); - if (sel_registerName_addr == LLDB_INVALID_ADDRESS) + sel_registerName_addr = m_execution_unit.FindSymbol(g_sel_registerName_str, + missing_weak); + if (sel_registerName_addr == LLDB_INVALID_ADDRESS || missing_weak) return false; if (log) @@ -1027,9 +1031,11 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) { if (!m_objc_getClass) { lldb::addr_t objc_getClass_addr; + bool missing_weak = false; static lldb_private::ConstString g_objc_getClass_str("objc_getClass"); - objc_getClass_addr = m_execution_unit.FindSymbol(g_objc_getClass_str); - if (objc_getClass_addr == LLDB_INVALID_ADDRESS) + objc_getClass_addr = m_execution_unit.FindSymbol(g_objc_getClass_str, + missing_weak); + if (objc_getClass_addr == LLDB_INVALID_ADDRESS || missing_weak) return false; if (log) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index e1d688153511a..6e822826381ff 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -4575,6 +4575,8 @@ size_t ObjectFileMachO::ParseSymtab() { sym[sym_idx].GetAddressRef().SetOffset(symbol_value); } sym[sym_idx].SetFlags(nlist.n_type << 16 | nlist.n_desc); + if (nlist.n_desc & N_WEAK_REF) + sym[sym_idx].SetIsWeak(true); if (symbol_byte_size > 0) sym[sym_idx].SetByteSize(symbol_byte_size); diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 6e9bfe75aad9c..589f69244a480 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -28,7 +28,8 @@ Symbol::Symbol() m_is_external(false), m_size_is_sibling(false), m_size_is_synthesized(false), m_size_is_valid(false), m_demangled_is_synthesized(false), m_contains_linker_annotations(false), - m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(), m_flags() {} + m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(), + m_flags() {} Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled, SymbolType type, bool external, bool is_debug, @@ -41,7 +42,8 @@ Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled, m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false), m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0), m_demangled_is_synthesized(false), - m_contains_linker_annotations(contains_linker_annotations), m_type(type), + m_contains_linker_annotations(contains_linker_annotations), + m_is_weak(false), m_type(type), m_mangled(ConstString(name), name_is_mangled), m_addr_range(section_sp, offset, size), m_flags(flags) {} @@ -56,8 +58,9 @@ Symbol::Symbol(uint32_t symID, const Mangled &mangled, SymbolType type, m_size_is_synthesized(false), m_size_is_valid(size_is_valid || range.GetByteSize() > 0), m_demangled_is_synthesized(false), - m_contains_linker_annotations(contains_linker_annotations), m_type(type), - m_mangled(mangled), m_addr_range(range), m_flags(flags) {} + m_contains_linker_annotations(contains_linker_annotations), + m_is_weak(false), m_type(type), m_mangled(mangled), m_addr_range(range), + m_flags(flags) {} Symbol::Symbol(const Symbol &rhs) : SymbolContextScope(rhs), m_uid(rhs.m_uid), m_type_data(rhs.m_type_data), @@ -68,7 +71,7 @@ Symbol::Symbol(const Symbol &rhs) m_size_is_valid(rhs.m_size_is_valid), m_demangled_is_synthesized(rhs.m_demangled_is_synthesized), m_contains_linker_annotations(rhs.m_contains_linker_annotations), - m_type(rhs.m_type), m_mangled(rhs.m_mangled), + m_is_weak(rhs.m_is_weak), m_type(rhs.m_type), m_mangled(rhs.m_mangled), m_addr_range(rhs.m_addr_range), m_flags(rhs.m_flags) {} const Symbol &Symbol::operator=(const Symbol &rhs) { @@ -85,6 +88,7 @@ const Symbol &Symbol::operator=(const Symbol &rhs) { m_size_is_valid = rhs.m_size_is_valid; m_demangled_is_synthesized = rhs.m_demangled_is_synthesized; m_contains_linker_annotations = rhs.m_contains_linker_annotations; + m_is_weak = rhs.m_is_weak; m_type = rhs.m_type; m_mangled = rhs.m_mangled; m_addr_range = rhs.m_addr_range; @@ -106,6 +110,7 @@ void Symbol::Clear() { m_size_is_valid = false; m_demangled_is_synthesized = false; m_contains_linker_annotations = false; + m_is_weak = false; m_type = eSymbolTypeInvalid; m_flags = 0; m_addr_range.Clear(); From aebeab77b9f7b9d163d6c463d73b614a87dbe705 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 29 Jun 2019 00:55:13 +0000 Subject: [PATCH 006/616] Use const auto * llvm-svn: 364702 (cherry picked from commit a83e94ebf26c4d4fcde5eb1a07970982399b3bf9) --- .../Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 10 +++++----- lldb/source/Symbol/Block.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 917fbf916c551..2f55b7d40ed9e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -51,7 +51,7 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &data, if (m_abbr_idx) { lldb::offset_t offset = *offset_ptr; - auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); + const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); if (abbrevDecl == nullptr) { cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( "{0x%8.8x}: invalid abbreviation code %u, please file a bug and " @@ -232,7 +232,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges( std::vector dies; bool set_frame_base_loclist_addr = false; - auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); + const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); SymbolFileDWARF &dwarf = cu->GetSymbolFileDWARF(); lldb::ModuleSP module = dwarf.GetObjectFile()->GetModule(); @@ -415,7 +415,7 @@ void DWARFDebugInfoEntry::Dump(const DWARFUnit *cu, Stream &s, if (abbrCode != m_abbr_idx) { s.Printf("error: DWARF has been modified\n"); } else if (abbrCode) { - auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); + const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); if (abbrevDecl) { s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag())); s.Printf(" [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*' : ' '); @@ -546,7 +546,7 @@ void DWARFDebugInfoEntry::DumpAttribute( size_t DWARFDebugInfoEntry::GetAttributes( const DWARFUnit *cu, DWARFAttributes &attributes, uint32_t curr_depth) const { - auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); + const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu); if (abbrevDecl) { const DWARFDataExtractor &data = cu->GetData(); lldb::offset_t offset = GetFirstAttributeOffset(); @@ -606,7 +606,7 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue( const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value, dw_offset_t *end_attr_offset_ptr, bool check_specification_or_abstract_origin) const { - if (auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) { + if (const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) { uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr); if (attr_idx != DW_INVALID_INDEX) { diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 5d4db034251ed..6fe617080f961 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -214,10 +214,10 @@ Block *Block::GetInlinedParent() { Block *Block::GetContainingInlinedBlockWithCallSite( const Declaration &find_call_site) { - auto inlined_block = GetContainingInlinedBlock(); + Block *inlined_block = GetContainingInlinedBlock(); while (inlined_block) { - auto function_info = inlined_block->GetInlinedFunctionInfo(); + const auto *function_info = inlined_block->GetInlinedFunctionInfo(); if (function_info && function_info->GetCallSite().FileAndLineEqual(find_call_site)) From a85f923d4e5a861c67c97fbede68862b806b1149 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Sat, 29 Jun 2019 18:32:16 +0000 Subject: [PATCH 007/616] Replace tabs with spaces. llvm-svn: 364716 (cherry picked from commit 6293cd05045cfd45dd934f3f559e4b066fe7ae30) --- .../gdb_remote_client/TestRecognizeBreakpoint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py index c112c58862581..c9c0525c588cc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -71,13 +71,13 @@ def readRegister(self, regno): def qXferRead(self, obj, annex, offset, length): if annex == "target.xml": return """ - + i386:x86-64 """, False - else: + else: return None, False def selectThread(self, op, thread): From 4c89e005520f105ac4042d046d4f6a43d07d9457 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 30 Jun 2019 19:00:09 +0000 Subject: [PATCH 008/616] Revert "[GDBRemote] Remove code that flushes GDB remote packets" Reverting this again as it doesn't appear to solve the flakiness on the LLDB standalone bot. llvm-svn: 364722 (cherry picked from commit 135cf982e8ee9e2f0d8af1b33ee214737e1ae707) --- .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 0d6b45a2286b0..9797184026e06 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -115,6 +115,13 @@ bool GDBRemoteCommunicationClient::HandshakeWithServer(Status *error_ptr) { // Start the read thread after we send the handshake ack since if we fail to // send the handshake ack, there is no reason to continue... if (SendAck()) { + // Wait for any responses that might have been queued up in the remote + // GDB server and flush them all + StringExtractorGDBRemote response; + PacketResult packet_result = PacketResult::Success; + while (packet_result == PacketResult::Success) + packet_result = ReadPacket(response, milliseconds(10), false); + // The return value from QueryNoAckModeSupported() is true if the packet // was sent and _any_ response (including UNIMPLEMENTED) was received), or // false if no response was received. This quickly tells us if we have a From 5cec62046ae5c64c5a8e8590ff8481e653b31b09 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Jul 2019 11:09:15 +0000 Subject: [PATCH 009/616] Remove null checks of results of new expressions operator new doesn't return a null pointer, even if one turns off exceptions (it calls std::terminate instead). Therefore, all of this is dead code. llvm-svn: 364744 (cherry picked from commit 0f73709cb7166c74c491a4dbdb32ec81c1990a3a) --- .../Plugins/ObjectFile/JIT/ObjectFileJIT.cpp | 14 ++++++-------- .../RegisterContextPOSIXProcessMonitor_arm.cpp | 2 +- .../RegisterContextPOSIXProcessMonitor_arm64.cpp | 2 +- .../RegisterContextPOSIXProcessMonitor_mips64.cpp | 2 +- .../RegisterContextPOSIXProcessMonitor_powerpc.cpp | 2 +- .../RegisterContextPOSIXProcessMonitor_x86.cpp | 2 +- .../Linux/NativeRegisterContextLinux_arm.cpp | 4 ---- .../Linux/NativeRegisterContextLinux_arm64.cpp | 4 ---- .../Linux/NativeRegisterContextLinux_mips64.cpp | 7 ------- .../Linux/NativeRegisterContextLinux_ppc64le.cpp | 4 ---- .../Linux/NativeRegisterContextLinux_s390x.cpp | 7 ------- .../NetBSD/NativeRegisterContextNetBSD_x86_64.cpp | 7 ------- .../Utility/RegisterContextDarwin_arm64.cpp | 4 ++-- .../Process/Utility/RegisterContextDarwin_i386.cpp | 3 +-- .../Utility/RegisterContextDarwin_x86_64.cpp | 3 +-- 15 files changed, 15 insertions(+), 52 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp index 7d7453c0a87ae..eaf973da38355 100644 --- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -246,14 +246,12 @@ size_t ObjectFileJIT::ReadSectionData( if (section->GetFileSize()) { const void *src = (void *)(uintptr_t)section->GetFileOffset(); - DataBufferSP data_sp( - new lldb_private::DataBufferHeap(src, section->GetFileSize())); - if (data_sp) { - section_data.SetData(data_sp, 0, data_sp->GetByteSize()); - section_data.SetByteOrder(GetByteOrder()); - section_data.SetAddressByteSize(GetAddressByteSize()); - return section_data.GetByteSize(); - } + DataBufferSP data_sp = + std::make_shared(src, section->GetFileSize()); + section_data.SetData(data_sp, 0, data_sp->GetByteSize()); + section_data.SetByteOrder(GetByteOrder()); + section_data.SetAddressByteSize(GetAddressByteSize()); + return section_data.GetByteSize(); } section_data.Clear(); return 0; diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp index 89677d4056fac..f0c4526357cc6 100644 --- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp @@ -155,7 +155,7 @@ bool RegisterContextPOSIXProcessMonitor_arm::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp index 801d1c4affc53..147f4b56a8040 100644 --- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp @@ -164,7 +164,7 @@ bool RegisterContextPOSIXProcessMonitor_arm64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { bool success = false; data_sp.reset(new lldb_private::DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp index 706e5ce795182..db9b5a6a038cb 100644 --- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp @@ -160,7 +160,7 @@ bool RegisterContextPOSIXProcessMonitor_mips64::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp index d94638dc44f0c..77694733fa395 100644 --- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp @@ -170,7 +170,7 @@ bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp index 01e1224ba2809..3046d97f153c9 100644 --- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp @@ -344,7 +344,7 @@ bool RegisterContextPOSIXProcessMonitor_x86_64::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 3c6e0142de745..6204dbe453dff 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -276,10 +276,6 @@ Status NativeRegisterContextLinux_arm::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) - return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, - (uint64_t)REG_CONTEXT_SIZE); - error = ReadGPR(); if (error.Fail()) return error; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index 8e0c459308672..3a232e054d133 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -277,10 +277,6 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) - return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); - error = ReadGPR(); if (error.Fail()) return error; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index 3ca9b436baf4e..4f91596a5ea5d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -381,13 +381,6 @@ Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) { - error.SetErrorStringWithFormat( - "failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); - return error; - } - error = ReadGPR(); if (!error.Success()) { error.SetErrorString("ReadGPR() failed"); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp index 697f6f4891b01..8e99a096b892d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp @@ -354,10 +354,6 @@ Status NativeRegisterContextLinux_ppc64le::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) - return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); - error = ReadGPR(); if (error.Fail()) return error; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp index 5d1355747228d..5a268986dcdb7 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp @@ -336,13 +336,6 @@ Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) { - error.SetErrorStringWithFormat( - "failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); - return error; - } - uint8_t *dst = data_sp->GetBytes(); if (dst == nullptr) { error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index da111989129e6..1a4d453e62dba 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -572,13 +572,6 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (!data_sp) { - error.SetErrorStringWithFormat( - "failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); - return error; - } - error = ReadRegisterSet(GPRegSet); if (error.Fail()) return error; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp index e0d67d12d4971..85d518a487bf1 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp @@ -646,8 +646,8 @@ bool RegisterContextDarwin_arm64::WriteRegister(const RegisterInfo *reg_info, bool RegisterContextDarwin_arm64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { data_sp = std::make_shared(REG_CONTEXT_SIZE, 0); - if (data_sp && ReadGPR(false) == KERN_SUCCESS && - ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) { + if (ReadGPR(false) == KERN_SUCCESS && ReadFPU(false) == KERN_SUCCESS && + ReadEXC(false) == KERN_SUCCESS) { uint8_t *dst = data_sp->GetBytes(); ::memcpy(dst, &gpr, sizeof(gpr)); dst += sizeof(gpr); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp index 69b56242c86ce..820d280c37f7b 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp @@ -830,8 +830,7 @@ bool RegisterContextDarwin_i386::WriteRegister(const RegisterInfo *reg_info, bool RegisterContextDarwin_i386::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { data_sp = std::make_shared(REG_CONTEXT_SIZE, 0); - if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 && - ReadEXC(false) == 0) { + if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) { uint8_t *dst = data_sp->GetBytes(); ::memcpy(dst, &gpr, sizeof(gpr)); dst += sizeof(gpr); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp index e908c6dffafcf..62e512adc9f7f 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -910,8 +910,7 @@ bool RegisterContextDarwin_x86_64::WriteRegister(const RegisterInfo *reg_info, bool RegisterContextDarwin_x86_64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { data_sp = std::make_shared(REG_CONTEXT_SIZE, 0); - if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 && - ReadEXC(false) == 0) { + if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) { uint8_t *dst = data_sp->GetBytes(); ::memcpy(dst, &gpr, sizeof(gpr)); dst += sizeof(gpr); From 2bfd96c04c64cb85e62ff1601cb08003ab8f4f1d Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Jul 2019 12:00:25 +0000 Subject: [PATCH 010/616] Fix TestGdbRemoteLibrariesSvr4Support D62502 had a bug (visible only with D62503 reverted), where it would error out if attempting to read a string from memory and the memory page after the string happened to be unmapped. This fixes the problem by checking for whether ReadMemory read *any* bytes, instead of checking whether it returned an error. A greater question is whether ReadMemory should even return an error if it read at least one byte, but I'm leaving that for a separate patch. llvm-svn: 364748 (cherry picked from commit 4f0a37728052d999a9bbac4cd5d81b1f264567cd) --- lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp index 3e08eccb9df49..50b2d05df3eef 100644 --- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp +++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp @@ -120,7 +120,7 @@ NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) { char name_buffer[PATH_MAX]; error = ReadMemory(link_map.l_name, &name_buffer, sizeof(name_buffer), bytes_read); - if (!error.Success()) + if (bytes_read == 0) return error.ToError(); name_buffer[PATH_MAX - 1] = '\0'; @@ -176,4 +176,4 @@ NativeProcessELF::GetLoadedSVR4Libraries() { return library_list; } -} // namespace lldb_private \ No newline at end of file +} // namespace lldb_private From 468eefe334b99864bcc4af8f5d71d462eccdae3d Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Jul 2019 12:41:20 +0000 Subject: [PATCH 011/616] Revert "Implement xfer:libraries-svr4:read packet" D62502, together with D62503 have broken the builds which have XML support enabled. Reverting D62503 (r364355) fixed that, but has broken has left some of the tests introduced by D62502 broken more or less nondeternimistically (it depended on whether the system happens to place the library list near unreadable pages of memory). I attempted to make a partial fix for this in r364748, but Jan Kratochvil pointed out that this reintroduces the problem which reverting D62503 was trying to solve. So instead, I back out the whole thing so we can get back to a clean slate that works for everyone. We can figure out a way forward from there. This reverts r364748, r363772 and r363707. llvm-svn: 364751 (cherry picked from commit 08c38f77c5fb4d3735ec215032fed8ee6730b3db) --- .../lldb/Host/common/NativeProcessProtocol.h | 14 -- .../tools/lldb-server/gdbremote_testcase.py | 29 +--- .../tools/lldb-server/libraries-svr4/Makefile | 17 --- .../TestGdbRemoteLibrariesSvr4Support.py | 130 ------------------ .../tools/lldb-server/libraries-svr4/main.cpp | 15 -- .../lldb-server/libraries-svr4/svr4lib_a.cpp | 9 -- .../lldb-server/libraries-svr4/svr4lib_a.mk | 9 -- .../libraries-svr4/svr4lib_b_quote.cpp | 9 -- .../libraries-svr4/svr4lib_b_quote.mk | 9 -- .../Process/Linux/NativeProcessLinux.cpp | 2 +- .../Process/NetBSD/NativeProcessNetBSD.h | 4 +- .../Process/POSIX/NativeProcessELF.cpp | 71 +--------- .../Plugins/Process/POSIX/NativeProcessELF.h | 7 - .../GDBRemoteCommunicationServerCommon.cpp | 1 - .../GDBRemoteCommunicationServerLLGS.cpp | 43 ------ .../GDBRemoteCommunicationServerLLGS.h | 2 - 16 files changed, 5 insertions(+), 366 deletions(-) delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp delete mode 100644 lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h index b574e57f80c2b..f05b8d01a1c9f 100644 --- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h +++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h @@ -32,14 +32,6 @@ namespace lldb_private { class MemoryRegionInfo; class ResumeActionList; -struct SVR4LibraryInfo { - std::string name; - lldb::addr_t link_map; - lldb::addr_t base_addr; - lldb::addr_t ld_addr; - lldb::addr_t next; -}; - // NativeProcessProtocol class NativeProcessProtocol { public: @@ -94,12 +86,6 @@ class NativeProcessProtocol { virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0; - virtual llvm::Expected> - GetLoadedSVR4Libraries() { - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Not implemented"); - } - virtual bool IsAlive() const; virtual size_t UpdateThreads() = 0; diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 8311e1623991f..e7c63bf21e821 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -513,8 +513,7 @@ def prep_debug_monitor_and_inferior( self, inferior_args=None, inferior_sleep_seconds=3, - inferior_exe_path=None, - inferior_env=None): + inferior_exe_path=None): """Prep the debug monitor, the inferior, and the expected packet stream. Handle the separate cases of using the debug monitor in attach-to-inferior mode @@ -577,9 +576,6 @@ def prep_debug_monitor_and_inferior( # Build the expected protocol stream self.add_no_ack_remote_stream() - if inferior_env: - for name, value in inferior_env.items(): - self.add_set_environment_packets(name, value) if self._inferior_startup == self._STARTUP_LAUNCH: self.add_verified_launch_packets(launch_args) @@ -660,12 +656,6 @@ def add_process_info_collection_packets(self): {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "process_info_raw"}}], True) - def add_set_environment_packets(self, name, value): - self.test_sequence.add_log_lines( - ["read packet: $QEnvironment:" + name + "=" + value + "#00", - "send packet: $OK#00", - ], True) - _KNOWN_PROCESS_INFO_KEYS = [ "pid", "parent-pid", @@ -826,7 +816,6 @@ def parse_memory_region_packet(self, context): "error"]) self.assertIsNotNone(val) - mem_region_dict["name"] = seven.unhexlify(mem_region_dict.get("name", "")) # Return the dictionary of key-value pairs for the memory region. return mem_region_dict @@ -1011,22 +1000,6 @@ def run_process_then_stop(self, run_seconds=1): return context - def continue_process_and_wait_for_stop(self): - self.test_sequence.add_log_lines( - [ - "read packet: $vCont;c#a8", - { - "direction": "send", - "regex": r"^\$T([0-9a-fA-F]{2})(.*)#[0-9a-fA-F]{2}$", - "capture": {1: "stop_signo", 2: "stop_key_val_text"}, - }, - ], - True, - ) - context = self.expect_gdbremote_sequence() - self.assertIsNotNone(context) - return self.parse_interrupt_packets(context) - def select_modifiable_register(self, reg_infos): """Find a register that can be read/written freely.""" PREFERRED_REGISTER_NAMES = set(["rax", ]) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile deleted file mode 100644 index 265c8ca3c4103..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -LEVEL = ../../../make - -LIB_PREFIX := svr4lib -LD_EXTRAS := -L. -l$(LIB_PREFIX)_a -l$(LIB_PREFIX)_b\" -CXX_SOURCES := main.cpp -USE_LIBDL := 1 -MAKE_DSYM := NO - -include $(LEVEL)/Makefile.rules - -a.out: $(LIB_PREFIX)_a $(LIB_PREFIX)_b_quote - -svr4lib_%: - $(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f "$(SRCDIR)/$(LIB_PREFIX)_$*.mk" - -clean:: - $(MAKE) -f $(SRCDIR)/$(LIB_PREFIX)_a.mk clean diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py deleted file mode 100644 index 521a150d8ffa7..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py +++ /dev/null @@ -1,130 +0,0 @@ -import xml.etree.ElementTree as ET - -import gdbremote_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * - - -class TestGdbRemoteLibrariesSvr4Support(gdbremote_testcase.GdbRemoteTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - FEATURE_NAME = "qXfer:libraries-svr4:read" - - def setup_test(self): - self.init_llgs_test() - self.build() - self.set_inferior_startup_launch() - env = {} - env[self.dylibPath] = self.getBuildDir() - self.prep_debug_monitor_and_inferior(inferior_env=env) - self.continue_process_and_wait_for_stop() - - def get_expected_libs(self): - return ["libsvr4lib_a.so", 'libsvr4lib_b".so'] - - def has_libraries_svr4_support(self): - self.add_qSupported_packets() - context = self.expect_gdbremote_sequence() - self.assertIsNotNone(context) - features = self.parse_qSupported_response(context) - return self.FEATURE_NAME in features and features[self.FEATURE_NAME] == "+" - - def get_libraries_svr4_data(self): - # Start up llgs and inferior, and check for libraries-svr4 support. - if not self.has_libraries_svr4_support(): - self.skipTest("libraries-svr4 not supported") - - # Grab the libraries-svr4 data. - self.reset_test_sequence() - self.test_sequence.add_log_lines( - [ - "read packet: $qXfer:libraries-svr4:read::0,ffff:#00", - { - "direction": "send", - "regex": re.compile( - r"^\$([^E])(.*)#[0-9a-fA-F]{2}$", re.MULTILINE | re.DOTALL - ), - "capture": {1: "response_type", 2: "content_raw"}, - }, - ], - True, - ) - - context = self.expect_gdbremote_sequence() - self.assertIsNotNone(context) - - # Ensure we end up with all libraries-svr4 data in one packet. - self.assertEqual(context.get("response_type"), "l") - - # Decode binary data. - content_raw = context.get("content_raw") - self.assertIsNotNone(content_raw) - return content_raw - - def get_libraries_svr4_xml(self): - libraries_svr4 = self.get_libraries_svr4_data() - xml_root = None - try: - xml_root = ET.fromstring(libraries_svr4) - except xml.etree.ElementTree.ParseError: - pass - self.assertIsNotNone(xml_root, "Malformed libraries-svr4 XML") - return xml_root - - def libraries_svr4_well_formed(self): - xml_root = self.get_libraries_svr4_xml() - self.assertEqual(xml_root.tag, "library-list-svr4") - for child in xml_root: - self.assertEqual(child.tag, "library") - self.assertItemsEqual(child.attrib.keys(), ["name", "lm", "l_addr", "l_ld"]) - - def libraries_svr4_has_correct_load_addr(self): - xml_root = self.get_libraries_svr4_xml() - for child in xml_root: - name = child.attrib.get("name") - base_name = os.path.basename(name) - if os.path.basename(name) not in self.get_expected_libs(): - continue - load_addr = int(child.attrib.get("l_addr"), 16) - self.reset_test_sequence() - self.add_query_memory_region_packets(load_addr) - context = self.expect_gdbremote_sequence() - mem_region = self.parse_memory_region_packet(context) - self.assertEqual(load_addr, int(mem_region.get("start", 0), 16)) - self.assertEqual( - os.path.realpath(name), os.path.realpath(mem_region.get("name", "")) - ) - - def libraries_svr4_libs_present(self): - xml_root = self.get_libraries_svr4_xml() - libraries_svr4_names = [] - for child in xml_root: - name = child.attrib.get("name") - libraries_svr4_names.append(os.path.realpath(name)) - for lib in self.get_expected_libs(): - self.assertIn(self.getBuildDir() + "/" + lib, libraries_svr4_names) - - @llgs_test - @skipUnlessPlatform(["linux", "android", "netbsd"]) - def test_supports_libraries_svr4(self): - self.setup_test() - self.assertTrue(self.has_libraries_svr4_support()) - - @llgs_test - @skipUnlessPlatform(["linux", "android", "netbsd"]) - def test_libraries_svr4_well_formed(self): - self.setup_test() - self.libraries_svr4_well_formed() - - @llgs_test - @skipUnlessPlatform(["linux", "android", "netbsd"]) - def test_libraries_svr4_load_addr(self): - self.setup_test() - self.libraries_svr4_has_correct_load_addr() - - @llgs_test - @skipUnlessPlatform(["linux", "android", "netbsd"]) - def test_libraries_svr4_libs_present(self): - self.setup_test() - self.libraries_svr4_libs_present() diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp deleted file mode 100644 index b62ca71b561d1..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -int main(int argc, char **argv) { - // Perform a null pointer access. - int *const null_int_ptr = nullptr; - *null_int_ptr = 0xDEAD; - - return 0; -} diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp deleted file mode 100644 index 47d4b979d92ec..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp +++ /dev/null @@ -1,9 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -int svr4lib_a() { return 42; } diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk deleted file mode 100644 index 626babbd6b296..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../make - -LIB_PREFIX := svr4lib - -DYLIB_NAME := $(LIB_PREFIX)_a -DYLIB_CXX_SOURCES := $(LIB_PREFIX)_a.cpp -DYLIB_ONLY := YES - -include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp deleted file mode 100644 index bd8eb0068e918..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp +++ /dev/null @@ -1,9 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -int svr4lib_b_quote() { return 42; } diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk deleted file mode 100644 index 5ed7a053b42ad..0000000000000 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../make - -LIB_PREFIX := svr4lib - -DYLIB_NAME := $(LIB_PREFIX)_b\" -DYLIB_CXX_SOURCES := $(LIB_PREFIX)_b_quote.cpp -DYLIB_ONLY := YES - -include $(LEVEL)/Makefile.rules diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index b40b70104ea17..7637237aa16bb 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -2076,4 +2076,4 @@ Status NativeProcessLinux::StopProcessorTracingOnThread(lldb::user_id_t traceid, m_processor_trace_monitor.erase(iter); return error; -} \ No newline at end of file +} diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h index 4e7f0a1c13ab1..e85ca3b7a9250 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -9,12 +9,12 @@ #ifndef liblldb_NativeProcessNetBSD_H_ #define liblldb_NativeProcessNetBSD_H_ -#include "Plugins/Process/POSIX/NativeProcessELF.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" #include "NativeThreadNetBSD.h" +#include "lldb/Host/common/NativeProcessProtocol.h" namespace lldb_private { namespace process_netbsd { @@ -25,7 +25,7 @@ namespace process_netbsd { /// for debugging. /// /// Changes in the inferior process state are broadcasted. -class NativeProcessNetBSD : public NativeProcessELF { +class NativeProcessNetBSD : public NativeProcessProtocol { public: class Factory : public NativeProcessProtocol::Factory { public: diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp index 50b2d05df3eef..559b16c8fd692 100644 --- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp +++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp @@ -107,73 +107,4 @@ lldb::addr_t NativeProcessELF::GetELFImageInfoAddress() { return LLDB_INVALID_ADDRESS; } -template -llvm::Expected -NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) { - ELFLinkMap link_map; - size_t bytes_read; - auto error = - ReadMemory(link_map_addr, &link_map, sizeof(link_map), bytes_read); - if (!error.Success()) - return error.ToError(); - - char name_buffer[PATH_MAX]; - error = ReadMemory(link_map.l_name, &name_buffer, sizeof(name_buffer), - bytes_read); - if (bytes_read == 0) - return error.ToError(); - name_buffer[PATH_MAX - 1] = '\0'; - - SVR4LibraryInfo info; - info.name = std::string(name_buffer); - info.link_map = link_map_addr; - info.base_addr = link_map.l_addr; - info.ld_addr = link_map.l_ld; - info.next = link_map.l_next; - - return info; -} - -llvm::Expected> -NativeProcessELF::GetLoadedSVR4Libraries() { - // Address of DT_DEBUG.d_ptr which points to r_debug - lldb::addr_t info_address = GetSharedLibraryInfoAddress(); - if (info_address == LLDB_INVALID_ADDRESS) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Invalid shared library info address"); - // Address of r_debug - lldb::addr_t address = 0; - size_t bytes_read; - auto status = - ReadMemory(info_address, &address, GetAddressByteSize(), bytes_read); - if (!status.Success()) - return status.ToError(); - if (address == 0) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Invalid r_debug address"); - // Read r_debug.r_map - lldb::addr_t link_map = 0; - status = ReadMemory(address + GetAddressByteSize(), &link_map, - GetAddressByteSize(), bytes_read); - if (!status.Success()) - return status.ToError(); - if (address == 0) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Invalid link_map address"); - - std::vector library_list; - while (link_map) { - llvm::Expected info = - GetAddressByteSize() == 8 ? ReadSVR4LibraryInfo(link_map) - : ReadSVR4LibraryInfo(link_map); - if (!info) - return info.takeError(); - if (!info->name.empty() && info->base_addr != 0) - library_list.push_back(*info); - link_map = info->next; - } - - return library_list; -} - -} // namespace lldb_private +} // namespace lldb_private \ No newline at end of file diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h index 4fb513baebf08..84dc8d08a3406 100644 --- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h +++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h @@ -37,13 +37,6 @@ class NativeProcessELF : public NativeProcessProtocol { template lldb::addr_t GetELFImageInfoAddress(); - llvm::Expected> - GetLoadedSVR4Libraries() override; - - template - llvm::Expected - ReadSVR4LibraryInfo(lldb::addr_t link_map_addr); - std::unique_ptr m_aux_vector; llvm::Optional m_shared_library_info_addr; }; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 9767d3e8b985f..d095c7a057ad4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -825,7 +825,6 @@ GDBRemoteCommunicationServerCommon::Handle_qSupported( #if defined(__linux__) || defined(__NetBSD__) response.PutCString(";QPassSignals+"); response.PutCString(";qXfer:auxv:read+"); - response.PutCString(";qXfer:libraries-svr4:read+"); #endif return SendPacketNoLock(response.GetString()); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 190db341ae00a..196607665bbaf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -2765,24 +2765,6 @@ GDBRemoteCommunicationServerLLGS::ReadXferObject(llvm::StringRef object, return std::move(*buffer_or_error); } - if (object == "libraries-svr4") { - auto library_list = m_debugged_process_up->GetLoadedSVR4Libraries(); - if (!library_list) - return library_list.takeError(); - - StreamString response; - response.Printf(""); - for (auto const &library : *library_list) { - response.Printf("", library.ld_addr); - } - response.Printf(""); - return MemoryBuffer::getMemBufferCopy(response.GetString(), __FUNCTION__); - } - return llvm::make_error( "Xfer object not supported"); } @@ -3301,28 +3283,3 @@ GDBRemoteCommunicationServerLLGS::FindModuleFile(const std::string &module_path, return GDBRemoteCommunicationServerCommon::FindModuleFile(module_path, arch); } - -std::string GDBRemoteCommunicationServerLLGS::XMLEncodeAttributeValue( - llvm::StringRef value) { - std::string result; - for (const char &c : value) { - switch (c) { - case '\'': - result += "'"; - break; - case '"': - result += """; - break; - case '<': - result += "<"; - break; - case '>': - result += ">"; - break; - default: - result += c; - break; - } - } - return result; -} \ No newline at end of file diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index 088ba92ad11ac..068ea52caaaf0 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -196,8 +196,6 @@ class GDBRemoteCommunicationServerLLGS llvm::Expected> ReadXferObject(llvm::StringRef object, llvm::StringRef annex); - static std::string XMLEncodeAttributeValue(llvm::StringRef value); - private: void HandleInferiorState_Exited(NativeProcessProtocol *process); From 855d1aa9105c35f7b8e7e821ba005fed5811a79f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Jul 2019 13:12:29 +0000 Subject: [PATCH 012/616] @skipIfXmlSupportMissing TestRecognizeBreakpoint llvm-svn: 364753 (cherry picked from commit 77c04c3a5774595d994aa8c521752c5f3b273a0a) --- .../functionalities/gdb_remote_client/TestRecognizeBreakpoint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py index c9c0525c588cc..335a1a132a78c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -16,6 +16,7 @@ class TestRecognizeBreakpoint(GDBRemoteTestBase): we would be able to reconstruct it from the thread info, but not if the stub doesn't support it """ + @skipIfXmlSupportMissing def test(self): class MyResponder(MockGDBServerResponder): def __init__(self): From 567a8f46a0f1e093292b3cf3c5f2ab862f09fcf2 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Jul 2019 13:18:19 +0000 Subject: [PATCH 013/616] Don't check the validity of newly contructed data buffers A bunch of places were checking that DataBufferHeap::GetBytes returns a non-null pointer right after constructing it. The only time when GetBytes returns a null pointer is if it is empty (and I'm not sure that even this is a good idea), but that is clearly not the case here, as the buffer was constructed with a non-zero size just a couple of lines back. llvm-svn: 364754 (cherry picked from commit c12dfcf1f56ba06589f63f49d256efeb38b3e8d5) --- .../Process/Linux/NativeRegisterContextLinux_arm.cpp | 7 ------- .../Process/Linux/NativeRegisterContextLinux_arm64.cpp | 7 ------- .../Process/Linux/NativeRegisterContextLinux_mips64.cpp | 7 ------- .../Process/Linux/NativeRegisterContextLinux_ppc64le.cpp | 7 ------- .../Process/Linux/NativeRegisterContextLinux_s390x.cpp | 7 ------- .../Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp | 7 ------- 6 files changed, 42 deletions(-) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 6204dbe453dff..d7206195acb68 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -285,13 +285,6 @@ Status NativeRegisterContextLinux_arm::ReadAllRegisterValues( return error; uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - (uint64_t)REG_CONTEXT_SIZE); - return error; - } - ::memcpy(dst, &m_gpr_arm, GetGPRSize()); dst += GetGPRSize(); ::memcpy(dst, &m_fpr, sizeof(m_fpr)); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index 3a232e054d133..9bb9e6b77ec5a 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -286,13 +286,6 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( return error; uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - REG_CONTEXT_SIZE); - return error; - } - ::memcpy(dst, &m_gpr_arm64, GetGPRSize()); dst += GetGPRSize(); ::memcpy(dst, &m_fpr, sizeof(m_fpr)); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index 4f91596a5ea5d..6e4fe59f37803 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -394,13 +394,6 @@ Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues( } uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - REG_CONTEXT_SIZE); - return error; - } - ::memcpy(dst, &m_gpr, GetRegisterInfoInterface().GetGPRSize()); dst += GetRegisterInfoInterface().GetGPRSize(); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp index 8e99a096b892d..11cf1a2ed09a1 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp @@ -371,13 +371,6 @@ Status NativeRegisterContextLinux_ppc64le::ReadAllRegisterValues( return error; uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - REG_CONTEXT_SIZE); - return error; - } - ::memcpy(dst, &m_gpr_ppc64le, GetGPRSize()); dst += GetGPRSize(); ::memcpy(dst, &m_fpr_ppc64le, GetFPRSize()); diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp index 5a268986dcdb7..b44bb93b4a6f9 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp @@ -337,13 +337,6 @@ Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues( data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - REG_CONTEXT_SIZE); - return error; - } - error = DoReadGPR(dst, sizeof(s390_regs)); dst += sizeof(s390_regs); if (error.Fail()) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index 1a4d453e62dba..c91e9bf2c504c 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -577,13 +577,6 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( return error; uint8_t *dst = data_sp->GetBytes(); - if (dst == nullptr) { - error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 - " returned a null pointer", - REG_CONTEXT_SIZE); - return error; - } - ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize()); dst += GetRegisterInfoInterface().GetGPRSize(); From db618f09a3f69696980086b3c83a664e2c44e5bb Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 1 Jul 2019 14:31:26 +0000 Subject: [PATCH 014/616] Fix lookup of symbols at the same address with no size vs. size This fixes a failing testcase on Fedora 30 x86_64 (regression Fedora 29->30): PASS: ./bin/lldb ./lldb-test-build.noindex/functionalities/unwind/noreturn/TestNoreturnUnwind.test_dwarf/a.out -o 'settings set symbols.enable-external-lookup false' -o r -o bt -o quit * frame #0: 0x00007ffff7aa6e75 libc.so.6`__GI_raise + 325 frame #1: 0x00007ffff7a91895 libc.so.6`__GI_abort + 295 frame #2: 0x0000000000401140 a.out`func_c at main.c:12:2 frame #3: 0x000000000040113a a.out`func_b at main.c:18:2 frame #4: 0x0000000000401134 a.out`func_a at main.c:26:2 frame #5: 0x000000000040112e a.out`main(argc=, argv=) at main.c:32:2 frame #6: 0x00007ffff7a92f33 libc.so.6`__libc_start_main + 243 frame #7: 0x000000000040106e a.out`_start + 46 vs. FAIL - unrecognized abort() function: ./bin/lldb ./lldb-test-build.noindex/functionalities/unwind/noreturn/TestNoreturnUnwind.test_dwarf/a.out -o 'settings set symbols.enable-external-lookup false' -o r -o bt -o quit * frame #0: 0x00007ffff7aa6e75 libc.so.6`.annobin_raise.c + 325 frame #1: 0x00007ffff7a91895 libc.so.6`.annobin_loadmsgcat.c_end.unlikely + 295 frame #2: 0x0000000000401140 a.out`func_c at main.c:12:2 frame #3: 0x000000000040113a a.out`func_b at main.c:18:2 frame #4: 0x0000000000401134 a.out`func_a at main.c:26:2 frame #5: 0x000000000040112e a.out`main(argc=, argv=) at main.c:32:2 frame #6: 0x00007ffff7a92f33 libc.so.6`.annobin_libc_start.c + 243 frame #7: 0x000000000040106e a.out`.annobin_init.c.hot + 46 The extra ELF symbols are there due to Annobin (I did not investigate why this problem happened specifically since F-30 and not since F-28). It is due to: Symbol table '.dynsym' contains 2361 entries: Valu e Size Type Bind Vis Name 0000000000022769 5 FUNC LOCAL DEFAULT _nl_load_domain.cold 000000000002276e 0 NOTYPE LOCAL HIDDEN .annobin_abort.c.unlikely ... 000000000002276e 0 NOTYPE LOCAL HIDDEN .annobin_loadmsgcat.c_end.unlikely ... 000000000002276e 0 NOTYPE LOCAL HIDDEN .annobin_textdomain.c_end.unlikely 000000000002276e 548 FUNC GLOBAL DEFAULT abort 000000000002276e 548 FUNC GLOBAL DEFAULT abort@@GLIBC_2.2.5 000000000002276e 548 FUNC LOCAL DEFAULT __GI_abort 0000000000022992 0 NOTYPE LOCAL HIDDEN .annobin_abort.c_end.unlikely Differential Revision: https://reviews.llvm.org/D63540 llvm-svn: 364773 (cherry picked from commit 3f594ed1686b44138bee245c708773e526643aaf) --- lldb/lit/SymbolFile/Inputs/sizeless-symbol.s | 8 ++++++++ lldb/lit/SymbolFile/sizeless-symbol.test | 14 ++++++++++++++ lldb/source/Symbol/Symtab.cpp | 10 ++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lldb/lit/SymbolFile/Inputs/sizeless-symbol.s create mode 100644 lldb/lit/SymbolFile/sizeless-symbol.test diff --git a/lldb/lit/SymbolFile/Inputs/sizeless-symbol.s b/lldb/lit/SymbolFile/Inputs/sizeless-symbol.s new file mode 100644 index 0000000000000..ac08dddb0e2c1 --- /dev/null +++ b/lldb/lit/SymbolFile/Inputs/sizeless-symbol.s @@ -0,0 +1,8 @@ + .text + .byte 0 +sizeless: +sizeful: + .byte 0 + .byte 0 +sizeend: + .size sizeful, sizeend - sizeful diff --git a/lldb/lit/SymbolFile/sizeless-symbol.test b/lldb/lit/SymbolFile/sizeless-symbol.test new file mode 100644 index 0000000000000..1459d6ada8def --- /dev/null +++ b/lldb/lit/SymbolFile/sizeless-symbol.test @@ -0,0 +1,14 @@ +# Some targets do not have the .size directive. +# RUN: %clang -target x86_64-unknown-unknown-elf %S/Inputs/sizeless-symbol.s -c -o %t.o +# RUN: %lldb %t.o -s %s -o quit | FileCheck %s + +image lookup --address 1 +# CHECK: Summary: sizeless-symbol.test.tmp.o`sizeful +image lookup --address 2 +# CHECK: Summary: sizeless-symbol.test.tmp.o`sizeful + 1 +image dump symtab +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK-NEXT:------- ------ --- --------------- ------------------ ------------------ ------------------ ---------- ---------------------------------- +# CHECK-NEXT:[ 0] 1 Code 0x0000000000000003 0x0000000000000000 0x00000000 sizeend +# CHECK-NEXT:[ 1] 2 Code 0x0000000000000001 0x0000000000000002 0x00000000 sizeful +# CHECK-NEXT:[ 2] 3 Code 0x0000000000000001 0x0000000000000000 0x00000000 sizeless diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 5203eba15b490..29c390e838781 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -896,8 +896,14 @@ void Symtab::InitAddressIndexes() { for (size_t i = 0; i < num_entries; i++) { FileRangeToIndexMap::Entry *entry = m_file_addr_to_index.GetMutableEntryAtIndex(i); - if (entry->GetByteSize() == 0) { - addr_t curr_base_addr = entry->GetRangeBase(); + if (entry->GetByteSize() > 0) + continue; + addr_t curr_base_addr = entry->GetRangeBase(); + // Symbols with non-zero size will show after zero-sized symbols on the + // same address. So do not set size of a non-last zero-sized symbol. + if (i == num_entries - 1 || + m_file_addr_to_index.GetMutableEntryAtIndex(i + 1) + ->GetRangeBase() != curr_base_addr) { const RangeVector::Entry *containing_section = section_ranges.FindEntryThatContains(curr_base_addr); From 2343ba5384ce6b80ffec334af0725e303d5a88f1 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Mon, 1 Jul 2019 14:38:47 +0000 Subject: [PATCH 015/616] Revert "[lldb] [Process/NetBSD] Fix constructor after r363707" Now that r364751 has been reverted, we need to revert this fixup as well. llvm-svn: 364776 (cherry picked from commit 535f39ce52171c1d2bae922b935d92329bbb3bc4) --- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 452d6ec769e05..8cfc722059746 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -140,7 +140,7 @@ NativeProcessNetBSD::NativeProcessNetBSD(::pid_t pid, int terminal_fd, NativeDelegate &delegate, const ArchSpec &arch, MainLoop &mainloop) - : NativeProcessELF(pid, terminal_fd, delegate), m_arch(arch) { + : NativeProcessProtocol(pid, terminal_fd, delegate), m_arch(arch) { if (m_terminal_fd != -1) { Status status = EnsureFDFlags(m_terminal_fd, O_NONBLOCK); assert(status.Success()); From dd12a63ab3f0d9e07cd21ce8d315b320fdf9cf46 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Mon, 1 Jul 2019 15:11:04 +0000 Subject: [PATCH 016/616] [lldb] [Process/NetBSD] Support reading YMM registers via PT_*XSTATE Provide a (conditional) support for the new PT_GETXSTATE and PT_SETXSTATE ptrace() requests, and use them to implement getting and setting YMM registers. The functions used for splitting and recombining YMM register data are based on matching functions in FreeBSD plugin, with some simplification and updates to match NetBSD structures. Differential Revision: https://reviews.llvm.org/D63545 llvm-svn: 364779 (cherry picked from commit 2b2ad9342e65042baefc379e4a70774d8e538e84) --- .../NativeRegisterContextNetBSD_x86_64.cpp | 89 ++++++++++++++++++- .../NativeRegisterContextNetBSD_x86_64.h | 10 ++- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index c91e9bf2c504c..d611e190489ac 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -22,7 +22,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -148,7 +151,7 @@ int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum( else if (reg_num <= k_last_fpr_x86_64) return FPRegSet; else if (reg_num <= k_last_avx_x86_64) - return -1; // AVX + return XStateRegSet; // AVX else if (reg_num <= k_last_mpxr_x86_64) return -1; // MPXR else if (reg_num <= k_last_mpxc_x86_64) @@ -167,6 +170,15 @@ Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) { return DoRegisterSet(PT_GETFPREGS, &m_fpr_x86_64); case DBRegSet: return DoRegisterSet(PT_GETDBREGS, &m_dbr_x86_64); + case XStateRegSet: +#ifdef HAVE_XSTATE + { + struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)}; + return DoRegisterSet(PT_GETXSTATE, &iov); + } +#else + return Status("XState is not supported by the kernel"); +#endif } llvm_unreachable("NativeRegisterContextNetBSD_x86_64::ReadRegisterSet"); } @@ -179,6 +191,15 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) { return DoRegisterSet(PT_SETFPREGS, &m_fpr_x86_64); case DBRegSet: return DoRegisterSet(PT_SETDBREGS, &m_dbr_x86_64); + case XStateRegSet: +#ifdef HAVE_XSTATE + { + struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)}; + return DoRegisterSet(PT_SETXSTATE, &iov); + } +#else + return Status("XState is not supported by the kernel"); +#endif } llvm_unreachable("NativeRegisterContextNetBSD_x86_64::WriteRegisterSet"); } @@ -360,6 +381,39 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info, reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64], reg_info->byte_size, endian::InlHostByteOrder()); break; + case lldb_ymm0_x86_64: + case lldb_ymm1_x86_64: + case lldb_ymm2_x86_64: + case lldb_ymm3_x86_64: + case lldb_ymm4_x86_64: + case lldb_ymm5_x86_64: + case lldb_ymm6_x86_64: + case lldb_ymm7_x86_64: + case lldb_ymm8_x86_64: + case lldb_ymm9_x86_64: + case lldb_ymm10_x86_64: + case lldb_ymm11_x86_64: + case lldb_ymm12_x86_64: + case lldb_ymm13_x86_64: + case lldb_ymm14_x86_64: + case lldb_ymm15_x86_64: +#ifdef HAVE_XSTATE + if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) || + !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) { + error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel", + reg_info->name); + } else { + uint32_t reg_index = reg - lldb_ymm0_x86_64; + YMMReg ymm = XStateToYMM( + m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes, + m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes); + reg_value.SetBytes(ymm.bytes, reg_info->byte_size, + endian::InlHostByteOrder()); + } +#else + error.SetErrorString("XState queries not supported by the kernel"); +#endif + break; case lldb_dr0_x86_64: case lldb_dr1_x86_64: case lldb_dr2_x86_64: @@ -552,6 +606,39 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister( ::memcpy(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64], reg_value.GetBytes(), reg_value.GetByteSize()); break; + case lldb_ymm0_x86_64: + case lldb_ymm1_x86_64: + case lldb_ymm2_x86_64: + case lldb_ymm3_x86_64: + case lldb_ymm4_x86_64: + case lldb_ymm5_x86_64: + case lldb_ymm6_x86_64: + case lldb_ymm7_x86_64: + case lldb_ymm8_x86_64: + case lldb_ymm9_x86_64: + case lldb_ymm10_x86_64: + case lldb_ymm11_x86_64: + case lldb_ymm12_x86_64: + case lldb_ymm13_x86_64: + case lldb_ymm14_x86_64: + case lldb_ymm15_x86_64: +#ifdef HAVE_XSTATE + if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) || + !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) { + error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel", + reg_info->name); + } else { + uint32_t reg_index = reg - lldb_ymm0_x86_64; + YMMReg ymm; + ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize()); + YMMToXState(ymm, + m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes, + m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes); + } +#else + error.SetErrorString("XState not supported by the kernel"); +#endif + break; case lldb_dr0_x86_64: case lldb_dr1_x86_64: case lldb_dr2_x86_64: diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h index 7bf2833c2e4e8..0fed16542a953 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h @@ -14,6 +14,7 @@ // clang-format off #include #include +#include #include // clang-format on @@ -21,6 +22,10 @@ #include "Plugins/Process/Utility/RegisterContext_x86.h" #include "Plugins/Process/Utility/lldb-x86-register-enums.h" +#if defined(PT_GETXSTATE) && defined(PT_SETXSTATE) +#define HAVE_XSTATE +#endif + namespace lldb_private { namespace process_netbsd { @@ -68,12 +73,15 @@ class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD { private: // Private member types. - enum { GPRegSet, FPRegSet, DBRegSet }; + enum { GPRegSet, FPRegSet, DBRegSet, XStateRegSet }; // Private member variables. struct reg m_gpr_x86_64; struct fpreg m_fpr_x86_64; struct dbreg m_dbr_x86_64; +#ifdef HAVE_XSTATE + struct xstate m_xstate_x86_64; +#endif int GetSetForNativeRegNum(int reg_num) const; From d7fbfecc0b5a5adee638d53be175b56ad9a76e07 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Mon, 1 Jul 2019 15:11:10 +0000 Subject: [PATCH 017/616] [lldb] [Process/NetBSD] Fix segfault when handling watchpoint Fix the watchpoint/breakpoint code to search for matching thread entry in m_threads explicitly rather than assuming that it will be present at specified index. The previous code segfault since it wrongly assumed that the index will match LWP ID which was incorrect even for a single thread (where index was 0 and LWP ID was 1). While fixing that off-by-one error would help for this specific task, I believe it is better to be explicit in what we are searching for. Differential Revision: https://reviews.llvm.org/D63791 llvm-svn: 364780 (cherry picked from commit baf64b65056954a887e54e55e4f76f3a12230682) --- .../Process/NetBSD/NativeProcessNetBSD.cpp | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 8cfc722059746..32d20d2b1215d 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -238,12 +238,25 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { SetState(StateType::eStateStopped, true); } break; case TRAP_DBREG: { + // Find the thread. + NativeThreadNetBSD* thread = nullptr; + for (const auto &t : m_threads) { + if (t->GetID() == info.psi_lwpid) { + thread = static_cast(t.get()); + break; + } + } + if (!thread) { + LLDB_LOG(log, + "thread not found in m_threads, pid = {0}, LWP = {1}", + GetID(), info.psi_lwpid); + break; + } + // If a watchpoint was hit, report it - uint32_t wp_index; - Status error = static_cast(*m_threads[info.psi_lwpid]) - .GetRegisterContext() - .GetWatchpointHitIndex( - wp_index, (uintptr_t)info.psi_siginfo.si_addr); + uint32_t wp_index = LLDB_INVALID_INDEX32; + Status error = thread->GetRegisterContext().GetWatchpointHitIndex( + wp_index, (uintptr_t)info.psi_siginfo.si_addr); if (error.Fail()) LLDB_LOG(log, "received error while checking for watchpoint hits, pid = " @@ -258,11 +271,9 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { } // If a breakpoint was hit, report it - uint32_t bp_index; - error = static_cast(*m_threads[info.psi_lwpid]) - .GetRegisterContext() - .GetHardwareBreakHitIndex(bp_index, - (uintptr_t)info.psi_siginfo.si_addr); + uint32_t bp_index = LLDB_INVALID_INDEX32; + error = thread->GetRegisterContext().GetHardwareBreakHitIndex( + bp_index, (uintptr_t)info.psi_siginfo.si_addr); if (error.Fail()) LLDB_LOG(log, "received error while checking for hardware " From 2932d15a882b42f21ec59c6012f080c3364a0e44 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Mon, 1 Jul 2019 15:11:42 +0000 Subject: [PATCH 018/616] [lldb] [Process/NetBSD] Use global enable bits for watchpoints Set global enable bits (i.e. bits 1, 3, 5, 7) to enable watchpoints on NetBSD rather than the local enable bits (0, 2, 4, 6). The former are necessary for watchpoints to be correctly recognized by the NetBSD kernel. The latter cause them to be reported as trace points. Differential Revision: https://reviews.llvm.org/D63792 llvm-svn: 364781 (cherry picked from commit 0856721e3a06aaf2423186a6b4f97dea03c64c13) --- .../watchpoint/hello_watchlocation/TestWatchLocation.py | 1 - .../watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py | 1 - .../watchpoint/multiple_hits/TestMultipleHits.py | 1 - .../multiple_threads/TestWatchpointMultipleThreads.py | 2 -- .../watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py | 1 - .../watchpoint/watchpoint_commands/TestWatchpointCommands.py | 4 ---- .../watchpoint_commands/command/TestWatchpointCommandLLDB.py | 2 -- .../command/TestWatchpointCommandPython.py | 2 -- .../condition/TestWatchpointConditionCmd.py | 1 - .../watchpoint/watchpoint_disable/TestWatchpointDisable.py | 1 - .../watchpoint_set_command/TestWatchLocationWithWatchSet.py | 1 - .../watchpoint/watchpoint_size/TestWatchpointSizes.py | 3 --- .../Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp | 4 ++-- 13 files changed, 2 insertions(+), 22 deletions(-) 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 823f26b4cdbed..d39d35f768831 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 @@ -42,7 +42,6 @@ def setUp(self): # SystemZ and PowerPC also currently supports only one H/W watchpoint @expectedFailureAll(archs=['powerpc64le', 's390x']) @skipIfDarwin - @expectedFailureNetBSD def test_hello_watchlocation(self): """Test watching a location with '-s size' option.""" self.build(dictionary=self.d) 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 bebcc07427011..8e19f9b3b5b8f 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 @@ -34,7 +34,6 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD @add_test_categories(["basic_process"]) def test_hello_watchpoint_using_watchpoint_set(self): """Test a simple sequence of watchpoint creation and watchpoint hit.""" diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py index 73757ae40b740..a6d77924892b5 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py @@ -23,7 +23,6 @@ class MultipleHitsTestCase(TestBase): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") @skipIf(bugnumber="llvm.org/pr30758", oslist=["linux"], archs=["arm", "aarch64", "powerpc64le"]) @skipIfwatchOS - @expectedFailureNetBSD def test(self): self.build() exe = self.getBuildArtifact("a.out") 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 40f18002c6408..85d6c84d68fff 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 @@ -23,7 +23,6 @@ class WatchpointForMultipleThreadsTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @skipIfNetBSD def test_watchpoint_before_thread_start(self): """Test that we can hit a watchpoint we set before starting another thread""" self.do_watchpoint_test("Before running the thread") @@ -31,7 +30,6 @@ def test_watchpoint_before_thread_start(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @skipIfNetBSD def test_watchpoint_after_thread_start(self): """Test that we can hit a watchpoint we set after starting another thread""" self.do_watchpoint_test("After running the thread") 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 bfd9c0d72f29d..e0c77b4ea6be0 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 @@ -25,7 +25,6 @@ class TestStepOverWatchpoint(TestBase): # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) @expectedFailureAll(oslist=["ios", "watchos", "tvos", "bridgeos"], bugnumber="") # watchpoint tests aren't working on arm64 - @expectedFailureNetBSD @add_test_categories(["basic_process"]) def test(self): """Test stepping over watchpoints.""" 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 ce2509aa45296..5bb683934c1be 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 @@ -41,7 +41,6 @@ def setUp(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD def test_rw_watchpoint(self): """Test read_write watchpoint and expect to stop two times.""" self.build(dictionary=self.d) @@ -170,7 +169,6 @@ def test_rw_watchpoint_delete(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD 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) @@ -231,7 +229,6 @@ def test_rw_watchpoint_set_ignore_count(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD def test_rw_disable_after_first_stop(self): """Test read_write watchpoint but disable it after the first stop.""" self.build(dictionary=self.d) @@ -302,7 +299,6 @@ def test_rw_disable_after_first_stop(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD def test_rw_disable_then_enable(self): """Test read_write watchpoint, disable initially, then enable it.""" self.build(dictionary=self.d) 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 52998c7c657a7..cd819f27ec5f0 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 @@ -40,7 +40,6 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) @@ -109,7 +108,6 @@ def test_watchpoint_command(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD 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) 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 431298a9f9975..d9edd05d3a762 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 @@ -41,7 +41,6 @@ def setUp(self): oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureNetBSD def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) @@ -112,7 +111,6 @@ def test_watchpoint_command(self): oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") - @expectedFailureNetBSD def test_continue_in_watchpoint_command(self): """Test continue in a watchpoint command.""" self.build(dictionary=self.d) 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 b4b489e89485f..a77b1e70e3dd5 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 @@ -40,7 +40,6 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD def test_watchpoint_cond(self): """Test watchpoint condition.""" self.build(dictionary=self.d) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py index bc02bc06d405d..ea4f06218a0da 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py @@ -27,7 +27,6 @@ def test_disable_works (self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD def test_disable_enable_works (self): """Set a watchpoint, disable it, and make sure it doesn't get hit.""" self.build() 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 abe678629023b..c7f7d02392eb0 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 @@ -39,7 +39,6 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD def test_watchlocation_using_watchpoint_set(self): """Test watching a location with 'watchpoint set expression -w write -s size' option.""" self.build() 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 7a1abbdae5472..d4f78a5f3ecc5 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 @@ -36,7 +36,6 @@ def setUp(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD 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') @@ -46,7 +45,6 @@ def test_byte_size_watchpoints_with_byte_selection(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD 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') @@ -56,7 +54,6 @@ def test_two_byte_watchpoints_with_word_selection(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD 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') diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index d611e190489ac..a7cd637bf826b 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -764,7 +764,7 @@ Status NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index, uint64_t control_bits = reg_value.GetAsUInt64(); - is_vacant = !(control_bits & (1 << (2 * wp_index))); + is_vacant = !(control_bits & (1 << (2 * wp_index + 1))); return error; } @@ -803,7 +803,7 @@ Status NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex( return error; // for watchpoints 0, 1, 2, or 3, respectively, set bits 1, 3, 5, or 7 - uint64_t enable_bit = 1 << (2 * wp_index); + uint64_t enable_bit = 1 << (2 * wp_index + 1); // set bits 16-17, 20-21, 24-25, or 28-29 // with 0b01 for write, and 0b11 for read/write From 68b5f9d41170dc7e6a68114b4cc5f6d6db824995 Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Mon, 1 Jul 2019 18:13:20 +0000 Subject: [PATCH 019/616] [lldb] [lldbsuite] Use a unique class name for TestBacktraceAll It looks like when this test was added, it was based on TestBreakAfterJoin and it ended up with the same class name. This is an issue because the logs associated with the tests use the class name as the identifier for the file and if two tests have the same name their logs overwrite each other. On non-windows, this just means we lose one of the logs, but on Windows this means that one of the tests will fail occasionally because the file are locked by the other test. llvm-svn: 364826 (cherry picked from commit 55d2e6f1c26c5dc73815e67733db0e91c10f05c7) --- .../functionalities/thread/backtrace_all/TestBacktraceAll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e2026267c60e8..18928850ec898 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 @@ -11,7 +11,7 @@ from lldbsuite.test import lldbutil -class BreakpointAfterJoinTestCase(TestBase): +class BacktraceAllTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) From 22f16a5bd6ecdacb4038dda29075d9de867e9beb Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Mon, 1 Jul 2019 20:36:33 +0000 Subject: [PATCH 020/616] [Core] Generalize ValueObject::IsRuntimeSupportValue Summary: Instead of falling back to ObjCLanguageRuntime, we should be falling back to every loaded language runtime. This makes ValueObject more language agnostic. Reviewers: labath, compnerd, JDevlieghere, davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D63240 llvm-svn: 364845 (cherry picked from commit d7fcee62f114c5f96bc0d8430af40ce198231daa) --- lldb/include/lldb/Target/CPPLanguageRuntime.h | 2 +- lldb/include/lldb/Target/LanguageRuntime.h | 6 ++-- .../include/lldb/Target/ObjCLanguageRuntime.h | 3 +- lldb/source/Core/ValueObject.cpp | 32 ++++++++++++------- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 3 +- lldb/source/Symbol/Function.cpp | 8 +++-- lldb/source/Target/CPPLanguageRuntime.cpp | 16 ++-------- lldb/source/Target/ObjCLanguageRuntime.cpp | 13 -------- 8 files changed, 36 insertions(+), 47 deletions(-) diff --git a/lldb/include/lldb/Target/CPPLanguageRuntime.h b/lldb/include/lldb/Target/CPPLanguageRuntime.h index 7d15acefc5b5a..7b7d8acc9afe5 100644 --- a/lldb/include/lldb/Target/CPPLanguageRuntime.h +++ b/lldb/include/lldb/Target/CPPLanguageRuntime.h @@ -78,7 +78,7 @@ class CPPLanguageRuntime : public LanguageRuntime { lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) override; - bool IsRuntimeSupportValue(ValueObject &valobj) override; + bool IsWhitelistedRuntimeValue(ConstString name) override; protected: // Classes that inherit from CPPLanguageRuntime can see and modify these CPPLanguageRuntime(Process *process); diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 54be5a75e9811..3521f46428725 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -152,9 +152,9 @@ class LanguageRuntime : public PluginInterface { virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) = 0; - /// Identify whether a value is a language implementation detaul - /// that should be hidden from the user interface by default. - virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; } + /// Identify whether a name is a runtime value that should not be hidden by + /// from the user interface. + virtual bool IsWhitelistedRuntimeValue(ConstString name) { return false; } virtual void ModulesDidLoad(const ModuleList &module_list) {} diff --git a/lldb/include/lldb/Target/ObjCLanguageRuntime.h b/lldb/include/lldb/Target/ObjCLanguageRuntime.h index 79737c925b772..1fc8744407a77 100644 --- a/lldb/include/lldb/Target/ObjCLanguageRuntime.h +++ b/lldb/include/lldb/Target/ObjCLanguageRuntime.h @@ -301,8 +301,7 @@ class ObjCLanguageRuntime : public LanguageRuntime { /// Check whether the name is "self" or "_cmd" and should show up in /// "frame variable". - static bool IsWhitelistedRuntimeValue(ConstString name); - bool IsRuntimeSupportValue(ValueObject &valobj) override; + bool IsWhitelistedRuntimeValue(ConstString name) override; protected: // Classes that inherit from ObjCLanguageRuntime can see and modify these diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 409f3d6b13fd0..73cd133943306 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1695,18 +1695,28 @@ bool ValueObject::IsPossibleDynamicType() { bool ValueObject::IsRuntimeSupportValue() { Process *process(GetProcessSP().get()); - if (process) { - LanguageRuntime *runtime = - process->GetLanguageRuntime(GetObjectRuntimeLanguage()); - if (!runtime) - runtime = ObjCLanguageRuntime::Get(*process); - if (runtime) - return runtime->IsRuntimeSupportValue(*this); - // If there is no language runtime, trust the compiler to mark all - // runtime support variables as artificial. - return GetVariable() && GetVariable()->IsArtificial(); + if (!process) + return false; + + // We trust the the compiler did the right thing and marked runtime support + // values as artificial. + if (!GetVariable() || !GetVariable()->IsArtificial()) + return false; + + LanguageType lang = eLanguageTypeUnknown; + if (auto *sym_ctx_scope = GetSymbolContextScope()) { + if (auto *func = sym_ctx_scope->CalculateSymbolContextFunction()) + lang = func->GetLanguage(); + else if (auto *comp_unit = + sym_ctx_scope->CalculateSymbolContextCompileUnit()) + lang = comp_unit->GetLanguage(); } - return false; + + if (auto *runtime = process->GetLanguageRuntime(lang)) + if (runtime->IsWhitelistedRuntimeValue(GetName())) + return false; + + return true; } bool ValueObject::IsNilReference() { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 5a2de4865b499..b85ab54a10d3a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2371,7 +2371,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit, func_name.SetValue(ConstString(mangled), true); else if ((die.GetParent().Tag() == DW_TAG_compile_unit || die.GetParent().Tag() == DW_TAG_partial_unit) && - Language::LanguageIsCPlusPlus(die.GetLanguage()) && name && + Language::LanguageIsCPlusPlus(die.GetLanguage()) && + !Language::LanguageIsObjC(die.GetLanguage()) && name && strcmp(name, "main") != 0) { // If the mangled name is not present in the DWARF, generate the // demangled name using the decl context. We skip if the function is diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 83350e7123fde..951392c1f1bff 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -589,10 +589,14 @@ uint32_t Function::GetPrologueByteSize() { } lldb::LanguageType Function::GetLanguage() const { + lldb::LanguageType lang = m_mangled.GuessLanguage(); + if (lang != lldb::eLanguageTypeUnknown) + return lang; + if (m_comp_unit) return m_comp_unit->GetLanguage(); - else - return lldb::eLanguageTypeUnknown; + + return lldb::eLanguageTypeUnknown; } ConstString Function::GetName() const { diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp index 8e503bd4932de..e10a117acbbee 100644 --- a/lldb/source/Target/CPPLanguageRuntime.cpp +++ b/lldb/source/Target/CPPLanguageRuntime.cpp @@ -43,20 +43,8 @@ CPPLanguageRuntime::~CPPLanguageRuntime() {} CPPLanguageRuntime::CPPLanguageRuntime(Process *process) : LanguageRuntime(process) {} -bool CPPLanguageRuntime::IsRuntimeSupportValue(ValueObject &valobj) { - // All runtime support values have to be marked as artificial by the - // compiler. But not all artificial variables should be hidden from - // the user. - if (!valobj.GetVariable()) - return false; - if (!valobj.GetVariable()->IsArtificial()) - return false; - - // Whitelist "this" and since there is no ObjC++ runtime, any ObjC names. - ConstString name = valobj.GetName(); - if (name == g_this) - return false; - return !ObjCLanguageRuntime::IsWhitelistedRuntimeValue(name); +bool CPPLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) { + return name == g_this; } bool CPPLanguageRuntime::GetObjectDescription(Stream &str, diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index ef059a84b191e..5e800981740d3 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -46,19 +46,6 @@ bool ObjCLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) { return name == g_self || name == g_cmd; } -bool ObjCLanguageRuntime::IsRuntimeSupportValue(ValueObject &valobj) { - // All runtime support values have to be marked as artificial by the - // compiler. But not all artificial variables should be hidden from - // the user. - if (!valobj.GetVariable()) - return false; - if (!valobj.GetVariable()->IsArtificial()) - return false; - - // Whitelist "self" and "_cmd". - return !IsWhitelistedRuntimeValue(valobj.GetName()); -} - bool ObjCLanguageRuntime::AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp, const char *class_name) { From ac30f3f7a56df13de9b415d4580e7cfd1ba8de00 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 1 Jul 2019 21:25:34 +0000 Subject: [PATCH 021/616] [Reproducer] Assert on unexpected packet I'm not able to reproduce the reproducer flakiness we're seeing on GreenDragon. I want to add this assert to find out if the GDB remote packets are somehow getting out of sync when this happens. llvm-svn: 364852 (cherry picked from commit 730bed5c83314a02f623d81cf0a9fb9c0f642697) --- .../Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp index 5cdf572bd5a36..b7763d86c200c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp @@ -142,6 +142,7 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse( entry.packet.data); LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'", packet.GetStringRef()); + assert(false && "Encountered unexpected packet during replay"); return PacketResult::ErrorSendFailed; } From e6f309fb45f79f8a0ca589d0591b841096b2355f Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Mon, 1 Jul 2019 22:12:55 +0000 Subject: [PATCH 022/616] [lldb] [lldbsuite] Use a unique class name for TestValueVarUpdate It looks like when this test was added, it was based on TestHelloWorld and it ended up with the same class name. This is an issue because the logs associated with the tests use the class name as the identifier for the file and if two tests have the same name their logs overwrite each other. On non-windows, this just means we lose one of the logs, but on Windows this means that one of the tests will fail occasionally because the file are locked by the other test. llvm-svn: 364860 (cherry picked from commit 86e4d7ea35eee5329e960d20dedda02ff9968aad) --- .../test/python_api/value_var_update/TestValueVarUpdate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py b/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py index a83fd6e123904..866d2a541e668 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py @@ -13,7 +13,7 @@ from lldbsuite.test import lldbutil -class HelloWorldTestCase(TestBase): +class ValueVarUpdateTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) From d7cc42e23c6881d561ba286a3d164cc7042f397b Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 2 Jul 2019 07:57:08 +0000 Subject: [PATCH 023/616] [DWARF] Add one more type unit test This test passes already, but it seems interesting to test that we can jump between type units in different dwo files nonetheless. llvm-svn: 364890 (cherry picked from commit a1c64dcdecb9349d5ff750396366b80fe123c653) --- .../DWARF/debug-types-dwo-cross-reference.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lldb/lit/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp diff --git a/lldb/lit/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp b/lldb/lit/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp new file mode 100644 index 0000000000000..29adff62cd1ee --- /dev/null +++ b/lldb/lit/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp @@ -0,0 +1,37 @@ +// Test that we can jump from a type unit in one dwo file into a type unit in a +// different dwo file. + +// REQUIRES: lld + +// RUN: %clang %s -target x86_64-pc-linux -fno-standalone-debug -g \ +// RUN: -fdebug-types-section -gsplit-dwarf -c -o %t1.o -DONE +// RUN: %clang %s -target x86_64-pc-linux -fno-standalone-debug -g \ +// RUN: -fdebug-types-section -gsplit-dwarf -c -o %t2.o -DTWO +// RUN: llvm-dwarfdump %t1.dwo -debug-types | FileCheck --check-prefix=ONEUNIT %s +// RUN: llvm-dwarfdump %t2.dwo -debug-types | FileCheck --check-prefix=ONEUNIT %s +// RUN: ld.lld %t1.o %t2.o -o %t +// RUN: %lldb %t -o "target var a b **b.a" -b | FileCheck %s + +// ONEUNIT-COUNT-1: DW_TAG_type_unit + +// CHECK: (const A) a = (a = 42) +// CHECK: (const B) b = { +// CHECK-NEXT: a = 0x{{.*}} +// CHECK-NEXT: } +// CHECK: (const A) **b.a = (a = 42) + +struct A; + +extern const A *a_ptr; +#ifdef ONE +struct A { + int a = 42; +}; +constexpr A a{}; +const A *a_ptr = &a; +#else +struct B { + const A **a; +}; +extern constexpr B b{&a_ptr}; +#endif From a5a08df0c58a3feffc7fd4b7a29aa89982e2f7dc Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 2 Jul 2019 17:25:20 +0000 Subject: [PATCH 024/616] [swig] Define attribute(ref) instead of accessing swig internals. As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no longer defined. The solution is to stop using these internal swig dictionaries and use %attribute and %attributeref instead. I plan on doing this incrementally, with this differential serving as an example. Differential revision: https://reviews.llvm.org/D63530 llvm-svn: 364946 (cherry picked from commit f9b91a52797325ccaaee229e414beae7c03f1948) --- lldb/scripts/interface/SBAddress.i | 43 +++----- lldb/scripts/interface/SBBlock.i | 39 +++---- lldb/scripts/interface/SBBreakpoint.i | 29 ++---- lldb/scripts/interface/SBCompileUnit.i | 11 +- lldb/scripts/interface/SBData.i | 94 +++++------------ lldb/scripts/interface/SBDeclaration.i | 18 ++-- lldb/scripts/interface/SBError.i | 25 ++--- lldb/scripts/interface/SBExecutionContext.i | 20 +--- lldb/scripts/interface/SBFileSpec.i | 16 +-- lldb/scripts/interface/SBFrame.i | 108 ++++++-------------- 10 files changed, 114 insertions(+), 289 deletions(-) diff --git a/lldb/scripts/interface/SBAddress.i b/lldb/scripts/interface/SBAddress.i index 068a24db43947..73a1d06ed09ae 100644 --- a/lldb/scripts/interface/SBAddress.i +++ b/lldb/scripts/interface/SBAddress.i @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +%include + namespace lldb { %feature("docstring", @@ -162,39 +164,20 @@ public: '''Convert the address to an hex string''' return '0x%x' % int(self) - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') - - __swig_getmethods__["offset"] = GetOffset - if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') - - __swig_getmethods__["section"] = GetSection - if _newclass: section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') - - __swig_getmethods__["load_addr"] = __get_load_addr_property__ - __swig_setmethods__["load_addr"] = __set_load_addr_property__ - if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') + load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') %} }; +%attributeref(lldb::SBAddress, lldb::SBModule, module, GetModule); +%attributeref(lldb::SBAddress, lldb::SBCompileUnit, compile_unit, GetCompileUnit); +%attributeref(lldb::SBAddress, lldb::SBLineEntry, line_entry, GetLineEntry); +%attributeref(lldb::SBAddress, lldb::SBFunction, function, GetFunction); +%attributeref(lldb::SBAddress, lldb::SBBlock, block, GetBlock); +%attributeref(lldb::SBAddress, lldb::SBSymbol, symbol, GetSymbol); +%attributeref(lldb::SBAddress, lldb::SBSection, section, GetSection); +%attribute(lldb::SBAddress, lldb::addr_t, symbol, GetOffset); +%attribute(lldb::SBAddress, lldb::addr_t, file_addr, GetFileAddress); + } // namespace lldb diff --git a/lldb/scripts/interface/SBBlock.i b/lldb/scripts/interface/SBBlock.i index 26f78166a8edb..e8e2af56700f9 100644 --- a/lldb/scripts/interface/SBBlock.i +++ b/lldb/scripts/interface/SBBlock.i @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +%include + namespace lldb { %feature("docstring", @@ -143,34 +145,17 @@ public: def get_call_site(self): return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) - __swig_getmethods__["parent"] = GetParent - if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') - - __swig_getmethods__["first_child"] = GetFirstChild - if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') - - __swig_getmethods__["call_site"] = get_call_site - if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') - - __swig_getmethods__["sibling"] = GetSibling - if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') - - __swig_getmethods__["name"] = GetInlinedName - if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') - - __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock - if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') - - __swig_getmethods__["range"] = get_ranges_access_object - if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') - - __swig_getmethods__["ranges"] = get_ranges_array - if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') - - __swig_getmethods__["num_ranges"] = GetNumRanges - if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') + call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') + range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') + ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') %} - }; +%attributeref(lldb::SBBlock, lldb::SBBlock, parent, GetParent); +%attributeref(lldb::SBBlock, lldb::SBBlock, first_child, GetFirstChild); +%attributeref(lldb::SBBlock, lldb::SBBlock, sibling, GetSibling); +%attributeref(lldb::SBBlock, lldb::SBBlock, inlined_block, GetContainingInlinedBlock); +%attribute(lldb::SBBlock, const char*, name, GetInlinedName); +%attribute(lldb::SBBlock, uint32_t, num_ranges, GetNumRanges); + } // namespace lldb diff --git a/lldb/scripts/interface/SBBreakpoint.i b/lldb/scripts/interface/SBBreakpoint.i index 1cf639b17a812..30ba769ff8ee1 100644 --- a/lldb/scripts/interface/SBBreakpoint.i +++ b/lldb/scripts/interface/SBBreakpoint.i @@ -7,6 +7,8 @@ //===----------------------------------------------------------------------===// namespace lldb { +%include + %feature("docstring", "Represents a logical breakpoint and its associated settings. @@ -286,31 +288,18 @@ public: object.''' return self.GetNumLocations() - __swig_getmethods__["locations"] = get_breakpoint_location_list - if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') - - __swig_getmethods__["location"] = get_locations_access_object - if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') - - __swig_getmethods__["id"] = GetID - if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') - - __swig_getmethods__["enabled"] = IsEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') - - __swig_getmethods__["one_shot"] = IsOneShot - __swig_setmethods__["one_shot"] = SetOneShot - if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') - - __swig_getmethods__["num_locations"] = GetNumLocations - if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') - + locations = property(get_breakpoint_location_list) + location = property(get_locations_access_object) %} }; +%attribute(lldb::SBBreakpoint, lldb::break_id_t, id, GetID); +%attribute(lldb::SBBreakpoint, bool, enabled, IsEnabled, SetEnabled); +%attribute(lldb::SBBreakpoint, bool, one_shot, IsOneShot, SetOneShot); +%attribute(lldb::SBBreakpoint, size_t, num_locations, GetNumLocations); + class SBBreakpointListImpl; class LLDB_API SBBreakpointList diff --git a/lldb/scripts/interface/SBCompileUnit.i b/lldb/scripts/interface/SBCompileUnit.i index 26c10df2c3dc8..ca94756019998 100644 --- a/lldb/scripts/interface/SBCompileUnit.i +++ b/lldb/scripts/interface/SBCompileUnit.i @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +%include + namespace lldb { %feature("docstring", @@ -125,13 +127,10 @@ public: '''Return the number of line entries in a lldb.SBCompileUnit object.''' return self.GetNumLineEntries() - - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') - - __swig_getmethods__["num_line_entries"] = GetNumLineEntries - if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') %} }; +%attributeref(lldb::SBCompileUnit, lldb::SBFileSpec, file, GetFileSpec); +%attribute(lldb::SBCompileUnit, uint32_t, num_line_entries, GetNumLineEntries); + } // namespace lldb diff --git a/lldb/scripts/interface/SBData.i b/lldb/scripts/interface/SBData.i index b7cef91d532c0..430143354172f 100644 --- a/lldb/scripts/interface/SBData.i +++ b/lldb/scripts/interface/SBData.i @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +%include namespace lldb { @@ -264,78 +265,31 @@ public: def _read_all_double(self): return self._make_helper_double().all() - __swig_getmethods__["uint8"] = _make_helper_uint8 - if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') - - __swig_getmethods__["uint16"] = _make_helper_uint16 - if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') - - __swig_getmethods__["uint32"] = _make_helper_uint32 - if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') - - __swig_getmethods__["uint64"] = _make_helper_uint64 - if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') - - __swig_getmethods__["sint8"] = _make_helper_sint8 - if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') - - __swig_getmethods__["sint16"] = _make_helper_sint16 - if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') - - __swig_getmethods__["sint32"] = _make_helper_sint32 - if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') - - __swig_getmethods__["sint64"] = _make_helper_sint64 - if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') - - __swig_getmethods__["float"] = _make_helper_float - if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') - - __swig_getmethods__["double"] = _make_helper_double - if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') - - __swig_getmethods__["uint8s"] = _read_all_uint8 - if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') - - __swig_getmethods__["uint16s"] = _read_all_uint16 - if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') - - __swig_getmethods__["uint32s"] = _read_all_uint32 - if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') - - __swig_getmethods__["uint64s"] = _read_all_uint64 - if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') - - __swig_getmethods__["sint8s"] = _read_all_sint8 - if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') - - __swig_getmethods__["sint16s"] = _read_all_sint16 - if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') - - __swig_getmethods__["sint32s"] = _read_all_sint32 - if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') - - __swig_getmethods__["sint64s"] = _read_all_sint64 - if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') - - __swig_getmethods__["floats"] = _read_all_float - if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') - - __swig_getmethods__["doubles"] = _read_all_double - if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') + uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') + uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') + uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') + uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') + sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') + sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') + sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') + sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') + float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') + double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') + uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') + uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') + uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') + uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') + sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') + sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') + sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') + sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') + floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') + doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') %} - - %pythoncode %{ - __swig_getmethods__["byte_order"] = GetByteOrder - __swig_setmethods__["byte_order"] = SetByteOrder - if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') - - %} - }; +%attribute(lldb::SBData, lldb::ByteOrder, byte_order, GetByteOrder, SetByteOrder); +%attribute(lldb::SBData, size_t, byte_order, GetByteSize); + } // namespace lldb diff --git a/lldb/scripts/interface/SBDeclaration.i b/lldb/scripts/interface/SBDeclaration.i index 1fa801425ef81..c51ccea0cd649 100644 --- a/lldb/scripts/interface/SBDeclaration.i +++ b/lldb/scripts/interface/SBDeclaration.i @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +%include + namespace lldb { %feature("docstring", @@ -52,18 +54,10 @@ namespace lldb { bool operator != (const lldb::SBDeclaration &rhs) const; - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') - - __swig_getmethods__["line"] = GetLine - if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') - - __swig_getmethods__["column"] = GetColumn - if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') - %} - }; +%attributeref(lldb::SBDeclaration, lldb::SBFileSpec, file, GetFileSpec); +%attribute(lldb::SBDeclaration, uint32_t, line, GetLine); +%attribute(lldb::SBDeclaration, uint32_t, column, GetColumn); + } // namespace lldb diff --git a/lldb/scripts/interface/SBError.i b/lldb/scripts/interface/SBError.i index d1b3dabb247df..b489a99457d1f 100644 --- a/lldb/scripts/interface/SBError.i +++ b/lldb/scripts/interface/SBError.i @@ -104,25 +104,12 @@ public: bool GetDescription (lldb::SBStream &description); - - %pythoncode %{ - __swig_getmethods__["value"] = GetError - if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') - - __swig_getmethods__["fail"] = Fail - if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') - - __swig_getmethods__["success"] = Success - if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''') - - __swig_getmethods__["description"] = GetCString - if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') - - %} - }; +%attribute(lldb::SBError, uint32_t, value, GetError); +%attribute(lldb::SBError, bool, fail, Fail); +%attribute(lldb::SBError, bool, success, Success); +%attribute(lldb::SBError, const char*, description, GetCString); +%attribute(lldb::SBError, lldb::ErrorType, type, GetType); + } // namespace lldb diff --git a/lldb/scripts/interface/SBExecutionContext.i b/lldb/scripts/interface/SBExecutionContext.i index 8ffa1f8a354a9..5ff87bea3fdc4 100644 --- a/lldb/scripts/interface/SBExecutionContext.i +++ b/lldb/scripts/interface/SBExecutionContext.i @@ -36,21 +36,11 @@ public: SBFrame GetFrame () const; - - %pythoncode %{ - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') - %} - }; +%attributeref(lldb::SBExecutionContext, lldb::SBTarget, target, GetTarget); +%attributeref(lldb::SBExecutionContext, lldb::SBProcess, process, GetProcess); +%attributeref(lldb::SBExecutionContext, lldb::SBThread, process, GetThread); +%attributeref(lldb::SBExecutionContext, lldb::SBFrame, process, GetFrame); + } // namespace lldb diff --git a/lldb/scripts/interface/SBFileSpec.i b/lldb/scripts/interface/SBFileSpec.i index d5cdb7d3c4ae4..11e9c769730eb 100644 --- a/lldb/scripts/interface/SBFileSpec.i +++ b/lldb/scripts/interface/SBFileSpec.i @@ -92,19 +92,13 @@ public: return spec_file return None - __swig_getmethods__["fullpath"] = __get_fullpath__ - if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') - - __swig_getmethods__["basename"] = GetFilename - if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') - - __swig_getmethods__["dirname"] = GetDirectory - if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') - - __swig_getmethods__["exists"] = Exists - if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') + fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') %} }; +%attribute(lldb::SBFileSpec, const char*, basename, GetFilename); +%attribute(lldb::SBFileSpec, const char*, dirname, GetDirectory); +%attribute(lldb::SBFileSpec, bool, exists, Exists); + } // namespace lldb diff --git a/lldb/scripts/interface/SBFrame.i b/lldb/scripts/interface/SBFrame.i index b8f383e06fc5e..9ff8d4e1751a1 100644 --- a/lldb/scripts/interface/SBFrame.i +++ b/lldb/scripts/interface/SBFrame.i @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +%include + namespace lldb { %feature("docstring", @@ -328,86 +330,34 @@ public: return registers_access(self.registers) - __swig_getmethods__["pc"] = GetPC - __swig_setmethods__["pc"] = SetPC - if _newclass: pc = property(GetPC, SetPC) - - __swig_getmethods__["addr"] = GetPCAddress - if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') - - __swig_getmethods__["fp"] = GetFP - if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') - - __swig_getmethods__["sp"] = GetSP - if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') - - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') - - __swig_getmethods__["is_inlined"] = IsInlined - if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') - - __swig_getmethods__["name"] = GetFunctionName - if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') - - __swig_getmethods__["disassembly"] = Disassemble - if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') - - __swig_getmethods__["idx"] = GetFrameID - if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') - - __swig_getmethods__["variables"] = get_all_variables - if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["vars"] = get_all_variables - if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["locals"] = get_locals - if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') - - __swig_getmethods__["args"] = get_arguments - if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["arguments"] = get_arguments - if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["statics"] = get_statics - if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') - - __swig_getmethods__["registers"] = GetRegisters - if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["regs"] = GetRegisters - if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["register"] = get_registers_access - if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') - - __swig_getmethods__["reg"] = get_registers_access - if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') - - __swig_getmethods__["parent"] = get_parent_frame - if _newclass: parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') - + parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') + variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') + args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') + register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') + reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') %} }; +%attributeref(lldb::SBFrame, lldb::SBAddress, addr, GetPCAddress); +%attributeref(lldb::SBFrame, lldb::SBModule, module, GetModule); +%attributeref(lldb::SBFrame, lldb::SBCompileUnit, compile_unit, GetCompileUnit); +%attributeref(lldb::SBFrame, lldb::SBFunction, function, GetFunction); +%attributeref(lldb::SBFrame, lldb::SBBlock, block, GetBlock); +%attributeref(lldb::SBFrame, lldb::SBSymbol, symbol, GetSymbol); +%attributeref(lldb::SBFrame, lldb::SBLineEntry, line_entry, GetLineEntry); +%attributeref(lldb::SBFrame, lldb::SBThread, thread, GetThread); +%attributeref(lldb::SBFrame, lldb::SBValueList, registers, GetRegisters); +%attributeref(lldb::SBFrame, lldb::SBValueList, regs, GetRegisters); +%attribute(lldb::SBFrame, lldb::addr_t, pc, GetPC, SetPC); +%attribute(lldb::SBFrame, lldb::addr_t, fp, GetFP); +%attribute(lldb::SBFrame, lldb::addr_t, sp, GetSP); +%attribute(lldb::SBFrame, bool, is_inlined, IsInlined); +%attribute(lldb::SBFrame, const char*, name, GetFunctionName); +%attribute(lldb::SBFrame, const char*, disassembly, Disassemble); +%attribute(lldb::SBFrame, uint32_t, idx, GetFrameID); + } // namespace lldb From 2aa70f9edfab8f49e0722144fc255307e7a95eb5 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 2 Jul 2019 18:04:55 +0000 Subject: [PATCH 025/616] Revert "[swig] Define attribute(ref) instead of accessing swig internals." This reverts commit f9b91a52797325ccaaee229e414beae7c03f1948. llvm-svn: 364951 (cherry picked from commit 97316fff5d6a7c3d2c072301a118ac0cb5094ad8) --- lldb/scripts/interface/SBAddress.i | 43 +++++--- lldb/scripts/interface/SBBlock.i | 39 ++++--- lldb/scripts/interface/SBBreakpoint.i | 29 ++++-- lldb/scripts/interface/SBCompileUnit.i | 11 +- lldb/scripts/interface/SBData.i | 94 ++++++++++++----- lldb/scripts/interface/SBDeclaration.i | 18 ++-- lldb/scripts/interface/SBError.i | 25 +++-- lldb/scripts/interface/SBExecutionContext.i | 20 +++- lldb/scripts/interface/SBFileSpec.i | 16 ++- lldb/scripts/interface/SBFrame.i | 108 ++++++++++++++------ 10 files changed, 289 insertions(+), 114 deletions(-) diff --git a/lldb/scripts/interface/SBAddress.i b/lldb/scripts/interface/SBAddress.i index 73a1d06ed09ae..068a24db43947 100644 --- a/lldb/scripts/interface/SBAddress.i +++ b/lldb/scripts/interface/SBAddress.i @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -%include - namespace lldb { %feature("docstring", @@ -164,20 +162,39 @@ public: '''Convert the address to an hex string''' return '0x%x' % int(self) - load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') + __swig_getmethods__["module"] = GetModule + if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') + + __swig_getmethods__["compile_unit"] = GetCompileUnit + if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') + + __swig_getmethods__["line_entry"] = GetLineEntry + if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') + + __swig_getmethods__["function"] = GetFunction + if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') + + __swig_getmethods__["block"] = GetBlock + if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') + + __swig_getmethods__["symbol"] = GetSymbol + if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') + + __swig_getmethods__["offset"] = GetOffset + if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') + + __swig_getmethods__["section"] = GetSection + if _newclass: section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') + + __swig_getmethods__["file_addr"] = GetFileAddress + if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') + + __swig_getmethods__["load_addr"] = __get_load_addr_property__ + __swig_setmethods__["load_addr"] = __set_load_addr_property__ + if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') %} }; -%attributeref(lldb::SBAddress, lldb::SBModule, module, GetModule); -%attributeref(lldb::SBAddress, lldb::SBCompileUnit, compile_unit, GetCompileUnit); -%attributeref(lldb::SBAddress, lldb::SBLineEntry, line_entry, GetLineEntry); -%attributeref(lldb::SBAddress, lldb::SBFunction, function, GetFunction); -%attributeref(lldb::SBAddress, lldb::SBBlock, block, GetBlock); -%attributeref(lldb::SBAddress, lldb::SBSymbol, symbol, GetSymbol); -%attributeref(lldb::SBAddress, lldb::SBSection, section, GetSection); -%attribute(lldb::SBAddress, lldb::addr_t, symbol, GetOffset); -%attribute(lldb::SBAddress, lldb::addr_t, file_addr, GetFileAddress); - } // namespace lldb diff --git a/lldb/scripts/interface/SBBlock.i b/lldb/scripts/interface/SBBlock.i index e8e2af56700f9..26f78166a8edb 100644 --- a/lldb/scripts/interface/SBBlock.i +++ b/lldb/scripts/interface/SBBlock.i @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -%include - namespace lldb { %feature("docstring", @@ -145,17 +143,34 @@ public: def get_call_site(self): return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) - call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') - range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') - ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') + __swig_getmethods__["parent"] = GetParent + if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') + + __swig_getmethods__["first_child"] = GetFirstChild + if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') + + __swig_getmethods__["call_site"] = get_call_site + if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') + + __swig_getmethods__["sibling"] = GetSibling + if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') + + __swig_getmethods__["name"] = GetInlinedName + if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') + + __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock + if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') + + __swig_getmethods__["range"] = get_ranges_access_object + if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') + + __swig_getmethods__["ranges"] = get_ranges_array + if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') + + __swig_getmethods__["num_ranges"] = GetNumRanges + if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') %} -}; -%attributeref(lldb::SBBlock, lldb::SBBlock, parent, GetParent); -%attributeref(lldb::SBBlock, lldb::SBBlock, first_child, GetFirstChild); -%attributeref(lldb::SBBlock, lldb::SBBlock, sibling, GetSibling); -%attributeref(lldb::SBBlock, lldb::SBBlock, inlined_block, GetContainingInlinedBlock); -%attribute(lldb::SBBlock, const char*, name, GetInlinedName); -%attribute(lldb::SBBlock, uint32_t, num_ranges, GetNumRanges); +}; } // namespace lldb diff --git a/lldb/scripts/interface/SBBreakpoint.i b/lldb/scripts/interface/SBBreakpoint.i index 30ba769ff8ee1..1cf639b17a812 100644 --- a/lldb/scripts/interface/SBBreakpoint.i +++ b/lldb/scripts/interface/SBBreakpoint.i @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// namespace lldb { -%include - %feature("docstring", "Represents a logical breakpoint and its associated settings. @@ -288,18 +286,31 @@ public: object.''' return self.GetNumLocations() - locations = property(get_breakpoint_location_list) - location = property(get_locations_access_object) + __swig_getmethods__["locations"] = get_breakpoint_location_list + if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') + + __swig_getmethods__["location"] = get_locations_access_object + if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') + + __swig_getmethods__["id"] = GetID + if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') + + __swig_getmethods__["enabled"] = IsEnabled + __swig_setmethods__["enabled"] = SetEnabled + if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') + + __swig_getmethods__["one_shot"] = IsOneShot + __swig_setmethods__["one_shot"] = SetOneShot + if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') + + __swig_getmethods__["num_locations"] = GetNumLocations + if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') + %} }; -%attribute(lldb::SBBreakpoint, lldb::break_id_t, id, GetID); -%attribute(lldb::SBBreakpoint, bool, enabled, IsEnabled, SetEnabled); -%attribute(lldb::SBBreakpoint, bool, one_shot, IsOneShot, SetOneShot); -%attribute(lldb::SBBreakpoint, size_t, num_locations, GetNumLocations); - class SBBreakpointListImpl; class LLDB_API SBBreakpointList diff --git a/lldb/scripts/interface/SBCompileUnit.i b/lldb/scripts/interface/SBCompileUnit.i index ca94756019998..26c10df2c3dc8 100644 --- a/lldb/scripts/interface/SBCompileUnit.i +++ b/lldb/scripts/interface/SBCompileUnit.i @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -%include - namespace lldb { %feature("docstring", @@ -127,10 +125,13 @@ public: '''Return the number of line entries in a lldb.SBCompileUnit object.''' return self.GetNumLineEntries() + + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') + + __swig_getmethods__["num_line_entries"] = GetNumLineEntries + if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') %} }; -%attributeref(lldb::SBCompileUnit, lldb::SBFileSpec, file, GetFileSpec); -%attribute(lldb::SBCompileUnit, uint32_t, num_line_entries, GetNumLineEntries); - } // namespace lldb diff --git a/lldb/scripts/interface/SBData.i b/lldb/scripts/interface/SBData.i index 430143354172f..b7cef91d532c0 100644 --- a/lldb/scripts/interface/SBData.i +++ b/lldb/scripts/interface/SBData.i @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -%include namespace lldb { @@ -265,31 +264,78 @@ public: def _read_all_double(self): return self._make_helper_double().all() - uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') - uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') - uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') - uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') - sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') - sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') - sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') - sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') - float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') - double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') - uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') - uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') - uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') - uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') - sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') - sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') - sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') - sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') - floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') - doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') + __swig_getmethods__["uint8"] = _make_helper_uint8 + if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') + + __swig_getmethods__["uint16"] = _make_helper_uint16 + if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') + + __swig_getmethods__["uint32"] = _make_helper_uint32 + if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') + + __swig_getmethods__["uint64"] = _make_helper_uint64 + if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') + + __swig_getmethods__["sint8"] = _make_helper_sint8 + if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') + + __swig_getmethods__["sint16"] = _make_helper_sint16 + if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') + + __swig_getmethods__["sint32"] = _make_helper_sint32 + if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') + + __swig_getmethods__["sint64"] = _make_helper_sint64 + if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') + + __swig_getmethods__["float"] = _make_helper_float + if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') + + __swig_getmethods__["double"] = _make_helper_double + if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') + + __swig_getmethods__["uint8s"] = _read_all_uint8 + if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') + + __swig_getmethods__["uint16s"] = _read_all_uint16 + if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') + + __swig_getmethods__["uint32s"] = _read_all_uint32 + if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') + + __swig_getmethods__["uint64s"] = _read_all_uint64 + if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') + + __swig_getmethods__["sint8s"] = _read_all_sint8 + if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') + + __swig_getmethods__["sint16s"] = _read_all_sint16 + if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') + + __swig_getmethods__["sint32s"] = _read_all_sint32 + if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') + + __swig_getmethods__["sint64s"] = _read_all_sint64 + if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') + + __swig_getmethods__["floats"] = _read_all_float + if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') + + __swig_getmethods__["doubles"] = _read_all_double + if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') %} -}; -%attribute(lldb::SBData, lldb::ByteOrder, byte_order, GetByteOrder, SetByteOrder); -%attribute(lldb::SBData, size_t, byte_order, GetByteSize); + %pythoncode %{ + __swig_getmethods__["byte_order"] = GetByteOrder + __swig_setmethods__["byte_order"] = SetByteOrder + if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') + + %} + +}; } // namespace lldb diff --git a/lldb/scripts/interface/SBDeclaration.i b/lldb/scripts/interface/SBDeclaration.i index c51ccea0cd649..1fa801425ef81 100644 --- a/lldb/scripts/interface/SBDeclaration.i +++ b/lldb/scripts/interface/SBDeclaration.i @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -%include - namespace lldb { %feature("docstring", @@ -54,10 +52,18 @@ namespace lldb { bool operator != (const lldb::SBDeclaration &rhs) const; - }; -%attributeref(lldb::SBDeclaration, lldb::SBFileSpec, file, GetFileSpec); -%attribute(lldb::SBDeclaration, uint32_t, line, GetLine); -%attribute(lldb::SBDeclaration, uint32_t, column, GetColumn); + %pythoncode %{ + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') + + __swig_getmethods__["line"] = GetLine + if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') + + __swig_getmethods__["column"] = GetColumn + if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') + %} + + }; } // namespace lldb diff --git a/lldb/scripts/interface/SBError.i b/lldb/scripts/interface/SBError.i index b489a99457d1f..d1b3dabb247df 100644 --- a/lldb/scripts/interface/SBError.i +++ b/lldb/scripts/interface/SBError.i @@ -104,12 +104,25 @@ public: bool GetDescription (lldb::SBStream &description); -}; -%attribute(lldb::SBError, uint32_t, value, GetError); -%attribute(lldb::SBError, bool, fail, Fail); -%attribute(lldb::SBError, bool, success, Success); -%attribute(lldb::SBError, const char*, description, GetCString); -%attribute(lldb::SBError, lldb::ErrorType, type, GetType); + %pythoncode %{ + __swig_getmethods__["value"] = GetError + if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') + + __swig_getmethods__["fail"] = Fail + if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') + + __swig_getmethods__["success"] = Success + if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''') + + __swig_getmethods__["description"] = GetCString + if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') + + %} + +}; } // namespace lldb diff --git a/lldb/scripts/interface/SBExecutionContext.i b/lldb/scripts/interface/SBExecutionContext.i index 5ff87bea3fdc4..8ffa1f8a354a9 100644 --- a/lldb/scripts/interface/SBExecutionContext.i +++ b/lldb/scripts/interface/SBExecutionContext.i @@ -36,11 +36,21 @@ public: SBFrame GetFrame () const; -}; -%attributeref(lldb::SBExecutionContext, lldb::SBTarget, target, GetTarget); -%attributeref(lldb::SBExecutionContext, lldb::SBProcess, process, GetProcess); -%attributeref(lldb::SBExecutionContext, lldb::SBThread, process, GetThread); -%attributeref(lldb::SBExecutionContext, lldb::SBFrame, process, GetFrame); + %pythoncode %{ + __swig_getmethods__["target"] = GetTarget + if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') + + __swig_getmethods__["process"] = GetProcess + if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') + + __swig_getmethods__["thread"] = GetThread + if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') + + __swig_getmethods__["frame"] = GetFrame + if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') + %} + +}; } // namespace lldb diff --git a/lldb/scripts/interface/SBFileSpec.i b/lldb/scripts/interface/SBFileSpec.i index 11e9c769730eb..d5cdb7d3c4ae4 100644 --- a/lldb/scripts/interface/SBFileSpec.i +++ b/lldb/scripts/interface/SBFileSpec.i @@ -92,13 +92,19 @@ public: return spec_file return None - fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') + __swig_getmethods__["fullpath"] = __get_fullpath__ + if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') + + __swig_getmethods__["basename"] = GetFilename + if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') + + __swig_getmethods__["dirname"] = GetDirectory + if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') + + __swig_getmethods__["exists"] = Exists + if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') %} }; -%attribute(lldb::SBFileSpec, const char*, basename, GetFilename); -%attribute(lldb::SBFileSpec, const char*, dirname, GetDirectory); -%attribute(lldb::SBFileSpec, bool, exists, Exists); - } // namespace lldb diff --git a/lldb/scripts/interface/SBFrame.i b/lldb/scripts/interface/SBFrame.i index 9ff8d4e1751a1..b8f383e06fc5e 100644 --- a/lldb/scripts/interface/SBFrame.i +++ b/lldb/scripts/interface/SBFrame.i @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -%include - namespace lldb { %feature("docstring", @@ -330,34 +328,86 @@ public: return registers_access(self.registers) - parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') - variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') - args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') - register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') - reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') + __swig_getmethods__["pc"] = GetPC + __swig_setmethods__["pc"] = SetPC + if _newclass: pc = property(GetPC, SetPC) + + __swig_getmethods__["addr"] = GetPCAddress + if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') + + __swig_getmethods__["fp"] = GetFP + if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') + + __swig_getmethods__["sp"] = GetSP + if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') + + __swig_getmethods__["module"] = GetModule + if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') + + __swig_getmethods__["compile_unit"] = GetCompileUnit + if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') + + __swig_getmethods__["function"] = GetFunction + if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') + + __swig_getmethods__["symbol"] = GetSymbol + if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') + + __swig_getmethods__["block"] = GetBlock + if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') + + __swig_getmethods__["is_inlined"] = IsInlined + if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') + + __swig_getmethods__["name"] = GetFunctionName + if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') + + __swig_getmethods__["line_entry"] = GetLineEntry + if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') + + __swig_getmethods__["thread"] = GetThread + if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') + + __swig_getmethods__["disassembly"] = Disassemble + if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') + + __swig_getmethods__["idx"] = GetFrameID + if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') + + __swig_getmethods__["variables"] = get_all_variables + if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + + __swig_getmethods__["vars"] = get_all_variables + if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + + __swig_getmethods__["locals"] = get_locals + if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') + + __swig_getmethods__["args"] = get_arguments + if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + + __swig_getmethods__["arguments"] = get_arguments + if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + + __swig_getmethods__["statics"] = get_statics + if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') + + __swig_getmethods__["registers"] = GetRegisters + if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + + __swig_getmethods__["regs"] = GetRegisters + if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + + __swig_getmethods__["register"] = get_registers_access + if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') + + __swig_getmethods__["reg"] = get_registers_access + if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') + + __swig_getmethods__["parent"] = get_parent_frame + if _newclass: parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') + %} }; -%attributeref(lldb::SBFrame, lldb::SBAddress, addr, GetPCAddress); -%attributeref(lldb::SBFrame, lldb::SBModule, module, GetModule); -%attributeref(lldb::SBFrame, lldb::SBCompileUnit, compile_unit, GetCompileUnit); -%attributeref(lldb::SBFrame, lldb::SBFunction, function, GetFunction); -%attributeref(lldb::SBFrame, lldb::SBBlock, block, GetBlock); -%attributeref(lldb::SBFrame, lldb::SBSymbol, symbol, GetSymbol); -%attributeref(lldb::SBFrame, lldb::SBLineEntry, line_entry, GetLineEntry); -%attributeref(lldb::SBFrame, lldb::SBThread, thread, GetThread); -%attributeref(lldb::SBFrame, lldb::SBValueList, registers, GetRegisters); -%attributeref(lldb::SBFrame, lldb::SBValueList, regs, GetRegisters); -%attribute(lldb::SBFrame, lldb::addr_t, pc, GetPC, SetPC); -%attribute(lldb::SBFrame, lldb::addr_t, fp, GetFP); -%attribute(lldb::SBFrame, lldb::addr_t, sp, GetSP); -%attribute(lldb::SBFrame, bool, is_inlined, IsInlined); -%attribute(lldb::SBFrame, const char*, name, GetFunctionName); -%attribute(lldb::SBFrame, const char*, disassembly, Disassemble); -%attribute(lldb::SBFrame, uint32_t, idx, GetFrameID); - } // namespace lldb From b158dd619fa1c44280a1d53a43f576aa574a090a Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 2 Jul 2019 19:53:07 +0000 Subject: [PATCH 026/616] [Symbol] Add DeclVendor::FindTypes Summary: Following up on the plan I outlined in D63622, we can remove the dependence on clang in all the places where we only want to find the types from the DeclVendor. This means that currently DeclVendor depends on clang, but centralizing the dependency makes it easier to refactor cleanly. Differential Revision: https://reviews.llvm.org/D63853 llvm-svn: 364962 (cherry picked from commit 8055cbc4490932e617e5dd0278a38e498adee98c) --- lldb/include/lldb/Symbol/DeclVendor.h | 13 ++++++ lldb/source/API/SBTarget.cpp | 26 +++-------- .../Plugins/Language/ObjC/ObjCLanguage.cpp | 44 +++++++------------ .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 10 ++--- .../AppleObjCTypeEncodingParser.cpp | 14 ++---- lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Symbol/DeclVendor.cpp | 29 ++++++++++++ 7 files changed, 73 insertions(+), 64 deletions(-) create mode 100644 lldb/source/Symbol/DeclVendor.cpp diff --git a/lldb/include/lldb/Symbol/DeclVendor.h b/lldb/include/lldb/Symbol/DeclVendor.h index 19458773b1091..9c10fe1177fba 100644 --- a/lldb/include/lldb/Symbol/DeclVendor.h +++ b/lldb/include/lldb/Symbol/DeclVendor.h @@ -47,6 +47,19 @@ class DeclVendor { uint32_t max_matches, std::vector &decls) = 0; + /// Look up the types that the DeclVendor currently knows about matching a + /// given name. + /// + /// \param[in] name + /// The name to look for. + /// + /// \param[in] max_matches + // The maximum number of matches. UINT32_MAX means "as many as possible". + /// + /// \return + /// The vector of CompilerTypes that was found. + std::vector FindTypes(ConstString name, uint32_t max_matches); + /// Interface for ExternalASTMerger. Returns an ImporterSource /// allowing type completion. /// diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index b1ad0d8f58b5e..5e87eb6273b3d 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1847,18 +1847,12 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { } // Didn't find the type in the symbols; Try the loaded language runtimes - // FIXME: This depends on clang, but should be able to support any - // TypeSystem/compiler. if (auto process_sp = target_sp->GetProcessSP()) { for (auto *runtime : process_sp->GetLanguageRuntimes()) { if (auto vendor = runtime->GetDeclVendor()) { - std::vector decls; - if (vendor->FindDecls(const_typename, /*append*/ true, - /*max_matches*/ 1, decls) > 0) { - if (CompilerType type = - ClangASTContext::GetTypeForDecl(decls.front())) - return LLDB_RECORD_RESULT(SBType(type)); - } + auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1); + if (!types.empty()) + return LLDB_RECORD_RESULT(SBType(types.front())); } } } @@ -1911,19 +1905,13 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { } // Try the loaded language runtimes - // FIXME: This depends on clang, but should be able to support any - // TypeSystem/compiler. if (auto process_sp = target_sp->GetProcessSP()) { for (auto *runtime : process_sp->GetLanguageRuntimes()) { if (auto *vendor = runtime->GetDeclVendor()) { - std::vector decls; - if (vendor->FindDecls(const_typename, /*append*/ true, - /*max_matches*/ 1, decls) > 0) { - for (auto *decl : decls) { - if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) - sb_type_list.Append(SBType(type)); - } - } + auto types = + vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX); + for (auto type : types) + sb_type_list.Append(SBType(type)); } } } diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index bce7e93ad3a1b..fc0c933e13f74 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -932,25 +932,16 @@ std::unique_ptr ObjCLanguage::GetTypeScavenger() { ResultSet &results) override { bool result = false; - Process *process = exe_scope->CalculateProcess().get(); - if (process) { - auto objc_runtime = ObjCLanguageRuntime::Get(*process); - if (objc_runtime) { - auto decl_vendor = objc_runtime->GetDeclVendor(); - if (decl_vendor) { - std::vector decls; + if (auto *process = exe_scope->CalculateProcess().get()) { + if (auto *objc_runtime = ObjCLanguageRuntime::Get(*process)) { + if (auto *decl_vendor = objc_runtime->GetDeclVendor()) { ConstString name(key); - decl_vendor->FindDecls(name, true, UINT32_MAX, decls); - for (auto decl : decls) { - if (decl) { - if (CompilerType candidate = - ClangASTContext::GetTypeForDecl(decl)) { - result = true; - std::unique_ptr result( - new ObjCScavengerResult(candidate)); - results.insert(std::move(result)); - } - } + for (const CompilerType &type : + decl_vendor->FindTypes(name, /*max_matches*/ UINT32_MAX)) { + result = true; + std::unique_ptr result( + new ObjCScavengerResult(type)); + results.insert(std::move(result)); } } } @@ -968,21 +959,16 @@ std::unique_ptr ObjCLanguage::GetTypeScavenger() { ResultSet &results) override { bool result = false; - Target *target = exe_scope->CalculateTarget().get(); - if (target) { - if (auto clang_modules_decl_vendor = + if (auto *target = exe_scope->CalculateTarget().get()) { + if (auto *clang_modules_decl_vendor = target->GetClangModulesDeclVendor()) { - std::vector decls; ConstString key_cs(key); - - if (clang_modules_decl_vendor->FindDecls(key_cs, false, UINT32_MAX, - decls) > 0 && - !decls.empty()) { - CompilerType module_type = - ClangASTContext::GetTypeForDecl(decls.front()); + auto types = clang_modules_decl_vendor->FindTypes( + key_cs, /*max_matches*/ UINT32_MAX); + if (!types.empty()) { result = true; std::unique_ptr result( - new ObjCScavengerResult(module_type)); + new ObjCScavengerResult(types.front())); results.insert(std::move(result)); } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index c849a5441f02d..38a4f9e4094e5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -474,12 +474,10 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( class_type_or_name.SetTypeSP(type_sp); } else { // try to go for a CompilerType at least - DeclVendor *vendor = GetDeclVendor(); - if (vendor) { - std::vector decls; - if (vendor->FindDecls(class_name, false, 1, decls) && decls.size()) - class_type_or_name.SetCompilerType( - ClangASTContext::GetTypeForDecl(decls[0])); + if (auto *vendor = GetDeclVendor()) { + auto types = vendor->FindTypes(class_name, /*max_matches*/ 1); + if (!types.empty()) + class_type_or_name.SetCompilerType(types.front()); } } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index e1068e8d403f1..26654e9212b9b 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -245,25 +245,19 @@ clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType( if (!decl_vendor) return clang::QualType(); - const bool append = false; - const uint32_t max_matches = 1; - std::vector decls; - - uint32_t num_types = - decl_vendor->FindDecls(ConstString(name), append, max_matches, decls); + auto types = decl_vendor->FindTypes(ConstString(name), /*max_matches*/ 1); // The user can forward-declare something that has no definition. The runtime // doesn't prohibit this at all. This is a rare and very weird case. We keep // this assert in debug builds so we catch other weird cases. #ifdef LLDB_CONFIGURATION_DEBUG - assert(num_types); + assert(!types.empty()); #else - if (!num_types) + if (types.empty()) return ast_ctx.getObjCIdType(); #endif - return ClangUtil::GetQualType( - ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType()); + return ClangUtil::GetQualType(types.front().GetPointerType()); } else { // We're going to resolve this dynamically anyway, so just smile and wave. return ast_ctx.getObjCIdType(); diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt index 18e3725b783b0..96ccc25220acb 100644 --- a/lldb/source/Symbol/CMakeLists.txt +++ b/lldb/source/Symbol/CMakeLists.txt @@ -21,6 +21,7 @@ add_lldb_library(lldbSymbol DWARFCallFrameInfo.cpp DebugMacros.cpp Declaration.cpp + DeclVendor.cpp FuncUnwinders.cpp Function.cpp LineEntry.cpp diff --git a/lldb/source/Symbol/DeclVendor.cpp b/lldb/source/Symbol/DeclVendor.cpp new file mode 100644 index 0000000000000..0a912a2fd2142 --- /dev/null +++ b/lldb/source/Symbol/DeclVendor.cpp @@ -0,0 +1,29 @@ +//===-- DeclVendor.cpp ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/Symbol/DeclVendor.h" + +#include "lldb/Symbol/ClangASTContext.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +std::vector DeclVendor::FindTypes(ConstString name, + uint32_t max_matches) { + // FIXME: This depends on clang, but should be able to support any + // TypeSystem. + std::vector ret; + std::vector decls; + if (FindDecls(name, /*append*/ true, max_matches, decls)) + for (auto *decl : decls) + if (auto type = ClangASTContext::GetTypeForDecl(decl)) + ret.push_back(type); + return ret; +} From 9404635390d3b94f078ee00a1aed69cb2bfdaeb4 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 2 Jul 2019 21:07:25 +0000 Subject: [PATCH 027/616] [lldb] Mention automatic codesign setup script [NFC] The script is the modern way of getting the certificate, so we should mention it in the documentation. Patch idea by Davidino Italiano! llvm-svn: 364967 (cherry picked from commit 48fe0fe884a34d5fe94e2de1495aae50cb76d6fd) --- lldb/docs/code-signing.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/docs/code-signing.txt b/lldb/docs/code-signing.txt index 3da3a8085e661..f2b75e601fbff 100644 --- a/lldb/docs/code-signing.txt +++ b/lldb/docs/code-signing.txt @@ -14,7 +14,10 @@ build folders that contained old signed items. The darwin kernel will cache code signing using the executable's file system node, so you will need to delete the file so the kernel clears its cache. -If you don't have one yet you will need to: +Automatic setup: +- Run scripts/macos-setup-codesign.sh + +Manual setup steps: - Launch /Applications/Utilities/Keychain Access.app - In Keychain Access select the "login" keychain in the "Keychains" From da62b2181ce3728bc9cb78f6874cae3913b5b596 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 2 Jul 2019 22:18:35 +0000 Subject: [PATCH 028/616] [swig] Don't mess with swig internals. As of SWIG 4.0, __swig_getmethods__ and __swig_setmethods__ are no longer defined. It appears that there's no need to mess with these internals, we can simplify define the corresponding properties inline. Originally I wanted to use the swig extension %attribute and %attributeref to define properties. However, I couldn't find a way to add documentation to these attributes. Since we already had the properties defined inline, we might as well keep them. Differential revision: https://reviews.llvm.org/D63530 llvm-svn: 364974 (cherry picked from commit 89b658428bae3b749f174ca79f0fe390451d8f69) --- lldb/scripts/interface/SBAddress.i | 41 ++----- lldb/scripts/interface/SBBlock.i | 35 ++---- lldb/scripts/interface/SBBreakpoint.i | 26 +---- lldb/scripts/interface/SBCompileUnit.i | 7 +- lldb/scripts/interface/SBData.i | 92 ++++----------- lldb/scripts/interface/SBDeclaration.i | 14 +-- lldb/scripts/interface/SBError.i | 20 +--- lldb/scripts/interface/SBExecutionContext.i | 15 +-- lldb/scripts/interface/SBFileSpec.i | 15 +-- lldb/scripts/interface/SBFrame.i | 105 +++++------------ lldb/scripts/interface/SBFunction.i | 31 ++--- lldb/scripts/interface/SBInstruction.i | 23 +--- lldb/scripts/interface/SBLineEntry.i | 21 +--- lldb/scripts/interface/SBModule.i | 54 +++------ lldb/scripts/interface/SBProcess.i | 52 +++------ lldb/scripts/interface/SBSection.i | 36 ++---- lldb/scripts/interface/SBSymbol.i | 37 ++---- lldb/scripts/interface/SBSymbolContext.i | 29 +---- lldb/scripts/interface/SBSymbolContextList.i | 22 +--- lldb/scripts/interface/SBTarget.i | 73 ++++-------- lldb/scripts/interface/SBThread.i | 51 +++------ lldb/scripts/interface/SBType.i | 91 ++++----------- lldb/scripts/interface/SBTypeCategory.i | 53 +++------ lldb/scripts/interface/SBTypeEnumMember.i | 15 +-- lldb/scripts/interface/SBTypeFilter.i | 8 +- lldb/scripts/interface/SBTypeFormat.i | 9 +- lldb/scripts/interface/SBTypeNameSpecifier.i | 7 +- lldb/scripts/interface/SBTypeSummary.i | 20 +--- lldb/scripts/interface/SBTypeSynthetic.i | 12 +- lldb/scripts/interface/SBUnixSignals.i | 3 +- lldb/scripts/interface/SBValue.i | 112 +++++-------------- 31 files changed, 287 insertions(+), 842 deletions(-) diff --git a/lldb/scripts/interface/SBAddress.i b/lldb/scripts/interface/SBAddress.i index 068a24db43947..92bc3f828f23f 100644 --- a/lldb/scripts/interface/SBAddress.i +++ b/lldb/scripts/interface/SBAddress.i @@ -162,37 +162,16 @@ public: '''Convert the address to an hex string''' return '0x%x' % int(self) - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') - - __swig_getmethods__["offset"] = GetOffset - if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') - - __swig_getmethods__["section"] = GetSection - if _newclass: section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') - - __swig_getmethods__["load_addr"] = __get_load_addr_property__ - __swig_setmethods__["load_addr"] = __set_load_addr_property__ - if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') - + module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') + compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') + line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') + function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') + block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') + symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') + offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') + section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') + file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') + load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') %} }; diff --git a/lldb/scripts/interface/SBBlock.i b/lldb/scripts/interface/SBBlock.i index 26f78166a8edb..6d2cebfa0cc26 100644 --- a/lldb/scripts/interface/SBBlock.i +++ b/lldb/scripts/interface/SBBlock.i @@ -143,32 +143,15 @@ public: def get_call_site(self): return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) - __swig_getmethods__["parent"] = GetParent - if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') - - __swig_getmethods__["first_child"] = GetFirstChild - if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') - - __swig_getmethods__["call_site"] = get_call_site - if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') - - __swig_getmethods__["sibling"] = GetSibling - if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') - - __swig_getmethods__["name"] = GetInlinedName - if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') - - __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock - if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') - - __swig_getmethods__["range"] = get_ranges_access_object - if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') - - __swig_getmethods__["ranges"] = get_ranges_array - if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') - - __swig_getmethods__["num_ranges"] = GetNumRanges - if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') + parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') + first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') + call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') + sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') + name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') + inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') + range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') + ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') + num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') %} }; diff --git a/lldb/scripts/interface/SBBreakpoint.i b/lldb/scripts/interface/SBBreakpoint.i index 1cf639b17a812..8aabb2b3d280f 100644 --- a/lldb/scripts/interface/SBBreakpoint.i +++ b/lldb/scripts/interface/SBBreakpoint.i @@ -286,26 +286,12 @@ public: object.''' return self.GetNumLocations() - __swig_getmethods__["locations"] = get_breakpoint_location_list - if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') - - __swig_getmethods__["location"] = get_locations_access_object - if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') - - __swig_getmethods__["id"] = GetID - if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') - - __swig_getmethods__["enabled"] = IsEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') - - __swig_getmethods__["one_shot"] = IsOneShot - __swig_setmethods__["one_shot"] = SetOneShot - if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') - - __swig_getmethods__["num_locations"] = GetNumLocations - if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') - + locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') + location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') + id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') + enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') + one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') + num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') %} diff --git a/lldb/scripts/interface/SBCompileUnit.i b/lldb/scripts/interface/SBCompileUnit.i index 26c10df2c3dc8..f5f4e5af14b72 100644 --- a/lldb/scripts/interface/SBCompileUnit.i +++ b/lldb/scripts/interface/SBCompileUnit.i @@ -126,11 +126,8 @@ public: object.''' return self.GetNumLineEntries() - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') - - __swig_getmethods__["num_line_entries"] = GetNumLineEntries - if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') + file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') + num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') %} }; diff --git a/lldb/scripts/interface/SBData.i b/lldb/scripts/interface/SBData.i index b7cef91d532c0..464a6e69233f4 100644 --- a/lldb/scripts/interface/SBData.i +++ b/lldb/scripts/interface/SBData.i @@ -264,76 +264,28 @@ public: def _read_all_double(self): return self._make_helper_double().all() - __swig_getmethods__["uint8"] = _make_helper_uint8 - if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') - - __swig_getmethods__["uint16"] = _make_helper_uint16 - if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') - - __swig_getmethods__["uint32"] = _make_helper_uint32 - if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') - - __swig_getmethods__["uint64"] = _make_helper_uint64 - if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') - - __swig_getmethods__["sint8"] = _make_helper_sint8 - if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') - - __swig_getmethods__["sint16"] = _make_helper_sint16 - if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') - - __swig_getmethods__["sint32"] = _make_helper_sint32 - if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') - - __swig_getmethods__["sint64"] = _make_helper_sint64 - if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') - - __swig_getmethods__["float"] = _make_helper_float - if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') - - __swig_getmethods__["double"] = _make_helper_double - if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') - - __swig_getmethods__["uint8s"] = _read_all_uint8 - if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') - - __swig_getmethods__["uint16s"] = _read_all_uint16 - if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') - - __swig_getmethods__["uint32s"] = _read_all_uint32 - if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') - - __swig_getmethods__["uint64s"] = _read_all_uint64 - if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') - - __swig_getmethods__["sint8s"] = _read_all_sint8 - if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') - - __swig_getmethods__["sint16s"] = _read_all_sint16 - if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') - - __swig_getmethods__["sint32s"] = _read_all_sint32 - if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') - - __swig_getmethods__["sint64s"] = _read_all_sint64 - if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') - - __swig_getmethods__["floats"] = _read_all_float - if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') - - __swig_getmethods__["doubles"] = _read_all_double - if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') - - %} - - %pythoncode %{ - __swig_getmethods__["byte_order"] = GetByteOrder - __swig_setmethods__["byte_order"] = SetByteOrder - if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') - + uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') + uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') + uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') + uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') + sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') + sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') + sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') + sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') + float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') + double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') + uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') + uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') + uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') + uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') + sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') + sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') + sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') + sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') + floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') + doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') + byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') + size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') %} }; diff --git a/lldb/scripts/interface/SBDeclaration.i b/lldb/scripts/interface/SBDeclaration.i index 1fa801425ef81..96407d7c60f64 100644 --- a/lldb/scripts/interface/SBDeclaration.i +++ b/lldb/scripts/interface/SBDeclaration.i @@ -54,16 +54,10 @@ namespace lldb { operator != (const lldb::SBDeclaration &rhs) const; %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') - - __swig_getmethods__["line"] = GetLine - if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') - - __swig_getmethods__["column"] = GetColumn - if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') - %} - + file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') + line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') + column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') + %} }; } // namespace lldb diff --git a/lldb/scripts/interface/SBError.i b/lldb/scripts/interface/SBError.i index d1b3dabb247df..42308ff8bb838 100644 --- a/lldb/scripts/interface/SBError.i +++ b/lldb/scripts/interface/SBError.i @@ -106,21 +106,11 @@ public: GetDescription (lldb::SBStream &description); %pythoncode %{ - __swig_getmethods__["value"] = GetError - if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') - - __swig_getmethods__["fail"] = Fail - if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') - - __swig_getmethods__["success"] = Success - if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''') - - __swig_getmethods__["description"] = GetCString - if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') - + value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') + fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') + success = property(Success, None, doc='''A read only property that returns the same result as Success().''') + description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') + type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') %} }; diff --git a/lldb/scripts/interface/SBExecutionContext.i b/lldb/scripts/interface/SBExecutionContext.i index 8ffa1f8a354a9..9e8d22b37288e 100644 --- a/lldb/scripts/interface/SBExecutionContext.i +++ b/lldb/scripts/interface/SBExecutionContext.i @@ -38,17 +38,10 @@ public: GetFrame () const; %pythoncode %{ - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') + target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') + process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') + thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') + frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') %} }; diff --git a/lldb/scripts/interface/SBFileSpec.i b/lldb/scripts/interface/SBFileSpec.i index d5cdb7d3c4ae4..98777c0e1e479 100644 --- a/lldb/scripts/interface/SBFileSpec.i +++ b/lldb/scripts/interface/SBFileSpec.i @@ -92,17 +92,10 @@ public: return spec_file return None - __swig_getmethods__["fullpath"] = __get_fullpath__ - if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') - - __swig_getmethods__["basename"] = GetFilename - if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') - - __swig_getmethods__["dirname"] = GetDirectory - if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') - - __swig_getmethods__["exists"] = Exists - if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') + fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') + basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') + dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') + exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') %} }; diff --git a/lldb/scripts/interface/SBFrame.i b/lldb/scripts/interface/SBFrame.i index b8f383e06fc5e..f36d83c32e181 100644 --- a/lldb/scripts/interface/SBFrame.i +++ b/lldb/scripts/interface/SBFrame.i @@ -328,85 +328,32 @@ public: return registers_access(self.registers) - __swig_getmethods__["pc"] = GetPC - __swig_setmethods__["pc"] = SetPC - if _newclass: pc = property(GetPC, SetPC) - - __swig_getmethods__["addr"] = GetPCAddress - if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') - - __swig_getmethods__["fp"] = GetFP - if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') - - __swig_getmethods__["sp"] = GetSP - if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') - - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') - - __swig_getmethods__["is_inlined"] = IsInlined - if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') - - __swig_getmethods__["name"] = GetFunctionName - if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') - - __swig_getmethods__["disassembly"] = Disassemble - if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') - - __swig_getmethods__["idx"] = GetFrameID - if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') - - __swig_getmethods__["variables"] = get_all_variables - if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["vars"] = get_all_variables - if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["locals"] = get_locals - if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') - - __swig_getmethods__["args"] = get_arguments - if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["arguments"] = get_arguments - if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["statics"] = get_statics - if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') - - __swig_getmethods__["registers"] = GetRegisters - if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["regs"] = GetRegisters - if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["register"] = get_registers_access - if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') - - __swig_getmethods__["reg"] = get_registers_access - if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') - - __swig_getmethods__["parent"] = get_parent_frame - if _newclass: parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') - + pc = property(GetPC, SetPC) + addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') + fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') + sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') + module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') + compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') + function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') + symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') + block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') + is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') + name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') + line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') + thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') + disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') + idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') + variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') + args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') + registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') + reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') + parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') %} }; diff --git a/lldb/scripts/interface/SBFunction.i b/lldb/scripts/interface/SBFunction.i index e3e6907e23f61..3acb0057cc3c4 100644 --- a/lldb/scripts/interface/SBFunction.i +++ b/lldb/scripts/interface/SBFunction.i @@ -115,29 +115,14 @@ public: def get_instructions_from_current_target (self): return self.GetInstructions (target) - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''') - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''') - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''') - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''') - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''') + addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''') + end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''') + block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''') + instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''') + mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''') + name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''') + prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') + type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''') %} }; diff --git a/lldb/scripts/interface/SBInstruction.i b/lldb/scripts/interface/SBInstruction.i index 9356656a889fd..82b31fd986904 100644 --- a/lldb/scripts/interface/SBInstruction.i +++ b/lldb/scripts/interface/SBInstruction.i @@ -83,23 +83,12 @@ public: def __load_adrr_property__ (self): return self.GetComment (target) - __swig_getmethods__["mnemonic"] = __mnemonic_property__ - if _newclass: mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''') - - __swig_getmethods__["operands"] = __operands_property__ - if _newclass: operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''') - - __swig_getmethods__["comment"] = __comment_property__ - if _newclass: comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''') - - __swig_getmethods__["addr"] = GetAddress - if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''') - - __swig_getmethods__["is_branch"] = DoesBranch - if _newclass: is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''') + mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''') + operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''') + comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''') + addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''') + size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''') + is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''') %} diff --git a/lldb/scripts/interface/SBLineEntry.i b/lldb/scripts/interface/SBLineEntry.i index d462ae1e37889..4dac71f04a7a4 100644 --- a/lldb/scripts/interface/SBLineEntry.i +++ b/lldb/scripts/interface/SBLineEntry.i @@ -85,23 +85,12 @@ public: operator != (const lldb::SBLineEntry &rhs) const; %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') - - __swig_getmethods__["line"] = GetLine - if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') - - __swig_getmethods__["column"] = GetColumn - if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this line entry.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''') - + file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') + line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') + column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') + addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this line entry.''') + end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''') %} - }; } // namespace lldb diff --git a/lldb/scripts/interface/SBModule.i b/lldb/scripts/interface/SBModule.i index df99bb1b17220..ba8f5fba2a31c 100644 --- a/lldb/scripts/interface/SBModule.i +++ b/lldb/scripts/interface/SBModule.i @@ -528,50 +528,24 @@ public: self.compile_units_array.append(self.GetCompileUnitAtIndex(idx)) return self.compile_units_array - __swig_getmethods__["symbols"] = get_symbols_array - if _newclass: symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''') - - __swig_getmethods__["symbol"] = get_symbols_access_object - if _newclass: symbol = property(get_symbols_access_object, None, doc='''A read only property that can be used to access symbols by index ("symbol = module.symbol[0]"), name ("symbols = module.symbol['main']"), or using a regular expression ("symbols = module.symbol[re.compile(...)]"). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access''') - - __swig_getmethods__["sections"] = get_sections_array - if _newclass: sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''') - - __swig_getmethods__["compile_units"] = get_compile_units_array - if _newclass: compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''') - - __swig_getmethods__["section"] = get_sections_access_object - if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''') - - __swig_getmethods__["compile_unit"] = get_compile_units_access_object - if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''') + symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''') + symbol = property(get_symbols_access_object, None, doc='''A read only property that can be used to access symbols by index ("symbol = module.symbol[0]"), name ("symbols = module.symbol['main']"), or using a regular expression ("symbols = module.symbol[re.compile(...)]"). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access''') + sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''') + compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''') + section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''') + section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''') def get_uuid(self): return uuid.UUID (self.GetUUIDString()) - __swig_getmethods__["uuid"] = get_uuid - if _newclass: uuid = property(get_uuid, None, doc='''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''') - - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''') - - __swig_getmethods__["platform_file"] = GetPlatformFileSpec - if _newclass: platform_file = property(GetPlatformFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''') - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''') - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this module.''') - - __swig_getmethods__["triple"] = GetTriple - if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this module.''') - - __swig_getmethods__["num_symbols"] = GetNumSymbols - if _newclass: num_symbols = property(GetNumSymbols, None, doc='''A read only property that returns number of symbols in the module symbol table as an integer.''') - - __swig_getmethods__["num_sections"] = GetNumSections - if _newclass: num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''') + uuid = property(get_uuid, None, doc='''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''') + file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''') + platform_file = property(GetPlatformFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''') + byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''') + addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this module.''') + triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this module.''') + num_symbols = property(GetNumSymbols, None, doc='''A read only property that returns number of symbols in the module symbol table as an integer.''') + num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''') %} diff --git a/lldb/scripts/interface/SBProcess.i b/lldb/scripts/interface/SBProcess.i index 38e99f34afbbb..cbe67ad3b7d90 100644 --- a/lldb/scripts/interface/SBProcess.i +++ b/lldb/scripts/interface/SBProcess.i @@ -478,45 +478,19 @@ public: return self.GetNumThreads() - __swig_getmethods__["threads"] = get_process_thread_list - if _newclass: threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') - - __swig_getmethods__["thread"] = get_threads_access_object - if _newclass: thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''') - - __swig_getmethods__["is_alive"] = __get_is_alive__ - if _newclass: is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''') - - __swig_getmethods__["is_running"] = __get_is_running__ - if _newclass: is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') - - __swig_getmethods__["is_stopped"] = __get_is_stopped__ - if _newclass: is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') - - __swig_getmethods__["id"] = GetProcessID - if _newclass: id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') - - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') - - __swig_getmethods__["num_threads"] = GetNumThreads - if _newclass: num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') - - __swig_getmethods__["selected_thread"] = GetSelectedThread - __swig_setmethods__["selected_thread"] = SetSelectedThread - if _newclass: selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''') - - __swig_getmethods__["state"] = GetState - if _newclass: state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''') - - __swig_getmethods__["exit_state"] = GetExitStatus - if _newclass: exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''') - - __swig_getmethods__["exit_description"] = GetExitDescription - if _newclass: exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''') - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') + threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') + thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''') + is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''') + is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') + is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') + id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') + target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') + num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') + selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''') + state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''') + exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''') + exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''') + broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') %} }; diff --git a/lldb/scripts/interface/SBSection.i b/lldb/scripts/interface/SBSection.i index 4f57d7f434eef..7bd6c592e6d8d 100644 --- a/lldb/scripts/interface/SBSection.i +++ b/lldb/scripts/interface/SBSection.i @@ -126,33 +126,15 @@ public: def get_addr(self): return SBAddress(self, 0) - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''') - - __swig_getmethods__["addr"] = get_addr - if _newclass: addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''') - - __swig_getmethods__["file_offset"] = GetFileOffset - if _newclass: file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''') - - __swig_getmethods__["file_size"] = GetFileByteSize - if _newclass: file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''') - - __swig_getmethods__["data"] = GetSectionData - if _newclass: data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''') - - __swig_getmethods__["type"] = GetSectionType - if _newclass: type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''') - - __swig_getmethods__["target_byte_size"] = GetTargetByteSize - if _newclass: target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''') - + name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''') + addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''') + file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''') + size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''') + file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''') + file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''') + data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''') + type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''') + target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''') %} private: diff --git a/lldb/scripts/interface/SBSymbol.i b/lldb/scripts/interface/SBSymbol.i index 7e9d01a35afce..7391b9ab6b5d5 100644 --- a/lldb/scripts/interface/SBSymbol.i +++ b/lldb/scripts/interface/SBSymbol.i @@ -76,34 +76,15 @@ public: def get_instructions_from_current_target (self): return self.GetInstructions (target) - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this symbol as a string.''') - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this symbol as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSymbolType") that represents the type of this symbol.''') - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this symbol.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this symbol.''') - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this symbol.''') - - __swig_getmethods__["external"] = IsExternal - if _newclass: external = property(IsExternal, None, doc='''A read only property that returns a boolean value that indicates if this symbol is externally visiable (exported) from the module that contains it.''') - - __swig_getmethods__["synthetic"] = IsSynthetic - if _newclass: synthetic = property(IsSynthetic, None, doc='''A read only property that returns a boolean value that indicates if this symbol was synthetically created from information in module that contains it.''') - - + name = property(GetName, None, doc='''A read only property that returns the name for this symbol as a string.''') + mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this symbol as a string.''') + type = property(GetType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSymbolType") that represents the type of this symbol.''') + addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this symbol.''') + end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this symbol.''') + prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') + instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this symbol.''') + external = property(IsExternal, None, doc='''A read only property that returns a boolean value that indicates if this symbol is externally visiable (exported) from the module that contains it.''') + synthetic = property(IsSynthetic, None, doc='''A read only property that returns a boolean value that indicates if this symbol was synthetically created from information in module that contains it.''') %} }; diff --git a/lldb/scripts/interface/SBSymbolContext.i b/lldb/scripts/interface/SBSymbolContext.i index 1c986e10677f1..29cc9538f2399 100644 --- a/lldb/scripts/interface/SBSymbolContext.i +++ b/lldb/scripts/interface/SBSymbolContext.i @@ -83,29 +83,12 @@ public: %pythoncode %{ - __swig_getmethods__["module"] = GetModule - __swig_setmethods__["module"] = SetModule - if _newclass: module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - __swig_setmethods__["compile_unit"] = SetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''') - - __swig_getmethods__["function"] = GetFunction - __swig_setmethods__["function"] = SetFunction - if _newclass: function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''') - - __swig_getmethods__["block"] = GetBlock - __swig_setmethods__["block"] = SetBlock - if _newclass: block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''') - - __swig_getmethods__["symbol"] = GetSymbol - __swig_setmethods__["symbol"] = SetSymbol - if _newclass: symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''') - - __swig_getmethods__["line_entry"] = GetLineEntry - __swig_setmethods__["line_entry"] = SetLineEntry - if _newclass: line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''') + module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''') + compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''') + function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''') + block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''') + symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''') + line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''') %} }; diff --git a/lldb/scripts/interface/SBSymbolContextList.i b/lldb/scripts/interface/SBSymbolContextList.i index 38397c57acac7..4ac6d82ca3b48 100644 --- a/lldb/scripts/interface/SBSymbolContextList.i +++ b/lldb/scripts/interface/SBSymbolContextList.i @@ -121,23 +121,13 @@ public: if obj: a.append(obj) return a - __swig_getmethods__["modules"] = get_module_array - if _newclass: modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''') - __swig_getmethods__["compile_units"] = get_compile_unit_array - if _newclass: compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''') - - __swig_getmethods__["functions"] = get_function_array - if _newclass: functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''') - - __swig_getmethods__["blocks"] = get_block_array - if _newclass: blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''') - - __swig_getmethods__["line_entries"] = get_line_entry_array - if _newclass: line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''') - - __swig_getmethods__["symbols"] = get_symbol_array - if _newclass: symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''') + modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''') + compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''') + functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''') + blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''') + line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''') + symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''') %} }; diff --git a/lldb/scripts/interface/SBTarget.i b/lldb/scripts/interface/SBTarget.i index c9b15d01782e7..e064852d61988 100644 --- a/lldb/scripts/interface/SBTarget.i +++ b/lldb/scripts/interface/SBTarget.i @@ -686,7 +686,7 @@ public: %feature("docstring", " Create a breakpoint using a scripted resolver. - + @param[in] class_name This is the name of the class that implements a scripted resolver. The class should have the following signature: @@ -699,7 +699,7 @@ public: # extra_args - an SBStructuredData that can be used to # parametrize this instance. Same as the extra_args passed # to BreakpointCreateFromScript. - + def __get_depth__ (self): # This is optional, but if defined, you should return the # depth at which you want the callback to be called. The @@ -708,7 +708,7 @@ public: # lldb.eSearchDepthCompUnit # The default if you don't implement this method is # eSearchDepthModule. - + def __callback__(self, sym_ctx): # sym_ctx - an SBSymbolContext that is the cursor in the # search through the program to resolve breakpoints. @@ -719,26 +719,26 @@ public: # Note, you will only get called for modules/compile_units that # pass the SearchFilter provided by the module_list & file_list # passed into BreakpointCreateFromScript. - + def get_short_help(self): # Optional, but if implemented return a short string that will # be printed at the beginning of the break list output for the # breakpoint. - + @param[in] extra_args This is an SBStructuredData object that will get passed to the constructor of the class in class_name. You can use this to reuse the same class, parametrizing it with entries from this dictionary. - + @param module_list If this is non-empty, this will be used as the module filter in the SearchFilter created for this breakpoint. - + @param file_list If this is non-empty, this will be used as the comp unit filter in the SearchFilter created for this breakpoint. - + @return An SBBreakpoint that will set locations based on the logic in the resolver's search callback.") BreakpointCreateFromScript; @@ -1051,49 +1051,20 @@ public: object.''' return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex') - __swig_getmethods__["modules"] = get_modules_array - if _newclass: modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') - - __swig_getmethods__["module"] = get_modules_access_object - if _newclass: module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[] allows array access to any modules.\n target.module[] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') - - __swig_getmethods__["executable"] = GetExecutable - if _newclass: executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') - - __swig_getmethods__["debugger"] = GetDebugger - if _newclass: debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') - - __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints - if _newclass: num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') - - __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints - if _newclass: num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') - - __swig_getmethods__["triple"] = GetTriple - if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') - - __swig_getmethods__["data_byte_size"] = GetDataByteSize - if _newclass: data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''') - - __swig_getmethods__["code_byte_size"] = GetCodeByteSize - if _newclass: code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''') - - __swig_getmethods__["platform"] = GetPlatform - if _newclass: platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') + modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') + module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[] allows array access to any modules.\n target.module[] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') + process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') + executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') + debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') + num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') + num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') + broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') + byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') + addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') + triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') + data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''') + code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''') + platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') %} - }; - } // namespace lldb diff --git a/lldb/scripts/interface/SBThread.i b/lldb/scripts/interface/SBThread.i index e370f56d5e0c2..c759e4a5db922 100644 --- a/lldb/scripts/interface/SBThread.i +++ b/lldb/scripts/interface/SBThread.i @@ -432,44 +432,19 @@ public: frames.append(frame) return frames - __swig_getmethods__["id"] = GetThreadID - if _newclass: id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') - - __swig_getmethods__["idx"] = GetIndexID - if _newclass: idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''') - - __swig_getmethods__["return_value"] = GetStopReturnValue - if _newclass: return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''') - - __swig_getmethods__["num_frames"] = GetNumFrames - if _newclass: num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''') - - __swig_getmethods__["frames"] = get_thread_frames - if _newclass: frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''') - - __swig_getmethods__["frame"] = get_frames_access_object - if _newclass: frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''') - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''') - - __swig_getmethods__["queue"] = GetQueueName - if _newclass: queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''') - - __swig_getmethods__["queue_id"] = GetQueueID - if _newclass: queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''') - - __swig_getmethods__["stop_reason"] = GetStopReason - if _newclass: stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''') - - __swig_getmethods__["is_suspended"] = IsSuspended - if _newclass: is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') - - __swig_getmethods__["is_stopped"] = IsStopped - if _newclass: is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') + id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') + idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''') + return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''') + process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''') + num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''') + frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''') + frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''') + name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''') + queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''') + queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''') + stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''') + is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') + is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') %} }; diff --git a/lldb/scripts/interface/SBType.i b/lldb/scripts/interface/SBType.i index 912eedb55c3ce..ae9abfeefd85d 100644 --- a/lldb/scripts/interface/SBType.i +++ b/lldb/scripts/interface/SBType.i @@ -44,24 +44,12 @@ public: GetBitfieldSizeInBits(); %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''') - - __swig_getmethods__["byte_offset"] = GetOffsetInBytes - if _newclass: byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''') - - __swig_getmethods__["bit_offset"] = GetOffsetInBits - if _newclass: bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''') - - __swig_getmethods__["is_bitfield"] = IsBitfield - if _newclass: is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''') - - __swig_getmethods__["bitfield_bit_size"] = GetBitfieldSizeInBits - if _newclass: bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''') - + name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''') + type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''') + byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''') + bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''') + is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''') + bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''') %} protected: @@ -334,41 +322,18 @@ public: return template_args return None - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') - - __swig_getmethods__["is_pointer"] = IsPointerType - if _newclass: is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') - - __swig_getmethods__["is_reference"] = IsReferenceType - if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') - - __swig_getmethods__["is_function"] = IsFunctionType - if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') - - __swig_getmethods__["num_fields"] = GetNumberOfFields - if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') - - __swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses - if _newclass: num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') - - __swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses - if _newclass: num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') - - __swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments - if _newclass: num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') - - __swig_getmethods__["template_args"] = template_arg_array - if _newclass: template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''') - - __swig_getmethods__["type"] = GetTypeClass - if _newclass: type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''') - - __swig_getmethods__["is_complete"] = IsTypeComplete - if _newclass: is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''') + name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') + size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') + is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') + is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') + is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') + num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') + num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') + num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') + num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') + template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''') + type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''') + is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''') def get_bases_array(self): '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.''' @@ -437,21 +402,11 @@ public: enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx)) return enum_members_list - __swig_getmethods__["bases"] = get_bases_array - if _newclass: bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''') - - __swig_getmethods__["vbases"] = get_vbases_array - if _newclass: vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''') - - __swig_getmethods__["fields"] = get_fields_array - if _newclass: fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''') - - __swig_getmethods__["members"] = get_members_array - if _newclass: members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''') - - __swig_getmethods__["enum_members"] = get_enum_members_array - if _newclass: enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''') - + bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''') + vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''') + fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''') + members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''') + enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''') %} }; diff --git a/lldb/scripts/interface/SBTypeCategory.i b/lldb/scripts/interface/SBTypeCategory.i index bcc6950df9e07..c183862702df9 100644 --- a/lldb/scripts/interface/SBTypeCategory.i +++ b/lldb/scripts/interface/SBTypeCategory.i @@ -198,45 +198,20 @@ namespace lldb { filters.append(self.GetFilterAtIndex(idx)) return filters - __swig_getmethods__["formats"] = get_formats_array - if _newclass: formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') - - __swig_getmethods__["format"] = get_formats_access_object - if _newclass: format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''') - - __swig_getmethods__["summaries"] = get_summaries_array - if _newclass: summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') - - __swig_getmethods__["summary"] = get_summaries_access_object - if _newclass: summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''') - - __swig_getmethods__["filters"] = get_filters_array - if _newclass: filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') - - __swig_getmethods__["filter"] = get_filters_access_object - if _newclass: filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''') - - __swig_getmethods__["synthetics"] = get_synthetics_array - if _newclass: synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') - - __swig_getmethods__["synthetic"] = get_synthetics_access_object - if _newclass: synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''') - - __swig_getmethods__["num_formats"] = GetNumFormats - if _newclass: num_formats = property(GetNumFormats, None) - __swig_getmethods__["num_summaries"] = GetNumSummaries - if _newclass: num_summaries = property(GetNumSummaries, None) - __swig_getmethods__["num_filters"] = GetNumFilters - if _newclass: num_filters = property(GetNumFilters, None) - __swig_getmethods__["num_synthetics"] = GetNumSynthetics - if _newclass: num_synthetics = property(GetNumSynthetics, None) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None) - - __swig_getmethods__["enabled"] = GetEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: enabled = property(GetEnabled, SetEnabled) + formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') + format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''') + summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') + summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''') + filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') + filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''') + synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') + synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''') + num_formats = property(GetNumFormats, None) + num_summaries = property(GetNumSummaries, None) + num_filters = property(GetNumFilters, None) + num_synthetics = property(GetNumSynthetics, None) + name = property(GetName, None) + enabled = property(GetEnabled, SetEnabled) %} }; diff --git a/lldb/scripts/interface/SBTypeEnumMember.i b/lldb/scripts/interface/SBTypeEnumMember.i index b95d781683034..0c9cf64a77eaf 100644 --- a/lldb/scripts/interface/SBTypeEnumMember.i +++ b/lldb/scripts/interface/SBTypeEnumMember.i @@ -44,17 +44,10 @@ public: lldb::DescriptionLevel description_level); %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''') - - __swig_getmethods__["signed"] = GetValueAsSigned - if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''') - - __swig_getmethods__["unsigned"] = GetValueAsUnsigned - if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''') + name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''') + type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''') + signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''') + unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''') %} protected: diff --git a/lldb/scripts/interface/SBTypeFilter.i b/lldb/scripts/interface/SBTypeFilter.i index 2e27ca9c0d556..100c420bf2e2b 100644 --- a/lldb/scripts/interface/SBTypeFilter.i +++ b/lldb/scripts/interface/SBTypeFilter.i @@ -62,12 +62,8 @@ namespace lldb { operator != (lldb::SBTypeFilter &rhs); %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["count"] = GetNumberOfExpressionPaths - if _newclass: count = property(GetNumberOfExpressionPaths, None) + options = property(GetOptions, SetOptions) + count = property(GetNumberOfExpressionPaths) %} }; diff --git a/lldb/scripts/interface/SBTypeFormat.i b/lldb/scripts/interface/SBTypeFormat.i index 3691b0875ca54..7c19ebbd0f1fb 100644 --- a/lldb/scripts/interface/SBTypeFormat.i +++ b/lldb/scripts/interface/SBTypeFormat.i @@ -62,13 +62,8 @@ namespace lldb { operator != (lldb::SBTypeFormat &rhs); %pythoncode %{ - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: format = property(GetFormat, SetFormat) - - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) + format = property(GetFormat, SetFormat) + options = property(GetOptions, SetOptions) %} }; diff --git a/lldb/scripts/interface/SBTypeNameSpecifier.i b/lldb/scripts/interface/SBTypeNameSpecifier.i index 959d32a96e0f9..537b9cecf2248 100644 --- a/lldb/scripts/interface/SBTypeNameSpecifier.i +++ b/lldb/scripts/interface/SBTypeNameSpecifier.i @@ -54,11 +54,8 @@ namespace lldb { operator != (lldb::SBTypeNameSpecifier &rhs); %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None) - - __swig_getmethods__["is_regex"] = IsRegex - if _newclass: is_regex = property(IsRegex, None) + name = property(GetName) + is_regex = property(IsRegex) %} diff --git a/lldb/scripts/interface/SBTypeSummary.i b/lldb/scripts/interface/SBTypeSummary.i index 8e2ba523b5fdc..2a44918441ff6 100644 --- a/lldb/scripts/interface/SBTypeSummary.i +++ b/lldb/scripts/interface/SBTypeSummary.i @@ -102,21 +102,11 @@ namespace lldb { operator != (lldb::SBTypeSummary &rhs); %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["is_summary_string"] = IsSummaryString - if _newclass: is_summary_string = property(IsSummaryString, None) - - __swig_getmethods__["is_function_name"] = IsFunctionName - if _newclass: is_function_name = property(IsFunctionName, None) - - __swig_getmethods__["is_function_name"] = IsFunctionCode - if _newclass: is_function_name = property(IsFunctionCode, None) - - __swig_getmethods__["summary_data"] = GetData - if _newclass: summary_data = property(GetData, None) + options = property(GetOptions, SetOptions) + is_summary_string = property(IsSummaryString) + is_function_name = property(IsFunctionName) + is_function_name = property(IsFunctionCode) + summary_data = property(GetData) %} }; diff --git a/lldb/scripts/interface/SBTypeSynthetic.i b/lldb/scripts/interface/SBTypeSynthetic.i index e45dd8ef3f325..04502fa7f350d 100644 --- a/lldb/scripts/interface/SBTypeSynthetic.i +++ b/lldb/scripts/interface/SBTypeSynthetic.i @@ -64,15 +64,9 @@ namespace lldb { operator != (lldb::SBTypeSynthetic &rhs); %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["contains_code"] = IsClassCode - if _newclass: contains_code = property(IsClassCode, None) - - __swig_getmethods__["synthetic_data"] = GetData - if _newclass: synthetic_data = property(GetData, None) + options = property(GetOptions, SetOptions) + contains_code = property(IsClassCode, None) + synthetic_data = property(GetData, None) %} }; diff --git a/lldb/scripts/interface/SBUnixSignals.i b/lldb/scripts/interface/SBUnixSignals.i index a895c6ac61a10..015aeae51b1db 100644 --- a/lldb/scripts/interface/SBUnixSignals.i +++ b/lldb/scripts/interface/SBUnixSignals.i @@ -67,8 +67,7 @@ public: signals.append(self.GetSignalAtIndex(sig)) return signals - __swig_getmethods__["signals"] = get_unix_signals_list - if _newclass: threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''') + threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''') %} }; diff --git a/lldb/scripts/interface/SBValue.i b/lldb/scripts/interface/SBValue.i index 93293761a9bbc..10ad04f2dd594 100644 --- a/lldb/scripts/interface/SBValue.i +++ b/lldb/scripts/interface/SBValue.i @@ -484,96 +484,40 @@ public: '''Return the number of child values of a lldb.SBValue object.''' return self.GetNumChildren() - __swig_getmethods__["children"] = get_value_child_list - if _newclass: children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') - - __swig_getmethods__["child"] = get_child_access_object - if _newclass: child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') - - __swig_getmethods__["is_in_scope"] = IsInScope - if _newclass: is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''') - - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''') - - __swig_getmethods__["value"] = GetValue - __swig_setmethods__["value"] = SetValueFromCString - if _newclass: value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''') - - __swig_getmethods__["value_type"] = GetValueType - if _newclass: value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''') - - __swig_getmethods__["changed"] = GetValueDidChange - if _newclass: changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''') - - __swig_getmethods__["data"] = GetData - if _newclass: data = property(GetData, None, doc='''A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.''') - - __swig_getmethods__["load_addr"] = GetLoadAddress - if _newclass: load_addr = property(GetLoadAddress, None, doc='''A read only property that returns the load address of this value as an integer.''') - - __swig_getmethods__["addr"] = GetAddress - if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.''') - - __swig_getmethods__["deref"] = Dereference - if _newclass: deref = property(Dereference, None, doc='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.''') - - __swig_getmethods__["address_of"] = AddressOf - if _newclass: address_of = property(AddressOf, None, doc='''A read only property that returns an lldb.SBValue that represents the address-of this value.''') - - __swig_getmethods__["error"] = GetError - if _newclass: error = property(GetError, None, doc='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.''') - - __swig_getmethods__["summary"] = GetSummary - if _newclass: summary = property(GetSummary, None, doc='''A read only property that returns the summary for this value as a string''') - - __swig_getmethods__["description"] = GetObjectDescription - if _newclass: description = property(GetObjectDescription, None, doc='''A read only property that returns the language-specific description of this value as a string''') - - __swig_getmethods__["dynamic"] = __get_dynamic__ - if _newclass: dynamic = property(__get_dynamic__, None, doc='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.''') - - __swig_getmethods__["location"] = GetLocation - if _newclass: location = property(GetLocation, None, doc='''A read only property that returns the location of this value as a string.''') - - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the lldb.SBTarget that this value is associated with.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the lldb.SBProcess that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the lldb.SBThread that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the lldb.SBFrame that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["num_children"] = GetNumChildren - if _newclass: num_children = property(GetNumChildren, None, doc='''A read only property that returns the number of child lldb.SBValues that this value has.''') - - __swig_getmethods__["unsigned"] = GetValueAsUnsigned - if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this SBValue as an usigned integer.''') - - __swig_getmethods__["signed"] = GetValueAsSigned - if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this SBValue as a signed integer.''') + children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') + child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') + name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') + type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') + size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') + is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''') + format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''') + value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''') + value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''') + changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''') + data = property(GetData, None, doc='''A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.''') + load_addr = property(GetLoadAddress, None, doc='''A read only property that returns the load address of this value as an integer.''') + addr = property(GetAddress, None, doc='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.''') + deref = property(Dereference, None, doc='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.''') + address_of = property(AddressOf, None, doc='''A read only property that returns an lldb.SBValue that represents the address-of this value.''') + error = property(GetError, None, doc='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.''') + summary = property(GetSummary, None, doc='''A read only property that returns the summary for this value as a string''') + description = property(GetObjectDescription, None, doc='''A read only property that returns the language-specific description of this value as a string''') + dynamic = property(__get_dynamic__, None, doc='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.''') + location = property(GetLocation, None, doc='''A read only property that returns the location of this value as a string.''') + target = property(GetTarget, None, doc='''A read only property that returns the lldb.SBTarget that this value is associated with.''') + process = property(GetProcess, None, doc='''A read only property that returns the lldb.SBProcess that this value is associated with, the returned value might be invalid and should be tested.''') + thread = property(GetThread, None, doc='''A read only property that returns the lldb.SBThread that this value is associated with, the returned value might be invalid and should be tested.''') + frame = property(GetFrame, None, doc='''A read only property that returns the lldb.SBFrame that this value is associated with, the returned value might be invalid and should be tested.''') + num_children = property(GetNumChildren, None, doc='''A read only property that returns the number of child lldb.SBValues that this value has.''') + unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this SBValue as an usigned integer.''') + signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this SBValue as a signed integer.''') def get_expr_path(self): s = SBStream() self.GetExpressionPath (s) return s.GetData() - __swig_getmethods__["path"] = get_expr_path - if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''') + path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''') def synthetic_child_from_expression(self, name, expr, options=None): if options is None: options = lldb.SBExpressionOptions() From 7fa85e64ae5e0a67655cd0660d137fa8717b6572 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 2 Jul 2019 23:06:13 +0000 Subject: [PATCH 029/616] add symbols/declvendor.cpp. llvm-svn: 364976 (cherry picked from commit aab3891702024fda3394d9995fdc2f24b82ffa5b) --- lldb/lldb.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 4c7eaeb11e5d3..c83b16ed8c62e 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -283,6 +283,7 @@ 23D4007E1C210201000C3885 /* DebugMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E77CDB1C20F2F2007192AD /* DebugMacros.cpp */; }; AF116BEF20CF234B0071093F /* DebugNamesDWARFIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF116BED20CF234B0071093F /* DebugNamesDWARFIndex.cpp */; }; 2689003913353E0400698AC0 /* Debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263664921140A4930075843B /* Debugger.cpp */; }; + AF1675A922CC1A3C00DC40ED /* DeclVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1675A822CC1A3C00DC40ED /* DeclVendor.cpp */; }; 268900D613353E6F00698AC0 /* Declaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1610F1B8EC00F91463 /* Declaration.cpp */; }; 49E4F66B1C9CAD16008487EA /* DiagnosticManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E4F6681C9CAD12008487EA /* DiagnosticManager.cpp */; }; 2689003A13353E0400698AC0 /* Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7610F1B85900F91463 /* Disassembler.cpp */; }; @@ -1826,6 +1827,7 @@ AF116BEE20CF234B0071093F /* DebugNamesDWARFIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugNamesDWARFIndex.h; sourceTree = ""; }; 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + AF1675A822CC1A3C00DC40ED /* DeclVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DeclVendor.cpp; path = source/Symbol/DeclVendor.cpp; sourceTree = ""; }; 49B01A2D15F67B1700666829 /* DeclVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeclVendor.h; path = include/lldb/Symbol/DeclVendor.h; sourceTree = ""; }; 26BC7F1610F1B8EC00F91463 /* Declaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Declaration.cpp; path = source/Symbol/Declaration.cpp; sourceTree = ""; }; 26BC7C5810F1B6E900F91463 /* Declaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Declaration.h; path = include/lldb/Symbol/Declaration.h; sourceTree = ""; }; @@ -5322,6 +5324,7 @@ 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */, 23E77CDB1C20F2F2007192AD /* DebugMacros.cpp */, 26BC7C5810F1B6E900F91463 /* Declaration.h */, + AF1675A822CC1A3C00DC40ED /* DeclVendor.cpp */, DDB5829B2278C8D600491B41 /* CxxModuleHandler.cpp */, 26BC7F1610F1B8EC00F91463 /* Declaration.cpp */, 49B01A2D15F67B1700666829 /* DeclVendor.h */, @@ -8267,6 +8270,7 @@ 268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */, 23E2E5451D904913006F38BB /* MinidumpTypes.cpp in Sources */, AF33B4BE1C1FA441001B28D9 /* NetBSDSignals.cpp in Sources */, + AF1675A922CC1A3C00DC40ED /* DeclVendor.cpp in Sources */, 949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */, AFD966BB217140B6006714AC /* SymbolFileNativePDB.cpp in Sources */, AFCB1D59219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp in Sources */, From 8ff81b481cc2172be22359708c45b10b3140ca72 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 2 Jul 2019 23:36:39 +0000 Subject: [PATCH 030/616] Update cmake build setup so lldb doesn't link against the DebugSymbols framework on macOS, in line with the source/xcode project changes in r364243. llvm-svn: 364979 (cherry picked from commit 37aeca39ba2d0b2620ef1c6fae1c8b1b647c529a) --- lldb/cmake/modules/LLDBConfig.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 13b21a09166da..e65b4bd97732f 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -335,7 +335,6 @@ if (APPLE) if(NOT IOS) find_library(CARBON_LIBRARY Carbon) find_library(CORE_SERVICES_LIBRARY CoreServices) - find_library(DEBUG_SYMBOLS_LIBRARY DebugSymbols PATHS "/System/Library/PrivateFrameworks") endif() find_library(FOUNDATION_LIBRARY Foundation) find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) From 847a7e7db60167ee74de9f919bb0826ff104af82 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Tue, 2 Jul 2019 23:38:07 +0000 Subject: [PATCH 031/616] Fix for r364686 - actually set symbol_is_missing_weak... This was set in a std::function, but I was shadowing a variable that I thought I was capturing. Even with this bug we were correctly not raising an error and returning an address of 0x0. We were not marking the symbol as weak, but apparently the JIT didn't need that, so the test still passed. llvm-svn: 364980 (cherry picked from commit 372cee511e274d098356ea148852747c8dda27d5) --- lldb/source/Expression/IRExecutionUnit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index da7496604b4f2..00e12f32b7284 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -791,7 +791,8 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( std::function - get_external_load_address = [&best_internal_load_address, target]( + get_external_load_address = [&best_internal_load_address, target, + &symbol_was_missing_weak]( lldb::addr_t &load_address, SymbolContextList &sc_list, const lldb_private::SymbolContext &sc) -> lldb::addr_t { load_address = LLDB_INVALID_ADDRESS; @@ -801,7 +802,7 @@ lldb::addr_t IRExecutionUnit::FindInSymbols( // missing_weak_symbol will be true only if we found only weak undefined // references to this symbol. - bool symbol_was_missing_weak = true; + symbol_was_missing_weak = true; for (auto candidate_sc : sc_list.SymbolContexts()) { // Only symbols can be weak undefined: if (!candidate_sc.symbol) From 100bb2f965cdb990061d15bf794782c80a45374b Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 3 Jul 2019 13:21:48 +0000 Subject: [PATCH 032/616] [CMake] Avoid libcxxabi dependency when building LLDB from the monorepo on macOS libc++abi became mandatory to link the libc++ binaries. LLDB only needs the build artifacts and not the linked output (we don't ship `libc++.dylib` and/or `libc++.a`). Disable the respective link steps to avoid the dependency to libc++abi. llvm-svn: 365038 (cherry picked from commit 1665dd63466b6d284c75c3543e3fdb19314d752f) --- lldb/cmake/caches/Apple-lldb-base.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake b/lldb/cmake/caches/Apple-lldb-base.cmake index 03287b06285fc..3ca0fc072ab4d 100644 --- a/lldb/cmake/caches/Apple-lldb-base.cmake +++ b/lldb/cmake/caches/Apple-lldb-base.cmake @@ -6,6 +6,9 @@ set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(LLVM_ENABLE_MODULES ON CACHE BOOL "") +set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") + # Release builds set these explicitly: #set(LLDB_VERSION_MAJOR 9999 CACHE STRING "") #set(LLDB_VERSION_MINOR 9 CACHE STRING "") From b7766d4568fedf9b9953faa4da187135f65738bb Mon Sep 17 00:00:00 2001 From: Antonio Afonso Date: Wed, 3 Jul 2019 17:30:07 +0000 Subject: [PATCH 033/616] Add plugin.process.gdb-remote.use-libraries-svr4 option Summary: This option allow the toggling of the libraries-svr4 usage in ProcessGDBRemote. It's a follow up of https://reviews.llvm.org/D62503#1564296 and it's meant to test / tweak this new packet with, hopefully, minimum impact and in a faster way. Enable it with `settings set plugin.process.gdb-remote.use-libraries-svr4 true`. For now, by default it's false. I didn't put tests up for this but I did test it manually. Reviewers: labath, jankratochvil Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64112 llvm-svn: 365059 (cherry picked from commit f8251f1ee6c6e4f08bfb71543b6e447c373d4420) --- .../Process/gdb-remote/ProcessGDBRemote.cpp | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 0501e205ca749..ef9a1dd80626c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -111,18 +111,40 @@ void DumpProcessGDBRemotePacketHistory(void *p, const char *path) { namespace { static constexpr PropertyDefinition g_properties[] = { - {"packet-timeout", OptionValue::eTypeUInt64, true, 5 + {"packet-timeout", + OptionValue::eTypeUInt64, + true, + 5 #if defined(__has_feature) #if __has_feature(address_sanitizer) * 2 #endif #endif - , nullptr, {}, + , + nullptr, + {}, "Specify the default packet timeout in seconds."}, - {"target-definition-file", OptionValue::eTypeFileSpec, true, 0, nullptr, {}, - "The file that provides the description for remote target registers."}}; - -enum { ePropertyPacketTimeout, ePropertyTargetDefinitionFile }; + {"target-definition-file", + OptionValue::eTypeFileSpec, + true, + 0, + nullptr, + {}, + "The file that provides the description for remote target registers."}, + {"use-libraries-svr4", + OptionValue::eTypeBoolean, + true, + false, + nullptr, + {}, + "If true, the libraries-svr4 feature will be used to get a hold of the " + "process's loaded modules."}}; + +enum { + ePropertyPacketTimeout, + ePropertyTargetDefinitionFile, + ePropertyUseSVR4 +}; class PluginProperties : public Properties { public: @@ -152,6 +174,12 @@ class PluginProperties : public Properties { const uint32_t idx = ePropertyTargetDefinitionFile; return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); } + + bool GetUseSVR4() const { + const uint32_t idx = ePropertyUseSVR4; + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, idx, g_properties[idx].default_uint_value != 0); + } }; typedef std::shared_ptr ProcessKDPPropertiesSP; @@ -4681,9 +4709,10 @@ Status ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) { log->Printf("ProcessGDBRemote::%s", __FUNCTION__); GDBRemoteCommunicationClient &comm = m_gdb_comm; + bool can_use_svr4 = GetGlobalPluginProperties()->GetUseSVR4(); // check that we have extended feature read support - if (comm.GetQXferLibrariesSVR4ReadSupported()) { + if (can_use_svr4 && comm.GetQXferLibrariesSVR4ReadSupported()) { list.clear(); // request the loaded library list From 0aae4f0954685d7c0da8619ec3fa3df7c2b3569b Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Jul 2019 20:45:06 +0000 Subject: [PATCH 034/616] [Docs] Unify build instructions The current build instructions are structured according the host platform. Instead of having instructions on how to build with CMake repeated for every platform, I unified them, using subsections if things are different for between platforms. I also added the code signing instructions, which were hidden in a text file in the repository. llvm-svn: 365081 (cherry picked from commit a767b05cf7087fc08f38116f8db07dc28578de32) --- lldb/docs/resources/build.rst | 487 +++++++++++++++++----------------- 1 file changed, 243 insertions(+), 244 deletions(-) diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst index f71fb9e414b56..1ed507510294a 100644 --- a/lldb/docs/resources/build.rst +++ b/lldb/docs/resources/build.rst @@ -4,35 +4,55 @@ Build .. contents:: :local: -Building LLDB on Windows ------------------------- +Preliminaries +------------- + +LLDB relies on many of the technologies developed by the larger LLVM project. +In particular, it requires both Clang and LLVM itself in order to build. Due to +this tight integration the Getting Started guides for both of these projects +come as prerequisite reading: + +* `LLVM `_ +* `Clang `_ + +The following requirements are shared on all platforms. + +* `CMake `_ +* `Ninja `_ (strongly recommended) +* `Python `_ +* `SWIG `_ + +Depending on your platform and package manager, one might run any of the +commands below. -**Required Dependencies** +:: + + > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig + > sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev + > pkg install swig python + > pkgin install swig python27 cmake ninja-build + > brew install swig cmake ninja + +Windows +******* * Visual Studio 2015 or greater -* Windows SDK 8.0 or higher. In general it is best to use the latest available version. +* Windows SDK 8.0 or higher. In general it is best to use the latest available + version. +* `GnuWin32 `_ * `Python 3.5 or higher `_ or higher. Earlier versions of Python can be made to work by compiling your own distribution from source, but this workflow is unsupported and you are own your own. -* `Ninja build tool `_ (strongly recommended) -* `GnuWin32 `_ -* `SWIG for Windows `_ (version 3+) - - -**Optional Dependencies** - * `Python Tools for Visual Studio `_. If you plan to debug test failures or even write new tests at all, PTVS is an indispensable debugging extension to VS that enables full editing and debugging support for Python (including mixed native/managed debugging) -**Preliminaries** - -This section describes how to set up your system and install the required -dependencies such that they can be found when needed during the build process. -The steps outlined here only need to be performed once. +The steps outlined here describes how to set up your system and install the +required dependencies such that they can be found when needed during the build +process. They only need to be performed once. #. Install Visual Studio and the Windows SDK. #. Install GnuWin32, making sure ``\bin`` is added to @@ -40,30 +60,79 @@ The steps outlined here only need to be performed once. #. Install SWIG for Windows, making sure ```` is added to your PATH environment variable. -**Building LLDB** - Any command prompt from which you build LLDB should have a valid Visual Studio environment setup. This means you should run ``vcvarsall.bat`` or open an appropriate Visual Studio Command Prompt corresponding to the version you wish to use. +Linux +***** + +* `libedit `_ + +macOS +***** + +* To use the in-tree debug server on macOS, lldb needs to be code signed. For + more information see :ref:`CodeSigning` below. +* If you are building both Clang and LLDB together, be sure to also check out + libc++, which is a required for testing on macOS. -Finally, when you are ready to build LLDB, generate CMake with the following -command line: +Building LLDB with CMake & Ninja +-------------------------------- + +CMake is a cross-platform build-generator tool. CMake does not build the +project, it generates the files needed by your build tool. Assuming you're +using Ninja, the invocation looks like this: :: - cmake -G Ninja + > cmake -G Ninja +Once CMake has configured your build, you can run ``ninja`` to build LLDB. -and run ``ninja`` to build LLDB. Information about running the LLDB test suite -can be found on the test page. +:: + > ninja lldb Following is a description of some of the most important CMake variables which you are likely to encounter. A variable FOO is set by adding ``-DFOO=value`` to the CMake command line. +If you want to debug the lldb that you're building -- that is, build it with +debug info enabled -- pass two additional arguments to cmake before running +ninja: + +:: + + > cmake -G Ninja \ + -DLLDB_EXPORT_ALL_SYMBOLS=1 \ + -DCMAKE_BUILD_TYPE=Debug + + +If you want to run the test suite, you will need a compiler to build the test +programs. If you have Clang checked out, that will be used by default. +Alternatively, you can specify a C and C++ compiler to be used by the test +suite. + +:: + + > cmake -G Ninja \ + -DLLDB_TEST_USE_CUSTOM_C_COMPILER=On \ + -DLLDB_TEST_USE_CUSTOM_CXX_COMPILER=On \ + -DLLDB_TEST_C_COMPILER= \ + -DLLDB_TEST_CXX_COMPILER= \ + + +It is strongly recommend to use a release build for the compiler to speed up +test execution. + +Windows +******* + +Although the following CMake variables are by no means Windows specific, they +are commonly used on Windows. + * ``LLDB_TEST_DEBUG_TEST_CRASHES`` (Default=0): If set to 1, will cause Windows to generate a crash dialog whenever lldb.exe or the python extension module crashes while running the test suite. If set to 0, LLDB will silently crash. @@ -80,248 +149,100 @@ the CMake command line. Python to use its default mechanism for finding the python installation at runtime (looking for installed Pythons, or using the ``PYTHONHOME`` environment variable if it is specified). -* ``LLDB_TEST_C_COMPILER`` or ``LLDB_TEST_CXX_COMPILER``: The test suite needs - to be able to find a copy of clang.exe that it can use to compile inferior - programs. Note that MSVC is not supported here, it must be a path to a clang - executable. Note that using a release clang.exe is strongly recommended here, - as it will make the test suite run much faster. This can be a path to any - recent clang.exe, including one you built yourself. These variables are - ignored unless the respective ``LLDB_TEST_USE_CUSTOM_C_COMPILER`` and - ``LLDB_TEST_USE_CUSTOM_CXX_COMPILER`` are set to ON. Sample command line: :: - cmake -G Ninja -DLLDB_TEST_DEBUG_TEST_CRASHES=1 -DPYTHON_HOME=C:\Python35 -DLLDB_TEST_USE_CUSTOM_C_COMPILER=ON -DLLDB_TEST_C_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe ..\..\llvm - - -**Working with both Ninja and MSVC** - -Compiling with ninja is both faster and simpler than compiling with MSVC, but -chances are you still want to debug LLDB with MSVC (at least until we can debug -LLDB on Windows with LLDB!). One solution to this is to run cmake twice and -generate the output into two different folders. One for compiling (the ninja -folder), and one for editing / browsing / debugging (the MSVC folder). - -To do this, simply run ``cmake -G Ninja `` from one folder, and -``cmake -G "Visual Studio 14 2015" `` in another folder. Then you -can open the .sln file in Visual Studio, set lldb as the startup project, and -use F5 to run it. You need only edit the project settings to set the executable -and the working directory to point to binaries inside of the ninja tree. - -Building LLDB on macOS ----------------------- - -There are two ways to build LLDB on macOS: Using Xcode and using CMake - -**Preliminaries** - -In addition to any dependencies required by LLVM and Clang, LLDB needs a few -development packages that may also need to be installed depending on your -system. The current list of dependencies are: - -* Xcode 4.3 or newer requires the "Command Line Tools" component (XCode->Preferences->Downloads->Components) -* `Swig `_ - -**Building LLDB with Xcode** - -Building on macOS with Xcode is as easy as downloading the code and building -the Xcode project or workspace: - -* Download the lldb sources. -* Follow the code signing instructions in ``lldb/docs/code-signing.txt``. -* In Xcode, open ``lldb/lldb.xcworkspace``, select the lldb-tool scheme, and build. - -**Building LLDB with CMake** - -First download the LLVM, Clang, libc++ and LLDB sources. Refer to this page for -precise instructions on this step. - -Refer to the code signing instructions in ``lldb/docs/code-signing.txt`` for -info on codesigning debugserver during the build. - -Using CMake is documented on the `Building LLVM with CMake -`_ page. Ninja is the recommended generator to -use when building LLDB with CMake. - -:: - - > cmake $PATH_TO_LLVM -G Ninja - > ninja lldb - -As noted in the "Building LLVM with CMake" page mentioned above, you can pass -variables to cmake to change build behavior. If LLDB is built as a part of -LLVM, then you can pass LLVM-specific CMake variables to cmake when building -LLDB. + > cmake -G Ninja^ + -DLLDB_TEST_DEBUG_TEST_CRASHES=1^ + -DPYTHON_HOME=C:\Python35^ + -DLLDB_TEST_USE_CUSTOM_C_COMPILER=ON^ + -DLLDB_TEST_C_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe^ + -If you are building both Clang and LLDB together, be sure to also add libc++, -which is currently required for testing on macOS: +NetBSD +****** -:: +Current stable NetBSD release doesn't ship with libpanel(3), therefore it's +required to disable curses(3) support with the +``-DLLDB_DISABLE_CURSES:BOOL=TRUE`` option. To make sure check if +``/usr/include/panel.h`` exists in your system. - > cmake -D LLVM_ENABLE_PROJECTS='clang;lldb;libcxx' $PATH_TO_LLVM -G Ninja +macOS +***** -Here are some commonly used LLDB-specific CMake variables: +Here are some commonly used LLDB-specific CMake variables on macOS. -* ``LLDB_EXPORT_ALL_SYMBOLS:BOOL`` : Exports all symbols. Useful in conjunction - with CMAKE_BUILD_TYPE=Debug. -* ``LLDB_BUILD_FRAMEWORK:BOOL`` : Builds LLDB.framework as Xcode would +* ``LLDB_BUILD_FRAMEWORK:BOOL`` : Builds the LLDB.framework. * ``LLDB_CODESIGN_IDENTITY:STRING`` : Determines the codesign identity to use. An empty string means skip building debugserver to avoid codesigning. -Building LLDB on Linux, FreeBSD and NetBSD ------------------------------------------- - -This document describes the steps needed to compile LLDB on most Linux systems, -FreeBSD and NetBSD. - -**Preliminaries** - -LLDB relies on many of the technologies developed by the larger LLVM project. -In particular, it requires both Clang and LLVM itself in order to build. Due to -this tight integration the Getting Started guides for both of these projects -come as prerequisite reading: - -* `LLVM `_ -* `Clang `_ - -Supported compilers for building LLDB on Linux include: - -* Clang 3.2 -* GCC 4.6.2 (later versions should work as well) - -It is recommended to use libstdc++ 4.6 (or higher) to build LLDB on Linux, but -using libc++ is also known to work. - -On FreeBSD the base system Clang and libc++ may be used to build LLDB, or the -GCC port or package. - -On NetBSD the base system GCC and libstdc++ are used to build LLDB, Clang/LLVM -and libc++ should also work. - -In addition to any dependencies required by LLVM and Clang, LLDB needs a few -development packages that may also need to be installed depending on your -system. The current list of dependencies are: - -* `Swig `_ -* `libedit (Linux only) `_ -* `Python `_ - - -So for example, on a Fedora system one might run: - -:: - - > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig - -On a Debian or Ubuntu system one might run: - -:: - - > sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev - -or - -:: - - > sudo apt-get build-dep lldb-3.3 # or lldb-3.4 - - -On FreeBSD one might run: - -:: - - > pkg install swig python - -On NetBSD one might run: - -:: - - > pkgin install swig python27 cmake ninja-build +Building LLDB with CMake and Other Generators +--------------------------------------------- -**To build with CMake** +Compiling with ninja is both faster and simpler than compiling with MSVC or +Xcode, but chances are you still want to debug LLDB with those IDEs. One +solution to this is to run cmake twice and generate the output into two +different folders. One for compiling (the ninja folder), and one for editing, +browsing and debugging. -Using CMake is documented on the `Building LLVM with CMake -`_ page. Building LLDB is possible using one -of the following generators: -* Ninja -* Unix Makefiles +Visual Studio +************* -**Using CMake + Ninja** - -Ninja is the fastest way to build LLDB! In order to use ninja, you need to have -recent versions of CMake and ninja on your system. To build using ninja: +Follow the previous instructions in one directory, and generate a Visual Studio +project in another directory. :: - > cmake ../llvm -G Ninja - > ninja lldb - > ninja check-lldb + > cmake -G "Visual Studio 14 2015" +Then you can open the .sln file in Visual Studio, set lldb as the startup +project, and use F5 to run it. You need only edit the project settings to set +the executable and the working directory to point to binaries inside of the +ninja tree. -If you want to debug the lldb that you're building -- that is, build it with -debug info enabled -- pass two additional arguments to cmake before running -ninja: - -:: +Xcode +***** - > cmake ../llvm -G Ninja -DLLDB_EXPORT_ALL_SYMBOLS=1 -DCMAKE_BUILD_TYPE=Debug - - -**Using CMake + Unix Makefiles** - -If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB: +Follow the previous instructions in one directory, and generate an Xcode +project in another directory. :: - > cmake .. - > make - > make check-lldb - - -**Building API reference documentation** - -LLDB exposes a C++ as well as a Python API. To build the reference -documentation for these two APIs, ensure you have the required dependencies -installed, and build the ``lldb-python-doc`` and ``lldb-cpp-doc`` CMake -targets. + > cmake -G Xcode -The output HTML reference documentation can be found in -``/tools/lldb/docs/``. -**Additional Notes** +Building The Documentation +-------------------------- -LLDB has a Python scripting capability and supplies its own Python module named -lldb. If a script is run inside the command line lldb application, the Python -module is made available automatically. However, if a script is to be run by a -Python interpreter outside the command line application, the ``PYTHONPATH`` -environment variable can be used to let the Python interpreter find the lldb -module. +If you wish to build the optional (reference) documentation, additional +dependencies are required: -Current stable NetBSD release doesn't ship with libpanel(3), therefore it's -required to disable curses(3) support with the -``-DLLDB_DISABLE_CURSES:BOOL=TRUE`` option. To make sure check if -``/usr/include/panel.h`` exists in your system. +* Sphinx (for the website) +* Graphviz (for the 'dot' tool) +* doxygen (if you wish to build the C++ API reference) +* epydoc (if you wish to build the Python API reference) -The correct path can be obtained by invoking the command line lldb tool with -the -P flag: +To install the prerequisites for building the documentation (on Debian/Ubuntu) +do: :: - > export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P` + > sudo apt-get install doxygen graphviz python3-sphinx + > sudo pip install epydoc -If you used a different build directory or made a release build, you may need -to adjust the above to suit your needs. To test that the lldb Python module is -built correctly and is available to the default Python interpreter, run: +To build the documentation, build the desired target(s). :: - > python -c 'import lldb' - -**Cross-compiling LLDB** + > cmake --build . --target docs-lldb-html + > cmake --build . --target lldb-cpp-doc + > cmake --build . --target lldb-python-doc +Cross-compiling LLDB +-------------------- In order to debug remote targets running different architectures than your host, you will need to compile LLDB (or at least the server component) for the @@ -389,7 +310,8 @@ The most important cmake options here are: You can of course also specify the usual cmake options like ``CMAKE_BUILD_TYPE``, etc. -**Example 1: Cross-compiling for linux arm64 on Ubuntu host** +Example 1: Cross-compiling for linux arm64 on Ubuntu host +********************************************************* Ubuntu already provides the packages necessary to cross-compile LLDB for arm64. It is sufficient to install packages ``gcc-aarch64-linux-gnu``, @@ -429,7 +351,8 @@ qemu and chroot to simulate the target environment. Then you can install the necessary packages in this environment (python-dev, libedit-dev, etc.) and point your compiler to use them using the correct -I and -L arguments. -**Example 2: Cross-compiling for Android on Linux** +Example 2: Cross-compiling for Android on Linux +*********************************************** In the case of Android, the toolchain and all required headers and libraries are available in the Android NDK. @@ -458,29 +381,105 @@ arm64 build: Note that currently only lldb-server is functional on android. The lldb client is not supported and unlikely to work. -Building The Documentation --------------------------- +Verifying Python Support +------------------------ -If you wish to build the optional (reference) documentation, additional -dependencies are required: +LLDB has a Python scripting capability and supplies its own Python module named +lldb. If a script is run inside the command line lldb application, the Python +module is made available automatically. However, if a script is to be run by a +Python interpreter outside the command line application, the ``PYTHONPATH`` +environment variable can be used to let the Python interpreter find the lldb +module. -* Sphinx (for the website) -* Graphviz (for the 'dot' tool) -* doxygen (if you wish to build the C++ API reference) -* epydoc (if you wish to build the Python API reference) +The correct path can be obtained by invoking the command line lldb tool with +the -P flag: -To install the prerequisites for building the documentation (on Debian/Ubuntu) -do: +:: + + > export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P` + +If you used a different build directory or made a release build, you may need +to adjust the above to suit your needs. To test that the lldb Python module is +built correctly and is available to the default Python interpreter, run: :: - > sudo apt-get install doxygen graphviz python3-sphinx - > sudo pip install epydoc + > python -c 'import lldb' -To build the documentation, build the desired target(s). +.. _CodeSigning: + +Code Signing on macOS +--------------------- + +To use the in-tree debug server on macOS, lldb needs to be code signed. The +Debug, DebugClang and Release builds are set to code sign using a code signing +certificate named ``lldb_codesign``. This document explains how to set up the +signing certificate. + +Note that it's possible to build and use lldb on macOS without setting up code +signing by using the system's debug server. To configure lldb in this way with +cmake, specify ``-DLLDB_CODESIGN_IDENTITY=''``. + +If you have re-installed a new OS, please delete all old ``lldb_codesign`` items +from your keychain. There will be a code signing certification and a public +and private key. Reboot after deleting them. You will also need to delete and +build folders that contained old signed items. The darwin kernel will cache +code signing using the executable's file system node, so you will need to +delete the file so the kernel clears its cache. + +Automatic setup: + +* Run ``scripts/macos-setup-codesign.sh`` + +Manual setup steps: + +* Launch /Applications/Utilities/Keychain Access.app +* In Keychain Access select the ``login`` keychain in the ``Keychains`` list in + the upper left hand corner of the window. +* Select the following menu item: Keychain Access->Certificate Assistant->Create a Certificate... +* Set the following settings :: - > cmake --build . --target docs-lldb-html - > cmake --build . --target lldb-cpp-doc - > cmake --build . --target lldb-python-doc + Name = lldb_codesign + Identity Type = Self Signed Root + Certificate Type = Code Signing + +* Click Create +* Click Continue +* Click Done +* Click on the "My Certificates" +* Double click on your new ``lldb_codesign`` certificate +* Turn down the "Trust" disclosure triangle, scroll to the "Code Signing" trust + pulldown menu and select "Always Trust" and authenticate as needed using your + username and password. +* Drag the new ``lldb_codesign`` code signing certificate (not the public or + private keys of the same name) from the ``login`` keychain to the ``System`` + keychain in the Keychains pane on the left hand side of the main Keychain + Access window. This will move this certificate to the ``System`` keychain. + You'll have to authorize a few more times, set it to be "Always trusted" when + asked. +* Remove ``~/Desktop/lldb_codesign.cer`` file on your desktop if there is one. +* In the Keychain Access GUI, click and drag ``lldb_codesign`` in the + ``System`` keychain onto the desktop. The drag will create a + ``Desktop/lldb_codesign.cer`` file used in the next step. +* Switch to Terminal, and run the following: + +:: + + sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer + rm -f ~/Desktop/lldb_codesign.cer + +* Drag the ``lldb_codesign`` certificate from the ``System`` keychain back into + the ``login`` keychain +* Quit Keychain Access +* Reboot +* Clean by removing all previously creating code signed binaries and rebuild + lldb and you should be able to debug. + +When you build your LLDB for the first time, the Xcode GUI will prompt you for +permission to use the ``lldb_codesign`` keychain. Be sure to click "Always +Allow" on your first build. From here on out, the ``lldb_codesign`` will be +trusted and you can build from the command line without having to authorize. +Also the first time you debug using a LLDB that was built with this code +signing certificate, you will need to authenticate once. From a471d2704613f6b1cc41ecbbd0e2983fac4ccac5 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Jul 2019 20:47:46 +0000 Subject: [PATCH 035/616] Remove code-signing.txt now that it's part of the docs The file's content is part of the website: https://lldb.llvm.org/resources/build.html llvm-svn: 365082 (cherry picked from commit a4210f7b102984de1b38f0f45abf3e9f1be0321d) --- lldb/docs/code-signing.txt | 69 -------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 lldb/docs/code-signing.txt diff --git a/lldb/docs/code-signing.txt b/lldb/docs/code-signing.txt deleted file mode 100644 index f2b75e601fbff..0000000000000 --- a/lldb/docs/code-signing.txt +++ /dev/null @@ -1,69 +0,0 @@ -To use the in-tree debug server on macOS, lldb needs to be code signed. The -Debug, DebugClang and Release builds are set to code sign using a code signing -certificate named "lldb_codesign". This document explains how to set up the -signing certificate. - -Note that it's possible to build and use lldb on macOS without setting up code -signing by using the system's debug server. To configure lldb in this way with -cmake, specify -DLLDB_CODESIGN_IDENTITY=''. - -If you have re-installed a new OS, please delete all old lldb_codesign items -from your keychain. There will be a code signing certification and a public -and private key. Reboot after deleting them. You will also need to delete and -build folders that contained old signed items. The darwin kernel will cache -code signing using the executable's file system node, so you will need to -delete the file so the kernel clears its cache. - -Automatic setup: -- Run scripts/macos-setup-codesign.sh - -Manual setup steps: -- Launch /Applications/Utilities/Keychain Access.app - -- In Keychain Access select the "login" keychain in the "Keychains" - list in the upper left hand corner of the window. - -- Select the following menu item: - - Keychain Access->Certificate Assistant->Create a Certificate... - -- Set the following settings - - Name = lldb_codesign - Identity Type = Self Signed Root - Certificate Type = Code Signing - -- Click Create -- Click Continue -- Click Done -- Click on the "My Certificates" -- Double click on your new lldb_codesign certificate -- Turn down the "Trust" disclosure triangle, scroll to the "Code Signing" trust - pulldown menu and select "Always Trust" and authenticate as needed using your - username and password. -- Drag the new "lldb_codesign" code signing certificate (not the public or private - keys of the same name) from the "login" keychain to the "System" keychain in the - Keychains pane on the left hand side of the main Keychain Access window. This will - move this certificate to the "System" keychain. You'll have to authorize a few - more times, set it to be "Always trusted" when asked. -- Remove "~/Desktop/lldb_codesign.cer" file on your desktop if there is one. -- In the Keychain Access GUI, click and drag "lldb_codesign" in the "System" keychain - onto the desktop. The drag will create a "~/Desktop/lldb_codesign.cer" file used in - the next step. -- Switch to Terminal, and run the following: - -sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer -rm -f ~/Desktop/lldb_codesign.cer - -- Drag the "lldb_codesign" certificate from the "System" keychain back into the - "login" keychain -- Quit Keychain Access -- Reboot -- Clean by removing all previously creating code signed binaries and rebuild - lldb and you should be able to debug. - -When you build your LLDB for the first time, the Xcode GUI will prompt you for permission -to use the "lldb_codesign" keychain. Be sure to click "Always Allow" on your first -build. From here on out, the "lldb_codesign" will be trusted and you can build from the -command line without having to authorize. Also the first time you debug using a LLDB that -was built with this code signing certificate, you will need to authenticate once. From efb113b79fe31d63f4dde9a2f712d566ab6e50a2 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Jul 2019 20:47:49 +0000 Subject: [PATCH 036/616] [Docs] Update documentation build instructions. Given that we use Ninja as the build system in the instructions below, we might as well use it to build the documentation as well. llvm-svn: 365083 (cherry picked from commit d2f8b928205215adfff2bd8a3cae82ca62fd757b) --- lldb/docs/resources/build.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst index 1ed507510294a..8d45f634e3f40 100644 --- a/lldb/docs/resources/build.rst +++ b/lldb/docs/resources/build.rst @@ -237,9 +237,9 @@ To build the documentation, build the desired target(s). :: - > cmake --build . --target docs-lldb-html - > cmake --build . --target lldb-cpp-doc - > cmake --build . --target lldb-python-doc + > ninja docs-lldb-html + > ninja lldb-cpp-doc + > ninja lldb-python-doc Cross-compiling LLDB -------------------- From 8b44704ef22684889a5e006edbafdb1a0a54fc82 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 3 Jul 2019 20:53:57 +0000 Subject: [PATCH 037/616] [Docs] Remove stale builder llvm-svn: 365086 (cherry picked from commit 667ca68bdef7673d84106c69a8ef0bd73c58f95e) --- lldb/docs/resources/bots.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst index 9bfe5f3f399e8..20ce69cd552d0 100644 --- a/lldb/docs/resources/bots.rst +++ b/lldb/docs/resources/bots.rst @@ -9,7 +9,6 @@ build slaves. Everyone can `add a buildbot for LLDB `_. -* `lldb-amd64-ninja-freebsd11 `_ * `lldb-x64-windows-ninja `_ * `lldb-x86_64-debian `_ * `lldb-x86_64-fedora `_ From 1c87ea636e8a849ebd7cafb63a4b48a01a0fd9b8 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Wed, 3 Jul 2019 22:21:10 +0000 Subject: [PATCH 038/616] Refactor ObjectFile::GetSDKVersion Summary: This patch modernizes the GetSDKVersion API and hopefully prevents problems such as the ones discovered in D61218. Reviewers: aprantl, jasonmolenda, clayborg Reviewed By: aprantl, clayborg Subscribers: clayborg, labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61233 llvm-svn: 365090 (cherry picked from commit e0afcd8d266ed4fa9d3793d0032623f0aa12b80a) --- lldb/include/lldb/Symbol/ObjectFile.h | 14 ++---- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 50 +++++-------------- .../ObjectFile/Mach-O/ObjectFileMachO.h | 4 +- .../Platform/MacOSX/PlatformMacOSX.cpp | 8 +-- 4 files changed, 23 insertions(+), 53 deletions(-) diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index ea7825a5e5a29..84683e3f2a3f5 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -578,15 +578,11 @@ class ObjectFile : public std::enable_shared_from_this, /// Get the SDK OS version this object file was built with. /// - /// The versions arguments and returns values are the same as the - /// GetMinimumOSVersion() - virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) { - if (versions && num_versions) { - for (uint32_t i = 0; i < num_versions; ++i) - versions[i] = UINT32_MAX; - } - return 0; - } + /// \return + /// This function returns extracted version numbers as a + /// llvm::VersionTuple. In case of error an empty VersionTuple is + /// returned. + virtual llvm::VersionTuple GetSDKVersion() { return llvm::VersionTuple(); } /// Return true if this file is a dynamic link editor (dyld) /// diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 6e822826381ff..ce928cf375dea 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -5849,12 +5849,10 @@ llvm::VersionTuple ObjectFileMachO::GetMinimumOSVersion() { return *m_min_os_version; } -uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, - uint32_t num_versions) { - if (m_sdk_versions.empty()) { +llvm::VersionTuple ObjectFileMachO::GetSDKVersion() { + if (!m_sdk_versions.hasValue()) { lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); - bool success = false; - for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) { + for (uint32_t i = 0; i < m_header.ncmds; ++i) { const lldb::offset_t load_cmd_offset = offset; version_min_command lc; @@ -5870,10 +5868,8 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, const uint32_t yy = (lc.sdk >> 8) & 0xffu; const uint32_t zz = lc.sdk & 0xffu; if (xxxx) { - m_sdk_versions.push_back(xxxx); - m_sdk_versions.push_back(yy); - m_sdk_versions.push_back(zz); - success = true; + m_sdk_versions = llvm::VersionTuple(xxxx, yy, zz); + break; } else { GetModule()->ReportWarning( "minimum OS version load command with invalid (0) version found."); @@ -5883,9 +5879,9 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, offset = load_cmd_offset + lc.cmdsize; } - if (!success) { + if (!m_sdk_versions.hasValue()) { offset = MachHeaderSizeFromMagic(m_header.magic); - for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) { + for (uint32_t i = 0; i < m_header.ncmds; ++i) { const lldb::offset_t load_cmd_offset = offset; version_min_command lc; @@ -5912,41 +5908,19 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, const uint32_t yy = (minos >> 8) & 0xffu; const uint32_t zz = minos & 0xffu; if (xxxx) { - m_sdk_versions.push_back(xxxx); - m_sdk_versions.push_back(yy); - m_sdk_versions.push_back(zz); - success = true; + m_sdk_versions = llvm::VersionTuple(xxxx, yy, zz); + break; } } offset = load_cmd_offset + lc.cmdsize; } } - if (!success) { - // Push an invalid value so we don't try to find - // the version # again on the next call to this - // method. - m_sdk_versions.push_back(UINT32_MAX); - } + if (!m_sdk_versions.hasValue()) + m_sdk_versions = llvm::VersionTuple(); } - // Legitimate version numbers will have 3 entries pushed - // on to m_sdk_versions. If we only have one value, it's - // the sentinel value indicating that this object file - // does not have a valid minimum os version #. - if (m_sdk_versions.size() > 1) { - if (versions != nullptr && num_versions > 0) { - for (size_t i = 0; i < num_versions; ++i) { - if (i < m_sdk_versions.size()) - versions[i] = m_sdk_versions[i]; - else - versions[i] = 0; - } - } - return m_sdk_versions.size(); - } - // Call the superclasses version that will empty out the data - return ObjectFile::GetSDKVersion(versions, num_versions); + return m_sdk_versions.getValue(); } bool ObjectFileMachO::GetIsDynamicLinkEditor() { diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index ca4f3025b4de8..df6b914fa7322 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -116,7 +116,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile { llvm::VersionTuple GetMinimumOSVersion() override; - uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) override; + llvm::VersionTuple GetSDKVersion() override; bool GetIsDynamicLinkEditor() override; @@ -198,7 +198,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile { std::vector m_mach_segments; std::vector m_mach_sections; llvm::Optional m_min_os_version; - std::vector m_sdk_versions; + llvm::Optional m_sdk_versions; typedef lldb_private::RangeVector FileRangeArray; lldb_private::Address m_entry_point_address; FileRangeArray m_thread_context_offsets; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 5fbb0f1babd45..51908fae7cbcc 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -163,8 +163,8 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { std::string xcode_contents_path; std::string default_xcode_sdk; FileSpec fspec; - uint32_t versions[2]; - if (objfile->GetSDKVersion(versions, 2)) { + llvm::VersionTuple version = objfile->GetSDKVersion(); + if (!version.empty()) { fspec = HostInfo::GetShlibDir(); if (fspec) { std::string path; @@ -208,8 +208,8 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { StreamString sdk_path; sdk_path.Printf("%sDeveloper/Platforms/MacOSX.platform/Developer/" "SDKs/MacOSX%u.%u.sdk", - xcode_contents_path.c_str(), versions[0], - versions[1]); + xcode_contents_path.c_str(), version.getMajor(), + version.getMinor().getValue()); fspec.SetFile(sdk_path.GetString(), FileSpec::Style::native); if (FileSystem::Instance().Exists(fspec)) return ConstString(sdk_path.GetString()); From 9de79b12b834feaace37a012730f035eb96b1671 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 4 Jul 2019 19:26:49 +0000 Subject: [PATCH 039/616] Plugins: permit building on Windows ARM64 Rather than relying on `sizeof(void *)` to determine the architecture, use the `CMAKE_SYSTEM_PROCESSOR` variable. This should allow us to build for Windows and cross-compile. Without this, we would attempt to build the x64 plugin on ARM64 which would fail due to the `CONTEXT` type being defined for ARM64 rather than `x64`. llvm-svn: 365155 (cherry picked from commit 1522073fedc2cd6f18655ea3e8268095c90868a2) --- .../Process/Windows/Common/CMakeLists.txt | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt index 3b243a6a5dcda..68486c1d99050 100644 --- a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt +++ b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt @@ -1,4 +1,5 @@ -set(PROC_WINDOWS_COMMON_SOURCES + +add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN DebuggerThread.cpp LocalDebugDelegate.cpp ProcessDebugger.cpp @@ -6,20 +7,6 @@ set(PROC_WINDOWS_COMMON_SOURCES ProcessWindowsLog.cpp RegisterContextWindows.cpp TargetThreadWindows.cpp - ) - -if (CMAKE_SIZEOF_VOID_P EQUAL 4) - set(PROC_WINDOWS_COMMON_SOURCES ${PROC_WINDOWS_COMMON_SOURCES} - x86/RegisterContextWindows_x86.cpp - ) -elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PROC_WINDOWS_COMMON_SOURCES ${PROC_WINDOWS_COMMON_SOURCES} - x64/RegisterContextWindows_x64.cpp - ) -endif() - -add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN - ${PROC_WINDOWS_COMMON_SOURCES} LINK_LIBS lldbCore @@ -33,3 +20,13 @@ add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN LINK_COMPONENTS Support ) + +# TODO add support for ARM (NT) and ARM64 +# TODO build these unconditionally as we cannot do cross-debugging or WoW +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + target_sources(lldbPluginProcessWindowsCommon PRIVATE + x64/RegisterContextWindows_x64.cpp) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|X86") + target_sources(lldbPluginProcessWindowsCommon PRIVATE + x86/RegisterContextWindows_x86.cpp) +endif() From a9698a4333e229c56598603ae7e21409d8cff62f Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 4 Jul 2019 19:49:31 +0000 Subject: [PATCH 040/616] Add assert for 'bad' code path in GetUniqueNamespaceDeclaration Summary: If we call this function with a non-namespace as a second argument (and a nullptr name), we currently only get a nullptr as a return when we hit the "Bad!!!" code path. This patch just adds an assert as this seems to be a programming error in the calling code. Reviewers: shafik Subscribers: abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D57880 llvm-svn: 365157 (cherry picked from commit c494481ea4f866c922521fd928166d10518ab957) --- lldb/source/Symbol/ClangASTContext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index ca56fd06d8a34..2d400476548e1 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -1954,7 +1954,8 @@ NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration( assert(namespace_decl == parent_namespace_decl->getAnonymousNamespace()); } else { - // BAD!!! + assert(false && "GetUniqueNamespaceDeclaration called with no name and " + "no namespace as decl_ctx"); } } } From af5efb8be376ff070015c7447eecbabfa8157af3 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 5 Jul 2019 17:42:08 +0000 Subject: [PATCH 041/616] Change LaunchThread interface to return an expected. Change the interface to return an expected, instead of taking a Status pointer. Differential revision: https://reviews.llvm.org/D64163 llvm-svn: 365226 (cherry picked from commit f39c2e188d811ede3758eb98aa0201c1c8f978a1) --- lldb/include/lldb/Host/ThreadLauncher.h | 9 +++-- lldb/source/API/SBHostOS.cpp | 15 ++++++--- lldb/source/Core/Communication.cpp | 17 ++++++++-- lldb/source/Core/Debugger.cpp | 27 ++++++++++++--- lldb/source/Host/common/TaskPool.cpp | 14 ++++++-- lldb/source/Host/common/ThreadLauncher.cpp | 22 ++++--------- lldb/source/Host/macosx/objcxx/Host.mm | 9 +++-- .../Process/MacOSX-Kernel/ProcessKDP.cpp | 12 +++++-- .../gdb-remote/GDBRemoteCommunication.cpp | 33 ++++++++++--------- .../GDBRemoteCommunicationReplayServer.cpp | 11 +++++-- .../Process/gdb-remote/ProcessGDBRemote.cpp | 12 +++++-- lldb/source/Target/Process.cpp | 18 ++++++---- 12 files changed, 133 insertions(+), 66 deletions(-) diff --git a/lldb/include/lldb/Host/ThreadLauncher.h b/lldb/include/lldb/Host/ThreadLauncher.h index 0e4498aa33365..e45ffa9df7571 100644 --- a/lldb/include/lldb/Host/ThreadLauncher.h +++ b/lldb/include/lldb/Host/ThreadLauncher.h @@ -1,5 +1,4 @@ -//===-- ThreadLauncher.h -----------------------------------------*- C++ -//-*-===// +//===-- ThreadLauncher.h ----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,18 +10,18 @@ #define lldb_Host_ThreadLauncher_h_ #include "lldb/Host/HostThread.h" -#include "lldb/Utility/Status.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" namespace lldb_private { class ThreadLauncher { public: - static HostThread + static llvm::Expected LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, - lldb::thread_arg_t thread_arg, Status *error_ptr, + lldb::thread_arg_t thread_arg, size_t min_stack_byte_size = 0); // Minimum stack size in bytes, // set stack size to zero for // default platform thread stack diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp index b5464c4e7df71..c3c92e68140d4 100644 --- a/lldb/source/API/SBHostOS.cpp +++ b/lldb/source/API/SBHostOS.cpp @@ -107,10 +107,17 @@ lldb::thread_t SBHostOS::ThreadCreate(const char *name, LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate, (lldb::thread_func_t, void *, SBError *), name, thread_function, thread_arg, error_ptr); - HostThread thread( - ThreadLauncher::LaunchThread(name, thread_function, thread_arg, - error_ptr ? error_ptr->get() : nullptr)); - return thread.Release(); + llvm::Expected thread = + ThreadLauncher::LaunchThread(name, thread_function, thread_arg); + if (!thread) { + if (error_ptr) + error_ptr->SetError(Status(thread.takeError())); + else + llvm::consumeError(thread.takeError()); + return LLDB_INVALID_HOST_THREAD; + } + + return thread->Release(); } void SBHostOS::ThreadCreated(const char *name) { diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index c39976d6556b1..a67cb925d648f 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -204,10 +204,23 @@ bool Communication::StartReadThread(Status *error_ptr) { m_read_thread_enabled = true; m_read_thread_did_exit = false; - m_read_thread = ThreadLauncher::LaunchThread( - thread_name, Communication::ReadThread, this, error_ptr); + auto maybe_thread = ThreadLauncher::LaunchThread( + thread_name, Communication::ReadThread, this); + if (maybe_thread) { + m_read_thread = *maybe_thread; + } else { + if (error_ptr) + *error_ptr = Status(maybe_thread.takeError()); + else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); + } + } + if (!m_read_thread.IsJoinable()) m_read_thread_enabled = false; + return m_read_thread_enabled; } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index f22fe043b8d9a..1a69fc582d0c3 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1642,8 +1642,17 @@ bool Debugger::StartEventHandlerThread() { full_name.AsCString() : "dbg.evt-handler"; // Use larger 8MB stack for this thread - m_event_handler_thread = ThreadLauncher::LaunchThread(thread_name, - EventHandlerThread, this, nullptr, g_debugger_event_thread_stack_bytes); + llvm::Expected event_handler_thread = + ThreadLauncher::LaunchThread(thread_name, EventHandlerThread, this, + g_debugger_event_thread_stack_bytes); + + if (event_handler_thread) { + m_event_handler_thread = *event_handler_thread; + } else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(event_handler_thread.takeError())); + } // Make sure DefaultEventHandler() is running and listening to events // before we return from this function. We are only listening for events of @@ -1674,10 +1683,18 @@ lldb::thread_result_t Debugger::IOHandlerThread(lldb::thread_arg_t arg) { bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); } bool Debugger::StartIOHandlerThread() { - if (!m_io_handler_thread.IsJoinable()) - m_io_handler_thread = ThreadLauncher::LaunchThread( - "lldb.debugger.io-handler", IOHandlerThread, this, nullptr, + if (!m_io_handler_thread.IsJoinable()) { + llvm::Expected io_handler_thread = ThreadLauncher::LaunchThread( + "lldb.debugger.io-handler", IOHandlerThread, this, 8 * 1024 * 1024); // Use larger 8MB stack for this thread + if (io_handler_thread) { + m_io_handler_thread = *io_handler_thread; + } else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(io_handler_thread.takeError())); + } + } return m_io_handler_thread.IsJoinable(); } diff --git a/lldb/source/Host/common/TaskPool.cpp b/lldb/source/Host/common/TaskPool.cpp index dcc4363078da0..73f761b5cf63a 100644 --- a/lldb/source/Host/common/TaskPool.cpp +++ b/lldb/source/Host/common/TaskPool.cpp @@ -8,6 +8,7 @@ #include "lldb/Host/TaskPool.h" #include "lldb/Host/ThreadLauncher.h" +#include "lldb/Utility/Log.h" #include #include @@ -65,9 +66,16 @@ void TaskPoolImpl::AddTask(std::function &&task_fn) { // Note that this detach call needs to happen with the m_tasks_mutex held. // This prevents the thread from exiting prematurely and triggering a linux // libc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). - lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr, - this, nullptr, min_stack_size) - .Release(); + llvm::Expected host_thread = + lldb_private::ThreadLauncher::LaunchThread( + "task-pool.worker", WorkerPtr, this, min_stack_size); + if (host_thread) { + host_thread->Release(); + } else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(host_thread.takeError())); + } } } diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 2eff981bfa85d..912ce3688f2c2 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -20,15 +20,9 @@ using namespace lldb; using namespace lldb_private; -HostThread ThreadLauncher::LaunchThread(llvm::StringRef name, - lldb::thread_func_t thread_function, - lldb::thread_arg_t thread_arg, - Status *error_ptr, - size_t min_stack_byte_size) { - Status error; - if (error_ptr) - error_ptr->Clear(); - +llvm::Expected ThreadLauncher::LaunchThread( + llvm::StringRef name, lldb::thread_func_t thread_function, + lldb::thread_arg_t thread_arg, size_t min_stack_byte_size) { // Host::ThreadCreateTrampoline will delete this pointer for us. HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo(name.data(), thread_function, thread_arg); @@ -38,7 +32,7 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name, 0, (unsigned)min_stack_byte_size, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL); if (thread == (lldb::thread_t)(-1L)) - error.SetError(::GetLastError(), eErrorTypeWin32); + return llvm::errorCodeToError(::GetLastError()); #else // ASAN instrumentation adds a lot of bookkeeping overhead on stack frames. @@ -73,12 +67,10 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name, if (destroy_attr) ::pthread_attr_destroy(&thread_attr); - error.SetError(err, eErrorTypePOSIX); + if (err) + return llvm::errorCodeToError( + std::error_code(err, std::generic_category())); #endif - if (error_ptr) - *error_ptr = error; - if (!error.Success()) - thread = LLDB_INVALID_HOST_THREAD; return HostThread(thread); } diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index 99b5601a9b3d1..da1ea666a0a83 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -313,13 +313,16 @@ repeat with the_window in (get windows)\n\ // in a shell and the shell will fork/exec a couple of times before we get // to the process that we wanted to launch. So when our process actually // gets launched, we will handshake with it and get the process ID for it. - HostThread accept_thread = ThreadLauncher::LaunchThread( - unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error); + llvm::Expected accept_thread = ThreadLauncher::LaunchThread( + unix_socket_name, AcceptPIDFromInferior, connect_url); + + if (!accept_thread) + return Status(accept_thread.takeError()); [applescript executeAndReturnError:nil]; thread_result_t accept_thread_result = NULL; - lldb_error = accept_thread.Join(&accept_thread_result); + lldb_error = accept_thread->Join(&accept_thread_result); if (lldb_error.Success() && accept_thread_result) { pid = (intptr_t)accept_thread_result; diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index c9e024fc49834..6f1bb4b64767d 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -32,6 +32,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/StringExtractor.h" #include "lldb/Utility/UUID.h" @@ -739,8 +740,15 @@ bool ProcessKDP::StartAsyncThread() { if (m_async_thread.IsJoinable()) return true; - m_async_thread = ThreadLauncher::LaunchThread( - "", ProcessKDP::AsyncThread, this, NULL); + llvm::Expected async_thread = ThreadLauncher::LaunchThread( + "", ProcessKDP::AsyncThread, this); + if (!async_thread) { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(async_thread.takeError())); + return false; + } + m_async_thread = *async_thread; return m_async_thread.IsJoinable(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 3886b6cfe009e..11052eff948f9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -888,22 +888,23 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, Status GDBRemoteCommunication::StartListenThread(const char *hostname, uint16_t port) { - Status error; - if (m_listen_thread.IsJoinable()) { - error.SetErrorString("listen thread already running"); - } else { - char listen_url[512]; - if (hostname && hostname[0]) - snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, - port); - else - snprintf(listen_url, sizeof(listen_url), "listen://%i", port); - m_listen_url = listen_url; - SetConnection(new ConnectionFileDescriptor()); - m_listen_thread = ThreadLauncher::LaunchThread( - listen_url, GDBRemoteCommunication::ListenThread, this, &error); - } - return error; + if (m_listen_thread.IsJoinable()) + return Status("listen thread already running"); + + char listen_url[512]; + if (hostname && hostname[0]) + snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, port); + else + snprintf(listen_url, sizeof(listen_url), "listen://%i", port); + m_listen_url = listen_url; + SetConnection(new ConnectionFileDescriptor()); + llvm::Expected listen_thread = ThreadLauncher::LaunchThread( + listen_url, GDBRemoteCommunication::ListenThread, this); + if (!listen_thread) + return Status(listen_thread.takeError()); + m_listen_thread = *listen_thread; + + return Status(); } bool GDBRemoteCommunication::JoinListenThread() { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp index b7763d86c200c..417f5737a30ff 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp @@ -203,9 +203,16 @@ bool GDBRemoteCommunicationReplayServer::StartAsyncThread() { if (!m_async_thread.IsJoinable()) { // Create a thread that watches our internal state and controls which // events make it to clients (into the DCProcess event queue). - m_async_thread = ThreadLauncher::LaunchThread( + llvm::Expected async_thread = ThreadLauncher::LaunchThread( "", - GDBRemoteCommunicationReplayServer::AsyncThread, this, nullptr); + GDBRemoteCommunicationReplayServer::AsyncThread, this); + if (!async_thread) { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(async_thread.takeError())); + return false; + } + m_async_thread = *async_thread; } // Wait for handshake. diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index ef9a1dd80626c..a6fdd8dd07070 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -3700,9 +3700,15 @@ bool ProcessGDBRemote::StartAsyncThread() { // Create a thread that watches our internal state and controls which // events make it to clients (into the DCProcess event queue). - m_async_thread = ThreadLauncher::LaunchThread( - "", ProcessGDBRemote::AsyncThread, this, - nullptr); + llvm::Expected async_thread = ThreadLauncher::LaunchThread( + "", ProcessGDBRemote::AsyncThread, this); + if (!async_thread) { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(async_thread.takeError())); + return false; + } + m_async_thread = *async_thread; } else if (log) log->Printf("ProcessGDBRemote::%s () - Called when Async thread was " "already running.", diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 9e87f04ff0dd7..cd27392bd560d 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3588,14 +3588,20 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) { // Create the private state thread, and start it running. PrivateStateThreadArgs *args_ptr = new PrivateStateThreadArgs(this, is_secondary_thread); - m_private_state_thread = + llvm::Expected private_state_thread = ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread, - (void *)args_ptr, nullptr, 8 * 1024 * 1024); - if (m_private_state_thread.IsJoinable()) { - ResumePrivateStateThread(); - return true; - } else + (void *)args_ptr, 8 * 1024 * 1024); + if (!private_state_thread) { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(private_state_thread.takeError())); return false; + } + + assert(private_state_thread->IsJoinable()); + m_private_state_thread = *private_state_thread; + ResumePrivateStateThread(); + return true; } void Process::PausePrivateStateThread() { From f91ee99560a42bf4c323ce59cb7ef03e37997105 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 5 Jul 2019 20:45:57 +0000 Subject: [PATCH 042/616] [CplusPlus] ISVTableName is unused. NFCI. Reviewers: teemperor, JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64265 llvm-svn: 365243 (cherry picked from commit ee7b1ce665ebbea86601fadc50552b87ec783cda) --- lldb/include/lldb/Target/CPPLanguageRuntime.h | 2 -- .../CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp | 8 -------- .../CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h | 2 -- .../RenderScriptRuntime/RenderScriptRuntime.cpp | 2 -- .../RenderScriptRuntime/RenderScriptRuntime.h | 2 -- 5 files changed, 16 deletions(-) diff --git a/lldb/include/lldb/Target/CPPLanguageRuntime.h b/lldb/include/lldb/Target/CPPLanguageRuntime.h index 7b7d8acc9afe5..28526361efc4a 100644 --- a/lldb/include/lldb/Target/CPPLanguageRuntime.h +++ b/lldb/include/lldb/Target/CPPLanguageRuntime.h @@ -58,8 +58,6 @@ class CPPLanguageRuntime : public LanguageRuntime { process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus)); } - virtual bool IsVTableName(const char *name) = 0; - bool GetObjectDescription(Stream &str, ValueObject &object) override; bool GetObjectDescription(Stream &str, Value &value, diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 72d06c5a111fe..41f38a4e3dcd0 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -307,14 +307,6 @@ TypeAndOrName ItaniumABILanguageRuntime::FixUpDynamicType( return ret; } -bool ItaniumABILanguageRuntime::IsVTableName(const char *name) { - if (name == nullptr) - return false; - - // Can we maybe ask Clang about this? - return strstr(name, "_vptr$") == name; -} - // Static Functions LanguageRuntime * ItaniumABILanguageRuntime::CreateInstance(Process *process, diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h index ced521f1ba7ca..8d32c301e418f 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h @@ -46,8 +46,6 @@ class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime { return runtime->isA(&ID); } - bool IsVTableName(const char *name) override; - bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index 1fb3491679d77..c9cd34cf379d0 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -1037,8 +1037,6 @@ lldb_private::ConstString RenderScriptRuntime::GetPluginName() { uint32_t RenderScriptRuntime::GetPluginVersion() { return 1; } -bool RenderScriptRuntime::IsVTableName(const char *name) { return false; } - bool RenderScriptRuntime::GetDynamicTypeAndAddress( ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h index 257e6d46f3f55..ee6947b6ef5bd 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h @@ -331,8 +331,6 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime { static void ModulesDidLoad(const lldb::ProcessSP &process_sp, const ModuleList &module_list); - bool IsVTableName(const char *name) override; - bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, From 6e5b7f5385c22511babc099d7a628077352c871d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 5 Jul 2019 21:22:54 +0000 Subject: [PATCH 043/616] lldb_assert: abort when assertions are enabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had a long discussion in D59911 about lldb_assert and what it means. The result was the assert manifesto on lldb.llvm.org. > LLDB provides lldb_assert() as a soft alternative to cover the middle > ground of situations that indicate a recoverable bug in LLDB. In a > Debug configuration lldb_assert() behaves like assert(). In a Release > configuration it will print a warning and encourage the user to file a > bug report, similar to LLVM’s crash handler, and then return > execution. However, currently lldb_assert doesn't behave they way it's being described there: it doesn't abort in a debug/assert build. This patch fixes that by adding a call to assert() in lldb_assert(). Differential revision: https://reviews.llvm.org/D64267#1571962 llvm-svn: 365246 (cherry picked from commit b0fc4d470f4ccc98dd4deea5f64f646a279d28c4) --- lldb/source/Utility/LLDBAssert.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp index 3cc99fe441dab..28cd584b5558b 100644 --- a/lldb/source/Utility/LLDBAssert.cpp +++ b/lldb/source/Utility/LLDBAssert.cpp @@ -21,6 +21,12 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text, if (LLVM_LIKELY(expression)) return; + // In a Debug configuration lldb_assert() behaves like assert(). + assert(false && "lldb_assert failed"); + + // In a Release configuration it will print a warning and encourage the user + // to file a bug report, similar to LLVM’s crash handler, and then return + // execution. errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", expr_text, func, file, line); errs() << "backtrace leading to the failure:\n"; From ca12005662a2dfa534a32696fdcb6c923777e51f Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 5 Jul 2019 21:32:39 +0000 Subject: [PATCH 044/616] [lldb] Added assert to VerifyDecl We could VerifyDecl sometimes with a nullptr. It would be nice if we could get an actual assert here instead of triggering UB. llvm-svn: 365247 (cherry picked from commit 5ccdabf25d8c1d7a252fac8eb95305d2bdae05ca) --- lldb/source/Symbol/VerifyDecl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Symbol/VerifyDecl.cpp b/lldb/source/Symbol/VerifyDecl.cpp index 88c7494e557be..1873d3a5d03c9 100644 --- a/lldb/source/Symbol/VerifyDecl.cpp +++ b/lldb/source/Symbol/VerifyDecl.cpp @@ -9,4 +9,7 @@ #include "lldb/Symbol/VerifyDecl.h" #include "clang/AST/DeclBase.h" -void lldb_private::VerifyDecl(clang::Decl *decl) { decl->getAccess(); } +void lldb_private::VerifyDecl(clang::Decl *decl) { + assert(decl && "VerifyDecl called with nullptr?"); + decl->getAccess(); +} From 4f170bb01072bcf9f61a9e683abd96e4629b9f9e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 5 Jul 2019 21:54:20 +0000 Subject: [PATCH 045/616] [LLDBAssert] Use unreachable instead of assert(0) As per Davide's suggestion offline. llvm-svn: 365250 (cherry picked from commit abd1561f15ee466c0fd9abeede2cdcde2ebb2cec) --- lldb/source/Utility/LLDBAssert.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp index 28cd584b5558b..75530d8063101 100644 --- a/lldb/source/Utility/LLDBAssert.cpp +++ b/lldb/source/Utility/LLDBAssert.cpp @@ -21,8 +21,8 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text, if (LLVM_LIKELY(expression)) return; - // In a Debug configuration lldb_assert() behaves like assert(). - assert(false && "lldb_assert failed"); + // In a Debug configuration lldb_assert() behaves like assert(0). + llvm_unreachable("lldb_assert failed"); // In a Release configuration it will print a warning and encourage the user // to file a bug report, similar to LLVM’s crash handler, and then return From f04d4ef40a78245463c4b6260ef7e2e2eda4d85a Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 7 Jul 2019 17:58:11 +0000 Subject: [PATCH 046/616] Process: generalise Windows thread setup The Windows build currently cannot support debugging foreign targets or debugging Windows ARM NT and Windows ARM64 targets. Do not assume a x64/x86 host. This enables building lldb for Windows ARM64. llvm-svn: 365282 (cherry picked from commit 842f55f3efe4bdc108a566ab41bfe7ce9d6be329) --- .../Windows/Common/TargetThreadWindows.cpp | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp index 19392e33017f6..0af0b56925bde 100644 --- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -20,9 +20,10 @@ #include "ProcessWindowsLog.h" #include "TargetThreadWindows.h" -#if defined(_WIN64) +// TODO support _M_ARM and _M_ARM64 +#if defined(_M_AMD64) #include "x64/RegisterContextWindows_x64.h" -#else +#elif defined(_M_IX86) #include "x86/RegisterContextWindows_x86.h" #endif @@ -66,24 +67,33 @@ TargetThreadWindows::CreateRegisterContextForFrame(StackFrame *frame) { if (!m_thread_reg_ctx_sp) { ArchSpec arch = HostInfo::GetArchitecture(); switch (arch.GetMachine()) { + case llvm::Triple::arm: + case llvm::Triple::thumb: + LLDB_LOG(log, "debugging ARM (NT) targets is currently unsupported"); + break; + + case llvm::Triple::aarch64: + LLDB_LOG(log, "debugging ARM64 targets is currently unsupported"); + break; + case llvm::Triple::x86: -#if defined(_WIN64) - // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64 - LLDB_LOG(log, "This is a Wow64 process, we should create a " - "RegisterContextWindows_Wow64, but we don't."); -#else +#if defined(_M_IX86) m_thread_reg_ctx_sp.reset( new RegisterContextWindows_x86(*this, concrete_frame_idx)); +#else + LLDB_LOG(log, "debugging foreign targets is currently unsupported"); #endif break; + case llvm::Triple::x86_64: -#if defined(_WIN64) +#if defined(_M_AMD64) m_thread_reg_ctx_sp.reset( new RegisterContextWindows_x64(*this, concrete_frame_idx)); #else - LLDB_LOG(log, "LLDB is 32-bit, but the target process is 64-bit."); + LLDB_LOG(log, "debugging foreign targets is currently unsupported"); #endif - LLVM_FALLTHROUGH; + break; + default: break; } From 5b1091832077739ed329c72fee633362053a2f0a Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 8 Jul 2019 07:07:05 +0000 Subject: [PATCH 047/616] Change LaunchThread interface to return an Expected for non-Apple-non-Windows Fixes Linux build errors after D64163/r365226 llvm-svn: 365295 (cherry picked from commit 23d10f7a4edde835a7cd26679ffb46ba3759df73) --- lldb/include/lldb/Host/Host.h | 2 +- lldb/include/lldb/Host/HostNativeProcessBase.h | 2 +- lldb/include/lldb/Host/HostProcess.h | 5 +++-- lldb/include/lldb/Host/posix/HostProcessPosix.h | 5 +++-- lldb/source/Host/common/Host.cpp | 4 ++-- lldb/source/Host/common/HostProcess.cpp | 2 +- lldb/source/Host/common/MonitoringProcessLauncher.cpp | 8 ++++++-- lldb/source/Host/common/ProcessLaunchInfo.cpp | 5 +++++ lldb/source/Host/posix/HostProcessPosix.cpp | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 2cb3aafc1af47..884c5cf632134 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -99,7 +99,7 @@ class Host { /// was spawned to monitor \a pid. /// /// \see static void Host::StopMonitoringChildProcess (uint32_t) - static HostThread + static llvm::Expected StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals); diff --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h index e8b0683da8bff..aaa517d532172 100644 --- a/lldb/include/lldb/Host/HostNativeProcessBase.h +++ b/lldb/include/lldb/Host/HostNativeProcessBase.h @@ -35,7 +35,7 @@ class HostNativeProcessBase { lldb::process_t GetSystemHandle() const { return m_process; } - virtual HostThread + virtual llvm::Expected StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) = 0; diff --git a/lldb/include/lldb/Host/HostProcess.h b/lldb/include/lldb/Host/HostProcess.h index 56eaa465f07d0..d48ff1fc90eef 100644 --- a/lldb/include/lldb/Host/HostProcess.h +++ b/lldb/include/lldb/Host/HostProcess.h @@ -43,8 +43,9 @@ class HostProcess { lldb::pid_t GetProcessId() const; bool IsRunning() const; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals); + llvm::Expected + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals); HostNativeProcessBase &GetNativeProcess(); const HostNativeProcessBase &GetNativeProcess() const; diff --git a/lldb/include/lldb/Host/posix/HostProcessPosix.h b/lldb/include/lldb/Host/posix/HostProcessPosix.h index ce0b8e8b176a9..a313358631b5e 100644 --- a/lldb/include/lldb/Host/posix/HostProcessPosix.h +++ b/lldb/include/lldb/Host/posix/HostProcessPosix.h @@ -32,8 +32,9 @@ class HostProcessPosix : public HostNativeProcessBase { lldb::pid_t GetProcessId() const override; bool IsRunning() const override; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals) override; + llvm::Expected + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals) override; }; } // namespace lldb_private diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index be206406e93a6..3ba9ab7f21f36 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -99,7 +99,7 @@ struct MonitorInfo { static thread_result_t MonitorChildProcessThreadFunction(void *arg); -HostThread Host::StartMonitoringChildProcess( +llvm::Expected Host::StartMonitoringChildProcess( const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals) { MonitorInfo *info_ptr = new MonitorInfo(); @@ -112,7 +112,7 @@ HostThread Host::StartMonitoringChildProcess( ::snprintf(thread_name, sizeof(thread_name), "", pid); return ThreadLauncher::LaunchThread( - thread_name, MonitorChildProcessThreadFunction, info_ptr, nullptr); + thread_name, MonitorChildProcessThreadFunction, info_ptr, 0); } #ifndef __linux__ diff --git a/lldb/source/Host/common/HostProcess.cpp b/lldb/source/Host/common/HostProcess.cpp index d8f71af5e6504..e180687551f8f 100644 --- a/lldb/source/Host/common/HostProcess.cpp +++ b/lldb/source/Host/common/HostProcess.cpp @@ -32,7 +32,7 @@ lldb::pid_t HostProcess::GetProcessId() const { bool HostProcess::IsRunning() const { return m_native_process->IsRunning(); } -HostThread +llvm::Expected HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { return m_native_process->StartMonitoring(callback, monitor_signals); diff --git a/lldb/source/Host/common/MonitoringProcessLauncher.cpp b/lldb/source/Host/common/MonitoringProcessLauncher.cpp index 2ee69353e19a6..55e9f69a089aa 100644 --- a/lldb/source/Host/common/MonitoringProcessLauncher.cpp +++ b/lldb/source/Host/common/MonitoringProcessLauncher.cpp @@ -53,8 +53,12 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info, Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); assert(launch_info.GetMonitorProcessCallback()); - process.StartMonitoring(launch_info.GetMonitorProcessCallback(), - launch_info.GetMonitorSignals()); + llvm::Expected maybe_thread = + process.StartMonitoring(launch_info.GetMonitorProcessCallback(), + launch_info.GetMonitorSignals()); + if (!maybe_thread) + error.SetErrorStringWithFormatv("failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); if (log) log->PutCString("started monitoring child process."); } else { diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp index ac8a41bf8831e..266b467639961 100644 --- a/lldb/source/Host/common/ProcessLaunchInfo.cpp +++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp @@ -188,8 +188,13 @@ bool ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, bool exited, int si bool ProcessLaunchInfo::MonitorProcess() const { if (m_monitor_callback && ProcessIDIsValid()) { + llvm::Expected maybe_thread = Host::StartMonitoringChildProcess(m_monitor_callback, GetProcessID(), m_monitor_signals); + if (!maybe_thread) + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); return true; } return false; diff --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp index 725f59d751261..cc187d4424686 100644 --- a/lldb/source/Host/posix/HostProcessPosix.cpp +++ b/lldb/source/Host/posix/HostProcessPosix.cpp @@ -87,7 +87,7 @@ bool HostProcessPosix::IsRunning() const { return error.Success(); } -HostThread HostProcessPosix::StartMonitoring( +llvm::Expected HostProcessPosix::StartMonitoring( const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { return Host::StartMonitoringChildProcess(callback, m_process, monitor_signals); From 65b1d8b7077d0bd77dbabf29edd668115c2d0563 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Mon, 8 Jul 2019 16:16:07 +0000 Subject: [PATCH 048/616] [lldb] [test] Update NetBSD XFAILs in test suite llvm-svn: 365338 (cherry picked from commit 10c96cabc17e57c32534fa4c5e9c22bc8c6aaaa0) --- .../watchpoint/hello_watchlocation/TestWatchLocation.py | 1 + .../multiple_threads/TestWatchpointMultipleThreads.py | 2 ++ .../watchpoint_commands/command/TestWatchpointCommandLLDB.py | 1 + .../watchpoint_commands/command/TestWatchpointCommandPython.py | 2 ++ .../watchpoint_commands/condition/TestWatchpointConditionCmd.py | 1 + .../watchpoint_set_command/TestWatchLocationWithWatchSet.py | 1 + .../lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py | 1 + .../lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py | 1 - .../test/python_api/watchpoint/TestWatchpointIgnoreCount.py | 1 - .../lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py | 1 - .../watchpoint/condition/TestWatchpointConditionAPI.py | 1 - 11 files changed, 9 insertions(+), 4 deletions(-) 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 d39d35f768831..740a75fc2e064 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 @@ -41,6 +41,7 @@ def setUp(self): @expectedFailureAll(triple=re.compile('^mips')) # SystemZ and PowerPC also currently supports only one H/W watchpoint @expectedFailureAll(archs=['powerpc64le', 's390x']) + @expectedFailureNetBSD @skipIfDarwin def test_hello_watchlocation(self): """Test watching a location with '-s size' option.""" 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 85d6c84d68fff..667ed56eca77a 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 @@ -23,6 +23,7 @@ class WatchpointForMultipleThreadsTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureNetBSD def test_watchpoint_before_thread_start(self): """Test that we can hit a watchpoint we set before starting another thread""" self.do_watchpoint_test("Before running the thread") @@ -30,6 +31,7 @@ def test_watchpoint_before_thread_start(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureNetBSD def test_watchpoint_after_thread_start(self): """Test that we can hit a watchpoint we set after starting another thread""" self.do_watchpoint_test("After running the thread") 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 cd819f27ec5f0..b4b6ebe9bfcd3 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 @@ -40,6 +40,7 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureNetBSD def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) 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 d9edd05d3a762..431298a9f9975 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 @@ -41,6 +41,7 @@ def setUp(self): oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") + @expectedFailureNetBSD def test_watchpoint_command(self): """Test 'watchpoint command'.""" self.build(dictionary=self.d) @@ -111,6 +112,7 @@ def test_watchpoint_command(self): oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") + @expectedFailureNetBSD def test_continue_in_watchpoint_command(self): """Test continue in a watchpoint command.""" self.build(dictionary=self.d) 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 a77b1e70e3dd5..b4b489e89485f 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 @@ -40,6 +40,7 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureNetBSD def test_watchpoint_cond(self): """Test watchpoint condition.""" self.build(dictionary=self.d) 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 c7f7d02392eb0..abe678629023b 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 @@ -39,6 +39,7 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @expectedFailureNetBSD def test_watchlocation_using_watchpoint_set(self): """Test watching a location with 'watchpoint set expression -w write -s size' option.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py index 8548506fdc463..dd12ac198cd35 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -22,6 +22,7 @@ def setUp(self): self.line = line_number('main.cpp', '// Set break point at this line.') @add_test_categories(['pyapi']) + @expectedFailureNetBSD def test_formatters_api(self): """Test Python APIs for working with formatters""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py index de182fb30ee82..0236d4b2c6d8e 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py @@ -33,7 +33,6 @@ def setUp(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD def test_watch_val(self): """Exercise SBValue.Watch() API to set a watchpoint.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index 7f0e262b1c4af..603b7a805008c 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -33,7 +33,6 @@ def setUp(self): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) - @expectedFailureNetBSD def test_set_watch_ignore_count(self): """Test SBWatchpoint.SetIgnoreCount() API.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py index d3aac68149d8d..b9fc7ceb1af62 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py @@ -36,7 +36,6 @@ def setUp(self): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @expectedFailureNetBSD def test_watch_iter(self): """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index 3252dee88e01a..bb32869543c71 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -38,7 +38,6 @@ def setUp(self): archs=["aarch64"], bugnumber="llvm.org/pr27710") @skipIfWindows # Watchpoints not supported on Windows, and this test hangs - @expectedFailureNetBSD def test_watchpoint_cond_api(self): """Test watchpoint condition API.""" self.build(dictionary=self.d) From e085fc9796ce441dff2d3cbefeefe70e3d4ebfbc Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 16:31:37 +0000 Subject: [PATCH 049/616] [Host] Fix out-of-line definition of StartMonitoringChildProcess llvm-svn: 365344 (cherry picked from commit 2734f5c89c349ee7b1d1f61249a58dd4874bef2e) --- lldb/source/Host/macosx/objcxx/Host.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index da1ea666a0a83..12d7ba0285e15 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -1420,7 +1420,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { return error; } -HostThread Host::StartMonitoringChildProcess( +llvm::Expected Host::StartMonitoringChildProcess( const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals) { unsigned long mask = DISPATCH_PROC_EXIT; From dd5e1a8a0c626400661a873552fcbbdd868f8a32 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 17:45:11 +0000 Subject: [PATCH 050/616] [Host] Fix out-of-line definition on Windows Add missing interface changes after r365295. llvm-svn: 365358 (cherry picked from commit 099231839aafeca616fd82913b1d0a01cc644490) --- lldb/source/Host/windows/Host.cpp | 2 +- lldb/source/Host/windows/HostProcessWindows.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp index 2b73beb0c789e..413b1720e9944 100644 --- a/lldb/source/Host/windows/Host.cpp +++ b/lldb/source/Host/windows/Host.cpp @@ -172,7 +172,7 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) { return true; } -HostThread Host::StartMonitoringChildProcess( +llvm::Expected Host::StartMonitoringChildProcess( const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals) { return HostThread(); diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index 573218ed8f623..c422a86683af3 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -80,7 +80,7 @@ bool HostProcessWindows::IsRunning() const { return (code == STILL_ACTIVE); } -HostThread HostProcessWindows::StartMonitoring( +llvm::Expected HostProcessWindows::StartMonitoring( const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { HostThread monitor_thread; MonitorInfo *info = new MonitorInfo; From 260046a2dea5d32fc4f98409e803ae1a7dd80329 Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Mon, 8 Jul 2019 18:53:32 +0000 Subject: [PATCH 051/616] Revert "Move common functionality from processwindows into processdebugger" This reverts commit 9c01eaff6aa3f59d91530f47b85bb470377a7780. The changes in this commit are causing several of the LLDB tests to hang and/or timeout. llvm-svn: 365371 (cherry picked from commit ed499a36b67cf46cbf66052cfe374c80a595f1c1) --- .../Process/Windows/Common/CMakeLists.txt | 1 - .../Windows/Common/ProcessDebugger.cpp | 572 ------------------ .../Process/Windows/Common/ProcessDebugger.h | 101 ---- .../Process/Windows/Common/ProcessWindows.cpp | 473 +++++++++++++-- .../Process/Windows/Common/ProcessWindows.h | 21 +- 5 files changed, 452 insertions(+), 716 deletions(-) delete mode 100644 lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp delete mode 100644 lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h diff --git a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt index 68486c1d99050..c63df5fb3255a 100644 --- a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt +++ b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN DebuggerThread.cpp LocalDebugDelegate.cpp - ProcessDebugger.cpp ProcessWindows.cpp ProcessWindowsLog.cpp RegisterContextWindows.cpp diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp deleted file mode 100644 index a79250b350ef3..0000000000000 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp +++ /dev/null @@ -1,572 +0,0 @@ -//===-- ProcessDebugger.cpp -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "ProcessDebugger.h" - -// Windows includes -#include "lldb/Host/windows/windows.h" -#include - -#include "lldb/Host/FileSystem.h" -#include "lldb/Host/HostNativeProcessBase.h" -#include "lldb/Host/HostProcess.h" -#include "lldb/Host/HostThread.h" -#include "lldb/Host/ProcessLaunchInfo.h" -#include "lldb/Target/MemoryRegionInfo.h" -#include "lldb/Target/Process.h" -#include "llvm/Support/ConvertUTF.h" -#include "llvm/Support/Error.h" - -#include "DebuggerThread.h" -#include "ExceptionRecord.h" -#include "ProcessWindowsLog.h" - -using namespace lldb; -using namespace lldb_private; - -static DWORD ConvertLldbToWinApiProtect(uint32_t protect) { - // We also can process a read / write permissions here, but if the debugger - // will make later a write into the allocated memory, it will fail. To get - // around it is possible inside DoWriteMemory to remember memory permissions, - // allow write, write and restore permissions, but for now we process only - // the executable permission. - // - // TODO: Process permissions other than executable - if (protect & ePermissionsExecutable) - return PAGE_EXECUTE_READWRITE; - - return PAGE_READWRITE; -} - -// The Windows page protection bits are NOT independent masks that can be -// bitwise-ORed together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE -// | PAGE_READ). To test for an access type, it's necessary to test for any of -// the bits that provide that access type. -static bool IsPageReadable(uint32_t protect) { - return (protect & PAGE_NOACCESS) == 0; -} - -static bool IsPageWritable(uint32_t protect) { - return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | - PAGE_READWRITE | PAGE_WRITECOPY)) != 0; -} - -static bool IsPageExecutable(uint32_t protect) { - return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | - PAGE_EXECUTE_WRITECOPY)) != 0; -} - -namespace lldb_private { - -lldb::pid_t ProcessDebugger::GetDebuggedProcessId() const { - if (m_session_data) - return m_session_data->m_debugger->GetProcess().GetProcessId(); - return LLDB_INVALID_PROCESS_ID; -} - -Status ProcessDebugger::DetachProcess() { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - DebuggerThreadSP debugger_thread; - { - // Acquire the lock only long enough to get the DebuggerThread. - // StopDebugging() will trigger a call back into ProcessDebugger which will - // also acquire the lock. Thus we have to release the lock before calling - // StopDebugging(). - llvm::sys::ScopedLock lock(m_mutex); - - if (!m_session_data) { - LLDB_LOG(log, "there is no active session."); - return Status(); - } - - debugger_thread = m_session_data->m_debugger; - } - - Status error; - - LLDB_LOG(log, "detaching from process {0}.", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle()); - error = debugger_thread->StopDebugging(false); - - // By the time StopDebugging returns, there is no more debugger thread, so - // we can be assured that no other thread will race for the session data. - m_session_data.reset(); - - return error; -} - -Status ProcessDebugger::LaunchProcess(ProcessLaunchInfo &launch_info, - DebugDelegateSP delegate) { - // Even though m_session_data is accessed here, it is before a debugger - // thread has been kicked off. So there's no race conditions, and it - // shouldn't be necessary to acquire the mutex. - - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - Status result; - - FileSpec working_dir = launch_info.GetWorkingDirectory(); - namespace fs = llvm::sys::fs; - if (working_dir) { - FileSystem::Instance().Resolve(working_dir); - if (!FileSystem::Instance().IsDirectory(working_dir)) { - result.SetErrorStringWithFormat("No such file or directory: %s", - working_dir.GetCString()); - return result; - } - } - - if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) { - StreamString stream; - stream.Printf("ProcessDebugger unable to launch '%s'. ProcessDebugger can " - "only be used for debug launches.", - launch_info.GetExecutableFile().GetPath().c_str()); - std::string message = stream.GetString(); - result.SetErrorString(message.c_str()); - - LLDB_LOG(log, "error: {0}", message); - return result; - } - - bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry); - m_session_data.reset(new ProcessWindowsData(stop_at_entry)); - m_session_data->m_debugger.reset(new DebuggerThread(delegate)); - DebuggerThreadSP debugger = m_session_data->m_debugger; - - // Kick off the DebugLaunch asynchronously and wait for it to complete. - result = debugger->DebugLaunch(launch_info); - if (result.Fail()) { - LLDB_LOG(log, "failed launching '{0}'. {1}", - launch_info.GetExecutableFile().GetPath(), result); - return result; - } - - HostProcess process; - Status error = WaitForDebuggerConnection(debugger, process); - if (error.Fail()) { - LLDB_LOG(log, "failed launching '{0}'. {1}", - launch_info.GetExecutableFile().GetPath(), error); - return error; - } - - LLDB_LOG(log, "successfully launched '{0}'", - launch_info.GetExecutableFile().GetPath()); - - // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the - // private state should already be set to eStateStopped as a result of - // hitting the initial breakpoint. If it was not set, the breakpoint should - // have already been resumed from and the private state should already be - // eStateRunning. - launch_info.SetProcessID(process.GetProcessId()); - - return result; -} - -Status ProcessDebugger::AttachProcess(const ProcessAttachInfo &attach_info, - DebugDelegateSP delegate) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - m_session_data.reset( - new ProcessWindowsData(!attach_info.GetContinueOnceAttached())); - DebuggerThreadSP debugger(new DebuggerThread(delegate)); - - m_session_data->m_debugger = debugger; - - DWORD process_id = static_cast(attach_info.GetProcessID()); - Status error = debugger->DebugAttach(process_id, attach_info); - if (error.Fail()) { - LLDB_LOG( - log, - "encountered an error occurred initiating the asynchronous attach. {0}", - error); - return error; - } - - HostProcess process; - error = WaitForDebuggerConnection(debugger, process); - if (error.Fail()) { - LLDB_LOG(log, - "encountered an error waiting for the debugger to connect. {0}", - error); - return error; - } - - LLDB_LOG(log, "successfully attached to process with pid={0}", process_id); - - // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the - // private state should already be set to eStateStopped as a result of - // hitting the initial breakpoint. If it was not set, the breakpoint should - // have already been resumed from and the private state should already be - // eStateRunning. - - return error; -} - -Status ProcessDebugger::DestroyProcess() { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - DebuggerThreadSP debugger_thread; - { - // Acquire this lock inside an inner scope, only long enough to get the - // DebuggerThread. StopDebugging() will trigger a call back into - // ProcessDebugger which will acquire the lock again, so we need to not - // deadlock. - llvm::sys::ScopedLock lock(m_mutex); - - if (!m_session_data) { - LLDB_LOG(log, "warning: there is no active session."); - return Status(); - } - - debugger_thread = m_session_data->m_debugger; - } - - LLDB_LOG(log, "Shutting down process {0}.", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle()); - Status error = debugger_thread->StopDebugging(true); - - // By the time StopDebugging returns, there is no more debugger thread, so - // we can be assured that no other thread will race for the session data. - m_session_data.reset(); - - return error; -} - -Status ProcessDebugger::HaltProcess(bool &caused_stop) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - Status error; - llvm::sys::ScopedLock lock(m_mutex); - caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess() - .GetNativeProcess() - .GetSystemHandle()); - if (!caused_stop) { - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error); - } - - return error; -} - -Status ProcessDebugger::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, - size_t &bytes_read) { - Status error; - bytes_read = 0; - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - - if (!m_session_data) { - error.SetErrorString( - "cannot read, there is no active debugger connection."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - - LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size, - vm_addr); - - HostProcess process = m_session_data->m_debugger->GetProcess(); - void *addr = reinterpret_cast(vm_addr); - SIZE_T num_of_bytes_read = 0; - if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, - buf, size, &num_of_bytes_read)) { - // Reading from the process can fail for a number of reasons - set the - // error code and make sure that the number of bytes read is set back to 0 - // because in some scenarios the value of bytes_read returned from the API - // is garbage. - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "reading failed with error: {0}", error); - } else { - bytes_read = num_of_bytes_read; - } - return error; -} - -Status ProcessDebugger::WriteMemory(lldb::addr_t vm_addr, const void *buf, - size_t size, size_t &bytes_written) { - Status error; - bytes_written = 0; - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size, - vm_addr); - - if (!m_session_data) { - error.SetErrorString( - "cannot write, there is no active debugger connection."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - void *addr = reinterpret_cast(vm_addr); - SIZE_T num_of_bytes_written = 0; - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (::WriteProcessMemory(handle, addr, buf, size, &num_of_bytes_written)) { - FlushInstructionCache(handle, addr, num_of_bytes_written); - bytes_written = num_of_bytes_written; - } else { - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "writing failed with error: {0}", error); - } - return error; -} - -Status ProcessDebugger::AllocateMemory(size_t size, uint32_t permissions, - lldb::addr_t &addr) { - Status error; - addr = LLDB_INVALID_ADDRESS; - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, - permissions); - - if (!m_session_data) { - error.SetErrorString( - "cannot allocate, there is no active debugger connection"); - LLDB_LOG(log, "error: {0}", error); - return error; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - auto protect = ConvertLldbToWinApiProtect(permissions); - auto result = ::VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); - if (!result) { - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "allocating failed with error: {0}", error); - } else { - addr = reinterpret_cast(result); - } - return error; -} - -Status ProcessDebugger::DeallocateMemory(lldb::addr_t vm_addr) { - Status result; - - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to deallocate bytes at address {0}", vm_addr); - - if (!m_session_data) { - result.SetErrorString( - "cannot deallocate, there is no active debugger connection"); - LLDB_LOG(log, "error: {0}", result); - return result; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (!::VirtualFreeEx(handle, reinterpret_cast(vm_addr), 0, - MEM_RELEASE)) { - result.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "deallocating failed with error: {0}", result); - } - - return result; -} - -Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr, - MemoryRegionInfo &info) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - Status error; - llvm::sys::ScopedLock lock(m_mutex); - info.Clear(); - - if (!m_session_data) { - error.SetErrorString( - "GetMemoryRegionInfo called with no debugging session."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (handle == nullptr || handle == LLDB_INVALID_PROCESS) { - error.SetErrorString( - "GetMemoryRegionInfo called with an invalid target process."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - - LLDB_LOG(log, "getting info for address {0:x}", vm_addr); - - void *addr = reinterpret_cast(vm_addr); - MEMORY_BASIC_INFORMATION mem_info = {}; - SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info)); - if (result == 0) { - if (::GetLastError() == ERROR_INVALID_PARAMETER) { - // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with - // an address past the highest accessible address. We should return a - // range from the vm_addr to LLDB_INVALID_ADDRESS - info.GetRange().SetRangeBase(vm_addr); - info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); - info.SetReadable(MemoryRegionInfo::eNo); - info.SetExecutable(MemoryRegionInfo::eNo); - info.SetWritable(MemoryRegionInfo::eNo); - info.SetMapped(MemoryRegionInfo::eNo); - return error; - } else { - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, - "VirtualQueryEx returned error {0} while getting memory " - "region info for address {1:x}", - error, vm_addr); - return error; - } - } - - // Protect bits are only valid for MEM_COMMIT regions. - if (mem_info.State == MEM_COMMIT) { - const bool readable = IsPageReadable(mem_info.Protect); - const bool executable = IsPageExecutable(mem_info.Protect); - const bool writable = IsPageWritable(mem_info.Protect); - info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); - info.SetExecutable(executable ? MemoryRegionInfo::eYes - : MemoryRegionInfo::eNo); - info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); - } else { - info.SetReadable(MemoryRegionInfo::eNo); - info.SetExecutable(MemoryRegionInfo::eNo); - info.SetWritable(MemoryRegionInfo::eNo); - } - - // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE. - if (mem_info.State != MEM_FREE) { - info.GetRange().SetRangeBase( - reinterpret_cast(mem_info.AllocationBase)); - info.GetRange().SetRangeEnd(reinterpret_cast(mem_info.BaseAddress) + - mem_info.RegionSize); - info.SetMapped(MemoryRegionInfo::eYes); - } else { - // In the unmapped case we need to return the distance to the next block of - // memory. VirtualQueryEx nearly does that except that it gives the - // distance from the start of the page containing vm_addr. - SYSTEM_INFO data; - ::GetSystemInfo(&data); - DWORD page_offset = vm_addr % data.dwPageSize; - info.GetRange().SetRangeBase(vm_addr); - info.GetRange().SetByteSize(mem_info.RegionSize - page_offset); - info.SetMapped(MemoryRegionInfo::eNo); - } - - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOGV(log, - "Memory region info for address {0}: readable={1}, " - "executable={2}, writable={3}", - vm_addr, info.GetReadable(), info.GetExecutable(), - info.GetWritable()); - return error; -} - -void ProcessDebugger::OnExitProcess(uint32_t exit_code) { - // If the process exits before any initial stop then notify the debugger - // of the error otherwise WaitForDebuggerConnection() will be blocked. - // An example of this issue is when a process fails to load a dependent DLL. - if (m_session_data && !m_session_data->m_initial_stop_received) { - Status error(exit_code, eErrorTypeWin32); - OnDebuggerError(error, 0); - } -} - -void ProcessDebugger::OnDebuggerConnected(lldb::addr_t image_base) {} - -ExceptionResult -ProcessDebugger::OnDebugException(bool first_chance, - const ExceptionRecord &record) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION); - llvm::sys::ScopedLock lock(m_mutex); - // FIXME: Without this check, occasionally when running the test suite - // there is an issue where m_session_data can be null. It's not clear how - // this could happen but it only surfaces while running the test suite. In - // order to properly diagnose this, we probably need to first figure allow the - // test suite to print out full lldb logs, and then add logging to the process - // plugin. - if (!m_session_data) { - LLDB_LOG(log, - "Debugger thread reported exception {0:x} at address {1:x}, but " - "there is no session.", - record.GetExceptionCode(), record.GetExceptionAddress()); - return ExceptionResult::SendToApplication; - } - - ExceptionResult result = ExceptionResult::SendToApplication; - if ((record.GetExceptionCode() == EXCEPTION_BREAKPOINT || - record.GetExceptionCode() == - 0x4000001FL /*WOW64 STATUS_WX86_BREAKPOINT*/) && - !m_session_data->m_initial_stop_received) { - // Handle breakpoints at the first chance. - result = ExceptionResult::BreakInDebugger; - LLDB_LOG( - log, - "Hit loader breakpoint at address {0:x}, setting initial stop event.", - record.GetExceptionAddress()); - m_session_data->m_initial_stop_received = true; - ::SetEvent(m_session_data->m_initial_stop_event); - } - return result; -} - -void ProcessDebugger::OnCreateThread(const HostThread &thread) { - // Do nothing by default -} - -void ProcessDebugger::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) { - // Do nothing by default -} - -void ProcessDebugger::OnLoadDll(const ModuleSpec &module_spec, - lldb::addr_t module_addr) { - // Do nothing by default -} - -void ProcessDebugger::OnUnloadDll(lldb::addr_t module_addr) { - // Do nothing by default -} - -void ProcessDebugger::OnDebugString(const std::string &string) {} - -void ProcessDebugger::OnDebuggerError(const Status &error, uint32_t type) { - llvm::sys::ScopedLock lock(m_mutex); - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - - if (m_session_data->m_initial_stop_received) { - // This happened while debugging. Do we shutdown the debugging session, - // try to continue, or do something else? - LLDB_LOG(log, - "Error {0} occurred during debugging. Unexpected behavior " - "may result. {1}", - error.GetError(), error); - } else { - // If we haven't actually launched the process yet, this was an error - // launching the process. Set the internal error and signal the initial - // stop event so that the DoLaunch method wakes up and returns a failure. - m_session_data->m_launch_error = error; - ::SetEvent(m_session_data->m_initial_stop_event); - LLDB_LOG(log, - "Error {0} occurred launching the process before the initial " - "stop. {1}", - error.GetError(), error); - return; - } -} - -Status ProcessDebugger::WaitForDebuggerConnection(DebuggerThreadSP debugger, - HostProcess &process) { - Status result; - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS | - WINDOWS_LOG_BREAKPOINTS); - LLDB_LOG(log, "Waiting for loader breakpoint."); - - // Block this function until we receive the initial stop from the process. - if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) == - WAIT_OBJECT_0) { - LLDB_LOG(log, "hit loader breakpoint, returning."); - - process = debugger->GetProcess(); - return m_session_data->m_launch_error; - } else - return Status(::GetLastError(), eErrorTypeWin32); -} - -} // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h deleted file mode 100644 index b291ab5f4f5cd..0000000000000 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h +++ /dev/null @@ -1,101 +0,0 @@ -//===-- ProcessDebugger.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ProcessDebugger_h_ -#define liblldb_ProcessDebugger_h_ - -#include "lldb/Host/windows/windows.h" - -#include "lldb/Utility/Status.h" -#include "lldb/lldb-forward.h" -#include "lldb/lldb-types.h" -#include "llvm/Support/Mutex.h" - -#include "ForwardDecl.h" -#include -#include - -namespace lldb_private { - -class HostProcess; -class HostThread; -class ProcessLaunchInfo; -class ProcessAttachInfo; - -class ProcessWindowsData { -public: - ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) { - m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); - } - - ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); } - - Status m_launch_error; - DebuggerThreadSP m_debugger; - // StopInfoSP m_pending_stop_info; - HANDLE m_initial_stop_event = nullptr; - bool m_initial_stop_received = false; - bool m_stop_at_entry; - std::map m_new_threads; - std::set m_exited_threads; -}; - -class ProcessDebugger { - -public: - virtual void OnExitProcess(uint32_t exit_code); - virtual void OnDebuggerConnected(lldb::addr_t image_base); - virtual ExceptionResult OnDebugException(bool first_chance, - const ExceptionRecord &record); - virtual void OnCreateThread(const HostThread &thread); - virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code); - virtual void OnLoadDll(const ModuleSpec &module_spec, - lldb::addr_t module_addr); - virtual void OnUnloadDll(lldb::addr_t module_addr); - virtual void OnDebugString(const std::string &string); - virtual void OnDebuggerError(const Status &error, uint32_t type); - -protected: - Status DetachProcess(); - - Status LaunchProcess(ProcessLaunchInfo &launch_info, - DebugDelegateSP delegate); - - Status AttachProcess(const ProcessAttachInfo &attach_info, - DebugDelegateSP delegate); - - Status DestroyProcess(); - - Status HaltProcess(bool &caused_stop); - - Status GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info); - - Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read); - - Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, - size_t &bytes_written); - - Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr); - - Status DeallocateMemory(lldb::addr_t addr); - - lldb::pid_t GetDebuggedProcessId() const; - - Status WaitForDebuggerConnection(DebuggerThreadSP debugger, - HostProcess &process); - -protected: - llvm::sys::Mutex m_mutex; - std::unique_ptr m_session_data; -}; - -} // namespace lldb_private - -#endif // #ifndef liblldb_ProcessDebugger_h_ diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index f9b58a166744c..f18cdfb24555f 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -70,10 +70,46 @@ std::string GetProcessExecutableName(DWORD pid) { } return file_name; } + +DWORD ConvertLldbToWinApiProtect(uint32_t protect) { + // We also can process a read / write permissions here, but if the debugger + // will make later a write into the allocated memory, it will fail. To get + // around it is possible inside DoWriteMemory to remember memory permissions, + // allow write, write and restore permissions, but for now we process only + // the executable permission. + // + // TODO: Process permissions other than executable + if (protect & ePermissionsExecutable) + return PAGE_EXECUTE_READWRITE; + + return PAGE_READWRITE; +} + } // anonymous namespace namespace lldb_private { +// We store a pointer to this class in the ProcessWindows, so that we don't +// expose Windows-specific types and implementation details from a public +// header file. +class ProcessWindowsData { +public: + ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) { + m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); + } + + ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); } + + Status m_launch_error; + DebuggerThreadSP m_debugger; + StopInfoSP m_pending_stop_info; + HANDLE m_initial_stop_event = nullptr; + bool m_initial_stop_received = false; + bool m_stop_at_entry; + std::map m_new_threads; + std::set m_exited_threads; +}; + ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *) { @@ -156,41 +192,159 @@ Status ProcessWindows::DisableBreakpointSite(BreakpointSite *bp_site) { } Status ProcessWindows::DoDetach(bool keep_stopped) { - Status error; Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - StateType private_state = GetPrivateState(); + DebuggerThreadSP debugger_thread; + StateType private_state; + { + // Acquire the lock only long enough to get the DebuggerThread. + // StopDebugging() will trigger a call back into ProcessWindows which will + // also acquire the lock. Thus we have to release the lock before calling + // StopDebugging(). + llvm::sys::ScopedLock lock(m_mutex); + + private_state = GetPrivateState(); + + if (!m_session_data) { + LLDB_LOG(log, "state = {0}, but there is no active session.", + private_state); + return Status(); + } + + debugger_thread = m_session_data->m_debugger; + } + + Status error; if (private_state != eStateExited && private_state != eStateDetached) { - error = DetachProcess(); - if (error.Success()) + LLDB_LOG(log, "detaching from process {0} while state = {1}.", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), + private_state); + error = debugger_thread->StopDebugging(false); + if (error.Success()) { SetPrivateState(eStateDetached); - else - LLDB_LOG(log, "Detaching process error: {0}", error); + } + + // By the time StopDebugging returns, there is no more debugger thread, so + // we can be assured that no other thread will race for the session data. + m_session_data.reset(); } else { - error.SetErrorStringWithFormat("error: process {0} in state = {1}, but " - "cannot detach it in this state.", - GetID(), private_state); - LLDB_LOG(log, "error: {0}", error); + LLDB_LOG( + log, + "error: process {0} in state = {1}, but cannot destroy in this state.", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), + private_state); } + return error; } Status ProcessWindows::DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) { - Status error; + // Even though m_session_data is accessed here, it is before a debugger + // thread has been kicked off. So there's no race conditions, and it + // shouldn't be necessary to acquire the mutex. + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + Status result; + + FileSpec working_dir = launch_info.GetWorkingDirectory(); + namespace fs = llvm::sys::fs; + if (working_dir) { + FileSystem::Instance().Resolve(working_dir); + if (!FileSystem::Instance().IsDirectory(working_dir)) { + result.SetErrorStringWithFormat("No such file or directory: %s", + working_dir.GetCString()); + return result; + } + } + + if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) { + StreamString stream; + stream.Printf("ProcessWindows unable to launch '%s'. ProcessWindows can " + "only be used for debug launches.", + launch_info.GetExecutableFile().GetPath().c_str()); + std::string message = stream.GetString(); + result.SetErrorString(message.c_str()); + + LLDB_LOG(log, "error: {0}", message); + return result; + } + + bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry); + m_session_data.reset(new ProcessWindowsData(stop_at_entry)); + DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this())); - error = LaunchProcess(launch_info, delegate); - if (error.Success()) - SetID(launch_info.GetProcessID()); - return error; + m_session_data->m_debugger.reset(new DebuggerThread(delegate)); + DebuggerThreadSP debugger = m_session_data->m_debugger; + + // Kick off the DebugLaunch asynchronously and wait for it to complete. + result = debugger->DebugLaunch(launch_info); + if (result.Fail()) { + LLDB_LOG(log, "failed launching '{0}'. {1}", + launch_info.GetExecutableFile().GetPath(), result); + return result; + } + + HostProcess process; + Status error = WaitForDebuggerConnection(debugger, process); + if (error.Fail()) { + LLDB_LOG(log, "failed launching '{0}'. {1}", + launch_info.GetExecutableFile().GetPath(), error); + return error; + } + + LLDB_LOG(log, "successfully launched '{0}'", + launch_info.GetExecutableFile().GetPath()); + + // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the + // private state should already be set to eStateStopped as a result of + // hitting the initial breakpoint. If it was not set, the breakpoint should + // have already been resumed from and the private state should already be + // eStateRunning. + launch_info.SetProcessID(process.GetProcessId()); + SetID(process.GetProcessId()); + + return result; } Status ProcessWindows::DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + m_session_data.reset( + new ProcessWindowsData(!attach_info.GetContinueOnceAttached())); + DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this())); - Status error = AttachProcess(attach_info, delegate); - if (error.Success()) - SetID(GetDebuggedProcessId()); + DebuggerThreadSP debugger(new DebuggerThread(delegate)); + + m_session_data->m_debugger = debugger; + + DWORD process_id = static_cast(pid); + Status error = debugger->DebugAttach(process_id, attach_info); + if (error.Fail()) { + LLDB_LOG( + log, + "encountered an error occurred initiating the asynchronous attach. {0}", + error); + return error; + } + + HostProcess process; + error = WaitForDebuggerConnection(debugger, process); + if (error.Fail()) { + LLDB_LOG(log, + "encountered an error waiting for the debugger to connect. {0}", + error); + return error; + } + + LLDB_LOG(log, "successfully attached to process with pid={0}", process_id); + + // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the + // private state should already be set to eStateStopped as a result of + // hitting the initial breakpoint. If it was not set, the breakpoint should + // have already been resumed from and the private state should already be + // eStateRunning. + SetID(process.GetProcessId()); return error; } @@ -246,25 +400,63 @@ Status ProcessWindows::DoResume() { } Status ProcessWindows::DoDestroy() { - Status error; Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - StateType private_state = GetPrivateState(); - if (private_state != eStateExited && private_state != eStateDetached) - return DestroyProcess(); - else { - error.SetErrorStringWithFormat( - "cannot destroy process {0} while state = {1}", GetID(), private_state); - LLDB_LOG(log, "error: {0}", error); + DebuggerThreadSP debugger_thread; + StateType private_state; + { + // Acquire this lock inside an inner scope, only long enough to get the + // DebuggerThread. StopDebugging() will trigger a call back into + // ProcessWindows which will acquire the lock again, so we need to not + // deadlock. + llvm::sys::ScopedLock lock(m_mutex); + + private_state = GetPrivateState(); + + if (!m_session_data) { + LLDB_LOG(log, "warning: state = {0}, but there is no active session.", + private_state); + return Status(); + } + + debugger_thread = m_session_data->m_debugger; + } + + Status error; + if (private_state != eStateExited && private_state != eStateDetached) { + LLDB_LOG(log, "Shutting down process {0} while state = {1}.", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), + private_state); + error = debugger_thread->StopDebugging(true); + + // By the time StopDebugging returns, there is no more debugger thread, so + // we can be assured that no other thread will race for the session data. + m_session_data.reset(); + } else { + LLDB_LOG(log, "cannot destroy process {0} while state = {1}", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), + private_state); } + return error; } Status ProcessWindows::DoHalt(bool &caused_stop) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + Status error; StateType state = GetPrivateState(); - if (state != eStateStopped) - return HaltProcess(caused_stop); - caused_stop = false; - return Status(); + if (state == eStateStopped) + caused_stop = false; + else { + llvm::sys::ScopedLock lock(m_mutex); + caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess() + .GetNativeProcess() + .GetSystemHandle()); + if (!caused_stop) { + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error); + } + } + return error; } void ProcessWindows::DidLaunch() { @@ -537,32 +729,198 @@ bool ProcessWindows::IsAlive() { size_t ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) { - size_t bytes_read = 0; - error = ProcessDebugger::ReadMemory(vm_addr, buf, size, bytes_read); + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + + if (!m_session_data) + return 0; + + LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size, + vm_addr); + + HostProcess process = m_session_data->m_debugger->GetProcess(); + void *addr = reinterpret_cast(vm_addr); + SIZE_T bytes_read = 0; + if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, + buf, size, &bytes_read)) { + // Reading from the process can fail for a number of reasons - set the + // error code and make sure that the number of bytes read is set back to 0 + // because in some scenarios the value of bytes_read returned from the API + // is garbage. + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "reading failed with error: {0}", error); + bytes_read = 0; + } return bytes_read; } size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) { - size_t bytes_written = 0; - error = ProcessDebugger::WriteMemory(vm_addr, buf, size, bytes_written); + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size, + vm_addr); + + if (!m_session_data) { + LLDB_LOG(log, "cannot write, there is no active debugger connection."); + return 0; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + void *addr = reinterpret_cast(vm_addr); + SIZE_T bytes_written = 0; + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (WriteProcessMemory(handle, addr, buf, size, &bytes_written)) + FlushInstructionCache(handle, addr, bytes_written); + else { + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "writing failed with error: {0}", error); + } return bytes_written; } lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t permissions, Status &error) { - lldb::addr_t vm_addr = LLDB_INVALID_ADDRESS; - error = ProcessDebugger::AllocateMemory(size, permissions, vm_addr); - return vm_addr; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, + permissions); + + if (!m_session_data) { + LLDB_LOG(log, "cannot allocate, there is no active debugger connection."); + error.SetErrorString( + "cannot allocate, there is no active debugger connection"); + return LLDB_INVALID_ADDRESS; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + auto protect = ConvertLldbToWinApiProtect(permissions); + auto result = VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); + if (!result) { + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "allocating failed with error: {0}", error); + return LLDB_INVALID_ADDRESS; + } + + return reinterpret_cast(result); } Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) { - return ProcessDebugger::DeallocateMemory(ptr); + Status result; + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to deallocate bytes at address {0}", ptr); + + if (!m_session_data) { + LLDB_LOG(log, "cannot deallocate, there is no active debugger connection."); + result.SetErrorString( + "cannot deallocate, there is no active debugger connection"); + return result; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (!VirtualFreeEx(handle, reinterpret_cast(ptr), 0, MEM_RELEASE)) { + result.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "deallocating failed with error: {0}", result); + return result; + } + + return result; } Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) { - return ProcessDebugger::GetMemoryRegionInfo(vm_addr, info); + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + Status error; + llvm::sys::ScopedLock lock(m_mutex); + info.Clear(); + + if (!m_session_data) { + error.SetErrorString( + "GetMemoryRegionInfo called with no debugging session."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (handle == nullptr || handle == LLDB_INVALID_PROCESS) { + error.SetErrorString( + "GetMemoryRegionInfo called with an invalid target process."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + + LLDB_LOG(log, "getting info for address {0:x}", vm_addr); + + void *addr = reinterpret_cast(vm_addr); + MEMORY_BASIC_INFORMATION mem_info = {}; + SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info)); + if (result == 0) { + if (::GetLastError() == ERROR_INVALID_PARAMETER) { + // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with + // an address past the highest accessible address. We should return a + // range from the vm_addr to LLDB_INVALID_ADDRESS + info.GetRange().SetRangeBase(vm_addr); + info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); + info.SetReadable(MemoryRegionInfo::eNo); + info.SetExecutable(MemoryRegionInfo::eNo); + info.SetWritable(MemoryRegionInfo::eNo); + info.SetMapped(MemoryRegionInfo::eNo); + return error; + } else { + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, + "VirtualQueryEx returned error {0} while getting memory " + "region info for address {1:x}", + error, vm_addr); + return error; + } + } + + // Protect bits are only valid for MEM_COMMIT regions. + if (mem_info.State == MEM_COMMIT) { + const bool readable = IsPageReadable(mem_info.Protect); + const bool executable = IsPageExecutable(mem_info.Protect); + const bool writable = IsPageWritable(mem_info.Protect); + info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); + info.SetExecutable(executable ? MemoryRegionInfo::eYes + : MemoryRegionInfo::eNo); + info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); + } else { + info.SetReadable(MemoryRegionInfo::eNo); + info.SetExecutable(MemoryRegionInfo::eNo); + info.SetWritable(MemoryRegionInfo::eNo); + } + + // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE. + if (mem_info.State != MEM_FREE) { + info.GetRange().SetRangeBase( + reinterpret_cast(mem_info.AllocationBase)); + info.GetRange().SetRangeEnd(reinterpret_cast(mem_info.BaseAddress) + + mem_info.RegionSize); + info.SetMapped(MemoryRegionInfo::eYes); + } else { + // In the unmapped case we need to return the distance to the next block of + // memory. VirtualQueryEx nearly does that except that it gives the + // distance from the start of the page containing vm_addr. + SYSTEM_INFO data; + GetSystemInfo(&data); + DWORD page_offset = vm_addr % data.dwPageSize; + info.GetRange().SetRangeBase(vm_addr); + info.GetRange().SetByteSize(mem_info.RegionSize - page_offset); + info.SetMapped(MemoryRegionInfo::eNo); + } + + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOGV(log, + "Memory region info for address {0}: readable={1}, " + "executable={2}, writable={3}", + vm_addr, info.GetReadable(), info.GetExecutable(), + info.GetWritable()); + return error; } lldb::addr_t ProcessWindows::GetImageInfoAddress() { @@ -777,4 +1135,41 @@ void ProcessWindows::OnDebuggerError(const Status &error, uint32_t type) { return; } } + +Status ProcessWindows::WaitForDebuggerConnection(DebuggerThreadSP debugger, + HostProcess &process) { + Status result; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS | + WINDOWS_LOG_BREAKPOINTS); + LLDB_LOG(log, "Waiting for loader breakpoint."); + + // Block this function until we receive the initial stop from the process. + if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) == + WAIT_OBJECT_0) { + LLDB_LOG(log, "hit loader breakpoint, returning."); + + process = debugger->GetProcess(); + return m_session_data->m_launch_error; + } else + return Status(::GetLastError(), eErrorTypeWin32); +} + +// The Windows page protection bits are NOT independent masks that can be +// bitwise-ORed together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE +// | PAGE_READ). To test for an access type, it's necessary to test for any of +// the bits that provide that access type. +bool ProcessWindows::IsPageReadable(uint32_t protect) { + return (protect & PAGE_NOACCESS) == 0; +} + +bool ProcessWindows::IsPageWritable(uint32_t protect) { + return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | + PAGE_READWRITE | PAGE_WRITECOPY)) != 0; +} + +bool ProcessWindows::IsPageExecutable(uint32_t protect) { + return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | + PAGE_EXECUTE_WRITECOPY)) != 0; +} + } // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h index 8d5134a49a429..1b1f173a36451 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h @@ -13,14 +13,17 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" +#include "llvm/Support/Mutex.h" + +#include "IDebugDelegate.h" #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" -#include "ProcessDebugger.h" namespace lldb_private { class HostProcess; +class ProcessWindowsData; -class ProcessWindows : public Process, public ProcessDebugger { +class ProcessWindows : public Process, public IDebugDelegate { public: // Static functions. static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, @@ -98,7 +101,19 @@ class ProcessWindows : public Process, public ProcessDebugger { void OnUnloadDll(lldb::addr_t module_addr) override; void OnDebugString(const std::string &string) override; void OnDebuggerError(const Status &error, uint32_t type) override; + +private: + Status WaitForDebuggerConnection(DebuggerThreadSP debugger, + HostProcess &process); + + // These decode the page protection bits. + static bool IsPageReadable(uint32_t protect); + static bool IsPageWritable(uint32_t protect); + static bool IsPageExecutable(uint32_t protect); + + llvm::sys::Mutex m_mutex; + std::unique_ptr m_session_data; }; -} // namespace lldb_private +} #endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_ From f42b97551be4c14c6d2c4337c1542a720a277d7c Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Mon, 8 Jul 2019 21:17:58 +0000 Subject: [PATCH 052/616] [lldb] Fix two more issues in Windows following rL365226: Change LaunchThread interface to return an expected A couple of the function signatures changed and they were not updated in the Windows HostProcess llvm-svn: 365388 (cherry picked from commit 05590baa071b33eefcf2a215d057ea9d35593c5b) --- lldb/include/lldb/Host/windows/HostProcessWindows.h | 5 +++-- lldb/source/Host/windows/HostProcessWindows.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Host/windows/HostProcessWindows.h b/lldb/include/lldb/Host/windows/HostProcessWindows.h index 4178956f56176..925d565c275ef 100644 --- a/lldb/include/lldb/Host/windows/HostProcessWindows.h +++ b/lldb/include/lldb/Host/windows/HostProcessWindows.h @@ -30,8 +30,9 @@ class HostProcessWindows : public HostNativeProcessBase { lldb::pid_t GetProcessId() const override; bool IsRunning() const override; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals) override; + virtual llvm::Expected + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals) override; private: static lldb::thread_result_t MonitorThread(void *thread_arg); diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index c422a86683af3..d7484f8a89b7e 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -94,7 +94,7 @@ llvm::Expected HostProcessWindows::StartMonitoring( &info->process_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) result = ThreadLauncher::LaunchThread("ChildProcessMonitor", HostProcessWindows::MonitorThread, - info, nullptr); + info); return result; } From be2ac1e6472fc1b282bd0d0a1c08ef8bd2fbf903 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 21:19:02 +0000 Subject: [PATCH 053/616] [Windows] Convert GetLastError to std::error_code Create a std::error_code from the result of GetLastError, which in turn we can use to return an llvm::Error. llvm-svn: 365390 (cherry picked from commit 39d1f2f5ea719b68f74b0c4520dee2d3304edc31) --- lldb/source/Host/common/ThreadLauncher.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 912ce3688f2c2..62834c5c33296 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -31,8 +31,10 @@ llvm::Expected ThreadLauncher::LaunchThread( thread = (lldb::thread_t)::_beginthreadex( 0, (unsigned)min_stack_byte_size, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL); - if (thread == (lldb::thread_t)(-1L)) - return llvm::errorCodeToError(::GetLastError()); + if (thread == (lldb::thread_t)(-1L)) { + DWORD err = GetLastError(); + return llvm::errorCodeToError(std::error_code(err, std::system_category())); + } #else // ASAN instrumentation adds a lot of bookkeeping overhead on stack frames. From c760c8b8ae302f1e688f0988a72190aa4cb4fcb1 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 21:38:34 +0000 Subject: [PATCH 054/616] Remove lldb-perf As discussed offline, this tool is no longer used or maintained, and doesn't provide the right abstraction for performance tracking in lldb. Differential revision: https://reviews.llvm.org/D64362 llvm-svn: 365391 (cherry picked from commit cbdf794872a96a9941ea711513901f9daba21083) --- .../lldb.xcworkspace/contents.xcworkspacedata | 3 - lldb/tools/lldb-perf/README | 295 ---- .../lldb-perf/common/clang/build-clang.sh | 33 - .../common/clang/lldb_perf_clang.cpp | 441 ------ lldb/tools/lldb-perf/common/clang/main.cpp | 20 - .../common/stepping/lldb-perf-stepping.cpp | 287 ---- .../common/stepping/stepping-testcase.cpp | 35 - .../darwin/formatters/fmts_tester.mm | 81 -- .../darwin/formatters/formatters.cpp | 267 ---- lldb/tools/lldb-perf/darwin/sketch/sketch.cpp | 329 ----- lldb/tools/lldb-perf/lib/Gauge.cpp | 49 - lldb/tools/lldb-perf/lib/Gauge.h | 50 - lldb/tools/lldb-perf/lib/Measurement.h | 157 --- lldb/tools/lldb-perf/lib/MemoryGauge.cpp | 119 -- lldb/tools/lldb-perf/lib/MemoryGauge.h | 88 -- lldb/tools/lldb-perf/lib/Metric.cpp | 59 - lldb/tools/lldb-perf/lib/Metric.h | 57 - lldb/tools/lldb-perf/lib/Results.cpp | 236 ---- lldb/tools/lldb-perf/lib/Results.h | 204 --- lldb/tools/lldb-perf/lib/TestCase.cpp | 307 ----- lldb/tools/lldb-perf/lib/TestCase.h | 144 -- lldb/tools/lldb-perf/lib/Timer.cpp | 46 - lldb/tools/lldb-perf/lib/Timer.h | 48 - lldb/tools/lldb-perf/lib/Xcode.cpp | 136 -- lldb/tools/lldb-perf/lib/Xcode.h | 57 - .../lldbperf.xcodeproj/project.pbxproj | 1224 ----------------- 26 files changed, 4772 deletions(-) delete mode 100644 lldb/tools/lldb-perf/README delete mode 100755 lldb/tools/lldb-perf/common/clang/build-clang.sh delete mode 100644 lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp delete mode 100644 lldb/tools/lldb-perf/common/clang/main.cpp delete mode 100644 lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp delete mode 100644 lldb/tools/lldb-perf/common/stepping/stepping-testcase.cpp delete mode 100644 lldb/tools/lldb-perf/darwin/formatters/fmts_tester.mm delete mode 100644 lldb/tools/lldb-perf/darwin/formatters/formatters.cpp delete mode 100644 lldb/tools/lldb-perf/darwin/sketch/sketch.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Gauge.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Gauge.h delete mode 100644 lldb/tools/lldb-perf/lib/Measurement.h delete mode 100644 lldb/tools/lldb-perf/lib/MemoryGauge.cpp delete mode 100644 lldb/tools/lldb-perf/lib/MemoryGauge.h delete mode 100644 lldb/tools/lldb-perf/lib/Metric.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Metric.h delete mode 100644 lldb/tools/lldb-perf/lib/Results.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Results.h delete mode 100644 lldb/tools/lldb-perf/lib/TestCase.cpp delete mode 100644 lldb/tools/lldb-perf/lib/TestCase.h delete mode 100644 lldb/tools/lldb-perf/lib/Timer.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Timer.h delete mode 100644 lldb/tools/lldb-perf/lib/Xcode.cpp delete mode 100644 lldb/tools/lldb-perf/lib/Xcode.h delete mode 100644 lldb/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj diff --git a/lldb/lldb.xcworkspace/contents.xcworkspacedata b/lldb/lldb.xcworkspace/contents.xcworkspacedata index 3266d5b39e25f..f92eeccdc230e 100644 --- a/lldb/lldb.xcworkspace/contents.xcworkspacedata +++ b/lldb/lldb.xcworkspace/contents.xcworkspacedata @@ -7,7 +7,4 @@ - - diff --git a/lldb/tools/lldb-perf/README b/lldb/tools/lldb-perf/README deleted file mode 100644 index 7cec4faac2c8e..0000000000000 --- a/lldb/tools/lldb-perf/README +++ /dev/null @@ -1,295 +0,0 @@ - The lldb-perf infrastructure for LLDB performance testing -=========================================================== - -lldb-perf is an infrastructure meant to simplify the creation of performance -tests for the LLDB debugger. It is contained in liblldbperf.a which is part of -the standard opensource checkout of LLDB - -Its main concepts are: -- Gauges: a gauge is a thing that takes a sample. Samples include elapsed time, - memory used, and energy consumed. -- Metrics: a metric is a collection of samples that knows how to do statistics - like sum() and average(). Metrics can be extended as needed. -- Measurements: a measurement is the thing that stores an action, a gauge and - a metric. You define measurements as in “take the time to run this function”, - “take the memory to run this block of code”, and then after you invoke it, - your stats will automagically be there. -- Tests: a test is a sequence of steps and measurements. - -Tests cases should be added as targets to the lldbperf.xcodeproj project. It -is probably easiest to duplicate one of the existing targets. In order to -write a test based on lldb-perf, you need to subclass lldb_perf::TestCase: - -using namespace lldb_perf; - -class FormattersTest : public TestCase -{ - -Usually, you will define measurements as variables of your test case class: - -private: - // C++ formatters - TimeMeasurement> m_dump_std_vector_measurement; - TimeMeasurement> m_dump_std_list_measurement; - TimeMeasurement> m_dump_std_map_measurement; - TimeMeasurement> m_dump_std_string_measurement; - - // Cocoa formatters - TimeMeasurement> m_dump_nsstring_measurement; - TimeMeasurement> m_dump_nsarray_measurement; - TimeMeasurement> m_dump_nsdictionary_measurement; - TimeMeasurement> m_dump_nsset_measurement; - TimeMeasurement> m_dump_nsbundle_measurement; - TimeMeasurement> m_dump_nsdate_measurement; - -A TimeMeasurement is, obviously, a class that measures “how much time to run -this block of code”. The block of code is passed as an std::function which you -can construct with a lambda! You need to give the prototype of your block of -code. In this example, we run blocks of code that take an SBValue and return -nothing. - -These blocks look like: - - m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "std-vector", "time to dump an std::vector"); - -Here we are saying: make me a measurement named “std-vector”, whose -description is “time to dump an std::vector” and that takes the time required -to call lldb_perf::Xcode::FetchVariable(value,1,false). - -The Xcode class is a collection of utility functions that replicate common -Xcode patterns (FetchVariable unsurprisingly calls API functions that Xcode -could use when populating a variables view entry - the 1 means “expand 1 level -of depth” and the false means “do not dump the data to stdout”) - -A full constructor for a TestCase looks like: - -FormattersTest () : TestCase() -{ - m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "std-vector", "time to dump an std::vector"); - m_dump_std_list_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "std-list", "time to dump an std::list"); - m_dump_std_map_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "std-map", "time to dump an std::map"); - m_dump_std_string_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "std-string", "time to dump an std::string"); - - m_dump_nsstring_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,0,false); - }, "ns-string", "time to dump an NSString"); - - m_dump_nsarray_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "ns-array", "time to dump an NSArray"); - - m_dump_nsdictionary_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "ns-dictionary", "time to dump an NSDictionary"); - - m_dump_nsset_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "ns-set", "time to dump an NSSet"); - - m_dump_nsbundle_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,1,false); - }, "ns-bundle", "time to dump an NSBundle"); - - m_dump_nsdate_measurement = CreateTimeMeasurement([] (SBValue value) -> void { - lldb_perf::Xcode::FetchVariable (value,0,false); - }, "ns-date", "time to dump an NSDate"); -} - -Once your test case is constructed, Setup() is called on it: - - virtual bool - Setup (int argc, const char** argv) - { - m_app_path.assign(argv[1]); - m_out_path.assign(argv[2]); - m_target = m_debugger.CreateTarget(m_app_path.c_str()); - m_target.BreakpointCreateByName("main"); - SBLaunchInfo launch_info (argv); - return Launch (launch_info); - } - -Setup() returns a boolean value that indicates if setup was successful. -In Setup() you fill out a SBLaunchInfo with any needed settings for launching -your process like arguments, environment variables, working directory, and -much more. - -The last thing you want to do in setup is call Launch(): - - bool - Launch (coSBLaunchInfo &launch_info); - -This ensures your target is now alive. Make sure to have a breakpoint created. - -Once you launched, the event loop is entered. The event loop waits for stops, -and when it gets one, it calls your test case’s TestStep() function: - - virtual void - TestStep (int counter, ActionWanted &next_action) - -the counter is the step id (a monotonically increasing counter). In TestStep() -you will essentially run your measurements and then return what you want the -driver to do by filling in the ActionWanted object named "next_action". - -Possible options are: -- continue process next_action.Continue(); -- kill process next_action.Kill(); -- Step-out on a thread next_action.StepOut(SBThread) -- step-over on a thread. next_action.StepOver(SBThread) - -If you use ActionWanted::Next() or ActionWanted::Finish() you need to specify -a thread to use. By default the TestCase class will select the first thread -that had a stop reason other than eStopReasonNone and place it into the -m_thread member variable of TestCase. This means if your test case hits a -breakpoint or steps, the thread that hit the breakpoint or finished the step -will automatically be selected in the process (m_process) and m_thread will -be set to this thread. If you have one or more threads that will stop with a -reason simultaneously, you will need to find those threads manually by -iterating through the process list and determine what to do next. - -For your convenience TestCase has m_debugger, m_target and m_process as member -variables. As state above m_thread will be filled in with the first thread -that has a stop reason. - -An example: - - virtual void - TestStep (int counter, ActionWanted &next_action) - { - case 0: - m_target.BreakpointCreateByLocation("fmts_tester.mm", 68); - next_action.Continue(); - break; - case 1: - DoTest (); - next_action.Continue(); - break; - case 2: - DoTest (); - next_action.StepOver(m_thread); - break; - -DoTest() is a function I define in my own class that calls the measurements: - void - DoTest () - { - SBThread thread_main(m_thread); - SBFrame frame_zero(thread_main.GetFrameAtIndex(0)); - - m_dump_nsarray_measurement(frame_zero.FindVariable("nsarray", lldb::eDynamicCanRunTarget)); - m_dump_nsarray_measurement(frame_zero.FindVariable("nsmutablearray", lldb::eDynamicCanRunTarget)); - - m_dump_nsdictionary_measurement(frame_zero.FindVariable("nsdictionary", lldb::eDynamicCanRunTarget)); - m_dump_nsdictionary_measurement(frame_zero.FindVariable("nsmutabledictionary", lldb::eDynamicCanRunTarget)); - - m_dump_nsstring_measurement(frame_zero.FindVariable("str0", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement(frame_zero.FindVariable("str1", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement(frame_zero.FindVariable("str2", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement(frame_zero.FindVariable("str3", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement(frame_zero.FindVariable("str4", lldb::eDynamicCanRunTarget)); - - m_dump_nsdate_measurement(frame_zero.FindVariable("me", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement(frame_zero.FindVariable("cutie", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement(frame_zero.FindVariable("mom", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement(frame_zero.FindVariable("dad", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement(frame_zero.FindVariable("today", lldb::eDynamicCanRunTarget)); - - m_dump_nsbundle_measurement(frame_zero.FindVariable("bundles", lldb::eDynamicCanRunTarget)); - m_dump_nsbundle_measurement(frame_zero.FindVariable("frameworks", lldb::eDynamicCanRunTarget)); - - m_dump_nsset_measurement(frame_zero.FindVariable("nsset", lldb::eDynamicCanRunTarget)); - m_dump_nsset_measurement(frame_zero.FindVariable("nsmutableset", lldb::eDynamicCanRunTarget)); - - m_dump_std_vector_measurement(frame_zero.FindVariable("vector", lldb::eDynamicCanRunTarget)); - m_dump_std_list_measurement(frame_zero.FindVariable("list", lldb::eDynamicCanRunTarget)); - m_dump_std_map_measurement(frame_zero.FindVariable("map", lldb::eDynamicCanRunTarget)); - - m_dump_std_string_measurement(frame_zero.FindVariable("sstr0", lldb::eDynamicCanRunTarget)); - m_dump_std_string_measurement(frame_zero.FindVariable("sstr1", lldb::eDynamicCanRunTarget)); - m_dump_std_string_measurement(frame_zero.FindVariable("sstr2", lldb::eDynamicCanRunTarget)); - m_dump_std_string_measurement(frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget)); - m_dump_std_string_measurement(frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget)); - } - -Essentially, you call your measurements as if they were functions, passing -them arguments and all, and they will do the right thing with gathering stats. - -The last step is usually to KILL the inferior and bail out: - - virtual ActionWanted - TestStep (int counter) - { -... - case 9: - DoTest (); - next_action.Continue(); - break; - case 10: - DoTest (); - next_action.Continue(); - break; - default: - next_action.Kill(); - break; - } - - -At the end, you define a Results() function: - - void - Results () - { - CFCMutableArray array; - m_dump_std_vector_measurement.Write(array); - m_dump_std_list_measurement.Write(array); - m_dump_std_map_measurement.Write(array); - m_dump_std_string_measurement.Write(array); - - m_dump_nsstring_measurement.Write(array); - m_dump_nsarray_measurement.Write(array); - m_dump_nsdictionary_measurement.Write(array); - m_dump_nsset_measurement.Write(array); - m_dump_nsbundle_measurement.Write(array); - m_dump_nsdate_measurement.Write(array); - - CFDataRef xmlData = CFPropertyListCreateData (kCFAllocatorDefault, - array.get(), - kCFPropertyListXMLFormat_v1_0, - 0, - NULL); - - CFURLRef file = CFURLCreateFromFileSystemRepresentation (NULL, - (const UInt8*)m_out_path.c_str(), - m_out_path.size(), - FALSE); - - CFURLWriteDataAndPropertiesToResource(file,xmlData,NULL,NULL); - } - -For now, pretty much copy this and just call Write() on all your measurements. -I plan to move this higher in the hierarchy (e.g. make a -TestCase::Write(filename) fairly soon). - -Your main() will look like: - -int main(int argc, const char * argv[]) -{ - MyTest test; - TestCase::Run (test, argc, argv); - return 0; -} - -If you are debugging your test, before Run() call - - test.SetVerbose(true); - -Feel free to send any questions and ideas for improvements. diff --git a/lldb/tools/lldb-perf/common/clang/build-clang.sh b/lldb/tools/lldb-perf/common/clang/build-clang.sh deleted file mode 100755 index 3d9add79c4abc..0000000000000 --- a/lldb/tools/lldb-perf/common/clang/build-clang.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -if [ -d "llvm-build" ]; then - echo "Using existing 'llvm-build' directory..." -else - mkdir llvm-build -fi - -cd llvm-build - -if [ -d "llvm" ]; then - echo "Using existing 'llvm' directory..." -else - svn co --revision 176809 http://llvm.org/svn/llvm-project/llvm/trunk llvm - ( cd llvm/tools ; svn co --revision 176809 http://llvm.org/svn/llvm-project/cfe/trunk clang ) -fi - -if [ ! -d "build" ]; then - mkdir build - cd build - ../llvm/configure --enable-targets=x86_64,arm --build=x86_64-apple-darwin10 --disable-optimized --disable-assertions --enable-libcpp - make -j8 clang-only DEBUG_SYMBOLS=1 - rm -rf lib projects runtime unittests utils config.* - ( cd ./Debug/bin ; rm -rf ll* clang-check clang-tblgen count diagtool fpcmp macho-dump not opt yaml2obj FileCheck FileUpdate arcmt-test c-arcmt-test c-index-test bugpoint ) - ( cd ./tools ; rm -rf ll* clang-check clang-tblgen count diagtool fpcmp lto macho-dump not opt yaml2obj FileCheck FileUpdate arcmt-test c-arcmt-test c-index-test bugpoint ) - ( cd ./tools/clang ; rm -rf lib unittests utils ) - ( cd ./tools/clang/tools ; rm -rf arcmt-test c-arcmt-test c-index-test clang-check diagtool libclang ) - ( cd ../llvm ; rm -rf cmake configure docs examples projects *.txt *.TXT autoconf bindings test unittests utils ; find . -type d -name .svn -print0 | xargs -0 rm -rf ) - ( cd ../llvm/tools ; rm -rf *.txt bugpoint bugpoint-passes ll* lto macho-dump opt gold ) -fi - - - diff --git a/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp b/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp deleted file mode 100644 index 4fc359db5c761..0000000000000 --- a/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp +++ /dev/null @@ -1,441 +0,0 @@ -//===-- lldb_perf_clang.cpp -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb-perf/lib/Measurement.h" -#include "lldb-perf/lib/Metric.h" -#include "lldb-perf/lib/Results.h" -#include "lldb-perf/lib/TestCase.h" -#include "lldb-perf/lib/Timer.h" -#include "lldb-perf/lib/Xcode.h" -#include "llvm/ADT/STLExtras.h" -#include -#include -#include -#include - -using namespace lldb_perf; - -#define NUM_EXPR_ITERATIONS 3 -class ClangTest : public TestCase { -public: - ClangTest() - : TestCase(), - m_time_create_target( - [this]() -> void { - m_memory_change_create_target.Start(); - m_target = m_debugger.CreateTarget(m_exe_path.c_str()); - m_memory_change_create_target.Stop(); - }, - "time-create-target", "The time it takes to create a target."), - m_time_set_bp_main( - [this]() -> void { - m_memory_change_break_main.Start(); - m_target.BreakpointCreateByName("main"); - m_memory_change_break_main.Stop(); - }, - "time-set-break-main", - "Elapsed time it takes to set a breakpoint at 'main' by name."), - m_memory_change_create_target(), m_memory_change_break_main(), - m_memory_total(), m_time_launch_stop_main(), m_time_total(), - m_expr_first_evaluate( - [this](SBFrame frame) -> void { - frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()") - .GetError(); - }, - "time-expr", "Elapsed time it takes to evaluate an expression for " - "the first time."), - m_expr_frame_zero( - [this](SBFrame frame) -> void { - frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()") - .GetError(); - }, - "time-expr-frame-zero", "Elapsed time it takes to evaluate an " - "expression 3 times at frame zero."), - m_expr_frame_non_zero( - [this](SBFrame frame) -> void { - frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()") - .GetError(); - }, - "time-expr-frame-non-zero", "Elapsed time it takes to evaluate an " - "expression 3 times at a non-zero " - "frame."), - m_exe_path(), m_out_path(), m_launch_info(NULL), m_use_dsym(false) {} - - virtual ~ClangTest() {} - - virtual bool Setup(int &argc, const char **&argv) { - if (m_exe_path.empty()) - return false; - m_launch_info.SetArguments(argv, false); - return true; - } - - void DoTest() {} - - virtual void TestStep(int counter, ActionWanted &next_action) { - char temp_source_path[PATH_MAX] = "/tmp/main.XXXXXX.cpp"; - - switch (counter) { - case 0: { - // Xcode::RunCommand(m_debugger,"log enable -f /tmp/packets.txt gdb-remote - // packets",true); - - m_memory_total.Start(); - m_time_total.Start(); - - // Time creating the target - m_time_create_target(); - - m_time_set_bp_main(); - - int fd = mkstemps(temp_source_path, 4); - - if (fd >= 0) { - const char *source_content = R"( -#include -#include -#include - -namespace { - struct Foo - { - int i; int j; - }; - void doit (const Foo &foo) - { - printf ("doit(%i)\n", foo.i); - } -} - -int main (int argc, char const *argv[], char const *envp[]) -{ - std::vector ints; - for (int i=0;i<10;++i) - ints.push_back(i); - printf ("hello world\n"); - Foo foo = { 12, 13 }; - doit (foo); - return 0; -} -)"; - write(fd, source_content, strlen(source_content)); - close(fd); - } else { - const char *error_cstr = strerror(errno); - fprintf(stderr, - "error: failed to created temporary source file: '%s' (%s)", - temp_source_path, error_cstr); - exit(2); - } - - m_time_launch_stop_main.Start(); - const char *clang_argv[] = {"-cc1", - "-triple", - "x86_64-apple-macosx10.8.0", - "-emit-obj", - "-mrelax-all", - "-disable-free", - "-disable-llvm-verifier", - "-main-file-name", - "main.cpp", - "-mrelocation-model", - "pic", - "-pic-level", - "2", - "-mdisable-fp-elim", - "-masm-verbose", - "-munwind-tables", - "-target-cpu", - "core2", - "-target-linker-version", - "132.10.1", - "-v", - "-g", - "-O0", - "-fdeprecated-macro", - "-ferror-limit", - "19", - "-fmessage-length", - "298", - "-stack-protector", - "1", - "-mstackrealign", - "-fblocks", - "-fobjc-runtime=macosx-10.8.0", - "-fobjc-dispatch-method=mixed", - "-fencode-extended-block-signature", - "-fcxx-exceptions", - "-fexceptions", - "-fdiagnostics-show-option", - "-fcolor-diagnostics", - "-backend-option", - "-vectorize-loops", - "-o", - "/tmp/main.o", - "-x", - "c++", - NULL, - NULL}; - clang_argv[llvm::array_lengthof(clang_argv) - 2] = temp_source_path; - SBLaunchInfo launch_info(clang_argv); - Launch(launch_info); - next_action - .None(); // Don't continue or do anything, just wait for next event... - } break; - case 1: { - m_time_launch_stop_main.Stop(); - m_time_total.Stop(); - SBFrame frame(m_thread.GetFrameAtIndex(0)); - - // Time the first expression evaluation - m_expr_first_evaluate(frame); - - SBValue result; - for (size_t i = 0; i < NUM_EXPR_ITERATIONS; ++i) { - m_expr_frame_zero(frame); - } - m_target.BreakpointCreateByName("DeclContext::lookup"); - next_action.Continue(); - } break; - case 2: { - SBFrame frame(m_thread.GetFrameAtIndex(21)); - SBValue result; - for (size_t i = 0; i < NUM_EXPR_ITERATIONS; ++i) { - m_expr_frame_non_zero(frame); - } - next_action.Continue(); - } break; - default: - m_memory_total.Stop(); - next_action.Kill(); - break; - } - } - - void WriteResults(Results &results) { - Results::Dictionary &results_dict = results.GetDictionary(); - - m_time_set_bp_main.WriteAverageAndStandardDeviation(results); - results_dict.Add( - "memory-change-create-target", - "Memory increase that occurs due to creating the target.", - m_memory_change_create_target.GetDeltaValue().GetResult(NULL, NULL)); - - results_dict.Add( - "memory-change-break-main", "Memory increase that occurs due to " - "setting a breakpoint at main by name.", - m_memory_change_break_main.GetDeltaValue().GetResult(NULL, NULL)); - - m_time_create_target.WriteAverageAndStandardDeviation(results); - m_expr_first_evaluate.WriteAverageAndStandardDeviation(results); - m_expr_frame_zero.WriteAverageAndStandardDeviation(results); - m_expr_frame_non_zero.WriteAverageAndStandardDeviation(results); - results_dict.Add("memory-total-break-main", - "The total memory that the current process is using after " - "setting the first breakpoint.", - m_memory_total.GetStopValue().GetResult(NULL, NULL)); - - results_dict.AddDouble( - "time-launch-stop-main", - "The time it takes to launch the process and stop at main.", - m_time_launch_stop_main.GetDeltaValue()); - - results_dict.AddDouble( - "time-total", "The time it takes to create the target, set breakpoint " - "at main, launch clang and hit the breakpoint at main.", - m_time_total.GetDeltaValue()); - results.Write(GetResultFilePath()); - } - - const char *GetExecutablePath() const { - if (m_exe_path.empty()) - return NULL; - return m_exe_path.c_str(); - } - - const char *GetResultFilePath() const { - if (m_out_path.empty()) - return NULL; - return m_out_path.c_str(); - } - - void SetExecutablePath(const char *path) { - if (path && path[0]) - m_exe_path = path; - else - m_exe_path.clear(); - } - - void SetResultFilePath(const char *path) { - if (path && path[0]) - m_out_path = path; - else - m_out_path.clear(); - } - - void SetUseDSYM(bool b) { m_use_dsym = b; } - -private: - // C++ formatters - TimeMeasurement> m_time_create_target; - TimeMeasurement> m_time_set_bp_main; - MemoryGauge m_memory_change_create_target; - MemoryGauge m_memory_change_break_main; - MemoryGauge m_memory_total; - TimeGauge m_time_launch_stop_main; - TimeGauge m_time_total; - TimeMeasurement> m_expr_first_evaluate; - TimeMeasurement> m_expr_frame_zero; - TimeMeasurement> m_expr_frame_non_zero; - std::string m_exe_path; - std::string m_out_path; - SBLaunchInfo m_launch_info; - bool m_use_dsym; -}; - -struct Options { - std::string clang_path; - std::string out_file; - bool verbose; - bool use_dsym; - bool error; - bool print_help; - - Options() : verbose(false), error(false), print_help(false) {} -}; - -static struct option g_long_options[] = { - {"verbose", no_argument, NULL, 'v'}, - {"clang", required_argument, NULL, 'c'}, - {"out-file", required_argument, NULL, 'o'}, - {"dsym", no_argument, NULL, 'd'}, - {NULL, 0, NULL, 0}}; - -std::string GetShortOptionString(struct option *long_options) { - std::string option_string; - for (int i = 0; long_options[i].name != NULL; ++i) { - if (long_options[i].flag == NULL) { - option_string.push_back((char)long_options[i].val); - switch (long_options[i].has_arg) { - default: - case no_argument: - break; - case required_argument: - option_string.push_back(':'); - break; - case optional_argument: - option_string.append(2, ':'); - break; - } - } - } - return option_string; -} - -int main(int argc, const char *argv[]) { - - // Prepare for & make calls to getopt_long_only. - - std::string short_option_string(GetShortOptionString(g_long_options)); - - ClangTest test; - - Options option_data; - bool done = false; - -#if __GLIBC__ - optind = 0; -#else - optreset = 1; - optind = 1; -#endif - while (!done) { - int long_options_index = -1; - const int short_option = ::getopt_long_only( - argc, const_cast(argv), short_option_string.c_str(), - g_long_options, &long_options_index); - - switch (short_option) { - case 0: - // Already handled - break; - - case -1: - done = true; - break; - - case '?': - option_data.print_help = true; - break; - - case 'h': - option_data.print_help = true; - break; - - case 'v': - option_data.verbose = true; - break; - - case 'c': { - SBFileSpec file(optarg); - if (file.Exists()) - test.SetExecutablePath(optarg); - else - fprintf(stderr, "error: file specified in --clang (-c) option doesn't " - "exist: '%s'\n", - optarg); - } break; - - case 'o': - test.SetResultFilePath(optarg); - break; - - case 'd': - test.SetUseDSYM(true); - break; - - default: - option_data.error = true; - option_data.print_help = true; - fprintf(stderr, "error: unrecognized option %c\n", short_option); - break; - } - } - - if (test.GetExecutablePath() == NULL) { - // --clang is mandatory - option_data.print_help = true; - option_data.error = true; - fprintf(stderr, "error: the '--clang=PATH' option is mandatory\n"); - } - - if (option_data.print_help) { - puts(R"( -NAME - lldb_perf_clang -- a tool that measures LLDB peformance while debugging clang. - -SYNOPSIS - lldb_perf_clang --clang=PATH [--out-file=PATH --verbose --dsym] -- [clang options] - -DESCRIPTION - Runs a set of static timing and memory tasks against clang and outputs results - to a plist file. -)"); - } - if (option_data.error) { - exit(1); - } - - // Update argc and argv after parsing options - argc -= optind; - argv += optind; - - test.SetVerbose(true); - TestCase::Run(test, argc, argv); - return 0; -} diff --git a/lldb/tools/lldb-perf/common/clang/main.cpp b/lldb/tools/lldb-perf/common/clang/main.cpp deleted file mode 100644 index 318a26b2c2810..0000000000000 --- a/lldb/tools/lldb-perf/common/clang/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -namespace { -struct Foo { - int i; - int j; -}; -void doit(const Foo &foo) { printf("doit(%i)\n", foo.i); } -} -int main(int argc, char const *argv[], char const *envp[]) { - std::vector ints; - for (int i = 0; i < 10; ++i) - ints.push_back(i); - printf("hello world\n"); - Foo foo = {12, 13}; - doit(foo); - return 0; -} diff --git a/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp b/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp deleted file mode 100644 index 0df8bdc9fdca6..0000000000000 --- a/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp +++ /dev/null @@ -1,287 +0,0 @@ -#include - -#include "lldb-perf/lib/Measurement.h" -#include "lldb-perf/lib/Metric.h" -#include "lldb-perf/lib/TestCase.h" -#include "lldb-perf/lib/Timer.h" -#include "lldb-perf/lib/Xcode.h" - -#include -#include -#include - -using namespace lldb_perf; - -class StepTest : public TestCase { - typedef void (*no_function)(void); - -public: - StepTest(bool use_single_stepping = false) - : m_main_source("stepping-testcase.cpp"), - m_use_single_stepping(use_single_stepping), - m_time_measurements(nullptr) {} - - virtual ~StepTest() {} - - virtual bool Setup(int &argc, const char **&argv) { - TestCase::Setup(argc, argv); - - // Toggle the fast stepping command on or off as required. - const char *single_step_cmd = "settings set target.use-fast-stepping false"; - const char *fast_step_cmd = "settings set target.use-fast-stepping true"; - const char *cmd_to_use; - - if (m_use_single_stepping) - cmd_to_use = single_step_cmd; - else - cmd_to_use = fast_step_cmd; - - SBCommandReturnObject return_object; - m_debugger.GetCommandInterpreter().HandleCommand(cmd_to_use, return_object); - if (!return_object.Succeeded()) { - if (return_object.GetError() != NULL) - printf("Got an error running settings set: %s.\n", - return_object.GetError()); - else - printf("Failed running settings set, no error.\n"); - } - - m_target = m_debugger.CreateTarget(m_app_path.c_str()); - m_first_bp = m_target.BreakpointCreateBySourceRegex( - "Here is some code to stop at originally.", m_main_source); - - const char *file_arg = m_app_path.c_str(); - const char *empty = nullptr; - const char *args[] = {file_arg, empty}; - SBLaunchInfo launch_info(args); - - return Launch(launch_info); - } - - void WriteResults(Results &results) { - // Gotta turn off the last timer now. - m_individual_step_times.push_back(m_time_measurements.Stop()); - - size_t num_time_measurements = m_individual_step_times.size(); - - Results::Dictionary &results_dict = results.GetDictionary(); - const char *short_format_string = "step-time-%0.2d"; - const size_t short_size = strlen(short_format_string) + 5; - char short_buffer[short_size]; - const char *long_format_string = - "The time it takes for step %d in the step sequence."; - const size_t long_size = strlen(long_format_string) + 5; - char long_buffer[long_size]; - - for (size_t i = 0; i < num_time_measurements; i++) { - snprintf(short_buffer, short_size, short_format_string, i); - snprintf(long_buffer, long_size, long_format_string, i); - - results_dict.AddDouble(short_buffer, long_buffer, - m_individual_step_times[i]); - } - results_dict.AddDouble("total-time", "Total time spent stepping.", - m_time_measurements.GetMetric().GetSum()); - results_dict.AddDouble( - "stddev-time", "StdDev of time spent stepping.", - m_time_measurements.GetMetric().GetStandardDeviation()); - - results.Write(m_out_path.c_str()); - } - - const char *GetExecutablePath() const { - if (m_app_path.empty()) - return NULL; - return m_app_path.c_str(); - } - - const char *GetResultFilePath() const { - if (m_out_path.empty()) - return NULL; - return m_out_path.c_str(); - } - - void SetExecutablePath(const char *path) { - if (path && path[0]) - m_app_path = path; - else - m_app_path.clear(); - } - - void SetResultFilePath(const char *path) { - if (path && path[0]) - m_out_path = path; - else - m_out_path.clear(); - } - - void SetUseSingleStep(bool use_it) { m_use_single_stepping = use_it; } - -private: - virtual void TestStep(int counter, ActionWanted &next_action) { - if (counter > 0) { - m_individual_step_times.push_back(m_time_measurements.Stop()); - } - - // Disable the breakpoint, just in case it gets multiple locations we don't - // want that confusing the stepping. - if (counter == 0) - m_first_bp.SetEnabled(false); - - next_action.StepOver(m_process.GetThreadAtIndex(0)); - m_time_measurements.Start(); - } - - SBBreakpoint m_first_bp; - SBFileSpec m_main_source; - TimeMeasurement m_time_measurements; - std::vector m_individual_step_times; - bool m_use_single_stepping; - std::string m_app_path; - std::string m_out_path; -}; - -struct Options { - std::string test_file_path; - std::string out_file; - bool verbose; - bool fast_step; - bool error; - bool print_help; - - Options() - : verbose(false), fast_step(true), error(false), print_help(false) {} -}; - -static struct option g_long_options[] = { - {"verbose", no_argument, NULL, 'v'}, - {"single-step", no_argument, NULL, 's'}, - {"test-file", required_argument, NULL, 't'}, - {"out-file", required_argument, NULL, 'o'}, - {NULL, 0, NULL, 0}}; - -std::string GetShortOptionString(struct option *long_options) { - std::string option_string; - for (int i = 0; long_options[i].name != NULL; ++i) { - if (long_options[i].flag == NULL) { - option_string.push_back((char)long_options[i].val); - switch (long_options[i].has_arg) { - default: - case no_argument: - break; - case required_argument: - option_string.push_back(':'); - break; - case optional_argument: - option_string.append(2, ':'); - break; - } - } - } - return option_string; -} - -int main(int argc, const char *argv[]) { - - // Prepare for & make calls to getopt_long_only. - - std::string short_option_string(GetShortOptionString(g_long_options)); - - StepTest test; - - Options option_data; - bool done = false; - -#if __GLIBC__ - optind = 0; -#else - optreset = 1; - optind = 1; -#endif - while (!done) { - int long_options_index = -1; - const int short_option = ::getopt_long_only( - argc, const_cast(argv), short_option_string.c_str(), - g_long_options, &long_options_index); - - switch (short_option) { - case 0: - // Already handled - break; - - case -1: - done = true; - break; - - case '?': - option_data.print_help = true; - break; - - case 'h': - option_data.print_help = true; - break; - - case 'v': - option_data.verbose = true; - break; - - case 's': - option_data.fast_step = false; - test.SetUseSingleStep(true); - break; - - case 't': { - SBFileSpec file(optarg); - if (file.Exists()) - test.SetExecutablePath(optarg); - else - fprintf(stderr, "error: file specified in --test-file (-t) option " - "doesn't exist: '%s'\n", - optarg); - } break; - - case 'o': - test.SetResultFilePath(optarg); - break; - - default: - option_data.error = true; - option_data.print_help = true; - fprintf(stderr, "error: unrecognized option %c\n", short_option); - break; - } - } - - if (option_data.print_help) { - puts(R"( -NAME - lldb-perf-stepping -- a tool that measures LLDB peformance of simple stepping operations. - -SYNOPSIS - lldb-perf-stepping --test-file=FILE [--out-file=PATH --verbose --fast-step] - -DESCRIPTION - Runs a set of stepping operations, timing each step and outputs results - to a plist file. -)"); - exit(0); - } - if (option_data.error) { - exit(1); - } - - if (test.GetExecutablePath() == NULL) { - // --clang is mandatory - option_data.print_help = true; - option_data.error = true; - fprintf(stderr, "error: the '--test-file=PATH' option is mandatory\n"); - } - - // Update argc and argv after parsing options - argc -= optind; - argv += optind; - - test.SetVerbose(true); - TestCase::Run(test, argc, argv); - return 0; -} diff --git a/lldb/tools/lldb-perf/common/stepping/stepping-testcase.cpp b/lldb/tools/lldb-perf/common/stepping/stepping-testcase.cpp deleted file mode 100644 index 50f0164a217bb..0000000000000 --- a/lldb/tools/lldb-perf/common/stepping/stepping-testcase.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -struct struct_for_copying { - struct_for_copying(int in_int, double in_double, const char *in_string) - : int_value(in_int), double_value(in_double), string_value(in_string) {} - struct_for_copying() { struct_for_copying(0, 0, ""); } - - int int_value; - double double_value; - std::string string_value; -}; - -int main(int argc, char **argv) { - struct_for_copying input_struct(150 * argc, 10.0 * argc, argv[0]); - struct_for_copying output_struct; - int some_int = 44; - double some_double = 34.5; - double other_double; - size_t vector_size; - std::vector my_vector; - - printf("Here is some code to stop at originally. Got: %d, %p.\n", argc, - argv); - output_struct = input_struct; - other_double = (some_double * some_int) / ((double)argc); - other_double = other_double > 0 - ? some_double / other_double - : some_double > 0 ? other_double / some_double : 10.0; - my_vector.push_back(input_struct); - vector_size = my_vector.size(); - - return vector_size == 0 ? 0 : 1; -} diff --git a/lldb/tools/lldb-perf/darwin/formatters/fmts_tester.mm b/lldb/tools/lldb-perf/darwin/formatters/fmts_tester.mm deleted file mode 100644 index b5f8bc0aaecf1..0000000000000 --- a/lldb/tools/lldb-perf/darwin/formatters/fmts_tester.mm +++ /dev/null @@ -1,81 +0,0 @@ -//===-- fmts_tester.cpp -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#import -#include -#include -#include -#include - -int main() { - NSArray *nsarray = @[ @1, @2, @"hello world", @3, @4, @"foobar" ]; - NSMutableArray *nsmutablearray = [[NSMutableArray alloc] initWithCapacity:5]; - [nsmutablearray addObject:@1]; - [nsmutablearray addObject:@2]; - [nsmutablearray addObject:@"hello world"]; - [nsmutablearray addObject:@3]; - [nsmutablearray addObject:@4]; - [nsmutablearray addObject:@"foobar"]; - NSDictionary *nsdictionary = - @{ @1 : @1, - @2 : @2, - @"hello" : @"world", - @3 : @3 }; - NSMutableDictionary *nsmutabledictionary = - [[NSMutableDictionary alloc] initWithCapacity:5]; - [nsmutabledictionary setObject:@1 forKey:@1]; - [nsmutabledictionary setObject:@2 forKey:@2]; - [nsmutabledictionary setObject:@"hello" forKey:@"world"]; - [nsmutabledictionary setObject:@3 forKey:@3]; - NSString *str0 = @"Hello world"; - NSString *str1 = @"Hello ℥"; - NSString *str2 = @"Hello world"; - NSString *str3 = @"Hello ℥"; - NSString *str4 = @"Hello world"; - NSDate *me = [NSDate dateWithNaturalLanguageString:@"April 10, 1985"]; - NSDate *cutie = [NSDate dateWithNaturalLanguageString:@"January 29, 1983"]; - NSDate *mom = [NSDate dateWithNaturalLanguageString:@"May 24, 1959"]; - NSDate *dad = [NSDate dateWithNaturalLanguageString:@"October 29, 1954"]; - NSDate *today = [NSDate dateWithNaturalLanguageString:@"March 14, 2013"]; - NSArray *bundles = [NSBundle allBundles]; - NSArray *frameworks = [NSBundle allFrameworks]; - NSSet *nsset = [NSSet setWithArray:nsarray]; - NSMutableSet *nsmutableset = [NSMutableSet setWithCapacity:5]; - [nsmutableset addObject:@1]; - [nsmutableset addObject:@2]; - [nsmutableset addObject:@"hello world"]; - [nsmutableset addObject:@3]; - [nsmutableset addObject:@4]; - [nsmutableset addObject:@"foobar"]; - std::vector vector; - vector.push_back(1); - vector.push_back(2); - vector.push_back(3); - vector.push_back(4); - vector.push_back(5); - std::list list; - list.push_back(1); - list.push_back(2); - list.push_back(3); - list.push_back(4); - list.push_back(5); - std::map map; - map[1] = 1; - map[2] = 2; - map[3] = 3; - map[4] = 4; - map[5] = 5; - std::string sstr0("Hello world"); - std::string sstr1("Hello world"); - std::string sstr2("Hello world"); - std::string sstr3("Hello world"); - std::string sstr4("Hello world"); - int x = 0; - for (;;) - x++; -} \ No newline at end of file diff --git a/lldb/tools/lldb-perf/darwin/formatters/formatters.cpp b/lldb/tools/lldb-perf/darwin/formatters/formatters.cpp deleted file mode 100644 index 822102aa7bb04..0000000000000 --- a/lldb/tools/lldb-perf/darwin/formatters/formatters.cpp +++ /dev/null @@ -1,267 +0,0 @@ -//===-- formatters.cpp ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include "lldb-perf/lib/Measurement.h" -#include "lldb-perf/lib/Metric.h" -#include "lldb-perf/lib/TestCase.h" -#include "lldb-perf/lib/Timer.h" -#include "lldb-perf/lib/Xcode.h" - -#include -#include -#include - -using namespace lldb_perf; - -class FormattersTest : public TestCase { -public: - FormattersTest() : TestCase() { - m_dump_std_vector_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "std-vector", "time to dump an std::vector"); - m_dump_std_list_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "std-list", "time to dump an std::list"); - m_dump_std_map_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "std-map", "time to dump an std::map"); - - // use this in manual mode - m_dump_std_string_measurement = CreateTimeMeasurement( - []() -> void {}, "std-string", "time to dump an std::string"); - - m_dump_nsstring_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 0, false); - }, - "ns-string", "time to dump an NSString"); - - m_dump_nsarray_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "ns-array", "time to dump an NSArray"); - - m_dump_nsdictionary_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "ns-dictionary", "time to dump an NSDictionary"); - - m_dump_nsset_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "ns-set", "time to dump an NSSet"); - - m_dump_nsbundle_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 1, false); - }, - "ns-bundle", "time to dump an NSBundle"); - - m_dump_nsdate_measurement = CreateTimeMeasurement( - [](SBValue value) -> void { - lldb_perf::Xcode::FetchVariable(value, 0, false); - }, - "ns-date", "time to dump an NSDate"); - } - - virtual ~FormattersTest() {} - - virtual bool Setup(int &argc, const char **&argv) { - m_app_path.assign(argv[1]); - m_out_path.assign(argv[2]); - m_target = m_debugger.CreateTarget(m_app_path.c_str()); - m_target.BreakpointCreateByName("main"); - SBLaunchInfo launch_info(argv); - return Launch(launch_info); - } - - void DoTest() { - SBFrame frame_zero(m_thread.GetFrameAtIndex(0)); - - m_dump_nsarray_measurement( - frame_zero.FindVariable("nsarray", lldb::eDynamicCanRunTarget)); - m_dump_nsarray_measurement( - frame_zero.FindVariable("nsmutablearray", lldb::eDynamicCanRunTarget)); - - m_dump_nsdictionary_measurement( - frame_zero.FindVariable("nsdictionary", lldb::eDynamicCanRunTarget)); - m_dump_nsdictionary_measurement(frame_zero.FindVariable( - "nsmutabledictionary", lldb::eDynamicCanRunTarget)); - - m_dump_nsstring_measurement( - frame_zero.FindVariable("str0", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement( - frame_zero.FindVariable("str1", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement( - frame_zero.FindVariable("str2", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement( - frame_zero.FindVariable("str3", lldb::eDynamicCanRunTarget)); - m_dump_nsstring_measurement( - frame_zero.FindVariable("str4", lldb::eDynamicCanRunTarget)); - - m_dump_nsdate_measurement( - frame_zero.FindVariable("me", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement( - frame_zero.FindVariable("cutie", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement( - frame_zero.FindVariable("mom", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement( - frame_zero.FindVariable("dad", lldb::eDynamicCanRunTarget)); - m_dump_nsdate_measurement( - frame_zero.FindVariable("today", lldb::eDynamicCanRunTarget)); - - m_dump_nsbundle_measurement( - frame_zero.FindVariable("bundles", lldb::eDynamicCanRunTarget)); - m_dump_nsbundle_measurement( - frame_zero.FindVariable("frameworks", lldb::eDynamicCanRunTarget)); - - m_dump_nsset_measurement( - frame_zero.FindVariable("nsset", lldb::eDynamicCanRunTarget)); - m_dump_nsset_measurement( - frame_zero.FindVariable("nsmutableset", lldb::eDynamicCanRunTarget)); - - m_dump_std_vector_measurement( - frame_zero.FindVariable("vector", lldb::eDynamicCanRunTarget)); - m_dump_std_list_measurement( - frame_zero.FindVariable("list", lldb::eDynamicCanRunTarget)); - m_dump_std_map_measurement( - frame_zero.FindVariable("map", lldb::eDynamicCanRunTarget)); - - auto sstr0 = frame_zero.FindVariable("sstr0", lldb::eDynamicCanRunTarget); - auto sstr1 = frame_zero.FindVariable("sstr1", lldb::eDynamicCanRunTarget); - auto sstr2 = frame_zero.FindVariable("sstr2", lldb::eDynamicCanRunTarget); - auto sstr3 = frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget); - auto sstr4 = frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget); - - m_dump_std_string_measurement.Start(); - Xcode::FetchVariable(sstr0, 0, false); - m_dump_std_string_measurement.Stop(); - - m_dump_std_string_measurement.Start(); - Xcode::FetchVariable(sstr1, 0, false); - m_dump_std_string_measurement.Stop(); - - m_dump_std_string_measurement.Start(); - Xcode::FetchVariable(sstr2, 0, false); - m_dump_std_string_measurement.Stop(); - - m_dump_std_string_measurement.Start(); - Xcode::FetchVariable(sstr3, 0, false); - m_dump_std_string_measurement.Stop(); - - m_dump_std_string_measurement.Start(); - Xcode::FetchVariable(sstr4, 0, false); - m_dump_std_string_measurement.Stop(); - } - - virtual void TestStep(int counter, ActionWanted &next_action) { - switch (counter) { - case 0: - m_target.BreakpointCreateByLocation("fmts_tester.mm", 78); - next_action.Continue(); - break; - case 1: - DoTest(); - next_action.Continue(); - break; - case 2: - DoTest(); - next_action.Continue(); - break; - case 3: - DoTest(); - next_action.Continue(); - break; - case 4: - DoTest(); - next_action.Continue(); - break; - case 5: - DoTest(); - next_action.Continue(); - break; - case 6: - DoTest(); - next_action.Continue(); - break; - case 7: - DoTest(); - next_action.Continue(); - break; - case 8: - DoTest(); - next_action.Continue(); - break; - case 9: - DoTest(); - next_action.Continue(); - break; - case 10: - DoTest(); - next_action.Continue(); - break; - default: - next_action.Kill(); - break; - } - } - - virtual void WriteResults(Results &results) { - m_dump_std_vector_measurement.WriteAverageAndStandardDeviation(results); - m_dump_std_list_measurement.WriteAverageAndStandardDeviation(results); - m_dump_std_map_measurement.WriteAverageAndStandardDeviation(results); - m_dump_std_string_measurement.WriteAverageAndStandardDeviation(results); - - m_dump_nsstring_measurement.WriteAverageAndStandardDeviation(results); - m_dump_nsarray_measurement.WriteAverageAndStandardDeviation(results); - m_dump_nsdictionary_measurement.WriteAverageAndStandardDeviation(results); - m_dump_nsset_measurement.WriteAverageAndStandardDeviation(results); - m_dump_nsbundle_measurement.WriteAverageAndStandardDeviation(results); - m_dump_nsdate_measurement.WriteAverageAndStandardDeviation(results); - results.Write(m_out_path.c_str()); - } - -private: - // C++ formatters - TimeMeasurement> m_dump_std_vector_measurement; - TimeMeasurement> m_dump_std_list_measurement; - TimeMeasurement> m_dump_std_map_measurement; - TimeMeasurement> m_dump_std_string_measurement; - - // Cocoa formatters - TimeMeasurement> m_dump_nsstring_measurement; - TimeMeasurement> m_dump_nsarray_measurement; - TimeMeasurement> m_dump_nsdictionary_measurement; - TimeMeasurement> m_dump_nsset_measurement; - TimeMeasurement> m_dump_nsbundle_measurement; - TimeMeasurement> m_dump_nsdate_measurement; - - // useful files - std::string m_app_path; - std::string m_out_path; -}; - -// argv[1] == path to app -// argv[2] == path to result -int main(int argc, const char *argv[]) { - FormattersTest frmtest; - frmtest.SetVerbose(true); - TestCase::Run(frmtest, argc, argv); - return 0; -} diff --git a/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp b/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp deleted file mode 100644 index 08352a97930b1..0000000000000 --- a/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp +++ /dev/null @@ -1,329 +0,0 @@ -//===-- sketch.cpp ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include "lldb-perf/lib/Measurement.h" -#include "lldb-perf/lib/Metric.h" -#include "lldb-perf/lib/TestCase.h" -#include "lldb-perf/lib/Timer.h" -#include "lldb-perf/lib/Xcode.h" - -#include -#include -#include -#include - -using namespace lldb_perf; - -static struct option g_long_options[] = { - {"verbose", no_argument, NULL, 'v'}, - {"sketch", required_argument, NULL, 'c'}, - {"foobar", required_argument, NULL, 'f'}, - {"out-file", required_argument, NULL, 'o'}, - {NULL, 0, NULL, 0}}; - -class SketchTest : public TestCase { -public: - SketchTest() - : m_fetch_frames_measurement( - [this]() -> void { - Xcode::FetchFrames(GetProcess(), false, false); - }, - "fetch-frames", - "time to dump backtrace for every frame in every thread"), - m_file_line_bp_measurement( - [this](const char *file, uint32_t line) -> void { - Xcode::CreateFileLineBreakpoint(GetTarget(), file, line); - }, - "file-line-bkpt", "time to set a breakpoint given a file and line"), - m_fetch_modules_measurement( - [this]() -> void { Xcode::FetchModules(GetTarget()); }, - "fetch-modules", "time to get info for all modules in the process"), - m_fetch_vars_measurement( - [this](int depth) -> void { - SBProcess process(GetProcess()); - auto threads_count = process.GetNumThreads(); - for (size_t thread_num = 0; thread_num < threads_count; - thread_num++) { - SBThread thread(process.GetThreadAtIndex(thread_num)); - SBFrame frame(thread.GetFrameAtIndex(0)); - Xcode::FetchVariables(frame, depth, GetVerbose()); - } - }, - "fetch-vars", - "time to dump variables for the topmost frame in every thread"), - m_run_expr_measurement( - [this](SBFrame frame, const char *expr) -> void { - SBValue value( - frame.EvaluateExpression(expr, lldb::eDynamicCanRunTarget)); - Xcode::FetchVariable(value, 0, GetVerbose()); - }, - "run-expr", - "time to evaluate an expression and display the result") { - m_app_path.clear(); - m_out_path.clear(); - m_doc_path.clear(); - m_print_help = false; - } - - virtual ~SketchTest() {} - - virtual bool ParseOption(int short_option, const char *optarg) { - switch (short_option) { - case 0: - return false; - - case -1: - return false; - - case '?': - case 'h': - m_print_help = true; - break; - - case 'v': - SetVerbose(true); - break; - - case 'c': { - SBFileSpec file(optarg); - if (file.Exists()) - SetExecutablePath(optarg); - else - fprintf(stderr, "error: file specified in --sketch (-c) option doesn't " - "exist: '%s'\n", - optarg); - } break; - - case 'f': { - SBFileSpec file(optarg); - if (file.Exists()) - SetDocumentPath(optarg); - else - fprintf(stderr, "error: file specified in --foobar (-f) option doesn't " - "exist: '%s'\n", - optarg); - } break; - - case 'o': - SetResultFilePath(optarg); - break; - - default: - m_print_help = true; - fprintf(stderr, "error: unrecognized option %c\n", short_option); - break; - } - return true; - } - - virtual struct option *GetLongOptions() { return g_long_options; } - - virtual bool Setup(int &argc, const char **&argv) { - TestCase::Setup(argc, argv); - bool error = false; - - if (GetExecutablePath() == NULL) { - // --sketch is mandatory - error = true; - fprintf(stderr, "error: the '--sketch=PATH' option is mandatory\n"); - } - - if (GetDocumentPath() == NULL) { - // --foobar is mandatory - error = true; - fprintf(stderr, "error: the '--foobar=PATH' option is mandatory\n"); - } - - if (error || GetPrintHelp()) { - puts(R"( - NAME - lldb_perf_sketch -- a tool that measures LLDB peformance while debugging sketch. - - SYNOPSIS - lldb_perf_sketch --sketch=PATH --foobar=PATH [--out-file=PATH --verbose] - - DESCRIPTION - Runs a set of static timing and memory tasks against sketch and outputs results - to a plist file. - )"); - } - - if (error) { - exit(1); - } - lldb::SBLaunchInfo launch_info = GetLaunchInfo(); - m_target = m_debugger.CreateTarget(m_app_path.c_str()); - m_file_line_bp_measurement("SKTDocument.m", 245); - m_file_line_bp_measurement("SKTDocument.m", 283); - m_file_line_bp_measurement("SKTText.m", 326); - return Launch(launch_info); - } - - lldb::SBLaunchInfo GetLaunchInfo() { - const char *file_arg = m_doc_path.c_str(); - const char *persist_arg = "-ApplePersistenceIgnoreState"; - const char *persist_skip = "YES"; - const char *empty = nullptr; - const char *args[] = {file_arg, persist_arg, persist_skip, empty}; - return SBLaunchInfo(args); - } - - void DoTest() { - m_fetch_frames_measurement(); - m_fetch_modules_measurement(); - m_fetch_vars_measurement(1); - } - - virtual void TestStep(int counter, ActionWanted &next_action) { - static int launch = 1; - switch (counter % 10) { - case 0: { - DoTest(); - if (counter == 0) - m_file_line_bp_measurement("SKTDocument.m", 254); - next_action.Continue(); - } break; - - case 1: { - DoTest(); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "properties"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), - "[properties description]"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "typeName"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "data"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "[data description]"); - next_action.Continue(); - } break; - - case 2: { - DoTest(); - next_action.Continue(); - } break; - - case 3: { - DoTest(); - next_action.StepOver(m_thread); - } break; - - case 4: { - DoTest(); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "layoutManager"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "contents"); - next_action.StepOver(m_thread); - } break; - - case 5: { - DoTest(); - next_action.StepOver(m_thread); - } break; - - case 6: { - DoTest(); - next_action.StepOver(m_thread); - } break; - - case 7: { - DoTest(); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "@\"an NSString\""); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), - "[(id)@\"an NSString\" description]"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), "@[@1,@2,@3]"); - next_action.StepOut(m_thread); - } break; - - case 8: { - DoTest(); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), - "[graphics description]"); - m_run_expr_measurement(m_thread.GetFrameAtIndex(0), - "[selectionIndexes description]"); - m_run_expr_measurement( - m_thread.GetFrameAtIndex(0), - "(BOOL)NSIntersectsRect(rect, graphicDrawingBounds)"); - } - next_action.CallNext(); - break; - case 9: - if (++launch < 10) - next_action.Relaunch(GetLaunchInfo()); - else - next_action.Kill(); - break; - - default: { next_action.Kill(); } break; - } - } - - virtual void WriteResults(Results &results) { - m_fetch_frames_measurement.WriteAverageAndStandardDeviation(results); - m_file_line_bp_measurement.WriteAverageAndStandardDeviation(results); - m_fetch_modules_measurement.WriteAverageAndStandardDeviation(results); - m_fetch_vars_measurement.WriteAverageAndStandardDeviation(results); - m_run_expr_measurement.WriteAverageAndStandardDeviation(results); - results.Write(GetResultFilePath()); - } - - void SetExecutablePath(const char *str) { - if (str) - m_app_path.assign(str); - } - - const char *GetExecutablePath() { - if (m_app_path.empty()) - return NULL; - return m_app_path.c_str(); - } - - void SetDocumentPath(const char *str) { - if (str) - m_doc_path.assign(str); - } - - const char *GetDocumentPath() { - if (m_doc_path.empty()) - return NULL; - return m_doc_path.c_str(); - } - - void SetResultFilePath(const char *str) { - if (str) - m_out_path.assign(str); - } - - const char *GetResultFilePath() { - if (m_out_path.empty()) - return "/dev/stdout"; - return m_out_path.c_str(); - } - - bool GetPrintHelp() { return m_print_help; } - -private: - Measurement> - m_fetch_frames_measurement; - Measurement> - m_file_line_bp_measurement; - Measurement> - m_fetch_modules_measurement; - Measurement> - m_fetch_vars_measurement; - Measurement> - m_run_expr_measurement; - - std::string m_app_path; - std::string m_doc_path; - std::string m_out_path; - bool m_print_help; -}; - -int main(int argc, const char *argv[]) { - SketchTest test; - return TestCase::Run(test, argc, argv); -} diff --git a/lldb/tools/lldb-perf/lib/Gauge.cpp b/lldb/tools/lldb-perf/lib/Gauge.cpp deleted file mode 100644 index 42c7934bca58a..0000000000000 --- a/lldb/tools/lldb-perf/lib/Gauge.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===-- Gauge.cpp -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "Gauge.h" -#include "lldb/lldb-forward.h" - -template <> -lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description, - double value) { - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddDouble("value", NULL, value); - return Results::ResultSP(value_dict_up.release()); - } - return Results::ResultSP(new Results::Double(NULL, NULL, value)); -} - -template <> -lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description, - uint64_t value) { - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddUnsigned("value", NULL, value); - return Results::ResultSP(value_dict_up.release()); - } - return Results::ResultSP(new Results::Unsigned(NULL, NULL, value)); -} - -template <> -lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description, - std::string value) { - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddString("value", NULL, value.c_str()); - return Results::ResultSP(value_dict_up.release()); - } - return Results::ResultSP(new Results::String(NULL, NULL, value.c_str())); -} diff --git a/lldb/tools/lldb-perf/lib/Gauge.h b/lldb/tools/lldb-perf/lib/Gauge.h deleted file mode 100644 index 8f2dd0b6bd289..0000000000000 --- a/lldb/tools/lldb-perf/lib/Gauge.h +++ /dev/null @@ -1,50 +0,0 @@ -//===-- Gauge.h -------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef PerfTestDriver_Gauge_h -#define PerfTestDriver_Gauge_h - -#include -#include - -#include "Results.h" - -namespace lldb_perf { - -template class Gauge { -public: - typedef T ValueType; - - Gauge() {} - - virtual ~Gauge() {} - - virtual void Start() = 0; - - virtual ValueType Stop() = 0; - - virtual ValueType GetStartValue() const = 0; - - virtual ValueType GetStopValue() const = 0; - - virtual ValueType GetDeltaValue() const = 0; -}; - -template -Results::ResultSP GetResult(const char *description, T value); - -template <> Results::ResultSP GetResult(const char *description, double value); - -template <> -Results::ResultSP GetResult(const char *description, uint64_t value); - -template <> -Results::ResultSP GetResult(const char *description, std::string value); -} - -#endif diff --git a/lldb/tools/lldb-perf/lib/Measurement.h b/lldb/tools/lldb-perf/lib/Measurement.h deleted file mode 100644 index 42e6a44890741..0000000000000 --- a/lldb/tools/lldb-perf/lib/Measurement.h +++ /dev/null @@ -1,157 +0,0 @@ -//===-- Measurement.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__Measurement__ -#define __PerfTestDriver__Measurement__ - -#include "Gauge.h" -#include "MemoryGauge.h" -#include "Metric.h" -#include "Timer.h" - -namespace lldb_perf { -template class Measurement { -public: - Measurement() : m_gauge(), m_callable(), m_metric() {} - - Measurement(Callable callable, const char *name, const char *desc) - : m_gauge(), m_callable(callable), - m_metric(Metric(name, desc)) {} - - Measurement(const char *name, const char *desc) - : m_gauge(), m_callable(), - m_metric(Metric(name, desc)) {} - - template - Measurement(const Measurement &rhs) - : m_gauge(rhs.GetGauge()), m_callable(rhs.GetCallable()), - m_metric(rhs.GetMetric()) {} - - template void operator()(Args... args) { - m_gauge.Start(); - m_callable(args...); - m_metric.Append(m_gauge.Stop()); - } - - virtual const Callable &GetCallable() const { return m_callable; } - - virtual const GaugeType &GetGauge() const { return m_gauge; } - - virtual const Metric &GetMetric() const { - return m_metric; - } - - void Start() { m_gauge.Start(); } - - typename GaugeType::ValueType Stop() { - auto value = m_gauge.Stop(); - m_metric.Append(value); - return value; - } - - void WriteStartValue(Results &results) { - auto metric = GetMetric(); - results.GetDictionary().Add( - metric.GetName(), metric.GetDescription(), - lldb_perf::GetResult( - NULL, metric.GetStartValue())); - } - - void WriteStopValue(Results &results) { - auto metric = GetMetric(); - results.GetDictionary().Add( - metric.GetName(), metric.GetDescription(), - lldb_perf::GetResult( - NULL, metric.GetStopValue())); - } - - void WriteAverageValue(Results &results) { - auto metric = GetMetric(); - results.GetDictionary().Add( - metric.GetName(), metric.GetDescription(), - lldb_perf::GetResult( - NULL, metric.GetAverage())); - } - - void WriteAverageAndStandardDeviation(Results &results) { - auto metric = GetMetric(); - auto dictionary = - (Results::Dictionary *)results.GetDictionary() - .Add(metric.GetName(), metric.GetDescription(), - lldb_perf::GetResult( - NULL, metric.GetAverage())) - .get(); - if (dictionary) { - dictionary->Add("stddev", NULL, - lldb_perf::GetResult( - NULL, metric.GetStandardDeviation())); - } - } - - void WriteStandardDeviation(Results &results) { - auto metric = GetMetric(); - results.GetDictionary().Add( - metric.GetName(), metric.GetDescription(), - lldb_perf::GetResult( - NULL, metric.GetStandardDeviation())); - } - -protected: - GaugeType m_gauge; - Callable m_callable; - Metric m_metric; -}; - -template -class TimeMeasurement : public Measurement { -public: - TimeMeasurement() : Measurement() {} - - TimeMeasurement(Callable callable, const char *name = NULL, - const char *descr = NULL) - : Measurement(callable, name, descr) {} - - template - TimeMeasurement(const TimeMeasurement &rhs) - : Measurement(rhs) {} - - template - TimeMeasurement(const Measurement &rhs) - : Measurement(rhs) {} - - template void operator()(Args... args) { - Measurement::operator()(args...); - } -}; - -template -class MemoryMeasurement : public Measurement { -public: - MemoryMeasurement() : Measurement() {} - - MemoryMeasurement(Callable callable, const char *name, const char *descr) - : Measurement(callable, name, descr) {} - - MemoryMeasurement(const char *name, const char *descr) - : Measurement(name, descr) {} - - template - MemoryMeasurement(const MemoryMeasurement &rhs) - : Measurement(rhs) {} - - template - MemoryMeasurement(const Measurement &rhs) - : Measurement(rhs) {} - - template void operator()(Args... args) { - Measurement::operator()(args...); - } -}; -} - -#endif /* defined(__PerfTestDriver__Measurement__) */ diff --git a/lldb/tools/lldb-perf/lib/MemoryGauge.cpp b/lldb/tools/lldb-perf/lib/MemoryGauge.cpp deleted file mode 100644 index 59d3936d0e927..0000000000000 --- a/lldb/tools/lldb-perf/lib/MemoryGauge.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//===-- MemoryGauge.cpp -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "MemoryGauge.h" -#include "lldb/lldb-forward.h" -#include -#include -#include -#include -#include - -using namespace lldb_perf; - -MemoryStats::MemoryStats(mach_vm_size_t virtual_size, - mach_vm_size_t resident_size, - mach_vm_size_t max_resident_size) - : m_virtual_size(virtual_size), m_resident_size(resident_size), - m_max_resident_size(max_resident_size) {} - -MemoryStats &MemoryStats::operator+=(const MemoryStats &rhs) { - m_virtual_size += rhs.m_virtual_size; - m_resident_size += rhs.m_resident_size; - m_max_resident_size += rhs.m_max_resident_size; - return *this; -} - -MemoryStats MemoryStats::operator-(const MemoryStats &rhs) { - return MemoryStats(m_virtual_size - rhs.m_virtual_size, - m_resident_size - rhs.m_resident_size, - m_max_resident_size - rhs.m_max_resident_size); -} - -MemoryStats MemoryStats::operator+(const MemoryStats &rhs) { - return MemoryStats(m_virtual_size + rhs.m_virtual_size, - m_resident_size + rhs.m_resident_size, - m_max_resident_size + rhs.m_max_resident_size); -} - -MemoryStats MemoryStats::operator/(size_t n) { - MemoryStats result(*this); - result.m_virtual_size /= n; - result.m_resident_size /= n; - result.m_max_resident_size /= n; - return result; -} - -MemoryStats MemoryStats::operator*(const MemoryStats &rhs) { - return MemoryStats(m_virtual_size * rhs.m_virtual_size, - m_resident_size * rhs.m_resident_size, - m_max_resident_size * rhs.m_max_resident_size); -} - -Results::ResultSP MemoryStats::GetResult(const char *name, - const char *description) const { - std::unique_ptr dict_up( - new Results::Dictionary(name, NULL)); - dict_up->AddUnsigned("resident", NULL, GetResidentSize()); - dict_up->AddUnsigned("max_resident", NULL, GetMaxResidentSize()); - return Results::ResultSP(dict_up.release()); -} - -MemoryGauge::ValueType MemoryGauge::Now() { - task_t task = mach_task_self(); - mach_task_basic_info_data_t taskBasicInfo; - mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT; - auto task_info_ret = task_info(task, MACH_TASK_BASIC_INFO, - (task_info_t)&taskBasicInfo, &count); - if (task_info_ret == KERN_SUCCESS) { - return MemoryStats(taskBasicInfo.virtual_size, taskBasicInfo.resident_size, - taskBasicInfo.resident_size_max); - } - return 0; -} - -MemoryGauge::MemoryGauge() - : m_state(MemoryGauge::State::eNeverUsed), m_start(), m_delta() {} - -void MemoryGauge::Start() { - m_state = MemoryGauge::State::eCounting; - m_start = Now(); -} - -MemoryGauge::ValueType MemoryGauge::Stop() { - m_stop = Now(); - assert(m_state == MemoryGauge::State::eCounting && - "cannot stop a non-started gauge"); - m_state = MemoryGauge::State::eStopped; - m_delta = m_stop - m_start; - return m_delta; -} - -MemoryGauge::ValueType MemoryGauge::GetDeltaValue() const { - assert(m_state == MemoryGauge::State::eStopped && - "gauge must be used before you can evaluate it"); - return m_delta; -} - -template <> -Results::ResultSP lldb_perf::GetResult(const char *description, - MemoryStats value) { - return value.GetResult(NULL, description); -} - -MemoryStats sqrt(const MemoryStats &arg) { - long double virt_size = arg.GetVirtualSize(); - long double resident_size = arg.GetResidentSize(); - long double max_resident_size = arg.GetMaxResidentSize(); - - virt_size = sqrtl(virt_size); - resident_size = sqrtl(resident_size); - max_resident_size = sqrtl(max_resident_size); - - return MemoryStats(virt_size, resident_size, max_resident_size); -} diff --git a/lldb/tools/lldb-perf/lib/MemoryGauge.h b/lldb/tools/lldb-perf/lib/MemoryGauge.h deleted file mode 100644 index 21b1fe13a586d..0000000000000 --- a/lldb/tools/lldb-perf/lib/MemoryGauge.h +++ /dev/null @@ -1,88 +0,0 @@ -//===-- MemoryGauge.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__MemoryGauge__ -#define __PerfTestDriver__MemoryGauge__ - -#include "Gauge.h" -#include "Results.h" - -#include - -namespace lldb_perf { - -class MemoryStats { -public: - MemoryStats(mach_vm_size_t virtual_size = 0, mach_vm_size_t resident_size = 0, - mach_vm_size_t max_resident_size = 0); - - MemoryStats &operator+=(const MemoryStats &rhs); - - MemoryStats operator-(const MemoryStats &rhs); - - MemoryStats operator+(const MemoryStats &rhs); - - MemoryStats operator/(size_t rhs); - - MemoryStats operator*(const MemoryStats &rhs); - - mach_vm_size_t GetVirtualSize() const { return m_virtual_size; } - - mach_vm_size_t GetResidentSize() const { return m_resident_size; } - - mach_vm_size_t GetMaxResidentSize() const { return m_max_resident_size; } - - void SetVirtualSize(mach_vm_size_t vs) { m_virtual_size = vs; } - - void SetResidentSize(mach_vm_size_t rs) { m_resident_size = rs; } - - void SetMaxResidentSize(mach_vm_size_t mrs) { m_max_resident_size = mrs; } - - Results::ResultSP GetResult(const char *name, const char *description) const; - -private: - mach_vm_size_t m_virtual_size; - mach_vm_size_t m_resident_size; - mach_vm_size_t m_max_resident_size; -}; - -class MemoryGauge : public Gauge { -public: - MemoryGauge(); - - virtual ~MemoryGauge() {} - - void Start(); - - ValueType Stop(); - - virtual ValueType GetStartValue() const { return m_start; } - - virtual ValueType GetStopValue() const { return m_stop; } - - virtual ValueType GetDeltaValue() const; - -private: - enum class State { eNeverUsed, eCounting, eStopped }; - - ValueType Now(); - - State m_state; - ValueType m_start; - ValueType m_stop; - ValueType m_delta; -}; - -template <> -Results::ResultSP GetResult(const char *description, MemoryStats value); - -} // namespace lldb_perf - -lldb_perf::MemoryStats sqrt(const lldb_perf::MemoryStats &arg); - -#endif // #ifndef __PerfTestDriver__MemoryGauge__ diff --git a/lldb/tools/lldb-perf/lib/Metric.cpp b/lldb/tools/lldb-perf/lib/Metric.cpp deleted file mode 100644 index 7bc6232fa51df..0000000000000 --- a/lldb/tools/lldb-perf/lib/Metric.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===-- Metric.cpp ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "Metric.h" -#include "MemoryGauge.h" -#include - -using namespace lldb_perf; - -template Metric::Metric() : Metric("") {} - -template -Metric::Metric(const char *n, const char *d) - : m_name(n ? n : ""), m_description(d ? d : ""), m_dataset() {} - -template void Metric::Append(T v) { m_dataset.push_back(v); } - -template size_t Metric::GetCount() const { - return m_dataset.size(); -} - -template T Metric::GetSum() const { - T sum = 0; - for (auto v : m_dataset) - sum += v; - return sum; -} - -template T Metric::GetAverage() const { - return GetSum() / GetCount(); -} - -// Knuth's algorithm for stddev - massive cancellation resistant -template -T Metric::GetStandardDeviation(StandardDeviationMode mode) const { - size_t n = 0; - T mean = 0; - T M2 = 0; - for (auto x : m_dataset) { - n = n + 1; - T delta = x - mean; - mean = mean + delta / n; - M2 = M2 + delta * (x - mean); - } - T variance; - if (mode == StandardDeviationMode::ePopulation || n == 1) - variance = M2 / n; - else - variance = M2 / (n - 1); - return sqrt(variance); -} - -template class lldb_perf::Metric; -template class lldb_perf::Metric; diff --git a/lldb/tools/lldb-perf/lib/Metric.h b/lldb/tools/lldb-perf/lib/Metric.h deleted file mode 100644 index 141edd39f98b1..0000000000000 --- a/lldb/tools/lldb-perf/lib/Metric.h +++ /dev/null @@ -1,57 +0,0 @@ -//===-- Metric.h ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__Metric__ -#define __PerfTestDriver__Metric__ - -#include -#include -#include - -namespace lldb_perf { - -class MemoryStats; - -template class Metric { -public: - enum class StandardDeviationMode { eSample, ePopulation }; - - Metric(); - Metric(const char *, const char * = NULL); - - void Append(ValueType v); - - ValueType GetAverage() const; - - size_t GetCount() const; - - ValueType GetSum() const; - - ValueType GetStandardDeviation( - StandardDeviationMode mode = StandardDeviationMode::ePopulation) const; - - const char *GetName() const { - if (m_name.empty()) - return NULL; - return m_name.c_str(); - } - - const char *GetDescription() const { - if (m_description.empty()) - return NULL; - return m_description.c_str(); - } - -private: - std::string m_name; - std::string m_description; - std::vector m_dataset; -}; -} - -#endif /* defined(__PerfTestDriver__Metric__) */ diff --git a/lldb/tools/lldb-perf/lib/Results.cpp b/lldb/tools/lldb-perf/lib/Results.cpp deleted file mode 100644 index 16df5c42155e0..0000000000000 --- a/lldb/tools/lldb-perf/lib/Results.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//===-- Results.cpp ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "Results.h" -#include - -#ifdef __APPLE__ -#include "CFCMutableArray.h" -#include "CFCMutableDictionary.h" -#include "CFCReleaser.h" -#include "CFCString.h" -#endif - -using namespace lldb_perf; - -static void AddResultToArray(CFCMutableArray &array, Results::Result *result); - -static void AddResultToDictionary(CFCMutableDictionary &parent_dict, - const char *key, Results::Result *result); - -static void AddResultToArray(CFCMutableArray &parent_array, - Results::Result *result) { - switch (result->GetType()) { - case Results::Result::Type::Invalid: - break; - - case Results::Result::Type::Array: { - Results::Array *value = result->GetAsArray(); - CFCMutableArray array; - value->ForEach([&array](const Results::ResultSP &value_sp) -> bool { - AddResultToArray(array, value_sp.get()); - return true; - }); - parent_array.AppendValue(array.get(), true); - } break; - - case Results::Result::Type::Dictionary: { - Results::Dictionary *value = result->GetAsDictionary(); - CFCMutableDictionary dict; - value->ForEach([&dict](const std::string &key, - const Results::ResultSP &value_sp) -> bool { - AddResultToDictionary(dict, key.c_str(), value_sp.get()); - return true; - }); - if (result->GetDescription()) { - dict.AddValueCString(CFSTR("description"), result->GetDescription()); - } - parent_array.AppendValue(dict.get(), true); - } break; - - case Results::Result::Type::Double: { - double d = result->GetAsDouble()->GetValue(); - CFCReleaser cf_number( - ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &d)); - if (cf_number.get()) - parent_array.AppendValue(cf_number.get(), true); - } break; - case Results::Result::Type::String: { - CFCString cfstr(result->GetAsString()->GetValue()); - if (cfstr.get()) - parent_array.AppendValue(cfstr.get(), true); - } break; - - case Results::Result::Type::Unsigned: { - uint64_t uval64 = result->GetAsUnsigned()->GetValue(); - CFCReleaser cf_number( - ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &uval64)); - if (cf_number.get()) - parent_array.AppendValue(cf_number.get(), true); - } break; - - default: - llvm_unreachable("unhandled result"); - } -} - -static void AddResultToDictionary(CFCMutableDictionary &parent_dict, - const char *key, Results::Result *result) { - assert(key && key[0]); - CFCString cf_key(key); - switch (result->GetType()) { - case Results::Result::Type::Invalid: - break; - - case Results::Result::Type::Array: { - Results::Array *value = result->GetAsArray(); - CFCMutableArray array; - value->ForEach([&array](const Results::ResultSP &value_sp) -> bool { - AddResultToArray(array, value_sp.get()); - return true; - }); - parent_dict.AddValue(cf_key.get(), array.get(), true); - } break; - case Results::Result::Type::Dictionary: { - Results::Dictionary *value = result->GetAsDictionary(); - CFCMutableDictionary dict; - value->ForEach([&dict](const std::string &key, - const Results::ResultSP &value_sp) -> bool { - AddResultToDictionary(dict, key.c_str(), value_sp.get()); - return true; - }); - if (result->GetDescription()) { - dict.AddValueCString(CFSTR("description"), result->GetDescription()); - } - parent_dict.AddValue(cf_key.get(), dict.get(), true); - } break; - case Results::Result::Type::Double: { - parent_dict.SetValueDouble(cf_key.get(), result->GetAsDouble()->GetValue(), - true); - } break; - case Results::Result::Type::String: { - parent_dict.SetValueCString(cf_key.get(), result->GetAsString()->GetValue(), - true); - } break; - - case Results::Result::Type::Unsigned: { - parent_dict.SetValueUInt64(cf_key.get(), - result->GetAsUnsigned()->GetValue(), true); - } break; - default: - llvm_unreachable("unhandled result"); - } -} -void Results::Write(const char *out_path) { -#ifdef __APPLE__ - CFCMutableDictionary dict; - - m_results.ForEach( - [&dict](const std::string &key, const ResultSP &value_sp) -> bool { - AddResultToDictionary(dict, key.c_str(), value_sp.get()); - return true; - }); - CFDataRef xmlData = CFPropertyListCreateData( - kCFAllocatorDefault, dict.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL); - - if (out_path == NULL) - out_path = "/dev/stdout"; - - CFURLRef file = CFURLCreateFromFileSystemRepresentation( - NULL, (const UInt8 *)out_path, strlen(out_path), FALSE); - - CFURLWriteDataAndPropertiesToResource(file, xmlData, NULL, NULL); -#endif -} - -Results::ResultSP Results::Dictionary::AddUnsigned(const char *name, - const char *description, - uint64_t value) { - assert(name && name[0]); - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddUnsigned("value", NULL, value); - m_dictionary[std::string(name)] = ResultSP(value_dict_up.release()); - } else - m_dictionary[std::string(name)] = - ResultSP(new Unsigned(name, description, value)); - return m_dictionary[std::string(name)]; -} - -Results::ResultSP Results::Dictionary::AddDouble(const char *name, - const char *description, - double value) { - assert(name && name[0]); - - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddDouble("value", NULL, value); - m_dictionary[std::string(name)] = ResultSP(value_dict_up.release()); - } else - m_dictionary[std::string(name)] = - ResultSP(new Double(name, description, value)); - return m_dictionary[std::string(name)]; -} -Results::ResultSP Results::Dictionary::AddString(const char *name, - const char *description, - const char *value) { - assert(name && name[0]); - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->AddString("value", NULL, value); - m_dictionary[std::string(name)] = ResultSP(value_dict_up.release()); - } else - m_dictionary[std::string(name)] = - ResultSP(new String(name, description, value)); - return m_dictionary[std::string(name)]; -} - -Results::ResultSP Results::Dictionary::Add(const char *name, - const char *description, - const ResultSP &result_sp) { - assert(name && name[0]); - if (description && description[0]) { - std::unique_ptr value_dict_up( - new Results::Dictionary()); - value_dict_up->AddString("description", NULL, description); - value_dict_up->Add("value", NULL, result_sp); - m_dictionary[std::string(name)] = ResultSP(value_dict_up.release()); - } else - m_dictionary[std::string(name)] = result_sp; - return m_dictionary[std::string(name)]; -} - -void Results::Dictionary::ForEach( - const std::function - &callback) { - collection::const_iterator pos, end = m_dictionary.end(); - for (pos = m_dictionary.begin(); pos != end; ++pos) { - if (callback(pos->first.c_str(), pos->second) == false) - return; - } -} - -Results::ResultSP Results::Array::Append(const ResultSP &result_sp) { - m_array.push_back(result_sp); - return result_sp; -} - -void Results::Array::ForEach( - const std::function &callback) { - collection::const_iterator pos, end = m_array.end(); - for (pos = m_array.begin(); pos != end; ++pos) { - if (callback(*pos) == false) - return; - } -} diff --git a/lldb/tools/lldb-perf/lib/Results.h b/lldb/tools/lldb-perf/lib/Results.h deleted file mode 100644 index f5171d541dca8..0000000000000 --- a/lldb/tools/lldb-perf/lib/Results.h +++ /dev/null @@ -1,204 +0,0 @@ -//===-- Results.h -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver_Results_h__ -#define __PerfTestDriver_Results_h__ - -#include "lldb/lldb-forward.h" -#include -#include -#include - -namespace lldb_perf { - -class Results { -public: - class Array; - class Dictionary; - class Double; - class String; - class Unsigned; - - class Result { - public: - enum class Type { Invalid, Array, Dictionary, Double, String, Unsigned }; - - Result(Type type, const char *name, const char *description) - : m_name(), m_description(), m_type(type) { - if (name && name[0]) - m_name = name; - if (description && description[0]) - m_description = description; - } - - virtual ~Result() {} - - virtual void Write(Results &results) = 0; - - Array *GetAsArray() { - if (m_type == Type::Array) - return (Array *)this; - return NULL; - } - Dictionary *GetAsDictionary() { - if (m_type == Type::Dictionary) - return (Dictionary *)this; - return NULL; - } - Double *GetAsDouble() { - if (m_type == Type::Double) - return (Double *)this; - return NULL; - } - - String *GetAsString() { - if (m_type == Type::String) - return (String *)this; - return NULL; - } - Unsigned *GetAsUnsigned() { - if (m_type == Type::Unsigned) - return (Unsigned *)this; - return NULL; - } - - const char *GetName() const { - if (m_name.empty()) - return NULL; - return m_name.c_str(); - } - - const char *GetDescription() const { - if (m_description.empty()) - return NULL; - return m_description.c_str(); - } - - Type GetType() const { return m_type; } - - protected: - std::string m_name; - std::string m_description; - Type m_type; - }; - - typedef std::shared_ptr ResultSP; - - class Array : public Result { - public: - Array(const char *name, const char *description) - : Result(Type::Array, name, description) {} - - virtual ~Array() {} - - ResultSP Append(const ResultSP &result_sp); - - void ForEach(const std::function &callback); - - virtual void Write(Results &results) {} - - protected: - typedef std::vector collection; - collection m_array; - }; - - class Dictionary : public Result { - public: - Dictionary() : Result(Type::Dictionary, NULL, NULL) {} - - Dictionary(const char *name, const char *description) - : Result(Type::Dictionary, name, description) {} - - virtual ~Dictionary() {} - - virtual void Write(Results &results) {} - - void ForEach(const std::function &callback); - - ResultSP Add(const char *name, const char *description, - const ResultSP &result_sp); - - ResultSP AddDouble(const char *name, const char *descriptiorn, - double value); - - ResultSP AddUnsigned(const char *name, const char *description, - uint64_t value); - - ResultSP AddString(const char *name, const char *description, - const char *value); - - protected: - typedef std::map collection; - collection m_dictionary; - }; - - class String : public Result { - public: - String(const char *name, const char *description, const char *value) - : Result(Type::String, name, description), m_string() { - if (value && value[0]) - m_string = value; - } - - virtual ~String() {} - - virtual void Write(Results &results) {} - - const char *GetValue() const { - return m_string.empty() ? NULL : m_string.c_str(); - } - - protected: - std::string m_string; - }; - - class Double : public Result { - public: - Double(const char *name, const char *description, double value) - : Result(Type::Double, name, description), m_double(value) {} - - virtual ~Double() {} - - virtual void Write(Results &results) {} - - double GetValue() const { return m_double; } - - protected: - double m_double; - }; - - class Unsigned : public Result { - public: - Unsigned(const char *name, const char *description, uint64_t value) - : Result(Type::Unsigned, name, description), m_unsigned(value) {} - - virtual ~Unsigned() {} - - virtual void Write(Results &results) {} - - uint64_t GetValue() const { return m_unsigned; } - - protected: - uint64_t m_unsigned; - }; - - Results() : m_results() {} - - ~Results() {} - - Dictionary &GetDictionary() { return m_results; } - - void Write(const char *path); - -protected: - Dictionary m_results; -}; - -} // namespace lldb_perf -#endif // #ifndef __PerfTestDriver_Results_h__ diff --git a/lldb/tools/lldb-perf/lib/TestCase.cpp b/lldb/tools/lldb-perf/lib/TestCase.cpp deleted file mode 100644 index 439d0444adec8..0000000000000 --- a/lldb/tools/lldb-perf/lib/TestCase.cpp +++ /dev/null @@ -1,307 +0,0 @@ -//===-- TestCase.cpp --------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "TestCase.h" -#include "Results.h" -#include "Xcode.h" - -using namespace lldb_perf; - -TestCase::TestCase() - : m_debugger(), m_target(), m_process(), m_thread(), m_listener(), - m_verbose(false), m_step(0) { - SBDebugger::Initialize(); - SBHostOS::ThreadCreated(""); - m_debugger = SBDebugger::Create(false); - m_listener = m_debugger.GetListener(); - m_listener.StartListeningForEventClass( - m_debugger, SBProcess::GetBroadcasterClass(), - SBProcess::eBroadcastBitStateChanged | SBProcess::eBroadcastBitInterrupt); -} - -static std::string GetShortOptionString(struct option *long_options) { - std::string option_string; - for (int i = 0; long_options[i].name != NULL; ++i) { - if (long_options[i].flag == NULL) { - option_string.push_back((char)long_options[i].val); - switch (long_options[i].has_arg) { - default: - case no_argument: - break; - case required_argument: - option_string.push_back(':'); - break; - case optional_argument: - option_string.append(2, ':'); - break; - } - } - } - return option_string; -} - -bool TestCase::Setup(int &argc, const char **&argv) { - bool done = false; - - struct option *long_options = GetLongOptions(); - - if (long_options) { - std::string short_option_string(GetShortOptionString(long_options)); - -#if __GLIBC__ - optind = 0; -#else - optreset = 1; - optind = 1; -#endif - while (!done) { - int long_options_index = -1; - const int short_option = ::getopt_long_only( - argc, const_cast(argv), short_option_string.c_str(), - long_options, &long_options_index); - - switch (short_option) { - case 0: - // Already handled - break; - - case -1: - done = true; - break; - - default: - done = !ParseOption(short_option, optarg); - break; - } - } - argc -= optind; - argv += optind; - } - - return false; -} - -bool TestCase::Launch(lldb::SBLaunchInfo &launch_info) { - lldb::SBError error; - m_process = m_target.Launch(launch_info, error); - if (!error.Success()) - fprintf(stderr, "error: %s\n", error.GetCString()); - if (m_process.IsValid()) - return true; - return false; -} - -bool TestCase::Launch(std::initializer_list args) { - std::vector args_vect(args); - args_vect.push_back(NULL); - lldb::SBLaunchInfo launch_info((const char **)&args_vect[0]); - return Launch(launch_info); -} - -void TestCase::SetVerbose(bool b) { m_verbose = b; } - -bool TestCase::GetVerbose() { return m_verbose; } - -void TestCase::Loop() { - while (true) { - bool call_test_step = false; - if (m_process.IsValid()) { - SBEvent evt; - m_listener.WaitForEvent(UINT32_MAX, evt); - StateType state = SBProcess::GetStateFromEvent(evt); - if (m_verbose) - printf("event = %s\n", SBDebugger::StateAsCString(state)); - if (SBProcess::GetRestartedFromEvent(evt)) { - if (m_verbose) { - const uint32_t num_threads = m_process.GetNumThreads(); - for (auto thread_index = 0; thread_index < num_threads; - thread_index++) { - SBThread thread(m_process.GetThreadAtIndex(thread_index)); - SBFrame frame(thread.GetFrameAtIndex(0)); - SBStream strm; - strm.RedirectToFileHandle(stdout, false); - frame.GetDescription(strm); - } - puts("restarted"); - } - call_test_step = false; - } else { - switch (state) { - case eStateInvalid: - case eStateDetached: - case eStateCrashed: - case eStateUnloaded: - break; - case eStateExited: - return; - case eStateConnected: - case eStateAttaching: - case eStateLaunching: - case eStateRunning: - case eStateStepping: - call_test_step = false; - break; - - case eStateStopped: - case eStateSuspended: { - call_test_step = true; - bool fatal = false; - bool selected_thread = false; - const uint32_t num_threads = m_process.GetNumThreads(); - for (auto thread_index = 0; thread_index < num_threads; - thread_index++) { - SBThread thread(m_process.GetThreadAtIndex(thread_index)); - SBFrame frame(thread.GetFrameAtIndex(0)); - SBStream strm; - strm.RedirectToFileHandle(stdout, false); - frame.GetDescription(strm); - bool select_thread = false; - StopReason stop_reason = thread.GetStopReason(); - if (m_verbose) - printf("tid = 0x%llx pc = 0x%llx ", thread.GetThreadID(), - frame.GetPC()); - switch (stop_reason) { - case eStopReasonNone: - if (m_verbose) - printf("none\n"); - break; - - case eStopReasonTrace: - select_thread = true; - if (m_verbose) - printf("trace\n"); - break; - - case eStopReasonPlanComplete: - select_thread = true; - if (m_verbose) - printf("plan complete\n"); - break; - case eStopReasonThreadExiting: - if (m_verbose) - printf("thread exiting\n"); - break; - case eStopReasonExec: - if (m_verbose) - printf("exec\n"); - break; - case eStopReasonInvalid: - if (m_verbose) - printf("invalid\n"); - break; - case eStopReasonException: - select_thread = true; - if (m_verbose) - printf("exception\n"); - fatal = true; - break; - case eStopReasonBreakpoint: - select_thread = true; - if (m_verbose) - printf("breakpoint id = %lld.%lld\n", - thread.GetStopReasonDataAtIndex(0), - thread.GetStopReasonDataAtIndex(1)); - break; - case eStopReasonWatchpoint: - select_thread = true; - if (m_verbose) - printf("watchpoint id = %lld\n", - thread.GetStopReasonDataAtIndex(0)); - break; - case eStopReasonSignal: - select_thread = true; - if (m_verbose) - printf("signal %d\n", (int)thread.GetStopReasonDataAtIndex(0)); - break; - } - if (select_thread && !selected_thread) { - m_thread = thread; - selected_thread = m_process.SetSelectedThread(thread); - } - } - if (fatal) { - if (m_verbose) - Xcode::RunCommand(m_debugger, "bt all", true); - exit(1); - } - } break; - } - } - } else { - call_test_step = true; - } - - if (call_test_step) { - do_the_call: - if (m_verbose) - printf("RUNNING STEP %d\n", m_step); - ActionWanted action; - TestStep(m_step, action); - m_step++; - SBError err; - switch (action.type) { - case ActionWanted::Type::eNone: - // Just exit and wait for the next event - break; - case ActionWanted::Type::eContinue: - err = m_process.Continue(); - break; - case ActionWanted::Type::eStepOut: - if (action.thread.IsValid() == false) { - if (m_verbose) { - Xcode::RunCommand(m_debugger, "bt all", true); - printf("error: invalid thread for step out on step %d\n", m_step); - } - exit(501); - } - m_process.SetSelectedThread(action.thread); - action.thread.StepOut(); - break; - case ActionWanted::Type::eStepOver: - if (action.thread.IsValid() == false) { - if (m_verbose) { - Xcode::RunCommand(m_debugger, "bt all", true); - printf("error: invalid thread for step over %d\n", m_step); - } - exit(500); - } - m_process.SetSelectedThread(action.thread); - action.thread.StepOver(); - break; - case ActionWanted::Type::eRelaunch: - if (m_process.IsValid()) { - m_process.Kill(); - m_process.Clear(); - } - Launch(action.launch_info); - break; - case ActionWanted::Type::eKill: - if (m_verbose) - printf("kill\n"); - m_process.Kill(); - return; - case ActionWanted::Type::eCallNext: - goto do_the_call; - break; - } - } - } - - if (GetVerbose()) - printf("I am gonna die at step %d\n", m_step); -} - -int TestCase::Run(TestCase &test, int argc, const char **argv) { - if (test.Setup(argc, argv)) { - test.Loop(); - Results results; - test.WriteResults(results); - return RUN_SUCCESS; - } else - return RUN_SETUP_ERROR; -} diff --git a/lldb/tools/lldb-perf/lib/TestCase.h b/lldb/tools/lldb-perf/lib/TestCase.h deleted file mode 100644 index 4ab4bd1c176ad..0000000000000 --- a/lldb/tools/lldb-perf/lib/TestCase.h +++ /dev/null @@ -1,144 +0,0 @@ -//===-- TestCase.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__TestCase__ -#define __PerfTestDriver__TestCase__ - -#include "Measurement.h" -#include "lldb/API/LLDB.h" -#include - -namespace lldb_perf { - -class Results; - -class TestCase { -public: - TestCase(); - - struct ActionWanted { - enum class Type { - eStepOver, - eContinue, - eStepOut, - eRelaunch, - eCallNext, - eNone, - eKill - } type; - lldb::SBThread thread; - lldb::SBLaunchInfo launch_info; - - ActionWanted() : type(Type::eContinue), thread(), launch_info(NULL) {} - - void None() { - type = Type::eNone; - thread = lldb::SBThread(); - } - - void Continue() { - type = Type::eContinue; - thread = lldb::SBThread(); - } - - void StepOver(lldb::SBThread t) { - type = Type::eStepOver; - thread = t; - } - - void StepOut(lldb::SBThread t) { - type = Type::eStepOut; - thread = t; - } - - void Relaunch(lldb::SBLaunchInfo l) { - type = Type::eRelaunch; - thread = lldb::SBThread(); - launch_info = l; - } - - void Kill() { - type = Type::eKill; - thread = lldb::SBThread(); - } - - void CallNext() { - type = Type::eCallNext; - thread = lldb::SBThread(); - } - }; - - virtual ~TestCase() {} - - virtual bool Setup(int &argc, const char **&argv); - - virtual void TestStep(int counter, ActionWanted &next_action) = 0; - - bool Launch(lldb::SBLaunchInfo &launch_info); - - bool Launch(std::initializer_list args = {}); - - void Loop(); - - void SetVerbose(bool); - - bool GetVerbose(); - - virtual void WriteResults(Results &results) = 0; - - template - Measurement CreateMeasurement(A a, const char *name = NULL, - const char *description = NULL) { - return Measurement(a, name, description); - } - - template - TimeMeasurement CreateTimeMeasurement(A a, const char *name = NULL, - const char *description = NULL) { - return TimeMeasurement(a, name, description); - } - - template - MemoryMeasurement CreateMemoryMeasurement(A a, const char *name = NULL, - const char *description = NULL) { - return MemoryMeasurement(a, name, description); - } - - static int Run(TestCase &test, int argc, const char **argv); - - virtual bool ParseOption(int short_option, const char *optarg) { - return false; - } - - virtual struct option *GetLongOptions() { return NULL; } - - lldb::SBDebugger &GetDebugger() { return m_debugger; } - - lldb::SBTarget &GetTarget() { return m_target; } - - lldb::SBProcess &GetProcess() { return m_process; } - - lldb::SBThread &GetThread() { return m_thread; } - - int GetStep() { return m_step; } - - static const int RUN_SUCCESS = 0; - static const int RUN_SETUP_ERROR = 100; - -protected: - lldb::SBDebugger m_debugger; - lldb::SBTarget m_target; - lldb::SBProcess m_process; - lldb::SBThread m_thread; - lldb::SBListener m_listener; - bool m_verbose; - int m_step; -}; -} - -#endif /* defined(__PerfTestDriver__TestCase__) */ diff --git a/lldb/tools/lldb-perf/lib/Timer.cpp b/lldb/tools/lldb-perf/lib/Timer.cpp deleted file mode 100644 index e4f3521786d96..0000000000000 --- a/lldb/tools/lldb-perf/lib/Timer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===-- Timer.cpp -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "Timer.h" -#include - -using namespace lldb_perf; - -TimeGauge::TimeType TimeGauge::Now() { return high_resolution_clock::now(); } - -TimeGauge::TimeGauge() : m_start(), m_state(TimeGauge::State::eNeverUsed) {} - -void TimeGauge::Start() { - m_state = TimeGauge::State::eCounting; - m_start = Now(); -} - -double TimeGauge::Stop() { - m_stop = Now(); - assert(m_state == TimeGauge::State::eCounting && - "cannot stop a non-started clock"); - m_state = TimeGauge::State::eStopped; - m_delta = duration_cast>(m_stop - m_start).count(); - return m_delta; -} - -double TimeGauge::GetStartValue() const { - return (double)m_start.time_since_epoch().count() * - (double)system_clock::period::num / (double)system_clock::period::den; -} - -double TimeGauge::GetStopValue() const { - return (double)m_stop.time_since_epoch().count() * - (double)system_clock::period::num / (double)system_clock::period::den; -} - -double TimeGauge::GetDeltaValue() const { - assert(m_state == TimeGauge::State::eStopped && - "clock must be used before you can evaluate it"); - return m_delta; -} diff --git a/lldb/tools/lldb-perf/lib/Timer.h b/lldb/tools/lldb-perf/lib/Timer.h deleted file mode 100644 index 7159c88a00e32..0000000000000 --- a/lldb/tools/lldb-perf/lib/Timer.h +++ /dev/null @@ -1,48 +0,0 @@ -//===-- Timer.h -------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__Timer__ -#define __PerfTestDriver__Timer__ - -#include "Gauge.h" - -#include - -using namespace std::chrono; - -namespace lldb_perf { -class TimeGauge : public Gauge { -public: - TimeGauge(); - - virtual ~TimeGauge() {} - - void Start(); - - double Stop(); - - virtual double GetStartValue() const; - - virtual double GetStopValue() const; - - virtual double GetDeltaValue() const; - -private: - enum class State { eNeverUsed, eCounting, eStopped }; - - typedef high_resolution_clock::time_point TimeType; - TimeType m_start; - TimeType m_stop; - double m_delta; - State m_state; - - TimeType Now(); -}; -} - -#endif /* defined(__PerfTestDriver__Timer__) */ diff --git a/lldb/tools/lldb-perf/lib/Xcode.cpp b/lldb/tools/lldb-perf/lib/Xcode.cpp deleted file mode 100644 index 58344083214f4..0000000000000 --- a/lldb/tools/lldb-perf/lib/Xcode.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//===-- Xcode.cpp -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "Xcode.h" -#include - -using namespace std; -using namespace lldb_perf; - -void Xcode::FetchVariable(SBValue value, uint32_t expand, bool verbose) { - auto name = value.GetName(); - auto num_value = value.GetValueAsUnsigned(0); - auto summary = value.GetSummary(); - auto in_scope = value.IsInScope(); - auto has_children = value.MightHaveChildren(); - auto type_1 = value.GetType(); - auto type_2 = value.GetType(); - auto type_name_1 = value.GetTypeName(); - auto type_3 = value.GetType(); - auto type_name_2 = value.GetTypeName(); - if (verbose) - printf("%s %s = 0x%llx (%llu) %s\n", value.GetTypeName(), value.GetName(), - num_value, num_value, summary); - if (expand > 0) { - auto count = value.GetNumChildren(); - for (int i = 0; i < count; i++) { - SBValue child(value.GetChildAtIndex(i, lldb::eDynamicCanRunTarget, true)); - FetchVariable(child, expand - 1, verbose); - } - } -} - -void Xcode::FetchModules(SBTarget target, bool verbose) { - auto count = target.GetNumModules(); - for (int i = 0; i < count; i++) { - SBModule module(target.GetModuleAtIndex(i)); - auto fspec = module.GetFileSpec(); - std::string path(1024, 0); - fspec.GetPath(&path[0], 1024); - auto uuid = module.GetUUIDBytes(); - if (verbose) { - printf("%s %s\n", path.c_str(), module.GetUUIDString()); - } - } -} - -void Xcode::FetchVariables(SBFrame frame, uint32_t expand, bool verbose) { - auto values = - frame.GetVariables(true, true, true, false, eDynamicCanRunTarget); - auto count = values.GetSize(); - for (int i = 0; i < count; i++) { - SBValue value(values.GetValueAtIndex(i)); - FetchVariable(value, expand, verbose); - } -} - -void Xcode::FetchFrames(SBProcess process, bool variables, bool verbose) { - auto pCount = process.GetNumThreads(); - for (int p = 0; p < pCount; p++) { - SBThread thread(process.GetThreadAtIndex(p)); - auto tCount = thread.GetNumFrames(); - if (verbose) - printf("%s %d %d {%d}\n", thread.GetQueueName(), tCount, - thread.GetStopReason(), eStopReasonBreakpoint); - for (int t = 0; t < tCount; t++) { - SBFrame frame(thread.GetFrameAtIndex(t)); - auto fp = frame.GetFP(); - SBThread thread_dup = frame.GetThread(); - SBFileSpec filespec(process.GetTarget().GetExecutable()); - std::string path(1024, 0); - filespec.GetPath(&path[0], 1024); - auto state = process.GetState(); - auto pCount_dup = process.GetNumThreads(); - auto byte_size = process.GetAddressByteSize(); - auto pc = frame.GetPC(); - SBSymbolContext context(frame.GetSymbolContext(0x0000006e)); - SBModule module(context.GetModule()); - SBLineEntry entry(context.GetLineEntry()); - SBFileSpec entry_filespec(process.GetTarget().GetExecutable()); - std::string entry_path(1024, 0); - entry_filespec.GetPath(&entry_path[0], 1024); - auto line_1 = entry.GetLine(); - auto line_2 = entry.GetLine(); - auto fname = frame.GetFunctionName(); - if (verbose) - printf("%llu %s %d %d %llu %s %d %s\n", fp, path.c_str(), state, - byte_size, pc, entry_path.c_str(), line_1, fname); - if (variables) - FetchVariables(frame, 0, verbose); - } - } -} - -void Xcode::RunExpression(SBFrame frame, const char *expression, bool po, - bool verbose) { - SBValue value(frame.EvaluateExpression(expression, eDynamicCanRunTarget)); - FetchVariable(value, 0, verbose); - if (po) { - auto descr = value.GetObjectDescription(); - if (descr) - printf("po = %s\n", descr); - } -} - -void Xcode::Next(SBThread thread) { thread.StepOver(); } - -void Xcode::Continue(SBProcess process) { process.Continue(); } - -void Xcode::RunCommand(SBDebugger debugger, const char *cmd, bool verbose) { - SBCommandReturnObject sb_ret; - auto interpreter = debugger.GetCommandInterpreter(); - interpreter.HandleCommand(cmd, sb_ret); - if (verbose) - printf("%s\n%s\n", sb_ret.GetOutput(false), sb_ret.GetError(false)); -} - -SBThread Xcode::GetThreadWithStopReason(SBProcess process, StopReason reason) { - auto threads_count = process.GetNumThreads(); - for (auto thread_num = 0; thread_num < threads_count; thread_num++) { - SBThread thread(process.GetThreadAtIndex(thread_num)); - if (thread.GetStopReason() == reason) { - return thread; - } - } - return SBThread(); -} - -SBBreakpoint Xcode::CreateFileLineBreakpoint(SBTarget target, const char *file, - uint32_t line) { - return target.BreakpointCreateByLocation(file, line); -} diff --git a/lldb/tools/lldb-perf/lib/Xcode.h b/lldb/tools/lldb-perf/lib/Xcode.h deleted file mode 100644 index 618b971de37ff..0000000000000 --- a/lldb/tools/lldb-perf/lib/Xcode.h +++ /dev/null @@ -1,57 +0,0 @@ -//===-- Xcode.h -------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PerfTestDriver__Xcode__ -#define __PerfTestDriver__Xcode__ - -#include "lldb/API/SBBreakpoint.h" -#include "lldb/API/SBCommandInterpreter.h" -#include "lldb/API/SBCommandReturnObject.h" -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBDefines.h" -#include "lldb/API/SBLineEntry.h" -#include "lldb/API/SBModule.h" -#include "lldb/API/SBProcess.h" -#include "lldb/API/SBTarget.h" -#include "lldb/API/SBThread.h" -#include "lldb/API/SBValue.h" - -using namespace lldb; - -namespace lldb_perf { -class Xcode { -public: - static void FetchVariable(SBValue value, uint32_t expand = 0, - bool verbose = false); - - static void FetchModules(SBTarget target, bool verbose = false); - - static void FetchVariables(SBFrame frame, uint32_t expand = 0, - bool verbose = false); - - static void FetchFrames(SBProcess process, bool variables = false, - bool verbose = false); - - static void RunExpression(SBFrame frame, const char *expression, - bool po = false, bool verbose = false); - - static void Next(SBThread thread); - - static void Continue(SBProcess process); - - static void RunCommand(SBDebugger debugger, const char *cmd, - bool verbose = false); - - static SBThread GetThreadWithStopReason(SBProcess process, StopReason reason); - - static SBBreakpoint CreateFileLineBreakpoint(SBTarget target, - const char *file, uint32_t line); -}; -} - -#endif /* defined(__PerfTestDriver__Xcode__) */ diff --git a/lldb/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj b/lldb/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj deleted file mode 100644 index 0750f700b11d5..0000000000000 --- a/lldb/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1224 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXAggregateTarget section */ - 4C1E37E316F7A0A500FF10BB /* All Perf Tests */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 4C1E37E416F7A0A600FF10BB /* Build configuration list for PBXAggregateTarget "All Perf Tests" */; - buildPhases = ( - ); - dependencies = ( - 4CE3706916FB6FCA00BFD501 /* PBXTargetDependency */, - 4CE3706B16FB6FCC00BFD501 /* PBXTargetDependency */, - 4CE3706D16FB6FCF00BFD501 /* PBXTargetDependency */, - 4CE3706F16FB6FD200BFD501 /* PBXTargetDependency */, - ); - name = "All Perf Tests"; - productName = All; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 26B902E51700FA8D00EFDCE2 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C86C5C616F7A37800844407 /* LLDB.framework */; }; - 26B902E61700FAE800EFDCE2 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C86C5C616F7A37800844407 /* LLDB.framework */; }; - 26DBAD6216FA63F0008243D2 /* lldb_perf_clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DBAD4916FA637D008243D2 /* lldb_perf_clang.cpp */; }; - 26DBAD6316FA66DC008243D2 /* liblldbperf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E373916F4035D00FF10BB /* liblldbperf.a */; }; - 26DBAD6516FA66EA008243D2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */; }; - 26DF762916FBCE7100B4CC2E /* Results.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DF762716FBCE7100B4CC2E /* Results.cpp */; }; - 26DF762A16FBCE7100B4CC2E /* Results.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DF762816FBCE7100B4CC2E /* Results.h */; }; - 26DF764316FBF30E00B4CC2E /* Gauge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DF764216FBF30E00B4CC2E /* Gauge.cpp */; }; - 4C1E374E16F407C800FF10BB /* Gauge.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374216F407C800FF10BB /* Gauge.h */; }; - 4C1E374F16F407C800FF10BB /* Measurement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374316F407C800FF10BB /* Measurement.h */; }; - 4C1E375016F407C800FF10BB /* MemoryGauge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E374416F407C800FF10BB /* MemoryGauge.cpp */; }; - 4C1E375116F407C800FF10BB /* MemoryGauge.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374516F407C800FF10BB /* MemoryGauge.h */; }; - 4C1E375216F407C800FF10BB /* Metric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E374616F407C800FF10BB /* Metric.cpp */; }; - 4C1E375316F407C800FF10BB /* Metric.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374716F407C800FF10BB /* Metric.h */; }; - 4C1E375416F407C800FF10BB /* TestCase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E374816F407C800FF10BB /* TestCase.cpp */; }; - 4C1E375516F407C800FF10BB /* TestCase.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374916F407C800FF10BB /* TestCase.h */; }; - 4C1E375616F407C800FF10BB /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E374A16F407C800FF10BB /* Timer.cpp */; }; - 4C1E375716F407C800FF10BB /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374B16F407C800FF10BB /* Timer.h */; }; - 4C1E375816F407C800FF10BB /* Xcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E374C16F407C800FF10BB /* Xcode.cpp */; }; - 4C1E375916F407C800FF10BB /* Xcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E374D16F407C800FF10BB /* Xcode.h */; }; - 4C1E377916F4089E00FF10BB /* sketch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E377816F4089E00FF10BB /* sketch.cpp */; }; - 4C1E377A16F4091700FF10BB /* liblldbperf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E373916F4035D00FF10BB /* liblldbperf.a */; }; - 4C1E378216F40B8900FF10BB /* CFCBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E375B16F4081300FF10BB /* CFCBundle.cpp */; }; - 4C1E378316F40B8C00FF10BB /* CFCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E375D16F4081300FF10BB /* CFCData.cpp */; }; - 4C1E378416F40B8F00FF10BB /* CFCMutableArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E375F16F4081300FF10BB /* CFCMutableArray.cpp */; }; - 4C1E378516F40B9200FF10BB /* CFCMutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E376116F4081300FF10BB /* CFCMutableDictionary.cpp */; }; - 4C1E378616F40B9600FF10BB /* CFCMutableSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E376316F4081300FF10BB /* CFCMutableSet.cpp */; }; - 4C1E378716F40B9C00FF10BB /* CFCReleaser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376516F4081300FF10BB /* CFCReleaser.h */; }; - 4C1E378816F40B9F00FF10BB /* CFCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E376616F4081300FF10BB /* CFCString.cpp */; }; - 4C1E378916F40BA200FF10BB /* CFCString.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376716F4081300FF10BB /* CFCString.h */; }; - 4C1E378A16F40BA600FF10BB /* CoreFoundationCPP.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376816F4081300FF10BB /* CoreFoundationCPP.h */; }; - 4C1E378B16F40BAB00FF10BB /* CFCBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E375C16F4081300FF10BB /* CFCBundle.h */; }; - 4C1E378C16F40BAF00FF10BB /* CFCData.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E375E16F4081300FF10BB /* CFCData.h */; }; - 4C1E378D16F40BB300FF10BB /* CFCMutableArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376016F4081300FF10BB /* CFCMutableArray.h */; }; - 4C1E378E16F40BB700FF10BB /* CFCMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376216F4081300FF10BB /* CFCMutableDictionary.h */; }; - 4C1E378F16F40BBB00FF10BB /* CFCMutableSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1E376416F4081300FF10BB /* CFCMutableSet.h */; }; - 4C1E37C716F79EC300FF10BB /* liblldbperf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E373916F4035D00FF10BB /* liblldbperf.a */; }; - 4C1E37CB16F79EFA00FF10BB /* formatters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E37B416F79E4600FF10BB /* formatters.cpp */; }; - 4C1E37E016F7A05D00FF10BB /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */; }; - 4C1E37E216F7A07300FF10BB /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */; }; - 4C86C5CB16F7C1D300844407 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C86C5C616F7A37800844407 /* LLDB.framework */; }; - 4C86C5CC16F7C1E000844407 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C86C5C616F7A37800844407 /* LLDB.framework */; }; - 4C86C5DA16F7CED300844407 /* fmts_tester.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C1E37B316F79E4600FF10BB /* fmts_tester.mm */; }; - 4CDDF51017011EBB00D95015 /* stepping-testcase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE3708716FB70E100BFD501 /* stepping-testcase.cpp */; }; - 4CE3707316FB701000BFD501 /* lldb-perf-stepping.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE3707216FB701000BFD501 /* lldb-perf-stepping.cpp */; }; - 4CE3707516FB703B00BFD501 /* liblldbperf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E373916F4035D00FF10BB /* liblldbperf.a */; }; - 4CE3707616FB704300BFD501 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 264B3DE816F7E47600D1E7AB /* LLDB.framework */; }; - 4CE3707716FB704B00BFD501 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 264B3DE516F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 26F5C26A10F3D9A4009D5894; - remoteInfo = "lldb-tool"; - }; - 264B3DE716F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 26680207115FD0ED008E1FE4; - remoteInfo = LLDB; - }; - 264B3DE916F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 26579F68126A25920007C5CB; - remoteInfo = "darwin-debug"; - }; - 264B3DEB16F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2689FFCA13353D7A00698AC0; - remoteInfo = "lldb-core"; - }; - 264B3DED16F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 26DC6A101337FE6900FF7998; - remoteInfo = "lldb-platform"; - }; - 264B3DEF16F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EDC6D49914E5C19B001B75F8; - remoteInfo = launcherXPCService; - }; - 264B3DF116F7E47600D1E7AB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EDE274EC14EDCE1F005B0F75; - remoteInfo = launcherRootXPCService; - }; - 26B902D61700F9BD00EFDCE2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 26680206115FD0ED008E1FE4; - remoteInfo = LLDB; - }; - 26B902E21700F9CC00EFDCE2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E373816F4035D00FF10BB; - remoteInfo = lldbperf; - }; - 4C1E379016F40BCD00FF10BB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E373816F4035D00FF10BB; - remoteInfo = lldbperf; - }; - 4C1E37C316F79EB000FF10BB /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E373816F4035D00FF10BB; - remoteInfo = lldbperf; - }; - 4C86C5DB16F7CF1200844407 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C86C5D016F7CC8900844407; - remoteInfo = "format-tester"; - }; - 4CE3706816FB6FCA00BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E376C16F4087A00FF10BB; - remoteInfo = "lldb-perf-sketch"; - }; - 4CE3706A16FB6FCC00BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E37B916F79E9D00FF10BB; - remoteInfo = "lldb-perf-formatters"; - }; - 4CE3706C16FB6FCF00BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 26DBAD5816FA63B1008243D2; - remoteInfo = "lldb-perf-clang"; - }; - 4CE3706E16FB6FD200BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CE3705316FB6FA100BFD501; - remoteInfo = "lldb-perf-step"; - }; - 4CE3708A16FB711200BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CE3707B16FB70AD00BFD501; - remoteInfo = "stepping-testcase"; - }; - 4CE3708C16FB712300BFD501 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C1E373116F4035D00FF10BB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C1E373816F4035D00FF10BB; - remoteInfo = lldbperf; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 26DBAD5716FA63B1008243D2 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 26DBAD4816FA637D008243D2 /* build-clang.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-clang.sh"; sourceTree = ""; }; - 26DBAD4916FA637D008243D2 /* lldb_perf_clang.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = lldb_perf_clang.cpp; sourceTree = ""; }; - 26DBAD5916FA63B1008243D2 /* lldb-perf-clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-perf-clang"; sourceTree = BUILT_PRODUCTS_DIR; }; - 26DF762716FBCE7100B4CC2E /* Results.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Results.cpp; sourceTree = ""; }; - 26DF762816FBCE7100B4CC2E /* Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Results.h; sourceTree = ""; }; - 26DF764216FBF30E00B4CC2E /* Gauge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gauge.cpp; sourceTree = ""; }; - 4C1E373916F4035D00FF10BB /* liblldbperf.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblldbperf.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C1E374216F407C800FF10BB /* Gauge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gauge.h; sourceTree = ""; }; - 4C1E374316F407C800FF10BB /* Measurement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Measurement.h; sourceTree = ""; }; - 4C1E374416F407C800FF10BB /* MemoryGauge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryGauge.cpp; sourceTree = ""; }; - 4C1E374516F407C800FF10BB /* MemoryGauge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryGauge.h; sourceTree = ""; }; - 4C1E374616F407C800FF10BB /* Metric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Metric.cpp; sourceTree = ""; }; - 4C1E374716F407C800FF10BB /* Metric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Metric.h; sourceTree = ""; }; - 4C1E374816F407C800FF10BB /* TestCase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestCase.cpp; sourceTree = ""; }; - 4C1E374916F407C800FF10BB /* TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCase.h; sourceTree = ""; }; - 4C1E374A16F407C800FF10BB /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = ""; }; - 4C1E374B16F407C800FF10BB /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = ""; }; - 4C1E374C16F407C800FF10BB /* Xcode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Xcode.cpp; sourceTree = ""; }; - 4C1E374D16F407C800FF10BB /* Xcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xcode.h; sourceTree = ""; }; - 4C1E375B16F4081300FF10BB /* CFCBundle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCBundle.cpp; sourceTree = ""; }; - 4C1E375C16F4081300FF10BB /* CFCBundle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCBundle.h; sourceTree = ""; }; - 4C1E375D16F4081300FF10BB /* CFCData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCData.cpp; sourceTree = ""; }; - 4C1E375E16F4081300FF10BB /* CFCData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCData.h; sourceTree = ""; }; - 4C1E375F16F4081300FF10BB /* CFCMutableArray.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCMutableArray.cpp; sourceTree = ""; }; - 4C1E376016F4081300FF10BB /* CFCMutableArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCMutableArray.h; sourceTree = ""; }; - 4C1E376116F4081300FF10BB /* CFCMutableDictionary.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCMutableDictionary.cpp; sourceTree = ""; }; - 4C1E376216F4081300FF10BB /* CFCMutableDictionary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCMutableDictionary.h; sourceTree = ""; }; - 4C1E376316F4081300FF10BB /* CFCMutableSet.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCMutableSet.cpp; sourceTree = ""; }; - 4C1E376416F4081300FF10BB /* CFCMutableSet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCMutableSet.h; sourceTree = ""; }; - 4C1E376516F4081300FF10BB /* CFCReleaser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCReleaser.h; sourceTree = ""; }; - 4C1E376616F4081300FF10BB /* CFCString.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CFCString.cpp; sourceTree = ""; }; - 4C1E376716F4081300FF10BB /* CFCString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFCString.h; sourceTree = ""; }; - 4C1E376816F4081300FF10BB /* CoreFoundationCPP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreFoundationCPP.h; sourceTree = ""; }; - 4C1E376D16F4087A00FF10BB /* lldb-perf-sketch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-perf-sketch"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C1E377716F4089E00FF10BB /* foobar.sketch2 */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = foobar.sketch2; sourceTree = ""; }; - 4C1E377816F4089E00FF10BB /* sketch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sketch.cpp; sourceTree = ""; }; - 4C1E37B316F79E4600FF10BB /* fmts_tester.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = fmts_tester.mm; sourceTree = ""; }; - 4C1E37B416F79E4600FF10BB /* formatters.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = formatters.cpp; sourceTree = ""; }; - 4C1E37BA16F79E9D00FF10BB /* lldb-perf-formatters */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-perf-formatters"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; - 4C86C5C316F7A35000844407 /* lldb.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = lldb.xcodeproj; path = ../../lldb.xcodeproj; sourceTree = ""; }; - 4C86C5C616F7A37800844407 /* LLDB.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LLDB.framework; path = build/Debug/LLDB.framework; sourceTree = ""; }; - 4C86C5D116F7CC8900844407 /* format-tester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "format-tester"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CE3705416FB6FA100BFD501 /* lldb-perf-step */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-perf-step"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CE3707216FB701000BFD501 /* lldb-perf-stepping.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-perf-stepping.cpp"; path = "stepping/lldb-perf-stepping.cpp"; sourceTree = ""; }; - 4CE3707C16FB70AD00BFD501 /* stepping-testcase */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "stepping-testcase"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4CE3708716FB70E100BFD501 /* stepping-testcase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "stepping-testcase.cpp"; path = "stepping/stepping-testcase.cpp"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 26DBAD5616FA63B1008243D2 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 26B902E61700FAE800EFDCE2 /* LLDB.framework in Frameworks */, - 26DBAD6516FA66EA008243D2 /* CoreFoundation.framework in Frameworks */, - 26DBAD6316FA66DC008243D2 /* liblldbperf.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E373616F4035D00FF10BB /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E376A16F4087A00FF10BB /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C86C5CC16F7C1E000844407 /* LLDB.framework in Frameworks */, - 4C1E377A16F4091700FF10BB /* liblldbperf.a in Frameworks */, - 4C1E37E016F7A05D00FF10BB /* CoreFoundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E37B716F79E9D00FF10BB /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C86C5CB16F7C1D300844407 /* LLDB.framework in Frameworks */, - 4C1E37E216F7A07300FF10BB /* CoreFoundation.framework in Frameworks */, - 4C1E37C716F79EC300FF10BB /* liblldbperf.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C86C5CE16F7CC8900844407 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4CE3705116FB6FA100BFD501 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 26B902E51700FA8D00EFDCE2 /* LLDB.framework in Frameworks */, - 4CE3707716FB704B00BFD501 /* CoreFoundation.framework in Frameworks */, - 4CE3707616FB704300BFD501 /* LLDB.framework in Frameworks */, - 4CE3707516FB703B00BFD501 /* liblldbperf.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4CE3707916FB70AD00BFD501 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 26DBAD4616FA637D008243D2 /* common */ = { - isa = PBXGroup; - children = ( - 4CE3707416FB701E00BFD501 /* stepping */, - 26DBAD4716FA637D008243D2 /* clang */, - ); - path = common; - sourceTree = ""; - }; - 26DBAD4716FA637D008243D2 /* clang */ = { - isa = PBXGroup; - children = ( - 26DBAD4816FA637D008243D2 /* build-clang.sh */, - 26DBAD4916FA637D008243D2 /* lldb_perf_clang.cpp */, - ); - path = clang; - sourceTree = ""; - }; - 4C1E373016F4035D00FF10BB = { - isa = PBXGroup; - children = ( - 4C86C5C316F7A35000844407 /* lldb.xcodeproj */, - 4C1E37B516F79E6600FF10BB /* Darwin */, - 26DBAD4616FA637D008243D2 /* common */, - 4C1E375A16F4081300FF10BB /* cfcpp */, - 4C1E374116F407C800FF10BB /* lib */, - 4C1E373A16F4035D00FF10BB /* Products */, - 4C1E37DD16F7A03900FF10BB /* Frameworks */, - ); - sourceTree = ""; - }; - 4C1E373A16F4035D00FF10BB /* Products */ = { - isa = PBXGroup; - children = ( - 4C1E373916F4035D00FF10BB /* liblldbperf.a */, - 4C1E376D16F4087A00FF10BB /* lldb-perf-sketch */, - 4C1E37BA16F79E9D00FF10BB /* lldb-perf-formatters */, - 4C86C5D116F7CC8900844407 /* format-tester */, - 26DBAD5916FA63B1008243D2 /* lldb-perf-clang */, - 4CE3705416FB6FA100BFD501 /* lldb-perf-step */, - 4CE3707C16FB70AD00BFD501 /* stepping-testcase */, - ); - name = Products; - sourceTree = ""; - }; - 4C1E374116F407C800FF10BB /* lib */ = { - isa = PBXGroup; - children = ( - 4C1E374216F407C800FF10BB /* Gauge.h */, - 26DF764216FBF30E00B4CC2E /* Gauge.cpp */, - 4C1E374316F407C800FF10BB /* Measurement.h */, - 4C1E374416F407C800FF10BB /* MemoryGauge.cpp */, - 4C1E374516F407C800FF10BB /* MemoryGauge.h */, - 4C1E374616F407C800FF10BB /* Metric.cpp */, - 4C1E374716F407C800FF10BB /* Metric.h */, - 26DF762716FBCE7100B4CC2E /* Results.cpp */, - 26DF762816FBCE7100B4CC2E /* Results.h */, - 4C1E374816F407C800FF10BB /* TestCase.cpp */, - 4C1E374916F407C800FF10BB /* TestCase.h */, - 4C1E374A16F407C800FF10BB /* Timer.cpp */, - 4C1E374B16F407C800FF10BB /* Timer.h */, - 4C1E374C16F407C800FF10BB /* Xcode.cpp */, - 4C1E374D16F407C800FF10BB /* Xcode.h */, - ); - path = lib; - sourceTree = ""; - }; - 4C1E375A16F4081300FF10BB /* cfcpp */ = { - isa = PBXGroup; - children = ( - 4C1E375B16F4081300FF10BB /* CFCBundle.cpp */, - 4C1E375C16F4081300FF10BB /* CFCBundle.h */, - 4C1E375D16F4081300FF10BB /* CFCData.cpp */, - 4C1E375E16F4081300FF10BB /* CFCData.h */, - 4C1E375F16F4081300FF10BB /* CFCMutableArray.cpp */, - 4C1E376016F4081300FF10BB /* CFCMutableArray.h */, - 4C1E376116F4081300FF10BB /* CFCMutableDictionary.cpp */, - 4C1E376216F4081300FF10BB /* CFCMutableDictionary.h */, - 4C1E376316F4081300FF10BB /* CFCMutableSet.cpp */, - 4C1E376416F4081300FF10BB /* CFCMutableSet.h */, - 4C1E376516F4081300FF10BB /* CFCReleaser.h */, - 4C1E376616F4081300FF10BB /* CFCString.cpp */, - 4C1E376716F4081300FF10BB /* CFCString.h */, - 4C1E376816F4081300FF10BB /* CoreFoundationCPP.h */, - ); - name = cfcpp; - path = ../../source/Host/macosx/cfcpp; - sourceTree = ""; - }; - 4C1E377616F4089E00FF10BB /* sketch */ = { - isa = PBXGroup; - children = ( - 4C1E377716F4089E00FF10BB /* foobar.sketch2 */, - 4C1E377816F4089E00FF10BB /* sketch.cpp */, - ); - name = sketch; - path = darwin/sketch; - sourceTree = ""; - }; - 4C1E37B216F79E4600FF10BB /* formatters */ = { - isa = PBXGroup; - children = ( - 4C1E37B316F79E4600FF10BB /* fmts_tester.mm */, - 4C1E37B416F79E4600FF10BB /* formatters.cpp */, - ); - name = formatters; - path = darwin/formatters; - sourceTree = ""; - }; - 4C1E37B516F79E6600FF10BB /* Darwin */ = { - isa = PBXGroup; - children = ( - 4C1E377616F4089E00FF10BB /* sketch */, - 4C1E37B216F79E4600FF10BB /* formatters */, - ); - name = Darwin; - sourceTree = ""; - }; - 4C1E37DD16F7A03900FF10BB /* Frameworks */ = { - isa = PBXGroup; - children = ( - 4C86C5C616F7A37800844407 /* LLDB.framework */, - 4C1E37DB16F7A03900FF10BB /* CoreFoundation.framework */, - ); - name = Frameworks; - path = ../..; - sourceTree = ""; - }; - 4C86C5DE16F7D18F00844407 /* Products */ = { - isa = PBXGroup; - children = ( - 264B3DE616F7E47600D1E7AB /* lldb */, - 264B3DE816F7E47600D1E7AB /* LLDB.framework */, - 264B3DEA16F7E47600D1E7AB /* darwin-debug */, - 264B3DEC16F7E47600D1E7AB /* liblldb-core.a */, - 264B3DEE16F7E47600D1E7AB /* lldb-platform */, - 264B3DF016F7E47600D1E7AB /* com.apple.lldb.launcherXPCService.xpc */, - 264B3DF216F7E47600D1E7AB /* com.apple.lldb.launcherRootXPCService.xpc */, - ); - name = Products; - sourceTree = ""; - }; - 4CE3707416FB701E00BFD501 /* stepping */ = { - isa = PBXGroup; - children = ( - 4CE3708716FB70E100BFD501 /* stepping-testcase.cpp */, - 4CE3707216FB701000BFD501 /* lldb-perf-stepping.cpp */, - ); - name = stepping; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 4C1E373716F4035D00FF10BB /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C1E375716F407C800FF10BB /* Timer.h in Headers */, - 26DF762A16FBCE7100B4CC2E /* Results.h in Headers */, - 4C1E378D16F40BB300FF10BB /* CFCMutableArray.h in Headers */, - 4C1E374E16F407C800FF10BB /* Gauge.h in Headers */, - 4C1E378716F40B9C00FF10BB /* CFCReleaser.h in Headers */, - 4C1E378916F40BA200FF10BB /* CFCString.h in Headers */, - 4C1E375116F407C800FF10BB /* MemoryGauge.h in Headers */, - 4C1E378C16F40BAF00FF10BB /* CFCData.h in Headers */, - 4C1E375516F407C800FF10BB /* TestCase.h in Headers */, - 4C1E375916F407C800FF10BB /* Xcode.h in Headers */, - 4C1E375316F407C800FF10BB /* Metric.h in Headers */, - 4C1E378F16F40BBB00FF10BB /* CFCMutableSet.h in Headers */, - 4C1E378E16F40BB700FF10BB /* CFCMutableDictionary.h in Headers */, - 4C1E378B16F40BAB00FF10BB /* CFCBundle.h in Headers */, - 4C1E378A16F40BA600FF10BB /* CoreFoundationCPP.h in Headers */, - 4C1E374F16F407C800FF10BB /* Measurement.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 26DBAD5816FA63B1008243D2 /* lldb-perf-clang */ = { - isa = PBXNativeTarget; - buildConfigurationList = 26DBAD5F16FA63B1008243D2 /* Build configuration list for PBXNativeTarget "lldb-perf-clang" */; - buildPhases = ( - 26DBAD5516FA63B1008243D2 /* Sources */, - 26DBAD5616FA63B1008243D2 /* Frameworks */, - 26DBAD5716FA63B1008243D2 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - 26B902E31700F9CC00EFDCE2 /* PBXTargetDependency */, - ); - name = "lldb-perf-clang"; - productName = lldb_perf_clang; - productReference = 26DBAD5916FA63B1008243D2 /* lldb-perf-clang */; - productType = "com.apple.product-type.tool"; - }; - 4C1E373816F4035D00FF10BB /* lldbperf */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C1E373D16F4035D00FF10BB /* Build configuration list for PBXNativeTarget "lldbperf" */; - buildPhases = ( - 4C1E373516F4035D00FF10BB /* Sources */, - 4C1E373616F4035D00FF10BB /* Frameworks */, - 4C1E373716F4035D00FF10BB /* Headers */, - ); - buildRules = ( - ); - dependencies = ( - 26B902D71700F9BD00EFDCE2 /* PBXTargetDependency */, - ); - name = lldbperf; - productName = lldbperf; - productReference = 4C1E373916F4035D00FF10BB /* liblldbperf.a */; - productType = "com.apple.product-type.library.static"; - }; - 4C1E376C16F4087A00FF10BB /* lldb-perf-sketch */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C1E377316F4087A00FF10BB /* Build configuration list for PBXNativeTarget "lldb-perf-sketch" */; - buildPhases = ( - 4C1E376916F4087A00FF10BB /* Sources */, - 4C1E376A16F4087A00FF10BB /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 4C1E379116F40BCD00FF10BB /* PBXTargetDependency */, - ); - name = "lldb-perf-sketch"; - productName = "lldb-perf-sketch"; - productReference = 4C1E376D16F4087A00FF10BB /* lldb-perf-sketch */; - productType = "com.apple.product-type.tool"; - }; - 4C1E37B916F79E9D00FF10BB /* lldb-perf-formatters */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C1E37C016F79E9D00FF10BB /* Build configuration list for PBXNativeTarget "lldb-perf-formatters" */; - buildPhases = ( - 4C1E37B616F79E9D00FF10BB /* Sources */, - 4C1E37B716F79E9D00FF10BB /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 4C1E37C416F79EB000FF10BB /* PBXTargetDependency */, - 4C86C5DC16F7CF1200844407 /* PBXTargetDependency */, - ); - name = "lldb-perf-formatters"; - productName = formatters; - productReference = 4C1E37BA16F79E9D00FF10BB /* lldb-perf-formatters */; - productType = "com.apple.product-type.tool"; - }; - 4C86C5D016F7CC8900844407 /* format-tester */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C86C5D716F7CC8900844407 /* Build configuration list for PBXNativeTarget "format-tester" */; - buildPhases = ( - 4C86C5CD16F7CC8900844407 /* Sources */, - 4C86C5CE16F7CC8900844407 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "format-tester"; - productName = "format-tester"; - productReference = 4C86C5D116F7CC8900844407 /* format-tester */; - productType = "com.apple.product-type.tool"; - }; - 4CE3705316FB6FA100BFD501 /* lldb-perf-step */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4CE3706716FB6FA100BFD501 /* Build configuration list for PBXNativeTarget "lldb-perf-step" */; - buildPhases = ( - 4CE3705016FB6FA100BFD501 /* Sources */, - 4CE3705116FB6FA100BFD501 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 4CE3708D16FB712300BFD501 /* PBXTargetDependency */, - 4CE3708B16FB711200BFD501 /* PBXTargetDependency */, - ); - name = "lldb-perf-step"; - productName = "lldb-step-test"; - productReference = 4CE3705416FB6FA100BFD501 /* lldb-perf-step */; - productType = "com.apple.product-type.tool"; - }; - 4CE3707B16FB70AD00BFD501 /* stepping-testcase */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4CE3708216FB70AD00BFD501 /* Build configuration list for PBXNativeTarget "stepping-testcase" */; - buildPhases = ( - 4CE3707816FB70AD00BFD501 /* Sources */, - 4CE3707916FB70AD00BFD501 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "stepping-testcase"; - productName = "stepping-testcase"; - productReference = 4CE3707C16FB70AD00BFD501 /* stepping-testcase */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 4C1E373116F4035D00FF10BB /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0500; - ORGANIZATIONNAME = lldb.llvm.org; - }; - buildConfigurationList = 4C1E373416F4035D00FF10BB /* Build configuration list for PBXProject "lldbperf" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 4C1E373016F4035D00FF10BB; - productRefGroup = 4C1E373A16F4035D00FF10BB /* Products */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 4C86C5DE16F7D18F00844407 /* Products */; - ProjectRef = 4C86C5C316F7A35000844407 /* lldb.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 4C1E373816F4035D00FF10BB /* lldbperf */, - 4C1E376C16F4087A00FF10BB /* lldb-perf-sketch */, - 4C1E37B916F79E9D00FF10BB /* lldb-perf-formatters */, - 26DBAD5816FA63B1008243D2 /* lldb-perf-clang */, - 4C86C5D016F7CC8900844407 /* format-tester */, - 4CE3705316FB6FA100BFD501 /* lldb-perf-step */, - 4CE3707B16FB70AD00BFD501 /* stepping-testcase */, - 4C1E37E316F7A0A500FF10BB /* All Perf Tests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 264B3DE616F7E47600D1E7AB /* lldb */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.executable"; - path = lldb; - remoteRef = 264B3DE516F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DE816F7E47600D1E7AB /* LLDB.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = LLDB.framework; - remoteRef = 264B3DE716F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DEA16F7E47600D1E7AB /* darwin-debug */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.executable"; - path = "darwin-debug"; - remoteRef = 264B3DE916F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DEC16F7E47600D1E7AB /* liblldb-core.a */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.dylib"; - path = "liblldb-core.a"; - remoteRef = 264B3DEB16F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DEE16F7E47600D1E7AB /* lldb-platform */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.executable"; - path = "lldb-platform"; - remoteRef = 264B3DED16F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DF016F7E47600D1E7AB /* com.apple.lldb.launcherXPCService.xpc */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = com.apple.lldb.launcherXPCService.xpc; - remoteRef = 264B3DEF16F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 264B3DF216F7E47600D1E7AB /* com.apple.lldb.launcherRootXPCService.xpc */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = com.apple.lldb.launcherRootXPCService.xpc; - remoteRef = 264B3DF116F7E47600D1E7AB /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXSourcesBuildPhase section */ - 26DBAD5516FA63B1008243D2 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 26DBAD6216FA63F0008243D2 /* lldb_perf_clang.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E373516F4035D00FF10BB /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C1E378316F40B8C00FF10BB /* CFCData.cpp in Sources */, - 4C1E378416F40B8F00FF10BB /* CFCMutableArray.cpp in Sources */, - 4C1E378216F40B8900FF10BB /* CFCBundle.cpp in Sources */, - 4C1E375016F407C800FF10BB /* MemoryGauge.cpp in Sources */, - 4C1E375416F407C800FF10BB /* TestCase.cpp in Sources */, - 4C1E375816F407C800FF10BB /* Xcode.cpp in Sources */, - 26DF762916FBCE7100B4CC2E /* Results.cpp in Sources */, - 4C1E375216F407C800FF10BB /* Metric.cpp in Sources */, - 4C1E375616F407C800FF10BB /* Timer.cpp in Sources */, - 4C1E378616F40B9600FF10BB /* CFCMutableSet.cpp in Sources */, - 4C1E378516F40B9200FF10BB /* CFCMutableDictionary.cpp in Sources */, - 4C1E378816F40B9F00FF10BB /* CFCString.cpp in Sources */, - 26DF764316FBF30E00B4CC2E /* Gauge.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E376916F4087A00FF10BB /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C1E377916F4089E00FF10BB /* sketch.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C1E37B616F79E9D00FF10BB /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C1E37CB16F79EFA00FF10BB /* formatters.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C86C5CD16F7CC8900844407 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C86C5DA16F7CED300844407 /* fmts_tester.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4CE3705016FB6FA100BFD501 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CE3707316FB701000BFD501 /* lldb-perf-stepping.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4CE3707816FB70AD00BFD501 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CDDF51017011EBB00D95015 /* stepping-testcase.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 26B902D71700F9BD00EFDCE2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = LLDB; - targetProxy = 26B902D61700F9BD00EFDCE2 /* PBXContainerItemProxy */; - }; - 26B902E31700F9CC00EFDCE2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E373816F4035D00FF10BB /* lldbperf */; - targetProxy = 26B902E21700F9CC00EFDCE2 /* PBXContainerItemProxy */; - }; - 4C1E379116F40BCD00FF10BB /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E373816F4035D00FF10BB /* lldbperf */; - targetProxy = 4C1E379016F40BCD00FF10BB /* PBXContainerItemProxy */; - }; - 4C1E37C416F79EB000FF10BB /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E373816F4035D00FF10BB /* lldbperf */; - targetProxy = 4C1E37C316F79EB000FF10BB /* PBXContainerItemProxy */; - }; - 4C86C5DC16F7CF1200844407 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C86C5D016F7CC8900844407 /* format-tester */; - targetProxy = 4C86C5DB16F7CF1200844407 /* PBXContainerItemProxy */; - }; - 4CE3706916FB6FCA00BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E376C16F4087A00FF10BB /* lldb-perf-sketch */; - targetProxy = 4CE3706816FB6FCA00BFD501 /* PBXContainerItemProxy */; - }; - 4CE3706B16FB6FCC00BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E37B916F79E9D00FF10BB /* lldb-perf-formatters */; - targetProxy = 4CE3706A16FB6FCC00BFD501 /* PBXContainerItemProxy */; - }; - 4CE3706D16FB6FCF00BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 26DBAD5816FA63B1008243D2 /* lldb-perf-clang */; - targetProxy = 4CE3706C16FB6FCF00BFD501 /* PBXContainerItemProxy */; - }; - 4CE3706F16FB6FD200BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CE3705316FB6FA100BFD501 /* lldb-perf-step */; - targetProxy = 4CE3706E16FB6FD200BFD501 /* PBXContainerItemProxy */; - }; - 4CE3708B16FB711200BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CE3707B16FB70AD00BFD501 /* stepping-testcase */; - targetProxy = 4CE3708A16FB711200BFD501 /* PBXContainerItemProxy */; - }; - 4CE3708D16FB712300BFD501 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C1E373816F4035D00FF10BB /* lldbperf */; - targetProxy = 4CE3708C16FB712300BFD501 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 26DBAD6016FA63B1008243D2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Debug; - }; - 26DBAD6116FA63B1008243D2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Release"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Release; - }; - 4C1E373B16F4035D00FF10BB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - ONLY_ACTIVE_ARCH = YES; - }; - name = Debug; - }; - 4C1E373C16F4035D00FF10BB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - }; - name = Release; - }; - 4C1E373E16F4035D00FF10BB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../include"; - }; - name = Debug; - }; - 4C1E373F16F4035D00FF10BB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../include"; - }; - name = Release; - }; - 4C1E377416F4087A00FF10BB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../include $(SRCROOT)/../../source/Host/macosx/cfcpp $(SRCROOT)/../"; - }; - name = Debug; - }; - 4C1E377516F4087A00FF10BB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../include $(SRCROOT)/../../source/Host/macosx/cfcpp $(SRCROOT)/../"; - }; - name = Release; - }; - 4C1E37C116F79E9D00FF10BB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Debug; - }; - 4C1E37C216F79E9D00FF10BB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Release; - }; - 4C1E37E516F7A0A600FF10BB /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 4C1E37E616F7A0A600FF10BB /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 4C86C5D816F7CC8900844407 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 4C86C5D916F7CC8900844407 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 4CE3705A16FB6FA100BFD501 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - MACOSX_DEPLOYMENT_TARGET = 10.9; - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Debug; - }; - 4CE3705B16FB6FA100BFD501 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../build/Debug", - ); - GCC_INLINES_ARE_PRIVATE_EXTERN = NO; - MACOSX_DEPLOYMENT_TARGET = 10.9; - OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../../../../build/Debug"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../ $(SRCROOT)/../../include/"; - }; - name = Release; - }; - 4CE3708316FB70AD00BFD501 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Debug; - }; - 4CE3708416FB70AD00BFD501 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_OPTIMIZATION_LEVEL = 0; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 26DBAD5F16FA63B1008243D2 /* Build configuration list for PBXNativeTarget "lldb-perf-clang" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 26DBAD6016FA63B1008243D2 /* Debug */, - 26DBAD6116FA63B1008243D2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C1E373416F4035D00FF10BB /* Build configuration list for PBXProject "lldbperf" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C1E373B16F4035D00FF10BB /* Debug */, - 4C1E373C16F4035D00FF10BB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C1E373D16F4035D00FF10BB /* Build configuration list for PBXNativeTarget "lldbperf" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C1E373E16F4035D00FF10BB /* Debug */, - 4C1E373F16F4035D00FF10BB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C1E377316F4087A00FF10BB /* Build configuration list for PBXNativeTarget "lldb-perf-sketch" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C1E377416F4087A00FF10BB /* Debug */, - 4C1E377516F4087A00FF10BB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C1E37C016F79E9D00FF10BB /* Build configuration list for PBXNativeTarget "lldb-perf-formatters" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C1E37C116F79E9D00FF10BB /* Debug */, - 4C1E37C216F79E9D00FF10BB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C1E37E416F7A0A600FF10BB /* Build configuration list for PBXAggregateTarget "All Perf Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C1E37E516F7A0A600FF10BB /* Debug */, - 4C1E37E616F7A0A600FF10BB /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C86C5D716F7CC8900844407 /* Build configuration list for PBXNativeTarget "format-tester" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C86C5D816F7CC8900844407 /* Debug */, - 4C86C5D916F7CC8900844407 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4CE3706716FB6FA100BFD501 /* Build configuration list for PBXNativeTarget "lldb-perf-step" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CE3705A16FB6FA100BFD501 /* Debug */, - 4CE3705B16FB6FA100BFD501 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4CE3708216FB70AD00BFD501 /* Build configuration list for PBXNativeTarget "stepping-testcase" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CE3708316FB70AD00BFD501 /* Debug */, - 4CE3708416FB70AD00BFD501 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 4C1E373116F4035D00FF10BB /* Project object */; -} From fffb3e305d6f5343614c37f5d6d9abd99083a81f Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 21:53:22 +0000 Subject: [PATCH 055/616] Remove install-headers After discussing this internally, it is my understanding this was used for building LLDB internally at Apple, and is no longer used or necessary. llvm-svn: 365392 (cherry picked from commit a5ede3182bc07cf453c7b601dce0f0a8af2b624d) --- lldb/lldb.xcodeproj/project.pbxproj | 145 ---------------------------- lldb/tools/install-headers/Makefile | 23 ----- 2 files changed, 168 deletions(-) delete mode 100644 lldb/tools/install-headers/Makefile diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index c83b16ed8c62e..11b3b3ea87ed5 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -16,7 +16,6 @@ dependencies = ( 26B391F11A6DCCBE00456239 /* PBXTargetDependency */, 26CEF3B014FD591F007286B2 /* PBXTargetDependency */, - 2687EACD1508115900DD8C2E /* PBXTargetDependency */, ); name = desktop_no_xpc; productName = snowleopard; @@ -30,7 +29,6 @@ dependencies = ( 26CEF3BB14FD595B007286B2 /* PBXTargetDependency */, 26B391EF1A6DCCAF00456239 /* PBXTargetDependency */, - 2687EACB1508115000DD8C2E /* PBXTargetDependency */, ); name = desktop; productName = desktop; @@ -45,7 +43,6 @@ dependencies = ( AFCA21D21D18E556004386B8 /* PBXTargetDependency */, 26CEF3C214FD5973007286B2 /* PBXTargetDependency */, - 2687EACF1508116300DD8C2E /* PBXTargetDependency */, ); name = ios; productName = ios; @@ -1188,27 +1185,6 @@ remoteGlobalIDString = 26680206115FD0ED008E1FE4; remoteInfo = LLDB; }; - 2687EACA1508115000DD8C2E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2687EAC51508110B00DD8C2E; - remoteInfo = "install-headers"; - }; - 2687EACC1508115900DD8C2E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2687EAC51508110B00DD8C2E; - remoteInfo = "install-headers"; - }; - 2687EACE1508116300DD8C2E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2687EAC51508110B00DD8C2E; - remoteInfo = "install-headers"; - }; 2689011413353E9B00698AC0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -7181,20 +7157,6 @@ passBuildSettingsInEnvironment = 1; productName = "LLDB Python Test Suite"; }; - 2687EAC51508110B00DD8C2E /* install-headers */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "$(ACTION)"; - buildConfigurationList = 2687EAC61508110B00DD8C2E /* Build configuration list for PBXLegacyTarget "install-headers" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/make; - buildWorkingDirectory = "$(SRCROOT)/tools/install-headers"; - dependencies = ( - ); - name = "install-headers"; - passBuildSettingsInEnvironment = 1; - productName = "install-headers"; - }; /* End PBXLegacyTarget section */ /* Begin PBXNativeTarget section */ @@ -7448,7 +7410,6 @@ 26579F67126A25920007C5CB /* darwin-debug */, 2689FFC913353D7A00698AC0 /* lldb-core */, 26DC6A0F1337FE6900FF7998 /* lldb-server */, - 2687EAC51508110B00DD8C2E /* install-headers */, 2690CD161A6DC0D000E717C8 /* lldb-mi */, 942829BF1A89835300521B30 /* lldb-argdumper */, 2679260B211CA3AC00EE1D10 /* lldb-vscode */, @@ -8792,21 +8753,6 @@ target = 26680206115FD0ED008E1FE4 /* LLDB */; targetProxy = 2679261F211CA40700EE1D10 /* PBXContainerItemProxy */; }; - 2687EACB1508115000DD8C2E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2687EAC51508110B00DD8C2E /* install-headers */; - targetProxy = 2687EACA1508115000DD8C2E /* PBXContainerItemProxy */; - }; - 2687EACD1508115900DD8C2E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2687EAC51508110B00DD8C2E /* install-headers */; - targetProxy = 2687EACC1508115900DD8C2E /* PBXContainerItemProxy */; - }; - 2687EACF1508116300DD8C2E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2687EAC51508110B00DD8C2E /* install-headers */; - targetProxy = 2687EACE1508116300DD8C2E /* PBXContainerItemProxy */; - }; 2689011513353E9B00698AC0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 2689FFC913353D7A00698AC0 /* lldb-core */; @@ -9833,62 +9779,6 @@ }; name = BuildAndIntegration; }; - 2687EAC71508110B00DD8C2E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 360.99.0; - DEBUGGING_SYMBOLS = YES; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Debug; - }; - 2687EAC81508110B00DD8C2E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 360.99.0; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Release; - }; - 2687EAC91508110B00DD8C2E /* BuildAndIntegration */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 360.99.0; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = BuildAndIntegration; - }; 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -11118,30 +11008,6 @@ }; name = DebugClang; }; - 49BB8F3F1611172B00BDD462 /* DebugClang */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 360.99.0; - DEBUGGING_SYMBOLS = YES; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = DebugClang; - }; 942829C51A89835400521B30 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -11539,17 +11405,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = BuildAndIntegration; }; - 2687EAC61508110B00DD8C2E /* Build configuration list for PBXLegacyTarget "install-headers" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2687EAC71508110B00DD8C2E /* Debug */, - 49BB8F3F1611172B00BDD462 /* DebugClang */, - 2687EAC81508110B00DD8C2E /* Release */, - 2687EAC91508110B00DD8C2E /* BuildAndIntegration */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = BuildAndIntegration; - }; 2689FFD813353D7A00698AC0 /* Build configuration list for PBXNativeTarget "lldb-core" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/lldb/tools/install-headers/Makefile b/lldb/tools/install-headers/Makefile deleted file mode 100644 index 384a54e6d6f67..0000000000000 --- a/lldb/tools/install-headers/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -installsrc: - echo "installsrc (doing nothing)" - -install: - echo "install (doing nothing)" - -clean: - echo "clean (doing nothing)" - -LLDB_VERSION=`echo ${CURRENT_PROJECT_VERSION} | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$$/\1/g'` -LLDB_REVISION=`echo ${CURRENT_PROJECT_VERSION} | /usr/bin/sed -E 's/^([0-9]+).([0-9]+).([0-9]+)(.[0-9]+)?$$/\3/g'` -LLDB_VERSION_STRING=`echo ${CURRENT_PROJECT_VERSION}` - -installhdrs: - cd "${TARGET_BUILD_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers" ;\ - for file in *.h ;\ - do \ - /usr/bin/sed -i '' 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 /1' "$$file" ;\ - /usr/bin/sed -i '' 's| Date: Mon, 8 Jul 2019 22:09:08 +0000 Subject: [PATCH 056/616] [lldb, windows] When StartMonitoring fails, return a proper error This is possible now that the function returns an llvm::Expected llvm-svn: 365400 (cherry picked from commit 7f843e22bae2fb5dc2c8dcfd3dd4dd16c9b5710d) --- lldb/source/Host/windows/HostProcessWindows.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index d7484f8a89b7e..f615318a7646d 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -82,20 +82,21 @@ bool HostProcessWindows::IsRunning() const { llvm::Expected HostProcessWindows::StartMonitoring( const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { - HostThread monitor_thread; MonitorInfo *info = new MonitorInfo; info->callback = callback; // Since the life of this HostProcessWindows instance and the life of the // process may be different, duplicate the handle so that the monitor thread // can have ownership over its own copy of the handle. - HostThread result; if (::DuplicateHandle(GetCurrentProcess(), m_process, GetCurrentProcess(), - &info->process_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) - result = ThreadLauncher::LaunchThread("ChildProcessMonitor", - HostProcessWindows::MonitorThread, - info); - return result; + &info->process_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { + return ThreadLauncher::LaunchThread("ChildProcessMonitor", + HostProcessWindows::MonitorThread, + info); + } else { + DWORD err = GetLastError(); + return llvm::errorCodeToError(std::error_code(err, std::system_category())); + } } lldb::thread_result_t HostProcessWindows::MonitorThread(void *thread_arg) { From d9df8a03868ac661e31561315ff3f59af7090935 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 8 Jul 2019 22:45:59 +0000 Subject: [PATCH 057/616] [ThreadLauncher] Use mapWindowsError and LLDB_INVALID_HOST_THREAD Address post-commit feedback from Pavel and Jim. llvm-svn: 365403 (cherry picked from commit ba06f15ac89a9982a91223dbb9fbc52770a991f0) --- lldb/source/Host/common/ThreadLauncher.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 62834c5c33296..50ab02c72cca6 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -31,10 +31,8 @@ llvm::Expected ThreadLauncher::LaunchThread( thread = (lldb::thread_t)::_beginthreadex( 0, (unsigned)min_stack_byte_size, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL); - if (thread == (lldb::thread_t)(-1L)) { - DWORD err = GetLastError(); - return llvm::errorCodeToError(std::error_code(err, std::system_category())); - } + if (thread == LLDB_INVALID_HOST_THREAD) + return llvm::errorCodeToError(llvm::mapWindowsError(GetLastError())); #else // ASAN instrumentation adds a lot of bookkeeping overhead on stack frames. From 9154610617184d3f6162d30cfafbc417f2290784 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 9 Jul 2019 01:05:12 +0000 Subject: [PATCH 058/616] [crashlog] Fix a mismatch between bytes and strings. The functions in read_plist() want bytes as input, not strings. llvm-svn: 365416 (cherry picked from commit 68946d10ad3bd27e3388f1cfd53720341725132b) --- lldb/examples/python/crashlog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 3ccf6f71e2b37..9a8ec8c1a43ff 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -300,7 +300,7 @@ def locate_module_and_debug_symbols(self): if os.path.exists(self.dsymForUUIDBinary): dsym_for_uuid_command = '%s %s' % ( self.dsymForUUIDBinary, uuid_str) - s = subprocess.check_output(dsym_for_uuid_command, shell=True).decode("utf-8") + s = subprocess.check_output(dsym_for_uuid_command, shell=True) if s: try: plist_root = read_plist(s) From 7bc7fc543cbd3330a922a46d8ad4d2eba30bae0d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 9 Jul 2019 01:35:31 +0000 Subject: [PATCH 059/616] [Windows] Include ErrorHandling.h Include ErrorHandling.h for mapWindowsError. llvm-svn: 365420 (cherry picked from commit 4936cbc9f10f038fb15ec83fe3b3c3735bc0a0ee) --- lldb/source/Host/common/ThreadLauncher.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 50ab02c72cca6..33881d8467ad9 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -17,6 +17,8 @@ #include "lldb/Host/windows/windows.h" #endif +#include "llvm/Support/ErrorHandling.h" + using namespace lldb; using namespace lldb_private; From 554a97abce330f1eabb86bf27d3b51b606f7f687 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 9 Jul 2019 01:35:34 +0000 Subject: [PATCH 060/616] Fix ASCII art header llvm-svn: 365421 (cherry picked from commit 53d5f3a08d2c93b4a719151dbf7b414589ad7c90) --- lldb/source/Host/common/ThreadLauncher.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 33881d8467ad9..e5fe2efc8e862 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -1,5 +1,4 @@ -//===-- ThreadLauncher.cpp ---------------------------------------*- C++ -//-*-===// +//===-- ThreadLauncher.cpp --------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. From 7ba15955e9e8b022848053d0fb05830d37caa2f6 Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Tue, 9 Jul 2019 10:28:53 +0000 Subject: [PATCH 061/616] [CMake] Remove old lldb_setup_framework_rpaths_in_tool() llvm-svn: 365457 (cherry picked from commit 189355f3ee5ac779a96997eceb48f813b74c19c4) --- lldb/cmake/modules/AddLLDB.cmake | 39 -------------------------------- 1 file changed, 39 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 064b51f1a786a..65d34f8d7e74e 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -203,45 +203,6 @@ function(lldb_append_link_flags target_name new_link_flags) set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) endfunction() -# For tools that depend on liblldb, account for varying directory structures in -# which LLDB.framework can be used and distributed: In the build-tree we find it -# by its absolute target path. This is only relevant for running the test suite. -# In the install step CMake will remove this entry and insert the final RPATHs. -# These are relative to the file path from where the tool will be loaded on the -# enduser system. -# -# Note that the LLVM install-tree doesn't match the enduser system structure -# for LLDB.framework, so by default dependent tools will not be functional in -# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix -# this. If specified, it causes the install-tree location of the framework to be -# added as an extra RPATH below. -# -function(lldb_setup_framework_rpaths_in_tool name) - # The installed framework is relocatable and can be in different locations. - set(rpaths_install_tree) - - if(LLDB_FRAMEWORK_INSTALL_DIR) - list(APPEND rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") - endif() - - list(APPEND rpaths_install_tree "@loader_path/../../../SharedFrameworks") - list(APPEND rpaths_install_tree "@loader_path/../../System/Library/PrivateFrameworks") - list(APPEND rpaths_install_tree "@loader_path/../../Library/PrivateFrameworks") - - # In the build-tree, we know the exact path to the framework directory. - get_target_property(framework_target_dir liblldb LIBRARY_OUTPUT_DIRECTORY) - - # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites - # the default settings from llvm_setup_rpath(). - set_target_properties(${name} PROPERTIES - BUILD_WITH_INSTALL_RPATH OFF - BUILD_RPATH "${framework_target_dir}" - INSTALL_RPATH "${rpaths_install_tree}" - ) - - add_dependencies(${name} lldb-framework) -endfunction() - # Unified handling for executable LLDB.framework resources. Given the name of an # executable target, this function adds a post-build step to copy it to the # framework bundle in the build-tree. From 90425a17613d0cc7cd40741304141a99068a1826 Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Tue, 9 Jul 2019 10:29:00 +0000 Subject: [PATCH 062/616] [CMake] Don't initialize LLVM_INSTALL_TOOLCHAIN_ONLY in Apple-lldb-base cache llvm-svn: 365458 (cherry picked from commit e9298dc90278230fdf6d8ab5ef66b2a259426bb9) --- lldb/cmake/caches/Apple-lldb-base.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake b/lldb/cmake/caches/Apple-lldb-base.cmake index 3ca0fc072ab4d..6cd69e8bd180a 100644 --- a/lldb/cmake/caches/Apple-lldb-base.cmake +++ b/lldb/cmake/caches/Apple-lldb-base.cmake @@ -2,7 +2,6 @@ set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "") set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") -set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(LLVM_ENABLE_MODULES ON CACHE BOOL "") From 1c11710523abdceb3301de1b2f922fc47e1a1c2a Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Tue, 9 Jul 2019 10:29:07 +0000 Subject: [PATCH 063/616] [CMake] Polish a comment llvm-svn: 365459 (cherry picked from commit e5b868d6a3ca22004b791e1bcd4b96e07dec6801) --- lldb/cmake/modules/LLDBFramework.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 04f35e1951d2a..96ffb52585573 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -26,7 +26,8 @@ set_target_properties(liblldb PROPERTIES MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in ) -# Defined in AddLLVM.cmake; handles edge cases for multi-config generators +# Used in llvm_add_library() to set default output directories for multi-config +# generators. Overwrite to account for special framework output directory. set_output_directory(liblldb BINARY_DIR ${framework_target_dir} LIBRARY_DIR ${framework_target_dir} From 9ee38d63fdc3d69016a6c5b3882b50e9f08ebdd9 Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Tue, 9 Jul 2019 18:10:36 +0000 Subject: [PATCH 064/616] [lldb, windows] Update two more locations that use LaunchThread to the new function signature llvm-svn: 365526 (cherry picked from commit 631b5f7dc0e9dab76355f8043b03727b0cb7d62d) --- .../Host/windows/HostProcessWindows.cpp | 4 +-- .../Process/Windows/Common/DebuggerThread.cpp | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index f615318a7646d..90517249db7e4 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -14,6 +14,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/WindowsError.h" #include @@ -94,8 +95,7 @@ llvm::Expected HostProcessWindows::StartMonitoring( HostProcessWindows::MonitorThread, info); } else { - DWORD err = GetLastError(); - return llvm::errorCodeToError(std::error_code(err, std::system_category())); + return llvm::errorCodeToError(llvm::mapWindowsError(GetLastError())); } } diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp index 104ac229f2f41..58769bdd70da0 100644 --- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp @@ -63,16 +63,18 @@ Status DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) { Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); LLDB_LOG(log, "launching '{0}'", launch_info.GetExecutableFile().GetPath()); - Status error; + Status result; DebugLaunchContext *context = new DebugLaunchContext(this, launch_info); - HostThread slave_thread(ThreadLauncher::LaunchThread( - "lldb.plugin.process-windows.slave[?]", DebuggerThreadLaunchRoutine, - context, &error)); - if (!error.Success()) - LLDB_LOG(log, "couldn't launch debugger thread. {0}", error); + llvm::Expected slave_thread = ThreadLauncher::LaunchThread( + "lldb.plugin.process-windows.slave[?]", DebuggerThreadLaunchRoutine, + context); + if (!slave_thread) { + result = Status(slave_thread.takeError()); + LLDB_LOG(log, "couldn't launch debugger thread. {0}", result); + } - return error; + return result; } Status DebuggerThread::DebugAttach(lldb::pid_t pid, @@ -80,16 +82,18 @@ Status DebuggerThread::DebugAttach(lldb::pid_t pid, Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); LLDB_LOG(log, "attaching to '{0}'", pid); - Status error; + Status result; DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info); - HostThread slave_thread(ThreadLauncher::LaunchThread( - "lldb.plugin.process-windows.slave[?]", DebuggerThreadAttachRoutine, - context, &error)); - if (!error.Success()) - LLDB_LOG(log, "couldn't attach to process '{0}'. {1}", pid, error); + llvm::Expected slave_thread = ThreadLauncher::LaunchThread( + "lldb.plugin.process-windows.slave[?]", DebuggerThreadAttachRoutine, + context); + if (!slave_thread) { + result = Status(slave_thread.takeError()); + LLDB_LOG(log, "couldn't attach to process '{0}'. {1}", pid, result); + } - return error; + return result; } lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine(void *data) { From 085e34c68c8d619580815082e9d194c9b3c59c9f Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Tue, 9 Jul 2019 18:18:02 +0000 Subject: [PATCH 065/616] [lldb-suite] Skip TestMachCore on Windows This test was originally marked as expected failure on Windows, but it is timing out instead of outright failing now. The expectedFailure attribute does not correctly track timeouts (as in, they don't count as failures), so now this is causing the test suite to fail. llvm-svn: 365527 (cherry picked from commit 2ea514c5662f1c69642f21c9cc32c0fbfb8e9ffb) --- .../functionalities/postmortem/mach-core/TestMachCore.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py index a299a4308bc8d..b03ea8da9bc8e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py @@ -26,7 +26,10 @@ def tearDown(self): lldb.DBG.SetSelectedPlatform(self._initial_platform) super(MachCoreTestCase, self).tearDown() - @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + # This was originally marked as expected failure on Windows, but it has + # started timing out instead, so the expectedFailure attribute no longer + # correctly tracks it: llvm.org/pr37371 + @skipIfWindows def test_selected_thread(self): """Test that the right thread is selected after a core is loaded.""" # Create core form YAML. From 4e97214b46a7a355ce26ba4f2912da087f4b2b49 Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Tue, 9 Jul 2019 18:41:31 +0000 Subject: [PATCH 066/616] [lldb, windows] Include WindowsError instead of ErrorHandling in ThreadLauncher ErrorHandling.h does not include WindowsError.h which is needed for mapWindowsError llvm-svn: 365533 (cherry picked from commit 20ecec6116b367cbf9fe2ed978656ed117665bf9) --- lldb/source/Host/common/ThreadLauncher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index e5fe2efc8e862..6e3c8b6a13a46 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/source/Host/common/ThreadLauncher.cpp @@ -16,7 +16,7 @@ #include "lldb/Host/windows/windows.h" #endif -#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/WindowsError.h" using namespace lldb; using namespace lldb_private; From c31fbc8b2439209588c937012e5cfeff83a35b8e Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 9 Jul 2019 21:21:45 +0000 Subject: [PATCH 067/616] [Docs] Replace SVN revisions with lldb versions Summary: Replaces references to svn commits with the lldb version number those commits first appeared in. Themotivation is to show that these features are no longer that new and can generally be adopted. Reviewers: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61778 llvm-svn: 365559 (cherry picked from commit 90148db02a5ba19f12cc731c210f4cd866456816) --- lldb/docs/use/python-reference.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/docs/use/python-reference.rst b/lldb/docs/use/python-reference.rst index 2346947f74299..8c76ef1a08307 100644 --- a/lldb/docs/use/python-reference.rst +++ b/lldb/docs/use/python-reference.rst @@ -494,10 +494,9 @@ Optionally, you can also provide a Python docstring, and LLDB will use it when p """This command takes a lot of options and does many fancy things""" # Your code goes here -Starting with SVN revision 218834, LLDB Python commands can also take an -SBExecutionContext as an argument. This is useful in cases where the command's -notion of where to act is independent of the currently-selected entities in the -debugger. +Since lldb 3.5.2, LLDB Python commands can also take an SBExecutionContext as an +argument. This is useful in cases where the command's notion of where to act is +independent of the currently-selected entities in the debugger. This feature is enabled if the command-implementing function can be recognized as taking 5 arguments, or a variable number of arguments, and it alters the @@ -519,7 +518,7 @@ signature as such: +-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+ | **exe_ctx** | **lldb.SBExecutionContext** | An execution context object carrying around information on the inferior process' context in which the command is expected to act | | | | | -| | | *Optional since SVN r218834, unavailable before* | +| | | *Optional since lldb 3.5.2, unavailable before* | +-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+ | **result** | **lldb.SBCommandReturnObject** | A return object which encapsulates success/failure information for the command and output text | | | | that needs to be printed as a result of the command. The plain Python "print" command also works but | @@ -529,8 +528,8 @@ signature as such: | | | and functions. | +-------------------+--------------------------------+----------------------------------------------------------------------------------------------------------------------------------+ -Starting with SVN revision 232224, Python commands can also be implemented by -means of a class which should implement the following interface: +Since lldb 3.7, Python commands can also be implemented by means of a class +which should implement the following interface: :: From baec9febd587bdced7215d1818012490607ce6b4 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 9 Jul 2019 21:35:58 +0000 Subject: [PATCH 068/616] [lldb_test_suite] Fix lldb test suite targeting remote Android Summary: Fixed `Android.rules` for running test suite on remote android - the build configuration is not compatible with ndk structure, change it to link to static libc++ - generally clang should be able to use libc++ and will link against the right library, but some libc++ installations require the user manually link libc++abi. - add flag `-lc++abi` to fix the test binary build failure Added `skipIfTargetAndroid` `skipUnlessTargetAndroid` for better test support - the `skipIfPlatform` method will ask `lldbplatformutil.getPlatform()` for platform info which is actually the os type, and //Android// is not os type but environment - create this function to handle the android target condition **To Run Test on Remote Android** 1 start lldb-server on your devices 2 run lldb-dotest with following configuration: `./lldb-dotest --out-of-tree-debugserver --arch aarch64 --platform-name remote-android --platform-url connect://localhost:12345 --platform-working-dir /data/local/tmp/ --compiler your/ndk/clang` Reviewers: xiaobai, labath Reviewed By: labath Subscribers: labath, javed.absar, kristof.beyls, srhines, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64118 llvm-svn: 365561 (cherry picked from commit 695f7821e2d90210ac93533393a0a028a4a08600) --- .../test/android/platform/TestDefaultCacheLineSize.py | 2 +- lldb/packages/Python/lldbsuite/test/decorators.py | 8 ++++++++ lldb/packages/Python/lldbsuite/test/make/Android.rules | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py b/lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py index 5eff454c3bfb2..38685cd1498a5 100644 --- a/lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py +++ b/lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py @@ -16,7 +16,7 @@ class DefaultCacheLineSizeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessPlatform(['android']) + @skipUnlessTargetAndroid def test_cache_line_size(self): self.build(dictionary=self.getBuildFlags()) exe = self.getBuildArtifact("a.out") diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index 7f3eac363c08c..0493a4316ed73 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -596,6 +596,10 @@ def skipIfWindows(func): """Decorate the item to skip tests that should be skipped on Windows.""" return skipIfPlatform(["windows"])(func) +def skipIfTargetAndroid(func): + return unittest2.skipIf(lldbplatformutil.target_is_android(), + "skip on target Android")(func) + def skipUnlessWindows(func): """Decorate the item to skip tests that should be skipped on any non-Windows platform.""" @@ -606,6 +610,10 @@ def skipUnlessDarwin(func): """Decorate the item to skip tests that should be skipped on any non Darwin platform.""" return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func) +def skipUnlessTargetAndroid(func): + return unittest2.skipUnless(lldbplatformutil.target_is_android(), + "requires target to be Android")(func) + def skipIfHostIncompatibleWithRemote(func): """Decorate the item to skip tests if binaries built on this host are incompatible.""" diff --git a/lldb/packages/Python/lldbsuite/test/make/Android.rules b/lldb/packages/Python/lldbsuite/test/make/Android.rules index fab956e23641a..ad42b9b2ea0d8 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Android.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Android.rules @@ -90,5 +90,6 @@ else ARCH_LDFLAGS += \ -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ - $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a + $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \ + -lc++abi endif From 39f788fcb63c0a32a49687b9d0e513a81ba848cf Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 9 Jul 2019 22:24:54 +0000 Subject: [PATCH 069/616] [lldb] Quick Fix: IRExecutionUnit check pointer before access it Summary: Move checking pointer code block before accessing the pointer This caused lldb to crash when testing on Android Patch by Wanyi Ye! Differential Revision: https://reviews.llvm.org/D64434 llvm-svn: 365567 (cherry picked from commit 269b9f940ff919d9ebf5cd94f5a87d38e32bdb2c) --- lldb/source/Expression/IRExecutionUnit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 00e12f32b7284..25404ad313e12 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -285,9 +285,6 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, m_execution_engine_up.reset(builder.create(target_machine)); - m_strip_underscore = - (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_'); - if (!m_execution_engine_up) { error.SetErrorToGenericError(); error.SetErrorStringWithFormat("Couldn't JIT the function: %s", @@ -295,6 +292,9 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, return; } + m_strip_underscore = + (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_'); + class ObjectDumper : public llvm::ObjectCache { public: void notifyObjectCompiled(const llvm::Module *module, From b35cb9202e8662254b97fbb7c39f8364d955c1f1 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Wed, 10 Jul 2019 03:34:57 +0000 Subject: [PATCH 070/616] Try again to move common functionality from ProcessWindows into ProcessDebugger This reverts commit ed499a36b67cf46cbf66052cfe374c80a595f1c1 and addresses a problem causing a Windows build bot to hang. llvm-svn: 365592 (cherry picked from commit 053eb35651906e693906fad6c695fce11415ade7) --- .../Plugins/ObjectFile/ELF/ELFHeader.cpp | 3 + .../Process/Windows/Common/CMakeLists.txt | 1 + .../Windows/Common/ProcessDebugger.cpp | 582 ++++++++++++++++++ .../Process/Windows/Common/ProcessDebugger.h | 101 +++ .../Process/Windows/Common/ProcessWindows.cpp | 473 ++------------ .../Process/Windows/Common/ProcessWindows.h | 21 +- 6 files changed, 726 insertions(+), 455 deletions(-) create mode 100644 lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp create mode 100644 lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp index aa9871071b0e0..14c7e471edfb9 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp @@ -180,6 +180,9 @@ unsigned ELFHeader::GetRelocationJumpSlotType() const { default: assert(false && "architecture not supported"); break; + case EM_CASCADE: + slot = R_CASCADE_JUMP_SLOT; + break; case EM_PPC: slot = R_PPC_JMP_SLOT; break; diff --git a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt index c63df5fb3255a..68486c1d99050 100644 --- a/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt +++ b/lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt @@ -2,6 +2,7 @@ add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN DebuggerThread.cpp LocalDebugDelegate.cpp + ProcessDebugger.cpp ProcessWindows.cpp ProcessWindowsLog.cpp RegisterContextWindows.cpp diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp new file mode 100644 index 0000000000000..6ee882f7f882b --- /dev/null +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp @@ -0,0 +1,582 @@ +//===-- ProcessDebugger.cpp -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "ProcessDebugger.h" + +// Windows includes +#include "lldb/Host/windows/windows.h" +#include + +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostNativeProcessBase.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/HostThread.h" +#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Target/Process.h" +#include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/Error.h" + +#include "DebuggerThread.h" +#include "ExceptionRecord.h" +#include "ProcessWindowsLog.h" + +using namespace lldb; +using namespace lldb_private; + +static DWORD ConvertLldbToWinApiProtect(uint32_t protect) { + // We also can process a read / write permissions here, but if the debugger + // will make later a write into the allocated memory, it will fail. To get + // around it is possible inside DoWriteMemory to remember memory permissions, + // allow write, write and restore permissions, but for now we process only + // the executable permission. + // + // TODO: Process permissions other than executable + if (protect & ePermissionsExecutable) + return PAGE_EXECUTE_READWRITE; + + return PAGE_READWRITE; +} + +// The Windows page protection bits are NOT independent masks that can be +// bitwise-ORed together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE +// | PAGE_READ). To test for an access type, it's necessary to test for any of +// the bits that provide that access type. +static bool IsPageReadable(uint32_t protect) { + return (protect & PAGE_NOACCESS) == 0; +} + +static bool IsPageWritable(uint32_t protect) { + return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | + PAGE_READWRITE | PAGE_WRITECOPY)) != 0; +} + +static bool IsPageExecutable(uint32_t protect) { + return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | + PAGE_EXECUTE_WRITECOPY)) != 0; +} + +namespace lldb_private { + +lldb::pid_t ProcessDebugger::GetDebuggedProcessId() const { + if (m_session_data) + return m_session_data->m_debugger->GetProcess().GetProcessId(); + return LLDB_INVALID_PROCESS_ID; +} + +Status ProcessDebugger::DetachProcess() { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + DebuggerThreadSP debugger_thread; + { + // Acquire the lock only long enough to get the DebuggerThread. + // StopDebugging() will trigger a call back into ProcessDebugger which will + // also acquire the lock. Thus we have to release the lock before calling + // StopDebugging(). + llvm::sys::ScopedLock lock(m_mutex); + + if (!m_session_data) { + LLDB_LOG(log, "there is no active session."); + return Status(); + } + + debugger_thread = m_session_data->m_debugger; + } + + Status error; + + LLDB_LOG(log, "detaching from process {0}.", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle()); + error = debugger_thread->StopDebugging(false); + + // By the time StopDebugging returns, there is no more debugger thread, so + // we can be assured that no other thread will race for the session data. + m_session_data.reset(); + + return error; +} + +Status ProcessDebugger::LaunchProcess(ProcessLaunchInfo &launch_info, + DebugDelegateSP delegate) { + // Even though m_session_data is accessed here, it is before a debugger + // thread has been kicked off. So there's no race conditions, and it + // shouldn't be necessary to acquire the mutex. + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + Status result; + + FileSpec working_dir = launch_info.GetWorkingDirectory(); + namespace fs = llvm::sys::fs; + if (working_dir) { + FileSystem::Instance().Resolve(working_dir); + if (!FileSystem::Instance().IsDirectory(working_dir)) { + result.SetErrorStringWithFormat("No such file or directory: %s", + working_dir.GetCString()); + return result; + } + } + + if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) { + StreamString stream; + stream.Printf("ProcessDebugger unable to launch '%s'. ProcessDebugger can " + "only be used for debug launches.", + launch_info.GetExecutableFile().GetPath().c_str()); + std::string message = stream.GetString(); + result.SetErrorString(message.c_str()); + + LLDB_LOG(log, "error: {0}", message); + return result; + } + + bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry); + m_session_data.reset(new ProcessWindowsData(stop_at_entry)); + m_session_data->m_debugger.reset(new DebuggerThread(delegate)); + DebuggerThreadSP debugger = m_session_data->m_debugger; + + // Kick off the DebugLaunch asynchronously and wait for it to complete. + result = debugger->DebugLaunch(launch_info); + if (result.Fail()) { + LLDB_LOG(log, "failed launching '{0}'. {1}", + launch_info.GetExecutableFile().GetPath(), result); + return result; + } + + HostProcess process; + Status error = WaitForDebuggerConnection(debugger, process); + if (error.Fail()) { + LLDB_LOG(log, "failed launching '{0}'. {1}", + launch_info.GetExecutableFile().GetPath(), error); + return error; + } + + LLDB_LOG(log, "successfully launched '{0}'", + launch_info.GetExecutableFile().GetPath()); + + // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the + // private state should already be set to eStateStopped as a result of + // hitting the initial breakpoint. If it was not set, the breakpoint should + // have already been resumed from and the private state should already be + // eStateRunning. + launch_info.SetProcessID(process.GetProcessId()); + + return result; +} + +Status ProcessDebugger::AttachProcess(lldb::pid_t pid, + const ProcessAttachInfo &attach_info, + DebugDelegateSP delegate) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + m_session_data.reset( + new ProcessWindowsData(!attach_info.GetContinueOnceAttached())); + DebuggerThreadSP debugger(new DebuggerThread(delegate)); + + m_session_data->m_debugger = debugger; + + DWORD process_id = static_cast(pid); + Status error = debugger->DebugAttach(process_id, attach_info); + if (error.Fail()) { + LLDB_LOG( + log, + "encountered an error occurred initiating the asynchronous attach. {0}", + error); + return error; + } + + HostProcess process; + error = WaitForDebuggerConnection(debugger, process); + if (error.Fail()) { + LLDB_LOG(log, + "encountered an error waiting for the debugger to connect. {0}", + error); + return error; + } + + LLDB_LOG(log, "successfully attached to process with pid={0}", process_id); + + // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the + // private state should already be set to eStateStopped as a result of + // hitting the initial breakpoint. If it was not set, the breakpoint should + // have already been resumed from and the private state should already be + // eStateRunning. + + return error; +} + +Status ProcessDebugger::DestroyProcess(const lldb::StateType state) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + DebuggerThreadSP debugger_thread; + { + // Acquire this lock inside an inner scope, only long enough to get the + // DebuggerThread. StopDebugging() will trigger a call back into + // ProcessDebugger which will acquire the lock again, so we need to not + // deadlock. + llvm::sys::ScopedLock lock(m_mutex); + + if (!m_session_data) { + LLDB_LOG(log, "warning: state = {0}, but there is no active session.", + state); + return Status(); + } + + debugger_thread = m_session_data->m_debugger; + } + + Status error; + if (state != eStateExited && state != eStateDetached) { + LLDB_LOG( + log, "Shutting down process {0}.", + debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle()); + error = debugger_thread->StopDebugging(true); + + // By the time StopDebugging returns, there is no more debugger thread, so + // we can be assured that no other thread will race for the session data. + m_session_data.reset(); + } else { + error.SetErrorStringWithFormat("cannot destroy process %" PRIx64 + " while state = %d", + GetDebuggedProcessId(), state); + LLDB_LOG(log, "error: {0}", error); + } + return error; +} + +Status ProcessDebugger::HaltProcess(bool &caused_stop) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + Status error; + llvm::sys::ScopedLock lock(m_mutex); + caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess() + .GetNativeProcess() + .GetSystemHandle()); + if (!caused_stop) { + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error); + } + + return error; +} + +Status ProcessDebugger::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + size_t &bytes_read) { + Status error; + bytes_read = 0; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + + if (!m_session_data) { + error.SetErrorString( + "cannot read, there is no active debugger connection."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + + LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size, + vm_addr); + + HostProcess process = m_session_data->m_debugger->GetProcess(); + void *addr = reinterpret_cast(vm_addr); + SIZE_T num_of_bytes_read = 0; + if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, + buf, size, &num_of_bytes_read)) { + // Reading from the process can fail for a number of reasons - set the + // error code and make sure that the number of bytes read is set back to 0 + // because in some scenarios the value of bytes_read returned from the API + // is garbage. + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "reading failed with error: {0}", error); + } else { + bytes_read = num_of_bytes_read; + } + return error; +} + +Status ProcessDebugger::WriteMemory(lldb::addr_t vm_addr, const void *buf, + size_t size, size_t &bytes_written) { + Status error; + bytes_written = 0; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size, + vm_addr); + + if (!m_session_data) { + error.SetErrorString( + "cannot write, there is no active debugger connection."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + void *addr = reinterpret_cast(vm_addr); + SIZE_T num_of_bytes_written = 0; + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (::WriteProcessMemory(handle, addr, buf, size, &num_of_bytes_written)) { + FlushInstructionCache(handle, addr, num_of_bytes_written); + bytes_written = num_of_bytes_written; + } else { + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "writing failed with error: {0}", error); + } + return error; +} + +Status ProcessDebugger::AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) { + Status error; + addr = LLDB_INVALID_ADDRESS; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, + permissions); + + if (!m_session_data) { + error.SetErrorString( + "cannot allocate, there is no active debugger connection"); + LLDB_LOG(log, "error: {0}", error); + return error; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + auto protect = ConvertLldbToWinApiProtect(permissions); + auto result = ::VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); + if (!result) { + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "allocating failed with error: {0}", error); + } else { + addr = reinterpret_cast(result); + } + return error; +} + +Status ProcessDebugger::DeallocateMemory(lldb::addr_t vm_addr) { + Status result; + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to deallocate bytes at address {0}", vm_addr); + + if (!m_session_data) { + result.SetErrorString( + "cannot deallocate, there is no active debugger connection"); + LLDB_LOG(log, "error: {0}", result); + return result; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (!::VirtualFreeEx(handle, reinterpret_cast(vm_addr), 0, + MEM_RELEASE)) { + result.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "deallocating failed with error: {0}", result); + } + + return result; +} + +Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr, + MemoryRegionInfo &info) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + Status error; + llvm::sys::ScopedLock lock(m_mutex); + info.Clear(); + + if (!m_session_data) { + error.SetErrorString( + "GetMemoryRegionInfo called with no debugging session."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (handle == nullptr || handle == LLDB_INVALID_PROCESS) { + error.SetErrorString( + "GetMemoryRegionInfo called with an invalid target process."); + LLDB_LOG(log, "error: {0}", error); + return error; + } + + LLDB_LOG(log, "getting info for address {0:x}", vm_addr); + + void *addr = reinterpret_cast(vm_addr); + MEMORY_BASIC_INFORMATION mem_info = {}; + SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info)); + if (result == 0) { + if (::GetLastError() == ERROR_INVALID_PARAMETER) { + // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with + // an address past the highest accessible address. We should return a + // range from the vm_addr to LLDB_INVALID_ADDRESS + info.GetRange().SetRangeBase(vm_addr); + info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); + info.SetReadable(MemoryRegionInfo::eNo); + info.SetExecutable(MemoryRegionInfo::eNo); + info.SetWritable(MemoryRegionInfo::eNo); + info.SetMapped(MemoryRegionInfo::eNo); + return error; + } else { + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, + "VirtualQueryEx returned error {0} while getting memory " + "region info for address {1:x}", + error, vm_addr); + return error; + } + } + + // Protect bits are only valid for MEM_COMMIT regions. + if (mem_info.State == MEM_COMMIT) { + const bool readable = IsPageReadable(mem_info.Protect); + const bool executable = IsPageExecutable(mem_info.Protect); + const bool writable = IsPageWritable(mem_info.Protect); + info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); + info.SetExecutable(executable ? MemoryRegionInfo::eYes + : MemoryRegionInfo::eNo); + info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); + } else { + info.SetReadable(MemoryRegionInfo::eNo); + info.SetExecutable(MemoryRegionInfo::eNo); + info.SetWritable(MemoryRegionInfo::eNo); + } + + // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE. + if (mem_info.State != MEM_FREE) { + info.GetRange().SetRangeBase( + reinterpret_cast(mem_info.AllocationBase)); + info.GetRange().SetRangeEnd(reinterpret_cast(mem_info.BaseAddress) + + mem_info.RegionSize); + info.SetMapped(MemoryRegionInfo::eYes); + } else { + // In the unmapped case we need to return the distance to the next block of + // memory. VirtualQueryEx nearly does that except that it gives the + // distance from the start of the page containing vm_addr. + SYSTEM_INFO data; + ::GetSystemInfo(&data); + DWORD page_offset = vm_addr % data.dwPageSize; + info.GetRange().SetRangeBase(vm_addr); + info.GetRange().SetByteSize(mem_info.RegionSize - page_offset); + info.SetMapped(MemoryRegionInfo::eNo); + } + + error.SetError(::GetLastError(), eErrorTypeWin32); + LLDB_LOGV(log, + "Memory region info for address {0}: readable={1}, " + "executable={2}, writable={3}", + vm_addr, info.GetReadable(), info.GetExecutable(), + info.GetWritable()); + return error; +} + +void ProcessDebugger::OnExitProcess(uint32_t exit_code) { + // If the process exits before any initial stop then notify the debugger + // of the error otherwise WaitForDebuggerConnection() will be blocked. + // An example of this issue is when a process fails to load a dependent DLL. + if (m_session_data && !m_session_data->m_initial_stop_received) { + Status error(exit_code, eErrorTypeWin32); + OnDebuggerError(error, 0); + } +} + +void ProcessDebugger::OnDebuggerConnected(lldb::addr_t image_base) {} + +ExceptionResult +ProcessDebugger::OnDebugException(bool first_chance, + const ExceptionRecord &record) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION); + llvm::sys::ScopedLock lock(m_mutex); + // FIXME: Without this check, occasionally when running the test suite + // there is an issue where m_session_data can be null. It's not clear how + // this could happen but it only surfaces while running the test suite. In + // order to properly diagnose this, we probably need to first figure allow the + // test suite to print out full lldb logs, and then add logging to the process + // plugin. + if (!m_session_data) { + LLDB_LOG(log, + "Debugger thread reported exception {0:x} at address {1:x}, but " + "there is no session.", + record.GetExceptionCode(), record.GetExceptionAddress()); + return ExceptionResult::SendToApplication; + } + + ExceptionResult result = ExceptionResult::SendToApplication; + if ((record.GetExceptionCode() == EXCEPTION_BREAKPOINT || + record.GetExceptionCode() == + 0x4000001FL /*WOW64 STATUS_WX86_BREAKPOINT*/) && + !m_session_data->m_initial_stop_received) { + // Handle breakpoints at the first chance. + result = ExceptionResult::BreakInDebugger; + LLDB_LOG( + log, + "Hit loader breakpoint at address {0:x}, setting initial stop event.", + record.GetExceptionAddress()); + m_session_data->m_initial_stop_received = true; + ::SetEvent(m_session_data->m_initial_stop_event); + } + return result; +} + +void ProcessDebugger::OnCreateThread(const HostThread &thread) { + // Do nothing by default +} + +void ProcessDebugger::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) { + // Do nothing by default +} + +void ProcessDebugger::OnLoadDll(const ModuleSpec &module_spec, + lldb::addr_t module_addr) { + // Do nothing by default +} + +void ProcessDebugger::OnUnloadDll(lldb::addr_t module_addr) { + // Do nothing by default +} + +void ProcessDebugger::OnDebugString(const std::string &string) {} + +void ProcessDebugger::OnDebuggerError(const Status &error, uint32_t type) { + llvm::sys::ScopedLock lock(m_mutex); + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + + if (m_session_data->m_initial_stop_received) { + // This happened while debugging. Do we shutdown the debugging session, + // try to continue, or do something else? + LLDB_LOG(log, + "Error {0} occurred during debugging. Unexpected behavior " + "may result. {1}", + error.GetError(), error); + } else { + // If we haven't actually launched the process yet, this was an error + // launching the process. Set the internal error and signal the initial + // stop event so that the DoLaunch method wakes up and returns a failure. + m_session_data->m_launch_error = error; + ::SetEvent(m_session_data->m_initial_stop_event); + LLDB_LOG(log, + "Error {0} occurred launching the process before the initial " + "stop. {1}", + error.GetError(), error); + return; + } +} + +Status ProcessDebugger::WaitForDebuggerConnection(DebuggerThreadSP debugger, + HostProcess &process) { + Status result; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS | + WINDOWS_LOG_BREAKPOINTS); + LLDB_LOG(log, "Waiting for loader breakpoint."); + + // Block this function until we receive the initial stop from the process. + if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) == + WAIT_OBJECT_0) { + LLDB_LOG(log, "hit loader breakpoint, returning."); + + process = debugger->GetProcess(); + return m_session_data->m_launch_error; + } else + return Status(::GetLastError(), eErrorTypeWin32); +} + +} // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h new file mode 100644 index 0000000000000..fd0b0e5bc0a27 --- /dev/null +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h @@ -0,0 +1,101 @@ +//===-- ProcessDebugger.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ProcessDebugger_h_ +#define liblldb_ProcessDebugger_h_ + +#include "lldb/Host/windows/windows.h" + +#include "lldb/Utility/Status.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" +#include "llvm/Support/Mutex.h" + +#include "ForwardDecl.h" +#include +#include + +namespace lldb_private { + +class HostProcess; +class HostThread; +class ProcessLaunchInfo; +class ProcessAttachInfo; + +class ProcessWindowsData { +public: + ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) { + m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); + } + + ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); } + + Status m_launch_error; + DebuggerThreadSP m_debugger; + // StopInfoSP m_pending_stop_info; + HANDLE m_initial_stop_event = nullptr; + bool m_initial_stop_received = false; + bool m_stop_at_entry; + std::map m_new_threads; + std::set m_exited_threads; +}; + +class ProcessDebugger { + +public: + virtual void OnExitProcess(uint32_t exit_code); + virtual void OnDebuggerConnected(lldb::addr_t image_base); + virtual ExceptionResult OnDebugException(bool first_chance, + const ExceptionRecord &record); + virtual void OnCreateThread(const HostThread &thread); + virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code); + virtual void OnLoadDll(const ModuleSpec &module_spec, + lldb::addr_t module_addr); + virtual void OnUnloadDll(lldb::addr_t module_addr); + virtual void OnDebugString(const std::string &string); + virtual void OnDebuggerError(const Status &error, uint32_t type); + +protected: + Status DetachProcess(); + + Status LaunchProcess(ProcessLaunchInfo &launch_info, + DebugDelegateSP delegate); + + Status AttachProcess(lldb::pid_t pid, const ProcessAttachInfo &attach_info, + DebugDelegateSP delegate); + + Status DestroyProcess(lldb::StateType process_state); + + Status HaltProcess(bool &caused_stop); + + Status GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info); + + Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read); + + Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, + size_t &bytes_written); + + Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr); + + Status DeallocateMemory(lldb::addr_t addr); + + lldb::pid_t GetDebuggedProcessId() const; + + Status WaitForDebuggerConnection(DebuggerThreadSP debugger, + HostProcess &process); + +protected: + llvm::sys::Mutex m_mutex; + std::unique_ptr m_session_data; +}; + +} // namespace lldb_private + +#endif // #ifndef liblldb_ProcessDebugger_h_ diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index f18cdfb24555f..49801fecdb2c8 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -70,46 +70,10 @@ std::string GetProcessExecutableName(DWORD pid) { } return file_name; } - -DWORD ConvertLldbToWinApiProtect(uint32_t protect) { - // We also can process a read / write permissions here, but if the debugger - // will make later a write into the allocated memory, it will fail. To get - // around it is possible inside DoWriteMemory to remember memory permissions, - // allow write, write and restore permissions, but for now we process only - // the executable permission. - // - // TODO: Process permissions other than executable - if (protect & ePermissionsExecutable) - return PAGE_EXECUTE_READWRITE; - - return PAGE_READWRITE; -} - } // anonymous namespace namespace lldb_private { -// We store a pointer to this class in the ProcessWindows, so that we don't -// expose Windows-specific types and implementation details from a public -// header file. -class ProcessWindowsData { -public: - ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) { - m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); - } - - ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); } - - Status m_launch_error; - DebuggerThreadSP m_debugger; - StopInfoSP m_pending_stop_info; - HANDLE m_initial_stop_event = nullptr; - bool m_initial_stop_received = false; - bool m_stop_at_entry; - std::map m_new_threads; - std::set m_exited_threads; -}; - ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *) { @@ -192,159 +156,41 @@ Status ProcessWindows::DisableBreakpointSite(BreakpointSite *bp_site) { } Status ProcessWindows::DoDetach(bool keep_stopped) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - DebuggerThreadSP debugger_thread; - StateType private_state; - { - // Acquire the lock only long enough to get the DebuggerThread. - // StopDebugging() will trigger a call back into ProcessWindows which will - // also acquire the lock. Thus we have to release the lock before calling - // StopDebugging(). - llvm::sys::ScopedLock lock(m_mutex); - - private_state = GetPrivateState(); - - if (!m_session_data) { - LLDB_LOG(log, "state = {0}, but there is no active session.", - private_state); - return Status(); - } - - debugger_thread = m_session_data->m_debugger; - } - Status error; + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); + StateType private_state = GetPrivateState(); if (private_state != eStateExited && private_state != eStateDetached) { - LLDB_LOG(log, "detaching from process {0} while state = {1}.", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), - private_state); - error = debugger_thread->StopDebugging(false); - if (error.Success()) { + error = DetachProcess(); + if (error.Success()) SetPrivateState(eStateDetached); - } - - // By the time StopDebugging returns, there is no more debugger thread, so - // we can be assured that no other thread will race for the session data. - m_session_data.reset(); + else + LLDB_LOG(log, "Detaching process error: {0}", error); } else { - LLDB_LOG( - log, - "error: process {0} in state = {1}, but cannot destroy in this state.", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), - private_state); + error.SetErrorStringWithFormat("error: process {0} in state = {1}, but " + "cannot detach it in this state.", + GetID(), private_state); + LLDB_LOG(log, "error: {0}", error); } - return error; } Status ProcessWindows::DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) { - // Even though m_session_data is accessed here, it is before a debugger - // thread has been kicked off. So there's no race conditions, and it - // shouldn't be necessary to acquire the mutex. - - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - Status result; - - FileSpec working_dir = launch_info.GetWorkingDirectory(); - namespace fs = llvm::sys::fs; - if (working_dir) { - FileSystem::Instance().Resolve(working_dir); - if (!FileSystem::Instance().IsDirectory(working_dir)) { - result.SetErrorStringWithFormat("No such file or directory: %s", - working_dir.GetCString()); - return result; - } - } - - if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) { - StreamString stream; - stream.Printf("ProcessWindows unable to launch '%s'. ProcessWindows can " - "only be used for debug launches.", - launch_info.GetExecutableFile().GetPath().c_str()); - std::string message = stream.GetString(); - result.SetErrorString(message.c_str()); - - LLDB_LOG(log, "error: {0}", message); - return result; - } - - bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry); - m_session_data.reset(new ProcessWindowsData(stop_at_entry)); - + Status error; DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this())); - m_session_data->m_debugger.reset(new DebuggerThread(delegate)); - DebuggerThreadSP debugger = m_session_data->m_debugger; - - // Kick off the DebugLaunch asynchronously and wait for it to complete. - result = debugger->DebugLaunch(launch_info); - if (result.Fail()) { - LLDB_LOG(log, "failed launching '{0}'. {1}", - launch_info.GetExecutableFile().GetPath(), result); - return result; - } - - HostProcess process; - Status error = WaitForDebuggerConnection(debugger, process); - if (error.Fail()) { - LLDB_LOG(log, "failed launching '{0}'. {1}", - launch_info.GetExecutableFile().GetPath(), error); - return error; - } - - LLDB_LOG(log, "successfully launched '{0}'", - launch_info.GetExecutableFile().GetPath()); - - // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the - // private state should already be set to eStateStopped as a result of - // hitting the initial breakpoint. If it was not set, the breakpoint should - // have already been resumed from and the private state should already be - // eStateRunning. - launch_info.SetProcessID(process.GetProcessId()); - SetID(process.GetProcessId()); - - return result; + error = LaunchProcess(launch_info, delegate); + if (error.Success()) + SetID(launch_info.GetProcessID()); + return error; } Status ProcessWindows::DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - m_session_data.reset( - new ProcessWindowsData(!attach_info.GetContinueOnceAttached())); - DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this())); - DebuggerThreadSP debugger(new DebuggerThread(delegate)); - - m_session_data->m_debugger = debugger; - - DWORD process_id = static_cast(pid); - Status error = debugger->DebugAttach(process_id, attach_info); - if (error.Fail()) { - LLDB_LOG( - log, - "encountered an error occurred initiating the asynchronous attach. {0}", - error); - return error; - } - - HostProcess process; - error = WaitForDebuggerConnection(debugger, process); - if (error.Fail()) { - LLDB_LOG(log, - "encountered an error waiting for the debugger to connect. {0}", - error); - return error; - } - - LLDB_LOG(log, "successfully attached to process with pid={0}", process_id); - - // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the - // private state should already be set to eStateStopped as a result of - // hitting the initial breakpoint. If it was not set, the breakpoint should - // have already been resumed from and the private state should already be - // eStateRunning. - SetID(process.GetProcessId()); + Status error = AttachProcess(pid, attach_info, delegate); + if (error.Success()) + SetID(GetDebuggedProcessId()); return error; } @@ -400,63 +246,16 @@ Status ProcessWindows::DoResume() { } Status ProcessWindows::DoDestroy() { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - DebuggerThreadSP debugger_thread; - StateType private_state; - { - // Acquire this lock inside an inner scope, only long enough to get the - // DebuggerThread. StopDebugging() will trigger a call back into - // ProcessWindows which will acquire the lock again, so we need to not - // deadlock. - llvm::sys::ScopedLock lock(m_mutex); - - private_state = GetPrivateState(); - - if (!m_session_data) { - LLDB_LOG(log, "warning: state = {0}, but there is no active session.", - private_state); - return Status(); - } - - debugger_thread = m_session_data->m_debugger; - } - - Status error; - if (private_state != eStateExited && private_state != eStateDetached) { - LLDB_LOG(log, "Shutting down process {0} while state = {1}.", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), - private_state); - error = debugger_thread->StopDebugging(true); - - // By the time StopDebugging returns, there is no more debugger thread, so - // we can be assured that no other thread will race for the session data. - m_session_data.reset(); - } else { - LLDB_LOG(log, "cannot destroy process {0} while state = {1}", - debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), - private_state); - } - - return error; + StateType private_state = GetPrivateState(); + return DestroyProcess(private_state); } Status ProcessWindows::DoHalt(bool &caused_stop) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); - Status error; StateType state = GetPrivateState(); - if (state == eStateStopped) - caused_stop = false; - else { - llvm::sys::ScopedLock lock(m_mutex); - caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess() - .GetNativeProcess() - .GetSystemHandle()); - if (!caused_stop) { - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error); - } - } - return error; + if (state != eStateStopped) + return HaltProcess(caused_stop); + caused_stop = false; + return Status(); } void ProcessWindows::DidLaunch() { @@ -729,198 +528,32 @@ bool ProcessWindows::IsAlive() { size_t ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - - if (!m_session_data) - return 0; - - LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size, - vm_addr); - - HostProcess process = m_session_data->m_debugger->GetProcess(); - void *addr = reinterpret_cast(vm_addr); - SIZE_T bytes_read = 0; - if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, - buf, size, &bytes_read)) { - // Reading from the process can fail for a number of reasons - set the - // error code and make sure that the number of bytes read is set back to 0 - // because in some scenarios the value of bytes_read returned from the API - // is garbage. - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "reading failed with error: {0}", error); - bytes_read = 0; - } + size_t bytes_read = 0; + error = ProcessDebugger::ReadMemory(vm_addr, buf, size, bytes_read); return bytes_read; } size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size, - vm_addr); - - if (!m_session_data) { - LLDB_LOG(log, "cannot write, there is no active debugger connection."); - return 0; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - void *addr = reinterpret_cast(vm_addr); - SIZE_T bytes_written = 0; - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (WriteProcessMemory(handle, addr, buf, size, &bytes_written)) - FlushInstructionCache(handle, addr, bytes_written); - else { - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "writing failed with error: {0}", error); - } + size_t bytes_written = 0; + error = ProcessDebugger::WriteMemory(vm_addr, buf, size, bytes_written); return bytes_written; } lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t permissions, Status &error) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, - permissions); - - if (!m_session_data) { - LLDB_LOG(log, "cannot allocate, there is no active debugger connection."); - error.SetErrorString( - "cannot allocate, there is no active debugger connection"); - return LLDB_INVALID_ADDRESS; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - auto protect = ConvertLldbToWinApiProtect(permissions); - auto result = VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); - if (!result) { - error.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "allocating failed with error: {0}", error); - return LLDB_INVALID_ADDRESS; - } - - return reinterpret_cast(result); + lldb::addr_t vm_addr = LLDB_INVALID_ADDRESS; + error = ProcessDebugger::AllocateMemory(size, permissions, vm_addr); + return vm_addr; } Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) { - Status result; - - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - llvm::sys::ScopedLock lock(m_mutex); - LLDB_LOG(log, "attempting to deallocate bytes at address {0}", ptr); - - if (!m_session_data) { - LLDB_LOG(log, "cannot deallocate, there is no active debugger connection."); - result.SetErrorString( - "cannot deallocate, there is no active debugger connection"); - return result; - } - - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (!VirtualFreeEx(handle, reinterpret_cast(ptr), 0, MEM_RELEASE)) { - result.SetError(GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, "deallocating failed with error: {0}", result); - return result; - } - - return result; + return ProcessDebugger::DeallocateMemory(ptr); } Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) { - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); - Status error; - llvm::sys::ScopedLock lock(m_mutex); - info.Clear(); - - if (!m_session_data) { - error.SetErrorString( - "GetMemoryRegionInfo called with no debugging session."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - HostProcess process = m_session_data->m_debugger->GetProcess(); - lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); - if (handle == nullptr || handle == LLDB_INVALID_PROCESS) { - error.SetErrorString( - "GetMemoryRegionInfo called with an invalid target process."); - LLDB_LOG(log, "error: {0}", error); - return error; - } - - LLDB_LOG(log, "getting info for address {0:x}", vm_addr); - - void *addr = reinterpret_cast(vm_addr); - MEMORY_BASIC_INFORMATION mem_info = {}; - SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info)); - if (result == 0) { - if (::GetLastError() == ERROR_INVALID_PARAMETER) { - // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with - // an address past the highest accessible address. We should return a - // range from the vm_addr to LLDB_INVALID_ADDRESS - info.GetRange().SetRangeBase(vm_addr); - info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); - info.SetReadable(MemoryRegionInfo::eNo); - info.SetExecutable(MemoryRegionInfo::eNo); - info.SetWritable(MemoryRegionInfo::eNo); - info.SetMapped(MemoryRegionInfo::eNo); - return error; - } else { - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOG(log, - "VirtualQueryEx returned error {0} while getting memory " - "region info for address {1:x}", - error, vm_addr); - return error; - } - } - - // Protect bits are only valid for MEM_COMMIT regions. - if (mem_info.State == MEM_COMMIT) { - const bool readable = IsPageReadable(mem_info.Protect); - const bool executable = IsPageExecutable(mem_info.Protect); - const bool writable = IsPageWritable(mem_info.Protect); - info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); - info.SetExecutable(executable ? MemoryRegionInfo::eYes - : MemoryRegionInfo::eNo); - info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); - } else { - info.SetReadable(MemoryRegionInfo::eNo); - info.SetExecutable(MemoryRegionInfo::eNo); - info.SetWritable(MemoryRegionInfo::eNo); - } - - // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE. - if (mem_info.State != MEM_FREE) { - info.GetRange().SetRangeBase( - reinterpret_cast(mem_info.AllocationBase)); - info.GetRange().SetRangeEnd(reinterpret_cast(mem_info.BaseAddress) + - mem_info.RegionSize); - info.SetMapped(MemoryRegionInfo::eYes); - } else { - // In the unmapped case we need to return the distance to the next block of - // memory. VirtualQueryEx nearly does that except that it gives the - // distance from the start of the page containing vm_addr. - SYSTEM_INFO data; - GetSystemInfo(&data); - DWORD page_offset = vm_addr % data.dwPageSize; - info.GetRange().SetRangeBase(vm_addr); - info.GetRange().SetByteSize(mem_info.RegionSize - page_offset); - info.SetMapped(MemoryRegionInfo::eNo); - } - - error.SetError(::GetLastError(), eErrorTypeWin32); - LLDB_LOGV(log, - "Memory region info for address {0}: readable={1}, " - "executable={2}, writable={3}", - vm_addr, info.GetReadable(), info.GetExecutable(), - info.GetWritable()); - return error; + return ProcessDebugger::GetMemoryRegionInfo(vm_addr, info); } lldb::addr_t ProcessWindows::GetImageInfoAddress() { @@ -963,6 +596,9 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) { Status error(exit_code, eErrorTypeWin32); OnDebuggerError(error, 0); } + + // Reset the session. + m_session_data.reset(); } void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { @@ -1135,41 +771,4 @@ void ProcessWindows::OnDebuggerError(const Status &error, uint32_t type) { return; } } - -Status ProcessWindows::WaitForDebuggerConnection(DebuggerThreadSP debugger, - HostProcess &process) { - Status result; - Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS | - WINDOWS_LOG_BREAKPOINTS); - LLDB_LOG(log, "Waiting for loader breakpoint."); - - // Block this function until we receive the initial stop from the process. - if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) == - WAIT_OBJECT_0) { - LLDB_LOG(log, "hit loader breakpoint, returning."); - - process = debugger->GetProcess(); - return m_session_data->m_launch_error; - } else - return Status(::GetLastError(), eErrorTypeWin32); -} - -// The Windows page protection bits are NOT independent masks that can be -// bitwise-ORed together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE -// | PAGE_READ). To test for an access type, it's necessary to test for any of -// the bits that provide that access type. -bool ProcessWindows::IsPageReadable(uint32_t protect) { - return (protect & PAGE_NOACCESS) == 0; -} - -bool ProcessWindows::IsPageWritable(uint32_t protect) { - return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | - PAGE_READWRITE | PAGE_WRITECOPY)) != 0; -} - -bool ProcessWindows::IsPageExecutable(uint32_t protect) { - return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | - PAGE_EXECUTE_WRITECOPY)) != 0; -} - } // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h index 1b1f173a36451..8d5134a49a429 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h @@ -13,17 +13,14 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" -#include "llvm/Support/Mutex.h" - -#include "IDebugDelegate.h" #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" +#include "ProcessDebugger.h" namespace lldb_private { class HostProcess; -class ProcessWindowsData; -class ProcessWindows : public Process, public IDebugDelegate { +class ProcessWindows : public Process, public ProcessDebugger { public: // Static functions. static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, @@ -101,19 +98,7 @@ class ProcessWindows : public Process, public IDebugDelegate { void OnUnloadDll(lldb::addr_t module_addr) override; void OnDebugString(const std::string &string) override; void OnDebuggerError(const Status &error, uint32_t type) override; - -private: - Status WaitForDebuggerConnection(DebuggerThreadSP debugger, - HostProcess &process); - - // These decode the page protection bits. - static bool IsPageReadable(uint32_t protect); - static bool IsPageWritable(uint32_t protect); - static bool IsPageExecutable(uint32_t protect); - - llvm::sys::Mutex m_mutex; - std::unique_ptr m_session_data; }; -} +} // namespace lldb_private #endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_ From 16fede6c4e9031273c1d1f5374ca3829111b0c25 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Wed, 10 Jul 2019 03:41:34 +0000 Subject: [PATCH 071/616] Revert accidental change to file llvm-svn: 365593 (cherry picked from commit 6858f337a8331472b25d059092e5350c68a164fc) --- lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp index 14c7e471edfb9..aa9871071b0e0 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp @@ -180,9 +180,6 @@ unsigned ELFHeader::GetRelocationJumpSlotType() const { default: assert(false && "architecture not supported"); break; - case EM_CASCADE: - slot = R_CASCADE_JUMP_SLOT; - break; case EM_PPC: slot = R_PPC_JMP_SLOT; break; From ef32469d662b34c06ea46735ecfeb53913281ade Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 11:09:01 +0000 Subject: [PATCH 072/616] [CMake] Remove extra lldb-framework target Summary: The custom lldb-framework target was meant to encapsulate all build steps that LLDB.framework needs on top of the ordinaly liblldb. In the end all of it happens in post-build steps, so we can do the same with liblldb and cut down another source of confusion. Reviewers: xiaobai, JDevlieghere Reviewed By: xiaobai, JDevlieghere Subscribers: mgorny, lldb-commits, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D64397 llvm-svn: 365615 (cherry picked from commit 685911ffce95e4541fcd003d13725f771d931290) --- lldb/CMakeLists.txt | 4 ---- lldb/cmake/modules/LLDBFramework.cmake | 16 ++++++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 280c3a29984a3..0f9e3c68d49cb 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -205,10 +205,6 @@ if (NOT LLDB_DISABLE_PYTHON) # Ensure we do the python post-build step when building lldb. add_dependencies(lldb finish_swig) - if(LLDB_BUILD_FRAMEWORK) - add_dependencies(lldb-framework finish_swig) - endif() - # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching # lldb.exe or any other executables that were linked with liblldb. if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "") diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 96ffb52585573..56e0880b42317 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -42,12 +42,8 @@ else() XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") endif() -# Target to capture extra steps for a fully functional framework bundle. -add_custom_target(lldb-framework ALL) -add_dependencies(lldb-framework liblldb) - # Apart from this one, CMake creates all required symlinks in the framework bundle. -add_custom_command(TARGET lldb-framework POST_BUILD +add_custom_command(TARGET liblldb POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${framework_target_dir}/LLDB.framework/Headers @@ -79,12 +75,12 @@ foreach(header endforeach() # Wrap output in a target, so lldb-framework can depend on it. -add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers}) -add_dependencies(lldb-framework lldb-framework-headers) +add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers}) +add_dependencies(liblldb liblldb-resource-headers) # At build time, copy the staged headers into the framework bundle (and do # some post-processing in-place). -add_custom_command(TARGET lldb-framework-headers POST_BUILD +add_custom_command(TARGET liblldb POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $/Headers COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $/Headers ${LLDB_VERSION} COMMENT "LLDB.framework: copy framework headers" @@ -93,7 +89,7 @@ add_custom_command(TARGET lldb-framework-headers POST_BUILD # Copy vendor-specific headers from clang (without staging). if(NOT IOS) if (TARGET clang-resource-headers) - add_dependencies(lldb-framework clang-resource-headers) + add_dependencies(liblldb clang-resource-headers) set(clang_resource_headers_dir $) else() # In standalone builds try the best possible guess @@ -115,7 +111,7 @@ if(NOT IOS) endif() endif() - add_custom_command(TARGET lldb-framework POST_BUILD + add_custom_command(TARGET liblldb POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${clang_resource_headers_dir} $/Resources/Clang/include From 5ecde906bd91cc3d2db4b9fa541afe714924b199 Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 11:09:11 +0000 Subject: [PATCH 073/616] [CMake] Distribution builds for LLDB standalone Summary: Enable `distribution` and `install-distribution` targets in LLDB standalone and pre-populate the cache accordingly on macOS. Documentation for distribution builds is here: https://llvm.org/docs/BuildingADistribution.html Reviewers: xiaobai, mgorny, JDevlieghere, davide, compnerd Reviewed By: xiaobai, JDevlieghere Subscribers: lldb-commits, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D64399 llvm-svn: 365616 (cherry picked from commit 05adc0f3170eb0b3e7cd4522b1a5d19e14691adf) --- lldb/CMakeLists.txt | 4 ++++ lldb/cmake/caches/Apple-lldb-macOS.cmake | 10 +++++++++- lldb/cmake/modules/LLDBStandalone.cmake | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 0f9e3c68d49cb..3217cb14384c2 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -218,3 +218,7 @@ if (NOT LLDB_DISABLE_PYTHON) COMMENT "Copying Python DLL to LLDB binaries directory.") endif () endif () + +if(LLDB_BUILT_STANDALONE) + llvm_distribution_add_targets() +endif() diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake index 81ff59385cf82..944fc906c5134 100644 --- a/lldb/cmake/caches/Apple-lldb-macOS.cmake +++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake @@ -15,5 +15,13 @@ set(LLDB_FRAMEWORK_INSTALL_DIR /Applications/Xcode.app/Contents/SharedFrameworks # Release builds may change these: set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "") -set(LLDB_USE_SYSTEM_DEBUGSERVER ON CACHE BOOL "") +set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "") + +set(LLVM_DISTRIBUTION_COMPONENTS + lldb + liblldb + lldb-argdumper + darwin-debug + debugserver + CACHE STRING "") diff --git a/lldb/cmake/modules/LLDBStandalone.cmake b/lldb/cmake/modules/LLDBStandalone.cmake index 8c30f84f07042..afe4cbbe08f7a 100644 --- a/lldb/cmake/modules/LLDBStandalone.cmake +++ b/lldb/cmake/modules/LLDBStandalone.cmake @@ -85,6 +85,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) include(TableGen) include(HandleLLVMOptions) include(CheckAtomic) + include(LLVMDistributionSupport) if (PYTHON_EXECUTABLE STREQUAL "") set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5) From f07fa61fcbf95728fb4c4e9784eca66cf1808c6a Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 11:09:29 +0000 Subject: [PATCH 074/616] [CMake] `install-distribution` for LLDB on Darwin Summary: There's a number of requirements for installing LLDB on macOS that are untypical for LLVM projects: use special install-prefix for LLDB.framework, ship headers and tools as framework resources, patch RPATHs, externalize debug-info to dSYM's and strip binaries with `-ST`. For some of it we could use `llvm_externalize_debuginfo()` in the past and just add special cases. However, this complicates the code for all projects and comes with the major drawback, that it adds all these actions at build-time, i.e. dSYM creation and stripping take a lot of time and don't make sense at build-time. LLVM's distribution mechanism (https://llvm.org/docs/BuildingADistribution.html) appears to be the natural candidate to install LLDB. Based on D64399 (enable in standalone builds), this patch integrates framework installation with the distribution mechanism and adds custom stripping flags and dSYM creation at install-time. Unlike the abandoned D61952, it leaves build-tree binaries untouched, so there's no side-effects on testing. Potential install-order issues must be handled externally. Please let me know what you think, while I run a few more tests and add remarks+documentation. Reviewers: xiaobai, compnerd, JDevlieghere, davide, labath, mgorny Reviewed By: xiaobai, JDevlieghere Subscribers: lldb-commits, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D64408 llvm-svn: 365617 (cherry picked from commit 110f97632e119d289e4bd9b5c01f0a300b8d2185) --- lldb/cmake/caches/Apple-lldb-macOS.cmake | 3 + lldb/cmake/modules/AddLLDB.cmake | 138 +++++++++++++------ lldb/cmake/modules/LLDBConfig.cmake | 9 +- lldb/cmake/modules/LLDBFramework.cmake | 2 + lldb/source/API/CMakeLists.txt | 8 +- lldb/tools/argdumper/CMakeLists.txt | 8 +- lldb/tools/darwin-debug/CMakeLists.txt | 8 +- lldb/tools/debugserver/source/CMakeLists.txt | 16 +-- 8 files changed, 118 insertions(+), 74 deletions(-) diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake index 944fc906c5134..e1a34ad326ac6 100644 --- a/lldb/cmake/caches/Apple-lldb-macOS.cmake +++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake @@ -13,6 +13,9 @@ set(CMAKE_INSTALL_PREFIX /Applications/Xcode.app/Contents/Developer/usr CACHE ST # CMAKE_INSTALL_PREFIX. In any case, DESTDIR will be an extra prefix. set(LLDB_FRAMEWORK_INSTALL_DIR /Applications/Xcode.app/Contents/SharedFrameworks CACHE STRING "") +# DESTDIR will be an extra prefix +set(LLDB_DEBUGINFO_INSTALL_PREFIX /debuginfo CACHE STRING "") + # Release builds may change these: set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "") set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "") diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 65d34f8d7e74e..f7f201ea1fdfc 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -36,7 +36,7 @@ function(add_lldb_library name) # MODULE;SHARED;STATIC library type and source files cmake_parse_arguments(PARAM "MODULE;SHARED;STATIC;OBJECT;PLUGIN" - "ENTITLEMENTS" + "INSTALL_PREFIX;ENTITLEMENTS" "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS" ${ARGN}) llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS}) @@ -91,38 +91,26 @@ function(add_lldb_library name) ${pass_ENTITLEMENTS} ${pass_NO_INSTALL_RPATH} ) + endif() - if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb") - if (PARAM_SHARED) - if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK) - if(LLDB_FRAMEWORK_INSTALL_DIR) - set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) - else() - set(install_dir ".") - endif() - else() - set(install_dir lib${LLVM_LIBDIR_SUFFIX}) - endif() - install(TARGETS ${name} - COMPONENT ${name} - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${install_dir} - ARCHIVE DESTINATION ${install_dir}) - else() - install(TARGETS ${name} - COMPONENT ${name} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) - endif() - if (NOT CMAKE_CONFIGURATION_TYPES) - add_llvm_install_targets(install-${name} - DEPENDS ${name} - COMPONENT ${name}) - endif() + if(PARAM_SHARED) + set(install_dest lib${LLVM_LIBDIR_SUFFIX}) + if(PARAM_INSTALL_PREFIX) + set(install_dest ${PARAM_INSTALL_PREFIX}) + endif() + # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS + install(TARGETS ${name} COMPONENT ${name} + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${install_dest} + ARCHIVE DESTINATION ${install_dest} + FRAMEWORK DESTINATION ${install_dest}) + if (NOT CMAKE_CONFIGURATION_TYPES) + add_llvm_install_targets(install-${name} + DEPENDS ${name} + COMPONENT ${name}) endif() endif() - # Hack: only some LLDB libraries depend on the clang autogenerated headers, # but it is simple enough to make all of LLDB depend on some of those # headers without negatively impacting much of anything. @@ -143,7 +131,7 @@ endfunction(add_lldb_library) function(add_lldb_executable name) cmake_parse_arguments(ARG "GENERATE_INSTALL" - "ENTITLEMENTS" + "INSTALL_PREFIX;ENTITLEMENTS" "LINK_LIBS;LINK_COMPONENTS" ${ARGN} ) @@ -167,16 +155,22 @@ function(add_lldb_executable name) set_target_properties(${name} PROPERTIES FOLDER "lldb executables") if(ARG_GENERATE_INSTALL) - install(TARGETS ${name} - COMPONENT ${name} - RUNTIME DESTINATION bin) + set(install_dest bin) + if(ARG_INSTALL_PREFIX) + set(install_dest ${ARG_INSTALL_PREFIX}) + endif() + install(TARGETS ${name} COMPONENT ${name} + RUNTIME DESTINATION ${install_dest}) if (NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} DEPENDS ${name} COMPONENT ${name}) endif() + if(APPLE AND ARG_INSTALL_PREFIX) + lldb_add_post_install_steps_darwin(${name} ${ARG_INSTALL_PREFIX}) + endif() endif() -endfunction(add_lldb_executable) +endfunction() macro(add_lldb_tool_subdirectory name) @@ -184,7 +178,19 @@ macro(add_lldb_tool_subdirectory name) endmacro() function(add_lldb_tool name) - add_lldb_executable(${name} GENERATE_INSTALL ${ARGN}) + cmake_parse_arguments(ARG "ADD_TO_FRAMEWORK" "" "" ${ARGN}) + if(LLDB_BUILD_FRAMEWORK AND ARG_ADD_TO_FRAMEWORK) + set(subdir LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources) + add_lldb_executable(${name} + GENERATE_INSTALL + INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR}/${subdir} + ${ARG_UNPARSED_ARGUMENTS} + ) + lldb_add_to_buildtree_lldb_framework(${name} ${subdir}) + return() + endif() + + add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS}) endfunction() # Support appending linker flags to an existing target. @@ -203,12 +209,7 @@ function(lldb_append_link_flags target_name new_link_flags) set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) endfunction() -# Unified handling for executable LLDB.framework resources. Given the name of an -# executable target, this function adds a post-build step to copy it to the -# framework bundle in the build-tree. -function(lldb_add_to_framework name) - set(subdir "LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources") - +function(lldb_add_to_buildtree_lldb_framework name subdir) # Destination for the copy in the build-tree. While the framework target may # not exist yet, it will exist when the generator expression gets expanded. set(copy_dest "$/../../../${subdir}") @@ -220,6 +221,61 @@ function(lldb_add_to_framework name) ) endfunction() +function(lldb_add_post_install_steps_darwin name install_prefix) + if(NOT APPLE) + message(WARNING "Darwin-specific functionality; not currently available on non-Apple platforms.") + return() + endif() + + get_target_property(output_name ${name} OUTPUT_NAME) + if(NOT output_name) + set(output_name ${name}) + endif() + + get_target_property(is_framework ${name} FRAMEWORK) + if(is_framework) + get_target_property(buildtree_dir ${name} LIBRARY_OUTPUT_DIRECTORY) + if(buildtree_dir) + set(bundle_subdir ${output_name}.framework/Versions/${LLDB_FRAMEWORK_VERSION}/) + else() + message(SEND_ERROR "Framework target ${name} missing property for output directory. Cannot generate post-install steps.") + return() + endif() + else() + get_target_property(target_type ${name} TYPE) + if(target_type STREQUAL "EXECUTABLE") + set(buildtree_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) + else() + # Only ever install shared libraries. + set(output_name "lib${output_name}.dylib") + set(buildtree_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}) + endif() + endif() + + # Generate dSYM in symroot + set(dsym_name ${output_name}.dSYM) + if(is_framework) + set(dsym_name ${output_name}.framework.dSYM) + endif() + if(LLDB_DEBUGINFO_INSTALL_PREFIX) + # This makes the path absolute, so we must respect DESTDIR. + set(dsym_name "\$ENV\{DESTDIR\}${LLDB_DEBUGINFO_INSTALL_PREFIX}/${dsym_name}") + endif() + + set(buildtree_name ${buildtree_dir}/${bundle_subdir}${output_name}) + install(CODE "message(STATUS \"Externalize debuginfo: ${dsym_name}\")" COMPONENT ${name}) + install(CODE "execute_process(COMMAND xcrun dsymutil -o=${dsym_name} ${buildtree_name})" + COMPONENT ${name}) + + # Strip distribution binary with -ST (removing debug symbol table entries and + # Swift symbols). Avoid CMAKE_INSTALL_DO_STRIP and llvm_externalize_debuginfo() + # as they can't be configured sufficiently. + set(installtree_name "\$ENV\{DESTDIR\}${install_prefix}/${bundle_subdir}${output_name}") + install(CODE "message(STATUS \"Stripping: ${installtree_name}\")" COMPONENT ${name}) + install(CODE "execute_process(COMMAND xcrun strip -ST ${installtree_name})" + COMPONENT ${name}) +endfunction() + # CMake's set_target_properties() doesn't allow to pass lists for RPATH # properties directly (error: "called with incorrect number of arguments"). # Instead of defining two list variables each time, use this helper function. diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index e65b4bd97732f..ef9356591c301 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -65,12 +65,9 @@ if(LLDB_BUILD_FRAMEWORK) set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework") set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework") - # Set designated directory for all dSYMs. Essentially, this emits the - # framework's dSYM outside of the framework directory. - if(LLVM_EXTERNALIZE_DEBUGINFO) - set(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING - "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)") - endif() + # Essentially, emit the framework's dSYM outside of the framework directory. + set(LLDB_DEBUGINFO_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING + "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)") endif() if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 56e0880b42317..f5f3cd4d60ac2 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -33,6 +33,8 @@ set_output_directory(liblldb LIBRARY_DIR ${framework_target_dir} ) +lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR}) + # Affects the layout of the framework bundle (default is macOS layout). if(IOS) set_target_properties(liblldb PROPERTIES diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index 8d2b7f06bef0d..d93b8b5e381db 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -9,8 +9,8 @@ if(NOT LLDB_DISABLE_PYTHON) set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp) endif() -if(LLDB_BUILD_FRAMEWORK AND LLVM_EXTERNALIZE_DEBUGINFO) - set(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION framework.dSYM) +if(LLDB_BUILD_FRAMEWORK) + set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR}) endif() add_lldb_library(liblldb SHARED @@ -99,7 +99,9 @@ add_lldb_library(liblldb SHARED ${LLDB_ALL_PLUGINS} LINK_COMPONENTS Support - ) + + ${option_install_prefix} +) if (MSVC) set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/lldb/tools/argdumper/CMakeLists.txt b/lldb/tools/argdumper/CMakeLists.txt index af9374b7ea859..d0767483781fe 100644 --- a/lldb/tools/argdumper/CMakeLists.txt +++ b/lldb/tools/argdumper/CMakeLists.txt @@ -1,10 +1,6 @@ -add_lldb_tool(lldb-argdumper +add_lldb_tool(lldb-argdumper ADD_TO_FRAMEWORK argdumper.cpp LINK_LIBS lldbUtility - ) - -if(LLDB_BUILD_FRAMEWORK) - lldb_add_to_framework(lldb-argdumper) -endif() +) diff --git a/lldb/tools/darwin-debug/CMakeLists.txt b/lldb/tools/darwin-debug/CMakeLists.txt index 6b9eac31fe51b..b902788f05ab2 100644 --- a/lldb/tools/darwin-debug/CMakeLists.txt +++ b/lldb/tools/darwin-debug/CMakeLists.txt @@ -1,7 +1,3 @@ -add_lldb_tool(darwin-debug +add_lldb_tool(darwin-debug ADD_TO_FRAMEWORK darwin-debug.cpp - ) - -if(LLDB_BUILD_FRAMEWORK) - lldb_add_to_framework(darwin-debug) -endif() +) diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt index 863afaaecfbeb..cf305c9d26803 100644 --- a/lldb/tools/debugserver/source/CMakeLists.txt +++ b/lldb/tools/debugserver/source/CMakeLists.txt @@ -272,22 +272,14 @@ if(build_and_sign_debugserver) COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION) endif() set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources}) - add_lldb_tool(debugserver + add_lldb_tool(debugserver ADD_TO_FRAMEWORK debugserver.cpp - - LINK_LIBS - lldbDebugserverCommon - - ENTITLEMENTS - ${entitlements} - ) + LINK_LIBS lldbDebugserverCommon + ENTITLEMENTS ${entitlements} + ) set_target_properties(debugserver PROPERTIES FOLDER "lldb libraries/debugserver") - if(LLDB_BUILD_FRAMEWORK) - lldb_add_to_framework(debugserver) - endif() - if(IOS) set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS WITH_LOCKDOWN From e9bf5e5e7c84b40fbda2bcd501417f9d925995bb Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 15:59:50 +0000 Subject: [PATCH 075/616] [CMake] Polish Apple-lldb caches llvm-svn: 365648 (cherry picked from commit 839e305eb143dbc172f90a09fd1b245eb012aefc) --- lldb/cmake/caches/Apple-lldb-base.cmake | 6 ------ lldb/cmake/caches/Apple-lldb-macOS.cmake | 20 ++++++++------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake b/lldb/cmake/caches/Apple-lldb-base.cmake index 6cd69e8bd180a..76ab843c4b6b7 100644 --- a/lldb/cmake/caches/Apple-lldb-base.cmake +++ b/lldb/cmake/caches/Apple-lldb-base.cmake @@ -7,9 +7,3 @@ set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") - -# Release builds set these explicitly: -#set(LLDB_VERSION_MAJOR 9999 CACHE STRING "") -#set(LLDB_VERSION_MINOR 9 CACHE STRING "") -#set(LLDB_VERSION_PATCH 9 CACHE STRING "") -#set(LLDB_VERSION_SUFFIX git CACHE STRING "") diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake index e1a34ad326ac6..50421d269c9e4 100644 --- a/lldb/cmake/caches/Apple-lldb-macOS.cmake +++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake @@ -2,25 +2,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake) set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "") set(LLDB_NO_INSTALL_DEFAULT_RPATH ON CACHE BOOL "") +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "") -# Set the install prefix to the default install location on the enduser machine. -# If the location is not writeable on the build machine, specify another prefix -# in the DESTDIR environment variable, e.g.: DESTDIR=/tmp ninja install +# Default install location on the enduser machine. On the build machine, use the +# DESTDIR environment variable in order to relocate the whole installation, e.g.: +# `DESTDIR=/tmp ninja install-distribution` set(CMAKE_INSTALL_PREFIX /Applications/Xcode.app/Contents/Developer/usr CACHE STRING "") -# Choose the install location for LLDB.framework so that it matches the -# INSTALL_RPATH of the lldb driver. It's either absolute or relative to -# CMAKE_INSTALL_PREFIX. In any case, DESTDIR will be an extra prefix. +# Install location for LLDB.framework on the enduser machine. +# DESTDIR will be an extra prefix. set(LLDB_FRAMEWORK_INSTALL_DIR /Applications/Xcode.app/Contents/SharedFrameworks CACHE STRING "") -# DESTDIR will be an extra prefix +# Install location for externalized debug-info on the build machine. +# DESTDIR will be an extra prefix. set(LLDB_DEBUGINFO_INSTALL_PREFIX /debuginfo CACHE STRING "") -# Release builds may change these: -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "") -set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "") -set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "") - set(LLVM_DISTRIBUTION_COMPONENTS lldb liblldb From eb9c39b9879c15fd04c2a1b1f9b16f2daa786378 Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 15:59:56 +0000 Subject: [PATCH 076/616] [CMake] Add Apple-lldb-Linux.cmake cache llvm-svn: 365649 (cherry picked from commit f554ce7f921f13efdebeb12553d3ac3a435a6876) --- lldb/cmake/caches/Apple-lldb-Linux.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lldb/cmake/caches/Apple-lldb-Linux.cmake diff --git a/lldb/cmake/caches/Apple-lldb-Linux.cmake b/lldb/cmake/caches/Apple-lldb-Linux.cmake new file mode 100644 index 0000000000000..13d3839f852f6 --- /dev/null +++ b/lldb/cmake/caches/Apple-lldb-Linux.cmake @@ -0,0 +1,8 @@ +include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake) + +set(LLVM_DISTRIBUTION_COMPONENTS + lldb + liblldb + lldb-argdumper + lldb-server + CACHE STRING "") From ce1d3b2774b43d0827c44c1bf6be4d032d32c7ad Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 16:00:03 +0000 Subject: [PATCH 077/616] [CMake][NFC] Polish comments in AddLLDB.cmake llvm-svn: 365650 (cherry picked from commit 86d3c9fd1fd70760e417b3efacc29c0a4cc6194b) --- lldb/cmake/modules/AddLLDB.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index f7f201ea1fdfc..d27d89e6e649c 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -209,18 +209,22 @@ function(lldb_append_link_flags target_name new_link_flags) set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) endfunction() +# The test suite relies on finding LLDB.framework binary resources in the +# build-tree. Remove them before installing to avoid collisions with their +# own install targets. function(lldb_add_to_buildtree_lldb_framework name subdir) # Destination for the copy in the build-tree. While the framework target may # not exist yet, it will exist when the generator expression gets expanded. set(copy_dest "$/../../../${subdir}") - # Copy into the framework's Resources directory for testing. + # Copy into the given subdirectory for testing. add_custom_command(TARGET ${name} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${copy_dest} COMMENT "Copy ${name} to ${copy_dest}" ) endfunction() +# Add extra install steps for dSYM creation and stripping for the given target. function(lldb_add_post_install_steps_darwin name install_prefix) if(NOT APPLE) message(WARNING "Darwin-specific functionality; not currently available on non-Apple platforms.") @@ -252,7 +256,7 @@ function(lldb_add_post_install_steps_darwin name install_prefix) endif() endif() - # Generate dSYM in symroot + # Generate dSYM set(dsym_name ${output_name}.dSYM) if(is_framework) set(dsym_name ${output_name}.framework.dSYM) From 5c4e5760ddae38d91c6bd27b1f882790e1e40fd0 Mon Sep 17 00:00:00 2001 From: Stefan Granitz Date: Wed, 10 Jul 2019 16:02:46 +0000 Subject: [PATCH 078/616] [CMake][NFC] Remove dead code lldb_append_link_flags() from AddLLDB.cmake llvm-svn: 365651 (cherry picked from commit bf223dff7ef076733c9b28c992028ee2dc8c9114) --- lldb/cmake/modules/AddLLDB.cmake | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index d27d89e6e649c..e588232986738 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -193,22 +193,6 @@ function(add_lldb_tool name) add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS}) endfunction() -# Support appending linker flags to an existing target. -# This will preserve the existing linker flags on the -# target, if there are any. -function(lldb_append_link_flags target_name new_link_flags) - # Retrieve existing linker flags. - get_target_property(current_link_flags ${target_name} LINK_FLAGS) - - # If we had any linker flags, include them first in the new linker flags. - if(current_link_flags) - set(new_link_flags "${current_link_flags} ${new_link_flags}") - endif() - - # Now set them onto the target. - set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) -endfunction() - # The test suite relies on finding LLDB.framework binary resources in the # build-tree. Remove them before installing to avoid collisions with their # own install targets. From a2e410933c349318bf64548b8318895b5a455f3f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 10 Jul 2019 16:10:43 +0000 Subject: [PATCH 079/616] ObjectFileELF: Add support for gnu-style compressed sections With this style, a compressed section is indicated by a "z" in the section name, instead of a section header flag. This patch consists of two small tweaks: - use an llvm Decompressor method in order to properly detect compressed sections - make sure we recognise .zdebug_info (and friends) when classifying section types. llvm-svn: 365654 (cherry picked from commit 0ace98c9df70200bdcd5af296f5172a49b3988e5) --- lldb/lit/Modules/ELF/compressed-sections.yaml | 13 +++- .../DWARF/gnu-style-compression.cpp | 14 +++++ .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 59 ++++++++++--------- 3 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 lldb/lit/SymbolFile/DWARF/gnu-style-compression.cpp diff --git a/lldb/lit/Modules/ELF/compressed-sections.yaml b/lldb/lit/Modules/ELF/compressed-sections.yaml index df070a2d53d67..f8c31d52bb83d 100644 --- a/lldb/lit/Modules/ELF/compressed-sections.yaml +++ b/lldb/lit/Modules/ELF/compressed-sections.yaml @@ -16,14 +16,18 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_COMPRESSED ] Content: deadbeefbaadf00d + - Name: .zdebug_info + Type: SHT_PROGBITS + Content: 5A4C49420000000000000008789c5330700848286898000009c802c1 # CHECK: Name: .hello_elf # CHECK-NEXT: Type: regular # CHECK: VM address: 0 # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 28 -# CHECK-NEXT: Data: +# CHECK-NEXT: Data: ( # CHECK-NEXT: 20304050 60708090 +# CHECK-NEXT: ) # CHECK: Name: .bogus # CHECK-NEXT: Type: regular @@ -31,3 +35,10 @@ Sections: # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 8 # CHECK-NEXT: Data: () + +# CHECK: Name: .zdebug_info +# CHECK: dwarf-info +# CHECK: File size: 28 +# CHECK: Data: ( +# CHECK-NEXT: 20304050 60708090 +# CHECK-NEXT: ) diff --git a/lldb/lit/SymbolFile/DWARF/gnu-style-compression.cpp b/lldb/lit/SymbolFile/DWARF/gnu-style-compression.cpp new file mode 100644 index 0000000000000..9dc87303ba9fd --- /dev/null +++ b/lldb/lit/SymbolFile/DWARF/gnu-style-compression.cpp @@ -0,0 +1,14 @@ +// REQUIRES: zlib + +// RUN: %clang %s -target x86_64-pc-linux -g -gsplit-dwarf -c -o %t \ +// RUN: -Wa,--compress-debug-sections=zlib-gnu +// RUN: %lldb %t -o "target var s a" -b | FileCheck %s + +// CHECK: (const short) s = 47 +// CHECK: (const A) a = (a = 42) + +struct A { + long a = 42; +}; +extern constexpr short s = 47; +extern constexpr A a{}; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 47d5664700d52..d62afa34bbe81 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1674,38 +1674,40 @@ lldb::user_id_t ObjectFileELF::GetSectionIndexByName(const char *name) { } static SectionType GetSectionTypeFromName(llvm::StringRef Name) { + if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) { + return llvm::StringSwitch(Name) + .Case("abbrev", eSectionTypeDWARFDebugAbbrev) + .Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo) + .Case("addr", eSectionTypeDWARFDebugAddr) + .Case("aranges", eSectionTypeDWARFDebugAranges) + .Case("cu_index", eSectionTypeDWARFDebugCuIndex) + .Case("frame", eSectionTypeDWARFDebugFrame) + .Case("info", eSectionTypeDWARFDebugInfo) + .Case("info.dwo", eSectionTypeDWARFDebugInfoDwo) + .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine) + .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr) + .Cases("loc", "loc.dwo", eSectionTypeDWARFDebugLoc) + .Cases("loclists", "loclists.dwo", eSectionTypeDWARFDebugLocLists) + .Case("macinfo", eSectionTypeDWARFDebugMacInfo) + .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro) + .Case("names", eSectionTypeDWARFDebugNames) + .Case("pubnames", eSectionTypeDWARFDebugPubNames) + .Case("pubtypes", eSectionTypeDWARFDebugPubTypes) + .Case("ranges", eSectionTypeDWARFDebugRanges) + .Case("rnglists", eSectionTypeDWARFDebugRngLists) + .Case("str", eSectionTypeDWARFDebugStr) + .Case("str.dwo", eSectionTypeDWARFDebugStrDwo) + .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets) + .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo) + .Case("types", eSectionTypeDWARFDebugTypes) + .Case("types.dwo", eSectionTypeDWARFDebugTypesDwo) + .Default(eSectionTypeOther); + } return llvm::StringSwitch(Name) .Case(".ARM.exidx", eSectionTypeARMexidx) .Case(".ARM.extab", eSectionTypeARMextab) .Cases(".bss", ".tbss", eSectionTypeZeroFill) .Cases(".data", ".tdata", eSectionTypeData) - .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev) - .Case(".debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo) - .Case(".debug_addr", eSectionTypeDWARFDebugAddr) - .Case(".debug_aranges", eSectionTypeDWARFDebugAranges) - .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex) - .Case(".debug_frame", eSectionTypeDWARFDebugFrame) - .Case(".debug_info", eSectionTypeDWARFDebugInfo) - .Case(".debug_info.dwo", eSectionTypeDWARFDebugInfoDwo) - .Cases(".debug_line", ".debug_line.dwo", eSectionTypeDWARFDebugLine) - .Cases(".debug_line_str", ".debug_line_str.dwo", - eSectionTypeDWARFDebugLineStr) - .Cases(".debug_loc", ".debug_loc.dwo", eSectionTypeDWARFDebugLoc) - .Cases(".debug_loclists", ".debug_loclists.dwo", - eSectionTypeDWARFDebugLocLists) - .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo) - .Cases(".debug_macro", ".debug_macro.dwo", eSectionTypeDWARFDebugMacro) - .Case(".debug_names", eSectionTypeDWARFDebugNames) - .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames) - .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes) - .Case(".debug_ranges", eSectionTypeDWARFDebugRanges) - .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists) - .Case(".debug_str", eSectionTypeDWARFDebugStr) - .Case(".debug_str.dwo", eSectionTypeDWARFDebugStrDwo) - .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets) - .Case(".debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo) - .Case(".debug_types", eSectionTypeDWARFDebugTypes) - .Case(".debug_types.dwo", eSectionTypeDWARFDebugTypesDwo) .Case(".eh_frame", eSectionTypeEHFrame) .Case(".gnu_debugaltlink", eSectionTypeDWARFGNUDebugAltLink) .Case(".gosymtab", eSectionTypeGoSymtab) @@ -3302,7 +3304,8 @@ size_t ObjectFileELF::ReadSectionData(Section *section, return section->GetObjectFile()->ReadSectionData(section, section_data); size_t result = ObjectFile::ReadSectionData(section, section_data); - if (result == 0 || !section->Test(SHF_COMPRESSED)) + if (result == 0 || !llvm::object::Decompressor::isCompressedELFSection( + section->Get(), section->GetName().GetStringRef())) return result; auto Decompressor = llvm::object::Decompressor::create( From c94b167caae0ce922439ed1568d58f1399cad18f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 10 Jul 2019 17:09:47 +0000 Subject: [PATCH 080/616] Options: Reduce code duplication Summary: While investigating breakages caused by D63110, I noticed we were building the short options strings in three places. Some of them used a leading ':' to detect missing arguments, and some didn't. This was the indirect cause of D63110. Here, I move the common code into a utility function. Also, unify the code which appends the sentinel value at the end of the option vector, and make it harder for users to pass invalid argc-argv combos to getopt (another component of D63110) by having the OptionParser::Parse function take a (Mutable)ArrayRef. This unification has uncovered that we don't handle missing arguments while building aliases, However, it's not possible to write an effective test for this, as right now it is not possible to return an error out of the alias parsing code (which means we are printing the generic "failure" message even after this patch). Reviewers: mgorny, aprantl Reviewed By: mgorny Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D63770 llvm-svn: 365665 (cherry picked from commit 1abaeece719c99ad9b408257b71c19c62db438cc) --- lldb/include/lldb/Host/OptionParser.h | 8 +- lldb/source/Host/common/OptionParser.cpp | 8 +- lldb/source/Interpreter/CommandAlias.cpp | 2 + lldb/source/Interpreter/Options.cpp | 102 ++++++++--------------- 4 files changed, 48 insertions(+), 72 deletions(-) diff --git a/lldb/include/lldb/Host/OptionParser.h b/lldb/include/lldb/Host/OptionParser.h index ca05946456455..b03eeb74ec4e0 100644 --- a/lldb/include/lldb/Host/OptionParser.h +++ b/lldb/include/lldb/Host/OptionParser.h @@ -13,6 +13,7 @@ #include #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/ArrayRef.h" struct option; @@ -37,8 +38,11 @@ class OptionParser { static void EnableError(bool error); - static int Parse(int argc, char *const argv[], llvm::StringRef optstring, - const Option *longopts, int *longindex); + /// Argv must be an argument vector "as passed to main", i.e. terminated with + /// a nullptr. + static int Parse(llvm::MutableArrayRef argv, + llvm::StringRef optstring, const Option *longopts, + int *longindex); static char *GetOptionArgument(); static int GetOptionIndex(); diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp index 92ff6f63d951f..1e76f9b8f9f14 100644 --- a/lldb/source/Host/common/OptionParser.cpp +++ b/lldb/source/Host/common/OptionParser.cpp @@ -27,8 +27,9 @@ void OptionParser::Prepare(std::unique_lock &lock) { void OptionParser::EnableError(bool error) { opterr = error ? 1 : 0; } -int OptionParser::Parse(int argc, char *const argv[], llvm::StringRef optstring, - const Option *longopts, int *longindex) { +int OptionParser::Parse(llvm::MutableArrayRef argv, + llvm::StringRef optstring, const Option *longopts, + int *longindex) { std::vector