aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
AgeCommit message (Collapse)AuthorFilesLines
13 days[LLDB] Add support for the structured data plugins in lldb-server (#159457)Walter Erquinigo1-0/+5
The LLDB client has support for structured data plugins, but lldb-server doesn't have corresponding support for it. This patch adds the missing functionality in LLGS for servers to register their supported plugins and send corresponding async messages.
2023-06-27[lldb] Use SmallVector for handling register dataDavid Spickett1-0/+6
Previously lldb was using arrays of size kMaxRegisterByteSize to handle registers. This was set to 256 because the largest possible register we support is Arm's scalable vectors (SVE) which can be up to 256 bytes long. This means for most operations aside from SVE, we're wasting 192 bytes of it. Which is ok given that we don't have to pay the cost of a heap alocation and 256 bytes isn't all that much overall. With the introduction of the Arm Scalable Matrix extension there is a new array storage register, ZA. This register is essentially a square made up of SVE vectors. Therefore ZA could be up to 64kb in size. https://developer.arm.com/documentation/ddi0616/latest/ "The Effective Streaming SVE vector length, SVL, is a power of two in the range 128 to 2048 bits inclusive." "The ZA storage is architectural register state consisting of a two-dimensional ZA array of [SVLB × SVLB] bytes." 99% of operations will never touch ZA and making every stack frame 64kb+ just for that slim chance is a bad idea. Instead I'm switching register handling to use SmallVector with a stack allocation size of kTypicalRegisterByteSize. kMaxRegisterByteSize will be used in places where we can't predict the size of register we're reading (in the GDB remote client). The result is that the 99% of small register operations can use the stack as before and the actual ZA operations will move to the heap as needed. I tested this by first working out -wframe-larger-than values for all the libraries using the arrays previously. With this change I was able to increase kMaxRegisterByteSize to 256*256 without hitting those limits. With the exception of the GDB server which needs to use a max size buffer. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D153626
2023-03-30[lldb-server/linux] Use waitpid(-1) to collect inferior eventsPavel Labath1-2/+2
This is a follow-up to D116372, which had a rather unfortunate side effect of making the processing of a single SIGCHLD quadratic in the number of threads -- which does not matter for simple applications, but can get really bad for applications with thousands of threads. This patch fixes the problem by implementing the other possibility mentioned in the first patch -- doing waitpid(-1) centrally and then routing the events to the correct process instance. The "uncollected" threads are held in the process factory class -- which I've renamed to Manager for this purpose, as it now does more than creating processes. Differential Revision: https://reviews.llvm.org/D146977
2022-07-15[lldb] [llgs] Fix disabling non-stop modeMichał Górny1-0/+1
Stop all processes and clear notification queues when disabling non-stop mode. Ensure that no stop notifications are sent for processes stopped due to the mode switch. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128893
2022-07-15[lldb] [llgs] Send process output asynchronously in non-stop modeMichał Górny1-0/+5
Introduce a new %Stdio notification category and use it to send process output asynchronously when running in non-stop mode. This is an LLDB extension since GDB does not use the 'O' packet for process output, just for replies to 'qRcmd' packets. Using the async notification mechanism implies that only the first output packet is sent immediately to the client. The client needs to request subsequent notifications (if any) using the new vStdio packet (that works pretty much like vStopped for the Stop notification queue). The packet handler in lldb-server tests is updated to handle the async stdio packets in addition to the regular O packets. However, due to the implications noted above, it can only handle the first output packet sent by the server. Subsequent packets need to be explicitly requested via vStdio. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128849
2022-07-15Reland "[lldb] [llgs] Fix multi-resume bugs with nonstop mode"Michał Górny1-0/+3
Improve handling of multiple successive continue packets in non-stop mode. More specifically: 1. Explicitly send error response (instead of crashing on assertion) if the user attempts to resume the same process twice. Since we do not support thread-level non-stop mode, one needs to always stop the process explicitly before resuming another thread set. 2. Actually stop the process if "vCont;t" is delivered to a running process. Similarly, we only support stopping all the running threads simultaneously (via -1) and return an error in any other case. With this patch, running multiple processes simultaneously is still unsupported. The patch also employs a hack to avoid enabling stdio forwarding on "vCont;t" packet. Both of these issues are addressed by followup patches. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128710
2022-07-15Revert "[lldb] [llgs] Fix multi-resume bugs with nonstop mode"Michał Górny1-3/+0
This reverts commit f8605da8758fbae16410e4ed5493a39429fd73ec. This is causing buildbot failures and now I see that I have not updated the tests to use "stop" instead of "trap".
2022-07-15[lldb] [llgs] Fix multi-resume bugs with nonstop modeMichał Górny1-0/+3
Improve handling of multiple successive continue packets in non-stop mode. More specifically: 1. Explicitly send error response (instead of crashing on assertion) if the user attempts to resume the same process twice. Since we do not support thread-level non-stop mode, one needs to always stop the process explicitly before resuming another thread set. 2. Actually stop the process if "vCont;t" is delivered to a running process. Similarly, we only support stopping all the running threads simultaneously (via -1) and return an error in any other case. With this patch, running multiple processes simultaneously is still unsupported. The patch also employs a hack to avoid enabling stdio forwarding on "vCont;t" packet. Both of these issues are addressed by followup patches. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128710
2022-07-14[lldb] [llgs] Remove not-really-used m_inferior_prev_stateMichał Górny1-1/+0
Remove m_inferior_prev_state that's not suitable for multiprocess debugging and that does not seem to be really used at all. The only use of the variable right now is to "prevent" sending the stop reason after attach/launch. However, this code is never actually run since none of the process plugins actually use eStateLaunching or eStateAttaching. Through adding an assert, I've confirmed that it's never hit in any of the LLDB tests or while attaching/launching debugged process via lldb-server and via lldb CLI. Differential Revision: https://reviews.llvm.org/D128878 Sponsored by: The FreeBSD Foundation
2022-07-14[lldb] [llgs] Convert m_debugged_processes into a map of structsMichał Górny1-3/+12
Convert the m_debugged_processes map from NativeProcessProtocol pointers to structs, and combine the additional set(s) holding the additional process properties into a flag field inside this struct. This is desirable since there are more properties to come and having a single structure with all information should be cleaner and more efficient than using multiple sets for that. Suggested by Pavel Labath in D128893. Differential Revision: https://reviews.llvm.org/D129652
2022-06-25Reland "[lldb] [llgs] Support multiprocess in qfThreadInfo"Michał Górny1-0/+3
Now preserving the non-standard behavior of returning "OK" response when there is no debugged process. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128152
2022-06-25Revert "[lldb] [llgs] Support multiprocess in qfThreadInfo"Michał Górny1-3/+0
This reverts part of commit 75757c86c695a6b4695458343637b3c4fe86def6. It broke the following test: commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py I need more time to figure it out, so I'm reverting the code changes and marking the tests depending on them xfail.
2022-06-24[lldb] [llgs] Introduce an AppendThreadIDToResponse() helperMichał Górny1-0/+3
Introduce a helper function to append GDB Remote Serial Protocol "thread IDs", with optional PID in multiprocess mode. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128324
2022-06-24[lldb] [llgs] Implement the 'T' packetMichał Górny1-0/+2
Implement the 'T' packet that is used to verify whether the specified thread belongs to the debugged processes. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128170
2022-06-24[lldb] [llgs] Support multiprocess in qfThreadInfoMichał Górny1-0/+3
Update the `qfThreadInfo` handler to report threads of all debugged processes and include PIDs when in multiprocess mode. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128152
2022-06-24[lldb] [llgs] Support resuming one process with PID!=current via vContMichał Górny1-9/+0
Extend vCont function to support resuming a process with an arbitrary PID, that could be different than the one selected via Hc (or no process at all may be selected). Resuming more than one process simultaneously is not supported yet. Remove the ReadTid() method that was only used by Handle_vCont(), and furthermore it was wrongly using m_current_process rather than m_continue_process. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D127862
2022-06-24[lldb] [llgs] Implement the vKill packetMichał Górny1-0/+4
Implement the support for the vKill packet. This is the modern packet used by the GDB Remote Serial Protocol to kill one of the debugged processes. Unlike the `k` packet, it has well-defined semantics. The `vKill` packet takes the PID of the process to kill, and always replies with an `OK` reply (rather than the exit status, as LLGS does for `k` packets at the moment). Additionally, unlike the `k` packet it does not cause the connection to be terminated once the last process is killed — the client needs to close it explicitly. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D127667
2022-06-21[lldb] [llgs] Implement non-stop style stop notification packetsMichał Górny1-2/+20
Implement the support for %Stop asynchronous notification packet format in LLGS. This does not implement full support for non-stop mode for threaded programs -- process plugins continue stopping all threads on every event. However, it will be used to implement asynchronous events in multiprocess debugging. The non-stop protocol is enabled using QNonStop packet. When it is enabled, the server uses notification protocol instead of regular stop replies. Since all threads are always stopped, notifications are always generated for all active threads and copied into stop notification queue. If the queue was empty, the initial asynchronous %Stop notification is sent to the client immediately. The client needs to (eventually) acknowledge the notification by sending the vStopped packet, in which case it is popped from the queue and the stop reason for the next thread is reported. This continues until notification queue is empty again, in which case an OK reply is sent. Asychronous notifications are also used for vAttach results and program exits. The `?` packet uses a hybrid approach -- it returns the first stop reason synchronously, and exposes the stop reasons for remaining threads via vStopped queue. The change includes a test case for a program generating a segfault on 3 threads. The server is expected to generate a stop notification for the segfaulting thread, along with the notifications for the other running threads (with "no stop reason"). This verifies that the stop reasons are correctly reported for all threads, and that notification queue works. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D125575
2022-06-20[lldb] [llgs] Refactor SendStopReasonForState for multiprocessMichał Górny1-1/+2
Refactor GDBRemoteCommunicationServerLLGS::SendStopReasonForState() to accept process as an argument rather than hardcoding m_current_process, in order to make it work correctly for multiprocess scenarios. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D127497
2022-06-20[lldb] [llgs] Refactor SendStopReplyPacketForThread for multiprocessMichał Górny1-1/+2
Refactor SendStopReplyPacketForThread() to accept process instance as a parameter rather than use m_current_process. This future-proofs it for multiprocess support. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D127289
2022-06-17[lldb] Fix modernize-use-override warnings (NFC)Jonas Devlieghere1-1/+1
Fix modernize-use-override warnings. Because this check is listed in LLDB's top level .clang-tidy configuration, the check is enabled by default and the resulting warnings show up in my editor. I've audited the modified lines. This is not a blind change.
2021-11-25[lldb/gdb-remote] Ignore spurious ACK packetsPavel Labath1-1/+0
Although I cannot find any mention of this in the specification, both gdb and lldb agree on sending an initial + packet after establishing the connection. OTOH, gdbserver and lldb-server behavior is subtly different. While lldb-server *expects* the initial ack, and drops the connection if it is not received, gdbserver will just ignore a spurious ack at _any_ point in the connection. This patch changes lldb's behavior to match that of gdb. An ACK packet is ignored at any point in the connection (except when expecting an ACK packet, of course). This is inline with the "be strict in what you generate, and lenient in what you accept" philosophy, and also enables us to remove some special cases from the server code. I've extended the same handling to NAK (-) packets, mainly because I don't see a reason to treat them differently here. (The background here is that we had a stub which was sending spurious + packets. This bug has since been fixed, but I think this change makes sense nonetheless.) Differential Revision: https://reviews.llvm.org/D114520
2021-10-26[lldb] [lldb-gdbserver] Unify listen/connect code to use ↵Michał Górny1-0/+2
ConnectionFileDescriptor Unify the listen and connect code inside lldb-server to use ConnectionFileDescriptor uniformly rather than a mix of it and Acceptor. This involves: - adding a function to map legacy values of host:port parameter (including legacy server URLs) into CFD-style URLs - adding a callback to return "local socket id" (i.e. UNIX socket path or TCP port number) between listen() and accept() calls in CFD - adding a "unix-abstract-accept" scheme to CFD As an additional advantage, this permits lldb-server to accept any URL known to CFD including the new serial:// scheme. Effectively, lldb-server can now listen on the serial port. Tests for connecting over a pty are added to test that. Differential Revision: https://reviews.llvm.org/D111964
2021-09-10[lldb] [gdb-remote] Implement the vRun packetMichał Górny1-0/+2
Implement the simpler vRun packet and prefer it over the A packet. Unlike the latter, it tranmits command-line arguments without redundant indices and lengths. This also improves GDB compatibility since modern versions of gdbserver do not implement the A packet at all. Make qLaunchSuccess not obligatory when using vRun. It is not implemented by gdbserver, and since vRun returns the stop reason, we can assume it to be successful. Differential Revision: https://reviews.llvm.org/D107931
2021-09-06[lldb] [llgs server] Support creating core dumps on NetBSDMichał Górny1-0/+2
Add a new SaveCore() process method that can be used to request a core dump. This is currently implemented on NetBSD via the PT_DUMPCORE ptrace(2) request, and enabled via 'savecore' extension. Protocol-wise, a new qSaveCore packet is introduced. It accepts zero or more semicolon-separated key:value options, invokes the core dump and returns a key:value response. Currently the only option supported is "path-hint", and the return value contains the "path" actually used. The support for the feature is exposed via qSaveCore qSupported feature. Differential Revision: https://reviews.llvm.org/D101285
2021-07-27[lldb][AArch64] Add memory tag writing to lldb-serverDavid Spickett1-0/+2
This is implemented using the QMemTags packet, as specified by GDB in: https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html#General-Query-Packets (recall that qMemTags was previously added to read tags) On receipt of a valid packet lldb-server will: * align the given address and length to granules (most of the time lldb will have already done this but the specification doesn't guarantee it) * Repeat the supplied tags as many times as needed to cover the range. (if tags > range we just use as many as needed) * Call ptrace POKEMTETAGS to write the tags. The ptrace step will loop just like the tag read does, until all tags are written or we get an error. Meaning that if ptrace succeeds it could be a partial write. So we call it again and if we then get an error, return an error to lldb. We are not going to attempt to restore tags after a partial write followed by an error. This matches the behaviour of the existing memory writes. The lldb-server tests have been extended to include read and write in the same test file. With some updated function names since "qMemTags" vs "QMemTags" isn't very clear when they're next to each other. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D105180
2021-06-24[lldb][AArch64] Add memory tag reading to lldb-serverDavid Spickett1-0/+2
This adds memory tag reading using the new "qMemTags" packet and ptrace on AArch64 Linux. This new packet is following the one used by GDB. (https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html) On AArch64 Linux we use ptrace's PEEKMTETAGS to read tags and we assume that lldb has already checked that the memory region actually has tagging enabled. We do not assume that lldb has expanded the requested range to granules and expand it again to be sure. (although lldb will be sending aligned ranges because it happens to need them client side anyway) Also we don't assume untagged addresses. So for AArch64 we'll remove the top byte before using them. (the top byte includes MTE and other non address data) To do the ptrace read NativeProcessLinux will ask the native register context for a memory tag manager based on the type in the packet. This also gives you the ptrace numbers you need. (it's called a register context but it also has non register data, so it saves adding another per platform sub class) The only supported platform for this is AArch64 Linux and the only supported tag type is MTE allocation tags. Anything else will error. Ptrace can return a partial result but for lldb-server we will be treating that as an error. To succeed we need to get all the tags we expect. (Note that the protocol leaves room for logical tags to be read via qMemTags but this is not going to be implemented for lldb at this time.) Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D95601
2021-04-24[lldb] [llgs] Support owning and detaching extra processesMichał Górny1-1/+6
Add a NativeDelegate API to pass new processes (forks) to LLGS, and support detaching them via the 'D' packet. A 'D' packet without a specific PID detaches all processes, otherwise it detaches either the specified subprocess or the main process, depending on the passed PID. Differential Revision: https://reviews.llvm.org/D100191
2021-04-24[lldb] [Process] Introduce protocol extension support APIMichał Górny1-0/+5
Introduce a NativeProcessProtocol API for indicating support for protocol extensions and enabling them. LLGS calls GetSupportedExtensions() method on the process factory to determine which extensions are supported by the plugin. If the future is both supported by the plugin and reported as supported by the client, LLGS enables it and reports to the client as supported by the server. The extension is enabled on the process instance by calling SetEnabledExtensions() method. This is done after qSupported exchange (if the debugger is attached to any process), as well as after launching or attaching to a new inferior. The patch adds 'fork' extension corresponding to 'fork-events+' qSupported feature and 'vfork' extension for 'vfork-events+'. Both features rely on 'multiprocess+' being supported as well. Differential Revision: https://reviews.llvm.org/D100153
2021-04-14[lldb] Move QThreadSuffixSupported and QListThreadsInStopReply into llgsPavel Labath1-0/+6
These were in the shared llgs+platform code, but they only make sense for llgs (as they deal with how the server reports information about debugged processes).
2021-04-13[lldb] [gdb-remote server] Abstract away getting current processMichał Górny1-1/+3
Introduce new m_current_process and m_continue_process variables that keep the pointers to currently selected process. At this moment, this is equivalent to m_debugged_process_up but it lays foundations for the future multiprocess support. Differential Revision: https://reviews.llvm.org/D100256
2021-04-13[lldb] [gdb-remote server] Refactor handling qSupportedMichał Górny1-0/+3
Refactor handling qSupported to use a virtual HandleFeatures() method. The client-provided features are split into an array and passed to the method. The method returns an array of server features that are concatenated into the qSupported response to the server. The base implementation of HandleFeatures() in GDBRemoteCommunicationServerCommon now includes only flags common to both platform server and llgs, while llgs-specific flags are inserted in GDBRemoteCommunicationServerLLGS. Differential Revision: https://reviews.llvm.org/D100140
2021-03-30[trace][intel-pt] Implement trace start and trace stopWalter Erquinigo1-5/+5
This implements the interactive trace start and stop methods. This diff ended up being much larger than I anticipated because, by doing it, I found that I had implemented in the beginning many things in a non optimal way. In any case, the code is much better now. There's a lot of boilerplate code due to the gdb-remote protocol, but the main changes are: - New tracing packets: jLLDBTraceStop, jLLDBTraceStart, jLLDBTraceGetBinaryData. The gdb-remote packet definitions are quite comprehensive. - Implementation of the "process trace start|stop" and "thread trace start|stop" commands. - Implementaiton of an API in Trace.h to interact with live traces. - Created an IntelPTDecoder for live threads, that use the debugger's stop id as checkpoint for its internal cache. - Added a functionality to stop the process in case "process tracing" is enabled and a new thread can't traced. - Added tests I have some ideas to unify the code paths for post mortem and live threads, but I'll do that in another diff. Differential Revision: https://reviews.llvm.org/D91679
2021-03-30[lldb] [server] Support for multiprocess extensionMichał Górny1-0/+9
Add a minimal support for the multiprocess extension in lldb-server. The server indicates support for it via qSupported, and accepts thread-ids containing a PID. However, it still does not support debugging more than one inferior, so any other PID value results in an error. Differential Revision: https://reviews.llvm.org/D98482
2021-01-24Implement vAttachOrWaitAugusto Noronha1-1/+5
Implements the required functions on gdb-remote so the '--include-existing' flag of process attach works correctly on Linux. Reviewed By: labath, clayborg Differential Revision: https://reviews.llvm.org/D94672
2021-01-14Implement vAttachWait in lldb-serverAugusto Noronha1-0/+13
This commit vAttachWait in lldb-server, so --waitfor can be used on Linux Reviewed By: labath, clayborg Differential Revision: https://reviews.llvm.org/D93895
2020-11-11[intel-pt][trace] Implement a "get supported trace type" packetWalter Erquinigo1-0/+2
Depends on D89283. The goal of this packet (jTraceGetSupportedType) is to be able to query the gdb-server for the tracing technology that can work for the current debuggeer, which can make the user experience simpler but allowing the user to simply type thread trace start to start tracing the current thread without even telling the debugger to use "intel-pt", for example. Similarly, `thread trace start [args...]` would accept args beloging to the working trace type. Also, if the user typed help thread trace start We could directly show the help information of the trace type that is supported for the target, or mention instead that no tracing is supported, if that's the case. I added some simple tests, besides, when I ran this on my machine with intel-pt support, I got $ process plugin packet send "jTraceSupportedType" packet: jTraceSupportedType response: {"description":"Intel Processor Trace","pluginName":"intel-pt"} On a machine without intel-pt support, I got $ process plugin packet send "jTraceSupportedType" packet: jTraceSupportedType response: E00; Reviewed By: clayborg, labath Differential Revision: https://reviews.llvm.org/D90490
2020-10-14[lldb-server][linux] Add ability to allocate memoryPavel Labath1-0/+2
This patch adds support for the _M and _m gdb-remote packets, which (de)allocate memory in the inferior. This works by "injecting" a m(un)map syscall into the inferior. This consists of: - finding an executable page of memory - writing the syscall opcode to it - setting up registers according to the os syscall convention - single stepping over the syscall The advantage of this approach over calling the mmap function is that this works even in case the mmap function is buggy or unavailable. The disadvantage is it is more platform-dependent, which is why this patch only works on X86 (_32 and _64) right now. Adding support for other linux architectures should be easy and consist of defining the appropriate syscall constants. Adding support for other OSes depends on the its ability to do a similar trick. Differential Revision: https://reviews.llvm.org/D89124
2020-06-02[lldb] NFC remove DISALLOW_COPY_AND_ASSIGNKonrad Kleine1-1/+4
Summary: This is how I applied my clang-tidy check (see https://reviews.llvm.org/D80531) in order to remove `DISALLOW_COPY_AND_ASSIGN` and have deleted copy ctors and deleted assignment operators instead. ``` lang=bash grep DISALLOW_COPY_AND_ASSIGN /opt/notnfs/kkleine/llvm/lldb -r -l | sort | uniq > files for i in $(cat files); do clang-tidy \ --checks="-*,modernize-replace-disallow-copy-and-assign-macro" \ --format-style=LLVM \ --header-filter=.* \ --fix \ -fix-errors \ $i; done ``` Reviewers: espindola, labath, aprantl, teemperor Reviewed By: labath, aprantl, teemperor Subscribers: teemperor, aprantl, labath, emaste, sbc100, aheejin, MaskRay, arphaman, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D80543
2020-04-02[lldb] Change Communication::SetConnection to take a unique_ptrPavel Labath1-1/+1
The function takes ownership of the object. This makes that explicit, and avoids unowned pointers floating around.
2020-02-20Add target.xml support for qXfer request.Muhammad Omair Javaid1-0/+2
Summary: Requesting registers one by one takes a while in our project. We want to get rid of it by using target.xml. Reviewers: jarin, labath, omjavaid Reviewed By: labath, omjavaid Subscribers: omjavaid, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74217
2020-02-17[lldb] Update header guards to be consistent and compliant with LLVM (NFC)Jonas Devlieghere1-3/+3
LLDB has a few different styles of header guards and they're not very consistent because things get moved around or copy/pasted. This patch unifies the header guards across LLDB and converts everything to match LLVM's style. Differential revision: https://reviews.llvm.org/D74743
2020-02-18Revert "[lldb/lldb-server] Add target.xml support for qXfer request."Muhammad Omair Javaid1-2/+0
This patch cause floating point registers to fail on LLDB aarch64-linux buildbot. http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/1713 This reverts commit aedc196101e33bd58f7443c5b93398418ce55edf.
2020-02-17[lldb/lldb-server] Add target.xml support for qXfer request.Levon Ter-Grigoryan1-0/+2
Summary: Synthesize target.xml in lldb-server to avoid a long chain of qRegisterInfo packets, which can be slow over low-latency links. Reviewers: jarin, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74217
2019-07-23Revert "Revert "Implement xfer:libraries-svr4:read packet""Antonio Afonso1-0/+2
This reverts commit 08c38f77c5fb4d3735ec215032fed8ee6730b3db. llvm-svn: 366847
2019-07-01Revert "Implement xfer:libraries-svr4:read packet"Pavel Labath1-2/+0
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
2019-06-18Implement xfer:libraries-svr4:read packetAntonio Afonso1-0/+2
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 llvm-svn: 363707
2019-06-10Create a generic handler for Xfer packetsAntonio Afonso1-2/+5
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:<object>:<read|write>:<annex>:<offset,length>` 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 llvm-svn: 362982
2019-05-30[lldb-server] Support 'g' packetsPavel Labath1-0/+2
Differential Revision: https://reviews.llvm.org/D62221 Patch by Guilherme Andrade <guiandrade@google.com>. llvm-svn: 362063
2019-04-10[NFC] Remove ASCII lines from commentsJonas Devlieghere1-10/+0
A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135