[Lldb-commits] [lldb] r361898 - Fix IPv6 support on lldb-server platform
Author: aadsm Date: Tue May 28 16:26:32 2019 New Revision: 361898 URL: http://llvm.org/viewvc/llvm-project?rev=361898&view=rev Log: Fix IPv6 support on lldb-server platform Summary: This is a general fix for the ConnectionFileDescriptor class but my main motivation was to make lldb-server working with IPv6. The connect URI can use square brackets ([]) to wrap the interface part of the URI (e.g.: ://[]:). For IPv6 addresses this is a must since its ip can include colons and it will overlap with the port colon otherwise. The URIParser class parses the square brackets correctly but the ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it impossible to connect to the gdb server when using this protocol. How to reproduce the issue: ``` $ lldb-server p --server --listen [::1]:8080 ... $ lldb (lldb) platform select remote-macosx (lldb) platform connect connect://[::1]:8080 (lldb) platform process -p error: unable to launch a GDB server on 'computer' ``` The server was actually launched we were just not able to connect to it. With this fix lldb will correctly connect. I fixed this by wrapping the ip portion with []. Reviewers: labath Reviewed By: labath Subscribers: xiaobai, mgorny, jfb, lldb-commits, labath Tags: #lldb Differential Revision: https://reviews.llvm.org/D61833 Added: lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp lldb/trunk/unittests/Host/SocketTestUtilities.cpp lldb/trunk/unittests/Host/SocketTestUtilities.h Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/trunk/unittests/Host/CMakeLists.txt lldb/trunk/unittests/Host/SocketTest.cpp Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp?rev=361898&r1=361897&r2=361898&view=diff == --- lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp (original) +++ lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp Tue May 28 16:26:32 2019 @@ -764,7 +764,7 @@ void ConnectionFileDescriptor::Initializ m_write_sp.reset(socket); m_read_sp = m_write_sp; StreamString strm; - strm.Printf("connect://%s:%u", tcp_socket->GetRemoteIPAddress().c_str(), + strm.Printf("connect://[%s]:%u", tcp_socket->GetRemoteIPAddress().c_str(), tcp_socket->GetRemotePortNumber()); m_uri = strm.GetString(); } Modified: lldb/trunk/unittests/Host/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=361898&r1=361897&r2=361898&view=diff == --- lldb/trunk/unittests/Host/CMakeLists.txt (original) +++ lldb/trunk/unittests/Host/CMakeLists.txt Tue May 28 16:26:32 2019 @@ -1,4 +1,5 @@ set (FILES + ConnectionFileDescriptorTest.cpp FileActionTest.cpp FileSystemTest.cpp HostInfoTest.cpp @@ -8,6 +9,7 @@ set (FILES ProcessLaunchInfoTest.cpp SocketAddressTest.cpp SocketTest.cpp + SocketTestUtilities.cpp TaskPoolTest.cpp ) Added: lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp?rev=361898&view=auto == --- lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp (added) +++ lldb/trunk/unittests/Host/ConnectionFileDescriptorTest.cpp Tue May 28 16:26:32 2019 @@ -0,0 +1,50 @@ +//===-- ConnectionFileDescriptorTest.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 "SocketTestUtilities.h" +#include "gtest/gtest.h" + +#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" +#include "lldb/Utility/UriParser.h" + +using namespace lldb_private; + +class ConnectionFileDescriptorTest : public testing::Test { +public: + void SetUp() override { +ASSERT_THAT_ERROR(Socket::Initialize(), llvm::Succeeded()); + } + + void TearDown() override { Socket::Terminate(); } + + void TestGetURI(std::string ip) { +std::unique_ptr socket_a_up; +std::unique_ptr socket_b_up; +if (!IsAddressFamilySupported(ip)) { + GTEST_LOG_(WARNING) << "Skipping test due to missing IPv" + << (IsIPv4(ip) ? "4" : "6") << " support."; + return; +} +CreateTCPConnectedSockets(ip, &socket_a_up, &socket_b_up); +auto socket = socket_a_up.release(); +ConnectionFileDescriptor connection_file_descriptor(socket); + +llvm::StringRef scheme; +llvm::StringRef hostname; +int port; +llvm::StringRef pat
[Lldb-commits] [lldb] r361531 - Test commit access by removing a empty line
Author: aadsm Date: Thu May 23 11:35:54 2019 New Revision: 361531 URL: http://llvm.org/viewvc/llvm-project?rev=361531&view=rev Log: Test commit access by removing a empty line Modified: lldb/trunk/source/Core/ModuleList.cpp Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=361531&r1=361530&r2=361531&view=diff == --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Thu May 23 11:35:54 2019 @@ -114,7 +114,6 @@ bool ModuleListProperties::SetClangModul nullptr, ePropertyClangModulesCachePath, path); } - ModuleList::ModuleList() : m_modules(), m_modules_mutex(), m_notifier(nullptr) {} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r362173 - Make ConnectionFileDescription work with all sockets
Author: aadsm Date: Thu May 30 16:30:35 2019 New Revision: 362173 URL: http://llvm.org/viewvc/llvm-project?rev=362173&view=rev Log: Make ConnectionFileDescription work with all sockets Summary: My main goal here is to make lldb-server work with Android Studio. This is currently not the case because lldb-server is started in platform mode listening on a domain socket. When Android Studio connects to it lldb-server crashes because even though it's listening on a domain socket as soon as it gets a connection it asserts that it's a TCP connection, which will obviously fails for any non-tcp connection. To do this I came up with a new method called GetConnectURI() in Socket that returns the URI needed to connect to the connected portion of the socket. Reviewers: labath, clayborg, xiaobai Reviewed By: labath Subscribers: mgorny, jfb, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62089 Modified: lldb/trunk/include/lldb/Host/Socket.h lldb/trunk/include/lldb/Host/common/TCPSocket.h lldb/trunk/include/lldb/Host/common/UDPSocket.h lldb/trunk/include/lldb/Host/posix/DomainSocket.h lldb/trunk/source/Host/common/TCPSocket.cpp lldb/trunk/source/Host/common/UDPSocket.cpp lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/trunk/source/Host/posix/DomainSocket.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/trunk/unittests/Host/SocketTest.cpp Modified: lldb/trunk/include/lldb/Host/Socket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Socket.h?rev=362173&r1=362172&r2=362173&view=diff == --- lldb/trunk/include/lldb/Host/Socket.h (original) +++ lldb/trunk/include/lldb/Host/Socket.h Thu May 30 16:30:35 2019 @@ -102,6 +102,9 @@ public: std::string &host_str, std::string &port_str, int32_t &port, Status *error_ptr); + // If this Socket is connected then return the URI used to connect. + virtual std::string GetRemoteConnectionURI() const { return ""; }; + protected: Socket(SocketProtocol protocol, bool should_close, bool m_child_process_inherit); Modified: lldb/trunk/include/lldb/Host/common/TCPSocket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/TCPSocket.h?rev=362173&r1=362172&r2=362173&view=diff == --- lldb/trunk/include/lldb/Host/common/TCPSocket.h (original) +++ lldb/trunk/include/lldb/Host/common/TCPSocket.h Thu May 30 16:30:35 2019 @@ -46,6 +46,8 @@ public: bool IsValid() const override; + std::string GetRemoteConnectionURI() const override; + private: TCPSocket(NativeSocket socket, const TCPSocket &listen_socket); Modified: lldb/trunk/include/lldb/Host/common/UDPSocket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/UDPSocket.h?rev=362173&r1=362172&r2=362173&view=diff == --- lldb/trunk/include/lldb/Host/common/UDPSocket.h (original) +++ lldb/trunk/include/lldb/Host/common/UDPSocket.h Thu May 30 16:30:35 2019 @@ -19,6 +19,8 @@ public: static Status Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket); + std::string GetRemoteConnectionURI() const override; + private: UDPSocket(NativeSocket socket); Modified: lldb/trunk/include/lldb/Host/posix/DomainSocket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/DomainSocket.h?rev=362173&r1=362172&r2=362173&view=diff == --- lldb/trunk/include/lldb/Host/posix/DomainSocket.h (original) +++ lldb/trunk/include/lldb/Host/posix/DomainSocket.h Thu May 30 16:30:35 2019 @@ -20,11 +20,14 @@ public: Status Listen(llvm::StringRef name, int backlog) override; Status Accept(Socket *&socket) override; + std::string GetRemoteConnectionURI() const override; + protected: DomainSocket(SocketProtocol protocol, bool child_processes_inherit); virtual size_t GetNameOffset() const; virtual void DeleteSocketFile(llvm::StringRef name); + std::string GetSocketName() const; private: DomainSocket(NativeSocket socket, const DomainSocket &listen_socket); Modified: lldb/trunk/source/Host/common/TCPSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=362173&r1=362172&r2=362173&view=diff == --- lldb/trunk/source/Host/common/TCPSocket.cpp (original) +++ lldb/trunk/source/Host/common/TCPSocket.cpp Thu May 30 16:30:35 2019 @@ -118,6 +118,14 @@ std::string TCPSocket::GetRemoteIPAddres return ""; } +std::string TCPSocket::GetRemoteConnectionURI(
[Lldb-commits] [lldb] r362619 - [DynamicLoader] Make sure we always set the rendezvous breakpoint
Author: aadsm Date: Wed Jun 5 09:22:33 2019 New Revision: 362619 URL: http://llvm.org/viewvc/llvm-project?rev=362619&view=rev Log: [DynamicLoader] Make sure we always set the rendezvous breakpoint Summary: Once we've attached to the process we load all current modules and also set a breakpoint at the rendezvous break address. However, we don't do this if we already have a load address for the image info address (e.g.: DT_DEBUG on ELF). This code was added 4 years ago when adding support for `$qXfer:Libraries:` packet (https://reviews.llvm.org/D9471) but its intention is not 100% clear to me. It seems to me we're using that check to know if the modules have already been loaded (which they have if `$qXfer:Libraries:` is supported by the gdb server) and skip loading the modules again in the following `if` block. The problem is that we also skip setting the Rendezvous breakpoint so we stop knowing when the process loads new modules. I fix this by moving the call to set the breakpoint to the end of the function so we always call it as long as we have a valid executable. Reviewers: ADodds, clayborg, eugene, labath Reviewed By: eugene, labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62168 Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=362619&r1=362618&r2=362619&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Wed Jun 5 09:22:33 2019 @@ -150,11 +150,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() true); LoadAllCurrentModules(); -if (!SetRendezvousBreakpoint()) { - // If we cannot establish rendezvous breakpoint right now we'll try again - // at entry point. - ProbeEntry(); -} m_process->GetTarget().ModulesDidLoad(module_list); if (log) { @@ -169,6 +164,14 @@ void DynamicLoaderPOSIXDYLD::DidAttach() } } } + + if (executable_sp.get()) { +if (!SetRendezvousBreakpoint()) { + // If we cannot establish rendezvous breakpoint right now we'll try again + // at entry point. + ProbeEntry(); +} + } } void DynamicLoaderPOSIXDYLD::DidLaunch() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r362107 - Remove length modifier when using assignment suppression in TimerTest
Author: aadsm Date: Thu May 30 08:38:05 2019 New Revision: 362107 URL: http://llvm.org/viewvc/llvm-project?rev=362107&view=rev Log: Remove length modifier when using assignment suppression in TimerTest Summary: This is useless and it's giving warnings in the build bots: /home/motus/netbsd8/netbsd8/llvm/tools/lldb/unittests/Utility/TimerTest.cpp:67:43: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=] Reviewers: xiaobai Subscribers: krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62626 Modified: lldb/trunk/unittests/Utility/TimerTest.cpp Modified: lldb/trunk/unittests/Utility/TimerTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/TimerTest.cpp?rev=362107&r1=362106&r2=362107&view=diff == --- lldb/trunk/unittests/Utility/TimerTest.cpp (original) +++ lldb/trunk/unittests/Utility/TimerTest.cpp Thu May 30 08:38:05 2019 @@ -62,7 +62,7 @@ TEST(TimerTest, CategoryTimes2) { Timer::DumpCategoryTimes(&ss); double seconds1, seconds2; ASSERT_EQ(2, sscanf(ss.GetData(), - "%lf sec (total: %*lfs; child: %*lfs; count: %*d) for " + "%lf sec (total: %*fs; child: %*fs; count: %*d) for " "CAT1%*[\n ]%lf sec for CAT2", &seconds1, &seconds2)) << "String: " << ss.GetData(); @@ -98,7 +98,7 @@ TEST(TimerTest, CategoryTimesStats) { ASSERT_EQ( 6, sscanf(ss.GetData(), "%lf sec (total: %lfs; child: %lfs; count: %d) for CAT1%*[\n ]" -"%lf sec (total: %*lfs; child: %*lfs; count: %d) for CAT2", +"%lf sec (total: %*fs; child: %*fs; count: %d) for CAT2", &seconds1, &total1, &child1, &count1, &seconds2, &count2)) << "String: " << ss.GetData(); EXPECT_NEAR(total1 - child1, seconds1, 0.002); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r363098 - Add support to read aux vector values
Author: aadsm Date: Tue Jun 11 13:16:13 2019 New Revision: 363098 URL: http://llvm.org/viewvc/llvm-project?rev=363098&view=rev Log: Add support to read aux vector values Summary: This is the second patch to improve module loading in a series that started here (where I explain the motivation and solution): https://reviews.llvm.org/D62499 I need to read the aux vector to know where the r_debug map with the loaded libraries are. The AuxVector class was made generic so it could be reused between the POSIX-DYLD plugin and NativeProcess*. The class itself ended up in the ProcessUtility plugin. Reviewers: clayborg, xiaobai, labath, JDevlieghere Reviewed By: clayborg, labath, JDevlieghere Subscribers: emaste, JDevlieghere, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62500 Added: lldb/trunk/source/Plugins/Process/Utility/AuxVector.cpp lldb/trunk/source/Plugins/Process/Utility/AuxVector.h Removed: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363098&r1=363097&r2=363098&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 11 13:16:13 2019 @@ -133,6 +133,10 @@ public: return GetArchitecture().GetByteOrder(); } + uint32_t GetAddressByteSize() const { +return GetArchitecture().GetAddressByteSize(); + } + virtual llvm::ErrorOr> GetAuxvData() const = 0; Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=363098&r1=363097&r2=363098&view=diff == --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Jun 11 13:16:13 2019 @@ -670,8 +670,8 @@ public: // The default action is to return an empty data buffer. // // \return - //A data buffer containing the contents of the AUXV data. - virtual const lldb::DataBufferSP GetAuxvData(); + //A data extractor containing the contents of the AUXV data. + virtual DataExtractor GetAuxvData(); /// Sometimes processes know how to retrieve and load shared libraries. This /// is normally done by DynamicLoader plug-ins, but sometimes the connection Removed: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp?rev=363097&view=auto == --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp (removed) @@ -1,141 +0,0 @@ -//===-- AuxVector.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 "AuxVector.h" -#include "lldb/Target/Process.h" -#include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Log.h" - -using namespace lldb; -using namespace lldb_private; - -static bool GetMaxU64(DataExtractor &data, lldb::offset_t *offset_ptr, - uint64_t *value, unsigned int byte_size) { - lldb::offset_t saved_offset = *offset_ptr; - *value = data.GetMaxU64(offset_ptr, byte_size); - return *offset_ptr != saved_offset; -} - -
[Lldb-commits] [lldb] r361987 - Add more information to the log timer dump
Author: aadsm Date: Wed May 29 09:31:32 2019 New Revision: 361987 URL: http://llvm.org/viewvc/llvm-project?rev=361987&view=rev Log: Add more information to the log timer dump Summary: The `log timer dump` is showing the time of the function itself minus any function that is called from this one that also happens to be timed. However, this is really not obvious and it also makes it hard to understand the time spent in total and also which children are actually taking the time. To get a better reading of the timer dump I added the total, children (which I named child) and also the hit count. I used these timers to figure out a performance issue and only after adding this things were more clear to me. It looks like this: ``` (lldb) log timer dump 35.447713617 sec (total: 35.449s; child: 0.001s; count: 1374) for void SymbolFileDWARF::Index() 29.717921481 sec (total: 29.718s; child: 0.000s; count: 8230500) for const lldb_private::ConstString &lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const 21.049508865 sec (total: 24.683s; child: 3.633s; count: 1399) for void lldb_private::Symtab::InitNameIndexes() ... ``` Reviewers: clayborg, teemperor, labath, espindola, xiaobai Reviewed By: labath, xiaobai Subscribers: emaste, mgorny, arichardson, eraman, MaskRay, jdoerfert, labath, davide, teemperor, aprantl, erik.pilkington, jfb, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61235 Modified: lldb/trunk/include/lldb/Utility/Timer.h lldb/trunk/source/Utility/Timer.cpp lldb/trunk/unittests/Utility/TimerTest.cpp Modified: lldb/trunk/include/lldb/Utility/Timer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Timer.h?rev=361987&r1=361986&r2=361987&view=diff == --- lldb/trunk/include/lldb/Utility/Timer.h (original) +++ lldb/trunk/include/lldb/Utility/Timer.h Wed May 29 09:31:32 2019 @@ -30,6 +30,8 @@ public: friend class Timer; const char *m_name; std::atomic m_nanos; +std::atomic m_nanos_total; +std::atomic m_count; std::atomic m_next; DISALLOW_COPY_AND_ASSIGN(Category); Modified: lldb/trunk/source/Utility/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Timer.cpp?rev=361987&r1=361986&r2=361987&view=diff == --- lldb/trunk/source/Utility/Timer.cpp (original) +++ lldb/trunk/source/Utility/Timer.cpp Wed May 29 09:31:32 2019 @@ -41,6 +41,8 @@ static TimerStack &GetTimerStackForCurre Timer::Category::Category(const char *cat) : m_name(cat) { m_nanos.store(0, std::memory_order_release); + m_nanos_total.store(0, std::memory_order_release); + m_count.store(0, std::memory_order_release); Category *expected = g_categories; do { m_next = expected; @@ -93,6 +95,8 @@ Timer::~Timer() { // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); + m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count(); + m_category.m_count++; } void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; } @@ -100,25 +104,38 @@ void Timer::SetDisplayDepth(uint32_t dep /* binary function predicate: * - returns whether a person is less than another person */ - -typedef std::pair TimerEntry; - -static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs, - const TimerEntry &rhs) { - return lhs.second > rhs.second; +namespace { +struct Stats { + const char *name; + uint64_t nanos; + uint64_t nanos_total; + uint64_t count; +}; +} // namespace + +static bool CategoryMapIteratorSortCriterion(const Stats &lhs, + const Stats &rhs) { + return lhs.nanos > rhs.nanos; } void Timer::ResetCategoryTimes() { - for (Category *i = g_categories; i; i = i->m_next) + for (Category *i = g_categories; i; i = i->m_next) { i->m_nanos.store(0, std::memory_order_release); +i->m_nanos_total.store(0, std::memory_order_release); +i->m_count.store(0, std::memory_order_release); + } } void Timer::DumpCategoryTimes(Stream *s) { - std::vector sorted; + std::vector sorted; for (Category *i = g_categories; i; i = i->m_next) { uint64_t nanos = i->m_nanos.load(std::memory_order_acquire); -if (nanos) - sorted.push_back(std::make_pair(i->m_name, nanos)); +if (nanos) { + uint64_t nanos_total = i->m_nanos_total.load(std::memory_order_acquire); + uint64_t count = i->m_count.load(std::memory_order_acquire); + Stats stats{i->m_name, nanos, nanos_total, count}; + sorted.push_back(stats); +} } if (sorted.empty()) return; // Later code will break without any elements. @@ -126,6 +143,9 @@ void Timer::DumpCategoryTimes(Stream *s) // Sort by time llvm::sort(sorted.begin(
[Lldb-commits] [lldb] r363458 - Implement GetSharedLibraryInfoAddress
Author: aadsm Date: Fri Jun 14 14:15:08 2019 New Revision: 363458 URL: http://llvm.org/viewvc/llvm-project?rev=363458&view=rev Log: Implement GetSharedLibraryInfoAddress Summary: This is the third patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Add functions to read the r_debug location to know where the linked list of loaded libraries are so I can generate the `xfer:libraries-svr4` packet. I'm also using this function to implement `GetSharedLibraryInfoAddress` that was "not implemented" for linux. Most of this code was inspired by the current ds2 implementation here: https://github.com/facebook/ds2/blob/master/Sources/Target/POSIX/ELFProcess.cpp. Reviewers: clayborg, xiaobai, labath Reviewed By: clayborg, labath Subscribers: emaste, krytarowski, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62501 Added: lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h lldb/trunk/unittests/Process/POSIX/ lldb/trunk/unittests/Process/POSIX/CMakeLists.txt lldb/trunk/unittests/Process/POSIX/NativeProcessELFTest.cpp lldb/trunk/unittests/TestingSupport/Host/ lldb/trunk/unittests/TestingSupport/Host/NativeProcessTestUtils.h Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h lldb/trunk/source/Plugins/Process/POSIX/CMakeLists.txt lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp lldb/trunk/unittests/Process/CMakeLists.txt Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=363458&r1=363457&r2=363458&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Fri Jun 14 14:15:08 2019 @@ -288,7 +288,7 @@ NativeProcessLinux::NativeProcessLinux(: NativeDelegate &delegate, const ArchSpec &arch, MainLoop &mainloop, llvm::ArrayRef<::pid_t> tids) -: NativeProcessProtocol(pid, terminal_fd, delegate), m_arch(arch) { +: NativeProcessELF(pid, terminal_fd, delegate), m_arch(arch) { if (m_terminal_fd != -1) { Status status = EnsureFDFlags(m_terminal_fd, O_NONBLOCK); assert(status.Success()); @@ -1389,11 +1389,6 @@ Status NativeProcessLinux::DeallocateMem return Status("not implemented"); } -lldb::addr_t NativeProcessLinux::GetSharedLibraryInfoAddress() { - // punt on this for now - return LLDB_INVALID_ADDRESS; -} - size_t NativeProcessLinux::UpdateThreads() { // The NativeProcessLinux monitoring threads are always up to date with // respect to thread state and they keep the thread list populated properly. @@ -2082,18 +2077,3 @@ Status NativeProcessLinux::StopProcessor return error; } - -llvm::Optional -NativeProcessLinux::GetAuxValue(enum AuxVector::EntryType type) { - if (m_aux_vector == nullptr) { -auto buffer_or_error = GetAuxvData(); -if (!buffer_or_error) - return llvm::None; -DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(), -buffer_or_error.get()->getBufferSize(), -GetByteOrder(), GetAddressByteSize()); -m_aux_vector = llvm::make_unique(auxv_data); - } - - return m_aux_vector->GetAuxValue(type); -} Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h?rev=363458&r1=363457&r2=363458&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h Fri Jun 14 14:15:08 2019 @@ -12,7 +12,6 @@ #include #include -#include "Plugins/Process/Utility/AuxVector.h" #include "lldb/Host/Debug.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/linux/Support.h" @@ -22,8 +21,8 @@ #include "lldb/lldb-types.h" #include "NativeThreadLinux.h" +#include "Plugins/Process/POSIX/NativeProcessELF.h" #include "ProcessorTrace.h" -#include "lldb/Host/common/NativeProcessProtocol.h" namespace lldb_private { class Status; @@ -37,7 +36,7 @@ namespace process_linux { /// for debugging. /// /// Changes in the inferior process state are broadcasted. -class NativeProcessLinux : public NativeProcessProtocol { +class NativeProcessLinux : public NativeProcessELF { public: class Factory : public NativeProcessProtocol::Factory { public: @@ -77,8 +76,6 @@ public: Status DeallocateMemory(l
[Lldb-commits] [lldb] r365059 - Add plugin.process.gdb-remote.use-libraries-svr4 option
Author: aadsm Date: Wed Jul 3 10:30:07 2019 New Revision: 365059 URL: http://llvm.org/viewvc/llvm-project?rev=365059&view=rev Log: 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 Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=365059&r1=365058&r2=365059&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Jul 3 10:30:07 2019 @@ -111,18 +111,40 @@ void DumpProcessGDBRemotePacketHistory(v 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 @@ public: 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::GetLoadedModule 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 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r362406 - [lldb-server unittest] Add missing teardown logic
Author: aadsm Date: Mon Jun 3 08:18:15 2019 New Revision: 362406 URL: http://llvm.org/viewvc/llvm-project?rev=362406&view=rev Log: [lldb-server unittest] Add missing teardown logic Summary: This test base class is missing the teardown making the second set of tests extending it to fail in an assertion in the FileSystem::Initialize() (as it's being initialized twice). Not sure why this isn't failing the build bots.. (unless they're running without asserts?). With this fix `ninja LLDBServerTests && ./tools/lldb/unittests/tools/lldb-server/tests/LLDBServerTests` successfully runs and passes all tests. Reviewers: clayborg, xiaobai, labath Reviewed By: xiaobai, labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62788 Modified: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h Modified: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h?rev=362406&r1=362405&r2=362406&view=diff == --- lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h (original) +++ lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h Mon Jun 3 08:18:15 2019 @@ -25,6 +25,11 @@ public: lldb_private::HostInfo::Initialize(); } + static void TearDownTestCase() { +lldb_private::HostInfo::Terminate(); +lldb_private::FileSystem::Terminate(); + } + static std::string getInferiorPath(llvm::StringRef Name) { llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH); llvm::sys::path::append(Path, Name + LLDB_TEST_INFERIOR_SUFFIX); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r364355 - Revert "Add ReadCStringFromMemory for faster string reads"
Author: aadsm Date: Tue Jun 25 15:22:13 2019 New Revision: 364355 URL: http://llvm.org/viewvc/llvm-project?rev=364355&view=rev Log: Revert "Add ReadCStringFromMemory for faster string reads" This reverts commit a7335393f50246b59db450dc6005f7c8f29e73a6. It seems this is breaking a bunch of tests (https://reviews.llvm.org/D62503#1549874) so reverting until I find the time to repro and fix. Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/source/Host/common/NativeProcessProtocol.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=364355&r1=364354&r2=364355&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 25 15:22:13 2019 @@ -84,31 +84,6 @@ public: Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read); - /// Reads a null terminated string from memory. - /// - /// Reads up to \p max_size bytes of memory until it finds a '\0'. - /// If a '\0' is not found then it reads max_size-1 bytes as a string and a - /// '\0' is added as the last character of the \p buffer. - /// - /// \param[in] addr - /// The address in memory to read from. - /// - /// \param[in] buffer - /// An allocated buffer with at least \p max_size size. - /// - /// \param[in] max_size - /// The maximum number of bytes to read from memory until it reads the - /// string. - /// - /// \param[out] total_bytes_read - /// The number of bytes read from memory into \p buffer. - /// - /// \return - /// Returns a StringRef backed up by the \p buffer passed in. - llvm::Expected - ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size, -size_t &total_bytes_read); - virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=364355&r1=364354&r2=364355&view=diff == --- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original) +++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jun 25 15:22:13 2019 @@ -16,8 +16,6 @@ #include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" -#include "llvm/Support/Process.h" - using namespace lldb; using namespace lldb_private; @@ -661,58 +659,6 @@ Status NativeProcessProtocol::ReadMemory return Status(); } -llvm::Expected -NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer, - size_t max_size, - size_t &total_bytes_read) { - static const size_t cache_line_size = - llvm::sys::Process::getPageSizeEstimate(); - size_t bytes_read = 0; - size_t bytes_left = max_size; - addr_t curr_addr = addr; - size_t string_size; - char *curr_buffer = buffer; - total_bytes_read = 0; - Status status; - - while (bytes_left > 0 && status.Success()) { -addr_t cache_line_bytes_left = -cache_line_size - (curr_addr % cache_line_size); -addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left); -status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer), -bytes_to_read, bytes_read); - -if (bytes_read == 0) - break; - -void *str_end = std::memchr(curr_buffer, '\0', bytes_read); -if (str_end != nullptr) { - total_bytes_read = - (size_t)(reinterpret_cast(str_end) - buffer + 1); - status.Clear(); - break; -} - -total_bytes_read += bytes_read; -curr_buffer += bytes_read; -curr_addr += bytes_read; -bytes_left -= bytes_read; - } - - string_size = total_bytes_read - 1; - - // Make sure we return a null terminated string. - if (bytes_left == 0 && max_size > 0 && buffer[max_size - 1] != '\0') { -buffer[max_size - 1] = '\0'; -total_bytes_read--; - } - - if (!status.Success()) -return status.ToError(); - - return llvm::StringRef(buffer, string_size); -} - lldb::StateType NativeProcessProtocol::GetState() const { std::lock_guard guard(m_state_mutex); return m_state; Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cp
[Lldb-commits] [lldb] r363750 - Add ReadCStringFromMemory for faster string reads
Author: aadsm Date: Tue Jun 18 16:27:57 2019 New Revision: 363750 URL: http://llvm.org/viewvc/llvm-project?rev=363750&view=rev Log: Add ReadCStringFromMemory for faster string reads Summary: This is the fifth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Reading strings with ReadMemory is really slow when reading the path of the shared library. This is because we don't know the length of the path so use PATH_MAX (4096) and these strings are actually super close to the boundary of an unreadable page. So even though we use process_vm_readv it will usually fail because the read size spans to the unreadable page and we then default to read the string word by word with ptrace. This new function is very similar to another ReadCStringFromMemory that already exists in lldb that makes sure it never reads cross page boundaries and checks if we already read the entire string by finding '\0'. I was able to reduce the GetLoadedSharedLibraries call from 30ms to 4ms (or something of that order). Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: emaste, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62503 Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/source/Host/common/NativeProcessProtocol.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363750&r1=363749&r2=363750&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 18 16:27:57 2019 @@ -84,6 +84,31 @@ public: Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read); + /// Reads a null terminated string from memory. + /// + /// Reads up to \p max_size bytes of memory until it finds a '\0'. + /// If a '\0' is not found then it reads max_size-1 bytes as a string and a + /// '\0' is added as the last character of the \p buffer. + /// + /// \param[in] addr + /// The address in memory to read from. + /// + /// \param[in] buffer + /// An allocated buffer with at least \p max_size size. + /// + /// \param[in] max_size + /// The maximum number of bytes to read from memory until it reads the + /// string. + /// + /// \param[out] total_bytes_read + /// The number of bytes read from memory into \p buffer. + /// + /// \return + /// Returns a StringRef backed up by the \p buffer passed in. + llvm::Expected + ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size, +size_t &total_bytes_read); + virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=363750&r1=363749&r2=363750&view=diff == --- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original) +++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jun 18 16:27:57 2019 @@ -16,6 +16,8 @@ #include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" +#include "llvm/Support/Process.h" + using namespace lldb; using namespace lldb_private; @@ -659,6 +661,58 @@ Status NativeProcessProtocol::ReadMemory return Status(); } +llvm::Expected +NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer, + size_t max_size, + size_t &total_bytes_read) { + static const size_t cache_line_size = + llvm::sys::Process::getPageSizeEstimate(); + size_t bytes_read = 0; + size_t bytes_left = max_size; + addr_t curr_addr = addr; + size_t string_size; + char *curr_buffer = buffer; + total_bytes_read = 0; + Status status; + + while (bytes_left > 0 && status.Success()) { +addr_t cache_line_bytes_left = +cache_line_size - (curr_addr % cache_line_size); +addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left); +status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer), +bytes_to_read, bytes_read); + +if (bytes_read == 0) + break; + +void *str_end = std::memchr(curr_buffer, '\0', bytes_read); +if (str_end != nullptr) { + total_bytes_read = + (size_t)(reinterpret_cast(
[Lldb-commits] [lldb] r362982 - Create a generic handler for Xfer packets
Author: aadsm Date: Mon Jun 10 13:59:58 2019 New Revision: 362982 URL: http://llvm.org/viewvc/llvm-project?rev=362982&view=rev Log: Create a generic handler for Xfer packets Summary: This is the first of a few patches I have to improve the performance of dynamic module loading on Android. In this first diff I'll describe the context of my main motivation and will then link to it in the other diffs to avoid repeating myself. ## Motivation I have a few scenarios where opening a specific feature on an Android app takes around 40s when lldb is attached to it. The reason for that is because 40 modules are dynamicly loaded at that point in time and each one of them is taking ~1s. ## The problem To learn about new modules we have a breakpoint on a linker function that is called twice whenever a module is loaded. One time just before it's loaded (so lldb can check which modules are loaded) and another right after it's loaded (so lldb can check again which ones are loaded and calculate the diference). It's figuring out which modules are loaded that is taking quite some time. This is currently done by traversing the linked list of loaded shared libraries that the linker maintains in memory. Each item in the linked list requires its own `x` packet sent to the gdb server (this is android so the network also plays a part). In my scenario there are 400+ loaded libraries and even though we read 0x800 worth of bytes at a time we still make ~180 requests that end up taking 150-200ms. We also do this twice, once before the module is loaded (state = eAdd) and another right after (state = eConsistent) which easly adds up to ~400ms per module. ## A solution **Implement `xfer:libraries-svr4` in lldb-server:** I noticed in the code that loads the new modules that it had support for the `xfer:libraries-svr4` packet (added ~4 years ago to support the ds2 debug server) but we didn't support it in lldb-server. This single packet returns an xml list of all the loaded modules by the process. The advantage is that there's no more need to make 180 requests to read the linked list. Additionally this new requests takes around 10ms. **More efficient usage of the `xfer:libraries-svr4` packet in lldb:** When `xfer:libraries-svr4` is available the Process class has a `LoadModules` function that requests this packet and then loads or unloads modules based on the current list of loaded modules by the process. This is the function that is used by the DYLDRendezvous class to get the list of loaded modules before and after the module is loaded. However, this is really not needed since the LoadModules function already loaded or unloaded the modules accordingly. I changed this strategy to call LoadModules only once (after the process has loaded the module). **Bugs** I found a few issues in lldb while implementing this and have submitted independent patches for them. I tried to devide this into multiple logical patches to make it easier to review and discuss. ## Tests I wanted to put these set of diffs up before having all the tests up and running to start having them reviewed from a techical point of view. I'm also having some trouble making the tests running on linux so I need more time to make that happen. # This diff The `xfer` packages follow the same protocol, they are requested with `xfer` and a return that starts with `l` or `m` depending if the offset and length covers the entire data or not. Before implementing the `xfer:libraries-svr4` I refactored the `xfer:auxv` to generically handle xfer packets so we can easly add new ones. The overall structure of the function ends up being: * Parse the packet into its components: object, offset etc. * Depending on the object do its own logic to generate the data. * Return the data based on its size, the requested offset and length. Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: mgorny, krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62499 Added: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp Modified: lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp lldb/trunk/unittests/Process/gdb-remote/CMakeLists.txt lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h Modified: lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h?rev=362982&r1=362981&r2=362982&view=diff
[Lldb-commits] [lldb] r363707 - Implement xfer:libraries-svr4:read packet
Author: aadsm Date: Tue Jun 18 10:51:56 2019 New Revision: 363707 URL: http://llvm.org/viewvc/llvm-project?rev=363707&view=rev Log: Implement xfer:libraries-svr4:read packet Summary: This is the fourth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Implement the `xfer:libraries-svr4` packet by adding a new function that generates the list and then in Handle_xfer I generate the XML for it. The XML is really simple so I'm just using string concatenation because I believe it's more readable than having to deal with a DOM api. Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: emaste, mgorny, srhines, krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62502 Added: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=363707&r1=363706&r2=363707&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jun 18 10:51:56 2019 @@ -32,6 +32,14 @@ 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: @@ -86,6 +94,12 @@ public: 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; Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=363707&r1=363706&r2=363707&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py Tue Jun 18 10:51:56 2019 @@ -513,7 +513,8 @@ class GdbRemoteTestCaseBase(TestBase): self, inferior_args=None, inferior_sleep_seconds=3, -inferior_exe_path=None): +inferior_exe_path=None, +inferior_env=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 @@ -576,6 +577,9 @@ class GdbRemoteTestCaseBase(TestBase): # 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) @@ -656,6 +660,12 @@ class GdbRemoteTestCaseBase(TestBase): {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "process_info_raw"}}], True) +def add_set_environment_packet
[Lldb-commits] [lldb] r367020 - Correctly use GetLoadedModuleList to take advantage of libraries-svr4
Author: aadsm Date: Thu Jul 25 07:28:21 2019 New Revision: 367020 URL: http://llvm.org/viewvc/llvm-project?rev=367020&view=rev Log: Correctly use GetLoadedModuleList to take advantage of libraries-svr4 Summary: Here's a replacement for D62504. I thought I could use LoadModules to implement this but in reality I can't because there are at few issues with it: * The LoadModules assumes that the list returned by GetLoadedModuleList is comprehensive in the sense that reflects all the mapped segments, however, this is not true, for instance VDSO entry is not there since it's loaded manually by LoadVDSO using GetMemoryRegionInfo and it doesn't represent a specific shared object in disk. Because of this LoadModules will unload the VDSO module. * The loader (interpreter) module might have also been loaded using GetMemoryRegionInfo, this is true when we launch the process and the rendezvous structure is not yet available (done through LoadInterpreterModule()). The problem here is that this entry will point to the same file name as the one found in /proc/pid/maps, however, when we read the same module from the r_debug.link_map structure it might be under a different name. This is true at least on CentOS where the loader is a symlink. Because of this LoadModules will unload and load the module in a way where the rendezvous breakpoint is unresolved but not resolved again (because we add the new module first and remove the old one after). The symlink issue might be fixable by first unloading the old and loading the news (but sounds super brittle), however, I'm not sure how to fix the VDSO issue. Since I can't trust it I'm just going to use GetLoadedModuleList directly with the same logic that we use today for when we read the linked list in lldb. The only safe thing to do here is to only calculate differences between different snapshots of the svr4 packet itself. This will also cut the dependency this plugin has from LoadModules. I separated the 2 logics into 2 different functions (remote and not remote) because I don't like mixing 2 different logics in the same function with if/else's. Two different functions makes it easier to reason with I believe. However, I did abstract away the logic that decides if we should take a snapshot or add/remove modules so both functions could reuse it. The other difference between the two is that on the UpdateSOEntriesFromRemote I take the snapshot only once when state = Consistent because I didn't find a good reason to always update that, as we already got the list from state = Add | Remove. I probably should use the same logic on UpdateSOEntries though I don't see a reason not to since it's really using the same data, just read in different places. Any thoughts here? It might also be worthwhile to add a test to make sure we don't unload modules that were not actually "unloaded" like the vdso. I haven't done this yet though. This diff is also missing the option for svr4 like proposed in https://reviews.llvm.org/D62503#1564296, I'll start working on this but wanted to have this up first. Reviewers: labath, jankratochvil, clayborg, xiaobai Reviewed By: labath Subscribers: srhines, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64013 Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=367020&r1=367019&r2=367020&view=diff == --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Jul 25 07:28:21 2019 @@ -680,10 +680,19 @@ public: /// shared library load state. /// /// \return - ///The number of shared libraries that were loaded - virtual size_t LoadModules() { return 0; } + ///A status object indicating if the operation was sucessful or not. + virtual llvm::Error LoadModules() { +return llvm::make_error("Not implemented.", + llvm::inconvertibleErrorCode()); + } - virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; } + /// Query remote GDBServer for a detailed loaded library list + /// \return + ///The list of modules currently loaded by the process, or an error. + virtual llvm::Expected GetLoadedModuleList() { +return llvm::createStringError(llvm::inconvertibleErrorCode(), +
[Lldb-commits] [lldb] r373687 - Revert "Explicitly set entry point arch when it's thumb"
Author: aadsm Date: Thu Oct 3 18:45:58 2019 New Revision: 373687 URL: http://llvm.org/viewvc/llvm-project?rev=373687&view=rev Log: Revert "Explicitly set entry point arch when it's thumb" Backing out because SymbolFile/Breakpad/symtab.test is failing and it seems to be a legit issue. Will investigate. This reverts commit 72153f95ee4c1b52d2f4f483f0ea4f650ec863be. Removed: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Removed: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s?rev=373686&view=auto == --- lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (original) +++ lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (removed) @@ -1,13 +0,0 @@ -# REQUIRES: lld, arm - -# RUN: llvm-mc -triple=thumbv7-eabi %s -filetype=obj -o %t.o -# RUN: ld.lld %t.o -o %t --section-start=.text=0x8074 -e 0x8075 -s -# RUN: %lldb -x -b -o 'dis -s 0x8074 -e 0x8080' -- %t | FileCheck %s -# CHECK: {{.*}}[0x8074] <+0>: movs r0, #0x2a -# CHECK-NEXT: {{.*}}[0x8076] <+2>: movs r7, #0x1 -# CHECK-NEXT: {{.*}}[0x8078] <+4>: svc#0x0 - -_start: -movs r0, #0x2a -movs r7, #0x1 -svc #0x0 \ No newline at end of file Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=373687&r1=373686&r2=373687&view=diff == --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Oct 3 18:45:58 2019 @@ -2703,46 +2703,6 @@ Symtab *ObjectFileELF::GetSymtab() { if (m_symtab_up == nullptr) m_symtab_up.reset(new Symtab(this)); -// In the event that there's no symbol entry for the entry point we'll -// artifically create one. We delegate to the symtab object the figuring -// out of the proper size, this will usually make it span til the next -// symbol it finds in the section. This means that if there are missing -// symbols the entry point might span beyond its function definition. -// We're fine with this as it doesn't make it worse than not having a -// symbol entry at all. -ArchSpec arch = GetArchitecture(); -auto entry_point_addr = GetEntryPointAddress().GetFileAddress(); -if (entry_point_addr != LLDB_INVALID_ADDRESS) { - if (!m_symtab_up->FindSymbolContainingFileAddress(entry_point_addr)) { -uint64_t symbol_id = m_symtab_up->GetNumSymbols(); -SectionSP section_sp = - GetSectionList()->FindSectionContainingFileAddress(entry_point_addr); -Symbol symbol( -symbol_id, -GetNextSyntheticSymbolName().GetCString(), // Symbol name. -false, // Is the symbol name mangled? -eSymbolTypeCode, // Type of this symbol. -true,// Is this globally visible? -false, // Is this symbol debug info? -false, // Is this symbol a trampoline? -true,// Is this symbol artificial? -section_sp, // Section in which this symbol is defined or null. -0, // Offset in section or symbol value. -0, // Size. -false, // Size is valid. -false, // Contains linker annotations? -0); // Symbol flags. -m_symtab_up->AddSymbol(symbol); -// When the entry point is arm thumb we need to explicitly set its -// class address to reflect that. This is important because expression -// evaluation relies on correctly setting a breakpoint at this address. -if (arch.GetMachine() == llvm::Triple::arm && (entry_point_addr & 1)) - m_address_class_map[entry_point_addr ^ 1] = AddressClass::eCodeAlternateISA; -else - m_address_class_map[entry_point_addr] = AddressClass::eCode; - } -} - m_symtab_up->CalculateSymbolSizes(); } Modified: lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp?rev=373687&r1=373686&r2=373687&view=diff == --- lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp (original) +++ lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Thu Oct 3 18:45:58 2019 @@ -172,129 +172,3 @@ TEST_F(ObjectFileELFTest, GetModuleSpeci Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20); EXPECT_EQ(Spec.GetUUID(), Uuid); } - -TEST_F(ObjectFileELFTest, GetSym
[Lldb-commits] [lldb] r367247 - Test load unloading of modules with libraries-svr4
Author: aadsm Date: Mon Jul 29 11:12:55 2019 New Revision: 367247 URL: http://llvm.org/viewvc/llvm-project?rev=367247&view=rev Log: Test load unloading of modules with libraries-svr4 Summary: This doubles the 3 tests running right now on linux by also executing each test with libraries-svr4 enabled. Not sure if there's a better way to do this as I had to copy/paste all the decorators as well... Reviewers: labath, clayborg, xiaobai Reviewed By: labath Subscribers: srhines, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65129 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=367247&r1=367246&r2=367247&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py Mon Jul 29 11:12:55 2019 @@ -93,6 +93,13 @@ class LoadUnloadTestCase(TestBase): "Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" % (wd, err.GetCString())) +def setSvr4Support(self, enabled): +self.runCmd( +"settings set plugin.process.gdb-remote.use-libraries-svr4 {enabled}".format( +enabled="true" if enabled else "false" +) +) + # libloadunload_d.so does not appear in the image list because executable # dependencies are resolved relative to the debuggers PWD. Bug? @expectedFailureAll(oslist=["linux"]) @@ -224,6 +231,20 @@ class LoadUnloadTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_lldb_process_load_and_unload_commands(self): +self.setSvr4Support(False) +self.run_lldb_process_load_and_unload_commands() + +@expectedFailureAll( +bugnumber="llvm.org/pr25805", +hostoslist=["windows"], +triple='.*-android') +@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support +@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently +def test_lldb_process_load_and_unload_commands_with_svr4(self): +self.setSvr4Support(True) +self.run_lldb_process_load_and_unload_commands() + +def run_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" self.copy_shlibs_to_remote() @@ -295,6 +316,15 @@ class LoadUnloadTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support def test_load_unload(self): +self.setSvr4Support(False) +self.run_load_unload() + +@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support +def test_load_unload_with_svr4(self): +self.setSvr4Support(True) +self.run_load_unload() + +def run_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" self.copy_shlibs_to_remote() @@ -335,6 +365,16 @@ class LoadUnloadTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_step_over_load(self): +self.setSvr4Support(False) +self.run_step_over_load() + +@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support +@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently +def test_step_over_load_with_svr4(self): +self.setSvr4Support(True) +self.run_step_over_load() + +def run_step_over_load(self): """Test stepping over code that loads a shared library works correctly.""" self.copy_shlibs_to_remote() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r367052 - [LLDB] Find debugserver in Command Line Tools as well
Author: aadsm Date: Thu Jul 25 13:53:00 2019 New Revision: 367052 URL: http://llvm.org/viewvc/llvm-project?rev=367052&view=rev Log: [LLDB] Find debugserver in Command Line Tools as well Summary: This might be an edge case in regular use but if you're shipping an lldb version with no debugserver lldb will try to use the System one. However, lldb only knows how to find the Xcode one and not the Command Line Tools one. This diff fixes that. We try to find debugserver with `PlatformDarwin::LocateExecutable("debugserver")`, we call `xcode-select -p` to get the path and then assume this path is of Xcode. The changes I did are: * Change `PlatformDarwin::LocateExecutable` to also add the Command Line Tools directory to the list of paths to search for debugserver. * Created a new function to find the Command Line Tools directory named `GetCommandLineToolsLibraryPath`. * Refactored the code that calls `xcode-select -p` into its own function `GetXcodeSelectPath()`. There were 2 identical pieces of code for this so I reduced it to one and used this function everywhere instead. * I also changed `PlatformDarwin::GetSDKDirectoryForModules` to use the `SDKs` directory that exists in the Command Line Tools installation. I'm not sure how to create tests for this. PlatformDarwinTest is really limited and I couldn't find how to mock Filesystem::Instance() so I could create a virtual file system. Reviewers: clayborg, JDevlieghere Reviewed By: clayborg, JDevlieghere Subscribers: jasonmolenda, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65171 Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=367052&r1=367051&r2=367052&view=diff == --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Thu Jul 25 13:53:00 2019 @@ -1102,6 +1102,34 @@ bool PlatformDarwin::ARMGetSupportedArch return false; } +static FileSpec GetXcodeSelectPath() { + static FileSpec g_xcode_select_filespec; + + if (!g_xcode_select_filespec) { +FileSpec xcode_select_cmd("/usr/bin/xcode-select"); +if (FileSystem::Instance().Exists(xcode_select_cmd)) { + int exit_status = -1; + int signo = -1; + std::string command_output; + Status status = + Host::RunShellCommand("/usr/bin/xcode-select --print-path", +nullptr, // current working directory +&exit_status, &signo, &command_output, +std::chrono::seconds(2), // short timeout +false); // don't run in a shell + if (status.Success() && exit_status == 0 && !command_output.empty()) { +size_t first_non_newline = command_output.find_last_not_of("\r\n"); +if (first_non_newline != std::string::npos) { + command_output.erase(first_non_newline + 1); +} +g_xcode_select_filespec = FileSpec(command_output); + } +} + } + + return g_xcode_select_filespec; +} + // Return a directory path like /Applications/Xcode.app/Contents/Developer const char *PlatformDarwin::GetDeveloperDirectory() { std::lock_guard guard(m_mutex); @@ -1159,34 +1187,10 @@ const char *PlatformDarwin::GetDeveloper } if (!developer_dir_path_valid) { - FileSpec xcode_select_cmd("/usr/bin/xcode-select"); - if (FileSystem::Instance().Exists(xcode_select_cmd)) { -int exit_status = -1; -int signo = -1; -std::string command_output; -Status error = -Host::RunShellCommand("/usr/bin/xcode-select --print-path", - nullptr, // current working directory - &exit_status, &signo, &command_output, - std::chrono::seconds(2), // short timeout - false); // don't run in a shell -if (error.Success() && exit_status == 0 && !command_output.empty()) { - const char *cmd_output_ptr = command_output.c_str(); - developer_dir_path[sizeof(developer_dir_path) - 1] = '\0'; - size_t i; - for (i = 0; i < sizeof(developer_dir_path) - 1; i++) { -if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' || -cmd_output_ptr[i] == '\0') - break; -developer_dir_path[i] = cmd_output_ptr[i]; - } - developer_dir_path[i] = '\0'; - - FileSpec devel_dir(developer_dir_path); - if (FileSystem::Instance().IsDirectory(devel_dir)) { -developer_dir_path_valid = true; - } -} + FileSpec devel_dir = GetXcodeSel
[Lldb-commits] [lldb] r373680 - Explicitly set entry point arch when it's thumb
Author: aadsm Date: Thu Oct 3 17:11:22 2019 New Revision: 373680 URL: http://llvm.org/viewvc/llvm-project?rev=373680&view=rev Log: Explicitly set entry point arch when it's thumb Summary: I found a case where the main android binary (app_process32) had thumb code at its entry point but no entry in the symbol table indicating this. This made lldb set a 4 byte breakpoint at that address (we default to arm code) instead of a 2 byte one (like we should for thumb). The big deal with this is that the expression evaluator uses the entry point as a way to know when a JITed expression has finished executing by putting a breakpoint there. Because of this, evaluating expressions on certain android devices (Google Pixel something) made the process crash. This was fixed by checking this specific situation when we parse the symbol table and add an artificial symbol for this 2 byte range and indicating that it's arm thumb. I created 2 unit tests for this, one to check that now we know that the entry point is arm thumb, and the other to make sure we didn't change the behaviour for arm code. I also run the following on the command line with the `app_process32` where I found the issue: **Before:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32[0x1640]: .long 0xf0004668; unknown opcode ``` **After:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32`: app_process32[0x1640] <+0>: movr0, sp app_process32[0x1642]: andeq r0, r0, r0 ``` Reviewers: clayborg, labath, wallace, espindola Subscribers: srhines, emaste, arichardson, kristof.beyls, MaskRay, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68069 Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s?rev=373680&view=auto == --- lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s (added) +++ lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s Thu Oct 3 17:11:22 2019 @@ -0,0 +1,13 @@ +# REQUIRES: lld, arm + +# RUN: llvm-mc -triple=thumbv7-eabi %s -filetype=obj -o %t.o +# RUN: ld.lld %t.o -o %t --section-start=.text=0x8074 -e 0x8075 -s +# RUN: %lldb -x -b -o 'dis -s 0x8074 -e 0x8080' -- %t | FileCheck %s +# CHECK: {{.*}}[0x8074] <+0>: movs r0, #0x2a +# CHECK-NEXT: {{.*}}[0x8076] <+2>: movs r7, #0x1 +# CHECK-NEXT: {{.*}}[0x8078] <+4>: svc#0x0 + +_start: +movs r0, #0x2a +movs r7, #0x1 +svc #0x0 \ No newline at end of file Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=373680&r1=373679&r2=373680&view=diff == --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Oct 3 17:11:22 2019 @@ -2703,6 +2703,46 @@ Symtab *ObjectFileELF::GetSymtab() { if (m_symtab_up == nullptr) m_symtab_up.reset(new Symtab(this)); +// In the event that there's no symbol entry for the entry point we'll +// artifically create one. We delegate to the symtab object the figuring +// out of the proper size, this will usually make it span til the next +// symbol it finds in the section. This means that if there are missing +// symbols the entry point might span beyond its function definition. +// We're fine with this as it doesn't make it worse than not having a +// symbol entry at all. +ArchSpec arch = GetArchitecture(); +auto entry_point_addr = GetEntryPointAddress().GetFileAddress(); +if (entry_point_addr != LLDB_INVALID_ADDRESS) { + if (!m_symtab_up->FindSymbolContainingFileAddress(entry_point_addr)) { +uint64_t symbol_id = m_symtab_up->GetNumSymbols(); +SectionSP section_sp = + GetSectionList()->FindSectionContainingFileAddress(entry_point_addr); +Symbol symbol( +symbol_id, +GetNextSyntheticSymbolName().GetCString(), // Symbol name. +false, // Is the symbol name mangled? +eSymbolTypeCode, // Type of this symbol. +true,// Is this globally visible? +false, // Is this symbol debug info? +false, // Is this symbol a trampoline? +true,// Is this symbol artificial? +section_sp, // Section in which this symbol is defined or null. +0, // Offset in section or symbol value. +0, // Size. +false, // Size is valid. +false, // Contains lin
[Lldb-commits] [lldb] r373768 - Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS
Author: aadsm Date: Fri Oct 4 11:10:42 2019 New Revision: 373768 URL: http://llvm.org/viewvc/llvm-project?rev=373768&view=rev Log: Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS Summary: I'd like to install lldb using the install-distribution target with LLVM_DISTRIBUTION_COMPONENTS but this is currently not possible as the lldb/scripts do not provide any component we can use and install the python scripts. For this effect I created an lldb-python-scripts target and added the install-lldb-python-scripts llvm install target. I tested with: cmake ... -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_DISTRIBUTION_COMPONENTS="lldb;liblldb;lldb-python-scripts" ... DESTDIR=... ninja install-distribution Then checked with bin/lldb -x -o 'script import lldb' Reviewers: labath, xiaobai, clayborg, lanza Subscribers: mgorny, lldb-commits, smeenai, wallace Tags: #lldb Differential Revision: https://reviews.llvm.org/D68370 Modified: lldb/trunk/scripts/CMakeLists.txt Modified: lldb/trunk/scripts/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=373768&r1=373767&r2=373768&view=diff == --- lldb/trunk/scripts/CMakeLists.txt (original) +++ lldb/trunk/scripts/CMakeLists.txt Fri Oct 4 11:10:42 2019 @@ -69,5 +69,14 @@ if(NOT LLDB_BUILD_FRAMEWORK) OUTPUT_STRIP_TRAILING_WHITESPACE) # Install the LLDB python module - install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR}) + add_custom_target(lldb-python-scripts) + add_dependencies(lldb-python-scripts finish_swig) + install(DIRECTORY ${SWIG_PYTHON_DIR}/ +DESTINATION ${SWIG_INSTALL_DIR} +COMPONENT lldb-scripts) + if (NOT LLVM_ENABLE_IDE) +add_llvm_install_targets(install-lldb-python-scripts + COMPONENT lldb-python-scripts + DEPENDS lldb-python-scripts) + endif() endif() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r366848 - Revert "Revert "Add ReadCStringFromMemory for faster string reads""
Author: aadsm Date: Tue Jul 23 13:40:37 2019 New Revision: 366848 URL: http://llvm.org/viewvc/llvm-project?rev=366848&view=rev Log: Revert "Revert "Add ReadCStringFromMemory for faster string reads"" This reverts commit 9c10b620c0619611dfe062216459431955ac4801. Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/source/Host/common/NativeProcessProtocol.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=366848&r1=366847&r2=366848&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jul 23 13:40:37 2019 @@ -84,6 +84,31 @@ public: Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read); + /// Reads a null terminated string from memory. + /// + /// Reads up to \p max_size bytes of memory until it finds a '\0'. + /// If a '\0' is not found then it reads max_size-1 bytes as a string and a + /// '\0' is added as the last character of the \p buffer. + /// + /// \param[in] addr + /// The address in memory to read from. + /// + /// \param[in] buffer + /// An allocated buffer with at least \p max_size size. + /// + /// \param[in] max_size + /// The maximum number of bytes to read from memory until it reads the + /// string. + /// + /// \param[out] total_bytes_read + /// The number of bytes read from memory into \p buffer. + /// + /// \return + /// Returns a StringRef backed up by the \p buffer passed in. + llvm::Expected + ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size, +size_t &total_bytes_read); + virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=366848&r1=366847&r2=366848&view=diff == --- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original) +++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Jul 23 13:40:37 2019 @@ -16,6 +16,8 @@ #include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" +#include "llvm/Support/Process.h" + using namespace lldb; using namespace lldb_private; @@ -659,6 +661,58 @@ Status NativeProcessProtocol::ReadMemory return Status(); } +llvm::Expected +NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer, + size_t max_size, + size_t &total_bytes_read) { + static const size_t cache_line_size = + llvm::sys::Process::getPageSizeEstimate(); + size_t bytes_read = 0; + size_t bytes_left = max_size; + addr_t curr_addr = addr; + size_t string_size; + char *curr_buffer = buffer; + total_bytes_read = 0; + Status status; + + while (bytes_left > 0 && status.Success()) { +addr_t cache_line_bytes_left = +cache_line_size - (curr_addr % cache_line_size); +addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left); +status = ReadMemory(curr_addr, reinterpret_cast(curr_buffer), +bytes_to_read, bytes_read); + +if (bytes_read == 0) + break; + +void *str_end = std::memchr(curr_buffer, '\0', bytes_read); +if (str_end != nullptr) { + total_bytes_read = + (size_t)(reinterpret_cast(str_end) - buffer + 1); + status.Clear(); + break; +} + +total_bytes_read += bytes_read; +curr_buffer += bytes_read; +curr_addr += bytes_read; +bytes_left -= bytes_read; + } + + string_size = total_bytes_read - 1; + + // Make sure we return a null terminated string. + if (bytes_left == 0 && max_size > 0 && buffer[max_size - 1] != '\0') { +buffer[max_size - 1] = '\0'; +total_bytes_read--; + } + + if (!status.Success()) +return status.ToError(); + + return llvm::StringRef(buffer, string_size); +} + lldb::StateType NativeProcessProtocol::GetState() const { std::lock_guard guard(m_state_mutex); return m_state; Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=366848&r1=366847&r2=366848&view=diff == --- lldb/t
[Lldb-commits] [lldb] r366847 - Revert "Revert "Implement xfer:libraries-svr4:read packet""
Author: aadsm Date: Tue Jul 23 13:40:30 2019 New Revision: 366847 URL: http://llvm.org/viewvc/llvm-project?rev=366847&view=rev Log: Revert "Revert "Implement xfer:libraries-svr4:read packet"" This reverts commit 08c38f77c5fb4d3735ec215032fed8ee6730b3db. Added: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.cpp lldb/trunk/source/Plugins/Process/POSIX/NativeProcessELF.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=366847&r1=366846&r2=366847&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Tue Jul 23 13:40:30 2019 @@ -32,6 +32,14 @@ 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: @@ -86,6 +94,12 @@ public: 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; Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=366847&r1=366846&r2=366847&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py Tue Jul 23 13:40:30 2019 @@ -513,7 +513,8 @@ class GdbRemoteTestCaseBase(TestBase): self, inferior_args=None, inferior_sleep_seconds=3, -inferior_exe_path=None): +inferior_exe_path=None, +inferior_env=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 @@ -576,6 +577,9 @@ class GdbRemoteTestCaseBase(TestBase): # 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) @@ -656,6 +660,12 @@ class GdbRemoteTestCaseBase(TestBase): {"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", @@ -816,6 +826,7 @@ class GdbRemoteTestCaseBase(TestBase): "error"]) self.assertIsNotNone(val) +mem_region_dict["name"] = seven.unhexlify(mem_region_dict.get("name", "")) # Return the dictionary of key-value pairs
[Lldb-commits] [lldb] r374005 - Fixing missing lldb-scripts rename from D68370
Author: aadsm Date: Mon Oct 7 18:10:03 2019 New Revision: 374005 URL: http://llvm.org/viewvc/llvm-project?rev=374005&view=rev Log: Fixing missing lldb-scripts rename from D68370 Modified: lldb/trunk/CMakeLists.txt Modified: lldb/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=374005&r1=374004&r2=374005&view=diff == --- lldb/trunk/CMakeLists.txt (original) +++ lldb/trunk/CMakeLists.txt Mon Oct 7 18:10:03 2019 @@ -237,7 +237,7 @@ if (NOT LLDB_DISABLE_PYTHON) add_dependencies(lldb-python-scripts finish_swig) install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/ DESTINATION ${LLDB_PYTHON_RELATIVE_PATH} - COMPONENT lldb-scripts) + COMPONENT lldb-python-scripts) if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-lldb-python-scripts COMPONENT lldb-python-scripts ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r374132 - Explicitly set entry point arch when it's thumb [Second Try]
Author: aadsm Date: Tue Oct 8 16:44:49 2019 New Revision: 374132 URL: http://llvm.org/viewvc/llvm-project?rev=374132&view=rev Log: Explicitly set entry point arch when it's thumb [Second Try] Summary: This is a redo of D68069 because I reverted it due to some concerns that were now addressed along with the new comments that @labath added. I found a case where the main android binary (app_process32) had thumb code at its entry point but no entry in the symbol table indicating this. This made lldb set a 4 byte breakpoint at that address (we default to arm code) instead of a 2 byte one (like we should for thumb). The big deal with this is that the expression evaluator uses the entry point as a way to know when a JITed expression has finished executing by putting a breakpoint there. Because of this, evaluating expressions on certain android devices (Google Pixel something) made the process crash. This was fixed by checking this specific situation when we parse the symbol table and add an artificial symbol for this 2 byte range and indicating that it's arm thumb. I created 2 unit tests for this, one to check that now we know that the entry point is arm thumb, and the other to make sure we didn't change the behaviour for arm code. I also run the following on the command line with the `app_process32` where I found the issue: **Before:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32[0x1640]: .long 0xf0004668; unknown opcode ``` **After:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32`: app_process32[0x1640] <+0>: movr0, sp app_process32[0x1642]: andeq r0, r0, r0 ``` Reviewers: clayborg, labath, wallace, espindola Reviewed By: labath Subscribers: labath, lldb-commits, MaskRay, kristof.beyls, arichardson, emaste, srhines Tags: #lldb Differential Revision: https://reviews.llvm.org/D68533 Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s Modified: lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml lldb/trunk/lit/SymbolFile/Breakpad/symtab.test lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Modified: lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml?rev=374132&r1=374131&r2=374132&view=diff == --- lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml (original) +++ lldb/trunk/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml Tue Oct 8 16:44:49 2019 @@ -6,7 +6,7 @@ FileHeader: Data:ELFDATA2LSB Type:ET_EXEC Machine: EM_X86_64 - Entry: 0x004000D0 + Entry: 0x0040 Sections: - Name:.text1 Type:SHT_PROGBITS Modified: lldb/trunk/lit/SymbolFile/Breakpad/symtab.test URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/symtab.test?rev=374132&r1=374131&r2=374132&view=diff == --- lldb/trunk/lit/SymbolFile/Breakpad/symtab.test (original) +++ lldb/trunk/lit/SymbolFile/Breakpad/symtab.test Tue Oct 8 16:44:49 2019 @@ -3,12 +3,13 @@ # RUN: -s %s | FileCheck %s # CHECK-LABEL: (lldb) image dump symtab symtab.out -# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4: +# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5: # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name -# CHECK: [0] 0 X Code0x004000c0 0x0010 0x f2 -# CHECK: [1] 0 X Code0x004000d0 0x0022 0x _start -# CHECK: [2] 0 X Code0x004000a0 0x000d 0x func_only -# CHECK: [3] 0 X Code0x004000b0 0x000c 0x f1_func +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol1$$symtab.out +# CHECK: [1] 0 X Code0x004000c0 0x0010 0x f2 +# CHECK: [2] 0 X Code0x004000d0 0x0022 0x _start +# CHECK: [3] 0 X Code0x004000a0 0x000d 0x func_only +# CHECK: [4] 0 X Code0x004000b0 0x000c 0x f1_func # CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v # CHECK: Address: symtab.out[0x004000b0] (symtab.out.PT_LOAD[0]..text2 + 0) Added: lldb/trunk/lit/SymbolFile/dissassemble-entry-point.s URL: http://llvm.org/viewvc/llv
[Lldb-commits] [lldb] r374192 - Update breakpad lit test to be independent of the unnamed symbol number
Author: aadsm Date: Wed Oct 9 11:02:59 2019 New Revision: 374192 URL: http://llvm.org/viewvc/llvm-project?rev=374192&view=rev Log: Update breakpad lit test to be independent of the unnamed symbol number Modified: lldb/trunk/lit/SymbolFile/Breakpad/symtab.test Modified: lldb/trunk/lit/SymbolFile/Breakpad/symtab.test URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/symtab.test?rev=374192&r1=374191&r2=374192&view=diff == --- lldb/trunk/lit/SymbolFile/Breakpad/symtab.test (original) +++ lldb/trunk/lit/SymbolFile/Breakpad/symtab.test Wed Oct 9 11:02:59 2019 @@ -5,7 +5,7 @@ # CHECK-LABEL: (lldb) image dump symtab symtab.out # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5: # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name -# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol1$$symtab.out +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out # CHECK: [1] 0 X Code0x004000c0 0x0010 0x f2 # CHECK: [2] 0 X Code0x004000d0 0x0022 0x _start # CHECK: [3] 0 X Code0x004000a0 0x000d 0x func_only ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits