aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote
AgeCommit message (Collapse)AuthorFilesLines
13 days[LLDB] Add support for the structured data plugins in lldb-server (#159457)Walter Erquinigo2-0/+36
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.
2025-08-26[lldb] Fix spacing in "proccess plugin packet monitor" helpDavid Spickett1-1/+1
2025-08-05[lldb] Fix the buildKazu Hirata1-1/+1
This patch fixes: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:623:47: error: expected ';' after expression
2025-08-05[LLDB] Complete a missing register format mapping in the gdb-remote p… ↵Walter Erquinigo2-1/+85
(#152170) …rotocol When writing a custom gdb-remote server I realized that the encoder and decoder of register formats is incomplete. - Add the encoder on the server side and add an llvm_unreachable is there's a missing case. - Add a decoder on the client side that doesn't fail. We have to keep it flexible. I couldn't figure out an easy way to test this but the changes seem very straightforward to me.
2025-07-29[lldb] Add WebAssembly Process Plugin (#150143)Jonas Devlieghere2-2/+9
Extend support in LLDB for WebAssembly. This PR adds a new Process plugin (ProcessWasm) that extends ProcessGDBRemote for WebAssembly targets. It adds support for WebAssembly's memory model with separate address spaces, and the ability to fetch the call stack from the WebAssembly runtime. I have tested this change with the WebAssembly Micro Runtime (WAMR, https://github.com/bytecodealliance/wasm-micro-runtime) which implements a GDB debug stub and supports the qWasmCallStack packet. ``` (lldb) process connect --plugin wasm connect://localhost:4567 Process 1 stopped * thread #1, name = 'nobody', stop reason = trace frame #0: 0x40000000000001ad wasm32_args.wasm`main: -> 0x40000000000001ad <+3>: global.get 0 0x40000000000001b3 <+9>: i32.const 16 0x40000000000001b5 <+11>: i32.sub 0x40000000000001b6 <+12>: local.set 0 (lldb) b add Breakpoint 1: where = wasm32_args.wasm`add + 28 at test.c:4:12, address = 0x400000000000019c (lldb) c Process 1 resuming Process 1 stopped * thread #1, name = 'nobody', stop reason = breakpoint 1.1 frame #0: 0x400000000000019c wasm32_args.wasm`add(a=<unavailable>, b=<unavailable>) at test.c:4:12 1 int 2 add(int a, int b) 3 { -> 4 return a + b; 5 } 6 7 int (lldb) bt * thread #1, name = 'nobody', stop reason = breakpoint 1.1 * frame #0: 0x400000000000019c wasm32_args.wasm`add(a=<unavailable>, b=<unavailable>) at test.c:4:12 frame #1: 0x40000000000001e5 wasm32_args.wasm`main at test.c:12:12 frame #2: 0x40000000000001fe wasm32_args.wasm ``` This PR is based on an unmerged patch from Paolo Severini: https://reviews.llvm.org/D78801. I intentionally stuck to the foundations to keep this PR small. I have more PRs in the pipeline to support the other features/packets. My motivation for supporting Wasm is to support debugging Swift compiled to WebAssembly: https://www.swift.org/documentation/articles/wasm-getting-started.html
2025-07-28[lldb] support ieee_single and ieee_double gdbtypes for registers (#150268)satyanarayana reddy janga1-1/+2
Some gdb remote servers send target.xml that contains ``` <reg name='ft0' bitsize='32' type='ieee_single' dwarf_regnum='32'/> <reg name='ft1' bitsize='32' type='ieee_single' dwarf_regnum='33'/> <reg name='ft2' bitsize='32' type='ieee_single' dwarf_regnum='34'/> <reg name='ft3' bitsize='32' type='ieee_single' dwarf_regnum='35'/> <reg name='ft4' bitsize='32' type='ieee_single' dwarf_regnum='36'/> <reg name='ft5' bitsize='32' type='ieee_single' dwarf_regnum='37'/> <reg name='ft6' bitsize='32' type='ieee_single' dwarf_regnum='38'/> <reg name='ft7' bitsize='32' type='ieee_single' dwarf_regnum='39'/> ``` it seems like a valid and supported type in gdb. from gdb16.3/gdb/target_descriptions.c (could not find a way to link it). ``` case TDESC_TYPE_IEEE_SINGLE: m_type = init_float_type (alloc, -1, "builtin_type_ieee_single", floatformats_ieee_single); return; case TDESC_TYPE_IEEE_DOUBLE: m_type = init_float_type (alloc, -1, "builtin_type_ieee_double", floatformats_ieee_double); return; ``` ### Testplan updated unittest to test this. Reviewers: @clayborg , @jeffreytan81 , @Jlalond
2025-07-28[lldb][NFC] Use IterationAction for ModuleList::ForEach callbacks (#150930)Michael Buch1-4/+4
2025-06-27[lldb] Extract debug server location code (#145706)Pavel Labath5-100/+77
.. from the guts of GDBRemoteCommunication to ~top level. This is motivated by #131519 and by the fact that's impossible to guess whether the author of a symlink intended it to be a "convenience shortcut" -- meaning it should be resolved before looking for related files; or an "implementation detail" -- meaning the related files should be located near the symlink itself. This debate is particularly ridiculous when it comes to lldb-server running in platform mode, because it also functions as a debug server, so what we really just need to do is to pass /proc/self/exe in a platform-independent manner. Moving the location logic higher up achieves that as lldb-platform (on non-macos) can pass `HostInfo::GetProgramFileSpec`, while liblldb can use the existing complex logic (which only worked on liblldb anyway as lldb-platform doesn't have a lldb_private::Platform instance). Another benefit of this patch is a reduction in dependency from GDBRemoteCommunication to the rest of liblldb (achieved by avoiding the Platform dependency).
2025-06-26[lldb] Remove child_process_inherit argument from Pipe (#145516)Pavel Labath1-4/+4
It's not necessary on posix platforms as of #126935 and it's ignored on windows as of #138896. For both platforms, we have a better way of inheriting FDs/HANDLEs.
2025-06-25[lldb] Fix qEcho message handling. (#145675)eleviant4-9/+15
This fixes issues found in e066f35c6981c720e3a7e5883efc40c861b3b7, which was later reverted. The problem was with "k" message which was sent with sync_on_timeout flag set to true, so lldb was waiting for response, which is currently not being sent by lldb-server. Not waiting for response at all seems to be not a solution, because on MAC OS X lldb waits for response from "k" to gracefully kill inferior.
2025-06-25[lldb] Clean up GDBRemoteCommunication::StartDebugserverProcess (#145021)Pavel Labath4-137/+78
The function was extremely messy in that it, depending on the set of arguments, it could either modify the Connection object in `this` or not. It had a lot of arguments, with each call site passing a different combination of null values. This PR: - packs "url" and "comm_fd" arguments into a variant as they are mutually exclusive - removes the (surprising) "null url *and* null comm_fd" code path which is not used as of https://github.com/llvm/llvm-project/pull/145017 - marks the function as `static` to make it clear it (now) does not operate on the `this` object. Depends on #145017
2025-06-24[lldb] Fix build for #145017Pavel Labath1-1/+1
Mid-flight collision with #145293.
2025-06-24[lldb] Use Socket::CreatePair for launching debugserver (#145017)Pavel Labath1-90/+55
This lets get rid of platform-specific code in ProcessGDBRemote and use the same code path (module differences in socket types) everywhere. It also unlocks further cleanups in the debugserver launching code. The main effect of this change is that lldb on windows will now use the `--fd` lldb-server argument for "local remote" debug sessions instead of having lldb-server connect back to lldb. This is the same method used by lldb on non-windows platforms (for many years) and "lldb-server platform" on windows for truly remote debug sessions (for ~one year). Depends on #145015.
2025-06-24[lldb] Remove GDBRemoteCommunication::ConnectLocally (#145293)Pavel Labath2-19/+2
Originally added for reproducers, it is now only used for test code. While we could make it a test helper, I think that after #145015 it is simple enough to not be needed. Also squeeze in a change to make ConnectionFileDescriptor accept a unique_ptr<Socket>.
2025-06-23[lldb] Add Socket::CreatePair (#145015)Pavel Labath1-26/+6
It creates a pair of connected sockets using the simplest mechanism for the given platform (TCP on windows, socketpair(2) elsewhere). Main motivation is to remove the ugly platform-specific code in ProcessGDBRemote::LaunchAndConnectToDebugserver, but it can also be used in other places where we need to create a pair of connected sockets.
2025-06-22Revert "[lldb] Fix qEcho message handling (#145072)" (#145241)eleviant2-3/+2
Temporarily revert commit e066f35c6981c720e3a7e5883efc40c861b3b7ee, because lldb tests randomly hang after it's been pushed.
2025-06-21[lldb] Fix qEcho message handling (#145072)eleviant2-2/+3
Patch fixes the sync-on-timeout logic in lldb and switches to qEcho based ping, instead of qC. This fixes vRun message case, when there is no process yet and qC returns an error.
2025-06-11[doc] Use ISO nomenclature for 1024 byte units (#133148)Alexander Ziaee1-1/+1
Increase specificity by using the correct unit sizes. KBytes is an abbreviation for kB, 1000 bytes, and the hardware industry as well as several operating systems have now switched to using 1000 byte kBs. If this change is acceptable, sometimes GitHub mangles merges to use the original email of the account. $dayjob asks contributions have my work email. Thanks!
2025-06-09[lldb] Use llvm::find (NFC) (#143338)Kazu Hirata1-1/+1
This patch should be mostly obvious, but in one place, this patch changes: const auto &it = std::find(...) to: auto it = llvm::find(...) We do not need to bind to a temporary with const ref.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath1-3/+3
If we're not touching them, we don't need to do anything special to pass them along -- with one important caveat: due to how cmake arguments work, the implicitly passed arguments need to be specified before arguments that we handle. This isn't particularly nice, but the alternative is enumerating all arguments that can be used by llvm_add_library and the macros it calls (it also relies on implicit passing of some arguments to llvm_process_sources).
2025-05-27[lldb] Correcting an error message. (#141696)John Harrison1-1/+1
'isconnect' I assume was supposed to be 'disconnect'.
2025-05-24[lldb] Use llvm::stable_sort (NFC) (#141352)Kazu Hirata1-5/+4
2025-05-13[lldb] Fix compilation errors from #138896 (#139711)Pavel Labath1-1/+2
- s/size_t/SIZE_T to match the windows API - case HANDLE to int64_t to avoid cast-to-int-of-different-size errors/warnings
2025-05-12Reapply "[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on ↵Pavel Labath1-2/+0
windows (#137978)" (#138896) This reverts commit https://github.com/llvm/llvm-project/commit/a0260a95ece74733ada00b19d8b1930dde462a66, reapplying https://github.com/llvm/llvm-project/commit/7c5f5f3ef83b1d1d43d63862a8431af3dded15bb, with a fix that makes *both* pipe handles inheritable. The original commit description was: This is a follow-up to https://github.com/llvm/llvm-project/pull/126935, which enables passing handles to a child process on windows systems. Unlike on unix-like systems, the handles need to be created with the "inheritable" flag because there's to way to change the flag value after it has been created. This is why I don't respect the child_process_inherit flag but rather always set the flag to true. (My next step is to delete the flag entirely.) This does mean that pipe may be created as inheritable even if its not necessary, but I think this is offset by the fact that windows (unlike unixes, which pass all ~O_CLOEXEC descriptors through execve and *all* descriptors through fork) has a way to specify the precise set of handles to pass to a specific child process. If this turns out to be insufficient, instead of a constructor flag, I'd rather go with creating a separate api to create an inheritable copy of a handle (as typically, you only want to inherit one end of the pipe).
2025-05-07Revert "[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on ↵Pavel Labath1-0/+2
windows (#137978)" This reverts commit 7c5f5f3ef83b1d1d43d63862a8431af3dded15bb due to failures on the lldb-remote-linux-win bot.
2025-05-07[lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on windows (#137978)Pavel Labath1-2/+0
This is a follow-up to https://github.com/llvm/llvm-project/pull/126935, which enables passing handles to a child process on windows systems. Unlike on unix-like systems, the handles need to be created with the "inheritable" flag because there's to way to change the flag value after it has been created. This is why I don't respect the child_process_inherit flag but rather always set the flag to true. (My next step is to delete the flag entirely.) This does mean that pipe may be created as inheritable even if its not necessary, but I think this is offset by the fact that windows (unlike unixes, which pass all ~O_CLOEXEC descriptors through execve and *all* descriptors through fork) has a way to specify the precise set of handles to pass to a specific child process. If this turns out to be insufficient, instead of a constructor flag, I'd rather go with creating a separate api to create an inheritable copy of a handle (as typically, you only want to inherit one end of the pipe).
2025-05-04[lldb] Remove unused local variables (NFC) (#138457)Kazu Hirata3-4/+0
2025-04-25[lldb] Fix error that lead Windows to think it could reverse execute (#137351)David Spickett1-1/+1
The new test added in https://github.com/llvm/llvm-project/pull/132783 was failing on Windows because it created a new error to say it did not support the feature, but then returned the existing, default constructed error. Which was a success value. This also changes the GDBRemote error message to the same phrasing used in all the other places so we don't have to special case any platform.
2025-04-22[lldb] Clean up StartDebugserverProcess before I start refactoring it (#135342)Pavel Labath2-297/+199
- use early exits where possible - avoid the listen thread by using Socket APIs which allow separate "listen" and "accept" steps - use formatv-like log statements There "should" be no functional changes from this patch.
2025-04-22[lldb/cmake] Normalize use of HAVE_LIBCOMPRESSION (#135528)Pavel Labath3-13/+7
I *think* this was the reason behind the failures in 2fd860c1f559c0b0be66cc000e38270a04d0a1a3: the clang include tool showed the Config.h headers as unused, and because the macro was referenced through an `#ifdef`, its removal didn't cause build failures. Switching to `#cmakedefine01` + `#if` should make sure this does not happen again. According to D48977, the `#ifndef`+`#cmakedefine` patterns is due to some files redefining the macro themselves. I no longer see any such files in the source tree (there also were no files like that in the source tree at the revision mentioned, but the macro *was* defined in the hand-maintained XCode project we had at the time).
2025-04-13Reapply "[lldb] ProcessGdbRemote header gardning"Pavel Labath3-27/+14
This reverts commit 68ab45f0533f3bbfc1c96bddd53de7e769180219, reapplying 2fd860c1f559c0b0be66cc000e38270a04d0a1a3. The only change is keeping "lldb/Host/Config.h", which I believe was the cause of the failures.
2025-04-13[lldb] Remove vestigial remnants of reproducers (#135361)Pavel Labath1-3/+0
Not touching the SB API.
2025-04-11Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear ↵Felipe de Azevedo Piovezan2-0/+12
(#134397)" (#135296) This reapplies commit https://github.com/llvm/llvm-project/commit/232525f06942adb3b9977632e38dcd5f08c0642d. The original commit triggered a sanitizer failure when `Target` was destroyed. In `Target::Destroy`, `DeleteCurrentProcess` was called, but it did not destroy the thread creation breakpoints for the underlying `ProcessGDBRemote` because `ProcessGDBRemote::Clear` was not called in that path. `Target `then proceeded to destroy its breakpoints, which resulted in a call to the destructor of a `std::vector` containing the breakpoints. Through a sequence of complicated events, destroying breakpoints caused the reference count of the underlying `ProcessGDBRemote` to finally reach zero. This, in turn, called `ProcessGDBRemote::Clear`, which attempted to destroy the breakpoints. To do that, it would go back into the Target's vector of breakpoints, which we are in the middle of destroying. We solve this by moving the breakpoint deletion into `Process:DoDestroy`, which is a virtual Process method that will be called much earlier.
2025-04-11Revert "[lldb] ProcessGdbRemote header gardning"Jonas Devlieghere3-11/+25
This reverts commit 2fd860c1f559c0b0be66cc000e38270a04d0a1a3 as this is causing a EXC_BAD_ACCESS on Darwin: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/23807/ https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/11255/
2025-04-11[lldb] ProcessGdbRemote header gardningPavel Labath3-25/+11
Remove unused headers, add used headers, remove declared-but-not-defined entities.
2025-04-08Revert "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear ↵Jason Molenda1-3/+0
(#134397)" This reverts commit 232525f06942adb3b9977632e38dcd5f08c0642d. This change is causing test crashes while running TestCompletion.py on Darwin systems, most of the CI runs have failed since it has been merged in.
2025-04-04[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)Felipe de Azevedo Piovezan1-0/+3
Currently, these breakpoints are being accumulated every time a new process if created (e.g. through a `run`). Depending on the circumstances, the old breakpoints are even left enabled, interfering with subsequent processes. This is addressed by removing the breakpoints in ProcessGDBRemote::Clear Note that these breakpoints are more of a PlatformDarwin thing, so in the future we should look into moving them there.
2025-03-19[lldb/gdb-remote] Do not crash on an invalid server response (#131979)Igor Kudrin2-6/+18
An invalid RLE sequence in the received packet could result in an out-of-bounds reading that could cause a crash.
2025-03-17Reapply "[lldb] Implement basic support for reverse-continue (#125242)" ↵Pavel Labath5-14/+115
(again) (#128156) This reverts commit https://github.com/llvm/llvm-project/commit/87b7f63a117c340a6d9ca47959335fd7ef6c7ad2, reapplying https://github.com/llvm/llvm-project/commit/7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b with a small (and probably temporary) change to generate more debug info to help with diagnosing buildbot issues.
2025-02-27[lldb] Assorted improvements to the Pipe class (#128719)Pavel Labath1-7/+17
The main motivation for this was the inconsistency in handling of partial reads/writes between the windows and posix implementations (windows was returning partial reads, posix was trying to fill the buffer completely). I settle on the windows implementation, as that's the more common behavior, and the "eager" version can be implemented on top of that (in most cases, it isn't necessary, since we're writing just a single byte). Since this also required auditing the callers to make sure they're handling partial reads/writes correctly, I used the opportunity to modernize the function signatures as a forcing function. They now use the `Timeout` class (basically an `optional<duration>`) to support both polls (timeout=0) and blocking (timeout=nullopt) operations in a single function, and use an `Expected` instead of a by-ref result to return the number of bytes read/written. As a drive-by, I also fix a problem with the windows implementation where we were rounding the timeout value down, which meant that calls could time out slightly sooner than expected.
2025-02-20[lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (#127961)Jonas Devlieghere1-2/+1
Make StreamAsynchronousIO an unique_ptr instead of a shared_ptr. I tried passing the class by value, but the llvm::raw_ostream forwarder stored in the Stream parent class isn't movable and I don't think it's worth changing that. Additionally, there's a few places that expect a StreamSP, which are easily created from a StreamUP.
2025-02-13[lldb] Change lldb's breakpoint handling behavior, reland (#126988)Jason Molenda1-62/+31
lldb today has two rules: When a thread stops at a BreakpointSite, we set the thread's StopReason to be "breakpoint hit" (regardless if we've actually hit the breakpoint, or if we've merely stopped *at* the breakpoint instruction/point and haven't tripped it yet). And second, when resuming a process, any thread sitting at a BreakpointSite is silently stepped over the BreakpointSite -- because we've already flagged the breakpoint hit when we stopped there originally. In this patch, I change lldb to only set a thread's stop reason to breakpoint-hit when we've actually executed the instruction/triggered the breakpoint. When we resume, we only silently step past a BreakpointSite that we've registered as hit. We preserve this state across inferior function calls that the user may do while stopped, etc. Also, when a user adds a new breakpoint at $pc while stopped, or changes $pc to be the address of a BreakpointSite, we will silently step past that breakpoint when the process resumes. This is purely a UX call, I don't think there's any person who wants to set a breakpoint at $pc and then hit it immediately on resuming. One non-intuitive UX from this change, butt is necessary: If you're stopped at a BreakpointSite that has not yet executed, you `stepi`, you will hit the breakpoint and the pc will not yet advance. This thread has not completed its stepi, and the ThreadPlanStepInstruction is still on the stack. If you then `continue` the thread, lldb will now stop and say, "instruction step completed", one instruction past the BreakpointSite. You can continue a second time to resume execution. The bugs driving this change are all from lldb dropping the real stop reason for a thread and setting it to breakpoint-hit when that was not the case. Jim hit one where we have an aarch64 watchpoint that triggers one instruction before a BreakpointSite. On this arch we are notified of the watchpoint hit after the instruction has been unrolled -- we disable the watchpoint, instruction step, re-enable the watchpoint and collect the new value. But now we're on a BreakpointSite so the watchpoint-hit stop reason is lost. Another was reported by ZequanWu in https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282 we attach to/launch a process with the pc at a BreakpointSite and misbehave. Caroline Tice mentioned it is also a problem they've had with putting a breakpoint on _dl_debug_state. The change to each Process plugin that does execution control is that 1. If we've stopped at a BreakpointSite that has not been executed yet, we will call Thread::SetThreadStoppedAtUnexecutedBP(pc) to record that. When the thread resumes, if the pc is still at the same site, we will continue, hit the breakpoint, and stop again. 2. When we've actually hit a breakpoint (enabled for this thread or not), the Process plugin should call Thread::SetThreadHitBreakpointSite(). When we go to resume the thread, we will push a step-over-breakpoint ThreadPlan before resuming. The biggest set of changes is to StopInfoMachException where we translate a Mach Exception into a stop reason. The Mach exception codes differ in a few places depending on the target (unambiguously), and I didn't want to duplicate the new code for each target so I've tested what mach exceptions we get for each action on each target, and reorganized StopInfoMachException::CreateStopReasonWithMachException to document these possible values, and handle them without specializing based on the target arch. I first landed this patch in July 2024 via https://github.com/llvm/llvm-project/pull/96260 but the CI bots and wider testing found a number of test case failures that needed to be updated, I reverted it. I've fixed all of those issues in separate PRs and this change should run cleanly on all the CI bots now. rdar://123942164
2025-02-08[lldb] Upstream a few remaining Triple::XROS patches (#126335)Jason Molenda1-0/+2
Recognize the visionOS Triple::OSType::XROS os type. Some of these have already been landed on main, but I reviewed the downstream sources and there were a few that still needed to be landed upstream.
2025-02-03[lldb] Improve isolation between Process plugins and OS plugins (#125302)Felipe de Azevedo Piovezan1-4/+0
Generally speaking, process plugins (e.g. ProcessGDBRemote) should not be aware of OS plugin threads. However, ProcessGDBRemote attempts to check for the existence of OS threads when calculating stop info. When OS threads are present, it sets the stop info directly on the OS plugin thread and leaves the ThreadGDBRemote without a StopInfo. This is problematic for a few reasons: 1. No other process plugins do this, as they shouldn't. They should set the stop info for their own process threads, and let the abstractions built on top propagate StopInfos. 2. This conflicts with the expectations of ThreadMemory, which checks for the backing threads's info, and then attempts to propagate it (in the future, it should probably ask the plugin itself too...). We see this happening in the code below. The `if` condition will not trigger, because `backing_stop_info_sp` will be null (remember, ProcessGDB remote is ignoring its own threads), and then this method returns false. ``` bool ThreadMemory::CalculateStopInfo() { ... lldb::StopInfoSP backing_stop_info_sp( m_backing_thread_sp->GetPrivateStopInfo()); if (backing_stop_info_sp && backing_stop_info_sp->IsValidForOperatingSystemThread(*this)) { backing_stop_info_sp->SetThread(shared_from_this()); ``` ``` Thread::GetPrivateStopInfo ... if (!CalculateStopInfo()) SetStopInfo(StopInfoSP()); ``` To solve this, we change ProcessGDB remote so that it does the principled thing: it now only sets the stop info of its own threads. This change by itself breaks the tests TestPythonOSPlugin.py and TestOSPluginStepping.py and probably explains why ProcessGDB had originally "violated" this isolation of layers. To make this work, BreakpointSites must be aware of BackingThreads when answering the question: "Is this breakpoint valid for this thread?". Why? Breakpoints are created on top of the OS threads (that's what the user sees), but breakpoints are hit by process threads. In the presence of OS threads, a TID-specific breakpoint is valid for a process thread if it is backing an OS thread with that TID.
2025-02-03[lldb] Implement bidirectional access for backing<->backed thread ↵Felipe de Azevedo Piovezan1-1/+1
relationship (#125300) This enables finding the backed thread from the backing thread without going through the thread list, and it will be useful for subsequent commits.
2025-01-31Revert "Reland "[lldb] Implement basic support for reverse-continue" (#125242)"Adrian Prantl5-115/+14
This reverts commit 7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b. Breaking green dragon: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/19569/testReport/junit/lldb-api/functionalities_reverse-execution/TestReverseContinueWatchpoints_py/
2025-01-31Reland "[lldb] Implement basic support for reverse-continue" (#125242)David Spickett5-14/+115
This reverts commit a774de807e56c1147d4630bfec3110c11d41776e. This is the same changes as last time, plus: * We load the binary into the target object so that on Windows, we can resolve the locations of the functions. * We now assert that each required breakpoint has at least 1 location, to prevent an issue like that in the future. * We are less strict about the unsupported error message, because it prints "error: windows" on Windows instead of "error: gdb-remote".
2025-01-31[lldb] Add support for gdb-style 'x' packet (#124733)Pavel Labath3-24/+45
See also https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288 and https://sourceware.org/pipermail/gdb/2025-January/051705.html
2025-01-30Revert "Reland "[lldb] Implement basic support for reverse-continue" ↵David Spickett5-115/+14
(#123906)"" (#125091) Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` ******************** Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py ******************** Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally.
2025-01-30Reland "[lldb] Implement basic support for reverse-continue" (#123906)" ↵David Spickett5-14/+115
(#123945) This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079). The problem is that x86_64 and Arm 32-bit have memory regions above the stack that are readable but not writeable. First Arm: ``` (lldb) memory region --all <...> [0x00000000fffcf000-0x00000000ffff0000) rw- [stack] [0x00000000ffff0000-0x00000000ffff1000) r-x [vectors] [0x00000000ffff1000-0xffffffffffffffff) --- ``` Then x86_64: ``` $ cat /proc/self/maps <...> 7ffdcd148000-7ffdcd16a000 rw-p 00000000 00:00 0 [stack] 7ffdcd193000-7ffdcd196000 r--p 00000000 00:00 0 [vvar] 7ffdcd196000-7ffdcd197000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall] ``` Compare this to AArch64 where the test did pass: ``` $ cat /proc/self/maps <...> ffffb87dc000-ffffb87dd000 r--p 00000000 00:00 0 [vvar] ffffb87dd000-ffffb87de000 r-xp 00000000 00:00 0 [vdso] ffffb87de000-ffffb87e0000 r--p 0002a000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffffb87e0000-ffffb87e2000 rw-p 0002c000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 fffff4216000-fffff4237000 rw-p 00000000 00:00 0 [stack] ``` To solve this, look up the memory region of the stack pointer (using https://lldb.llvm.org/resources/lldbgdbremote.html#qmemoryregioninfo-addr) and constrain the read to within that region. Since we know the stack is all readable and writeable. I have also added skipIfRemote to the tests, since getting them working in that context is too complex to be worth it. Memory write failures now display the range they tried to write, and register write errors will show the name of the register where possible. The patch also includes a workaround for a an issue where the test code could mistake an `x` response that happens to begin with an `O` for an output packet (stdout). This workaround will not be necessary one we start using the [new implementation](https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288) of the `x` packet. --------- Co-authored-by: Pavel Labath <pavel@labath.sk>