aboutsummaryrefslogtreecommitdiff
path: root/lldb/tools/debugserver/source/RNBRemote.cpp
AgeCommit message (Collapse)AuthorFilesLines
8 days[lldb] Use std::make_shared where possible (NFC) (#150714)Jonas Devlieghere1-3/+3
This is a continuation of 68fd102, which did the same thing but only for StopInfo. Using make_shared is both safer and more efficient: - With make_shared, the object and the control block are allocated together, which is more efficient. - With make_shared, the enable_shared_from_this base class is properly linked to the control block before the constructor finishes, so shared_from_this() will be safe to use (though still not recommended during construction).
2025-06-16[lldb] Remove a redundant control flow statement (NFC) (#144284)Kazu Hirata1-1/+0
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-05-29[LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir ↵Akash Agrawal1-1/+0
& few other files (#141478) A few files of lldb dir & few other files had duplicate headers included. This patch removes those redundancies. --------- Co-authored-by: Akash Agrawal <akashag@qti.qualcomm.com>
2025-04-27[debugserver] Migrate RNBRemote away from PThreadMutex (NFC) (#137547)Jonas Devlieghere1-2/+2
The debugserver code predates modern C++, but with C++11 and later there's no need to have something like PThreadMutex. This migrates RNBRemote away from PThreadMutex in preparation for removing it.
2025-03-20[lldb][debugserver] remove g/G packet handling from debugserver (#132127)Jason Molenda1-95/+0
In 2013 we added the QSaveRegisterState and QRestoreRegisterState packets to checkpoint a thread's register state while executing an inferior function call, instead of using the g packet to read all registers into lldb, then the G packet to set them again after the func call. Since then, lldb has not sent g/G (except as a bug) - it either asks for registers individually (p/P) or or asks debugserver to save and restore the entire register set with these lldb extensions. Felipe recently had a codepath that fell back to using g/G and found that it does not work with the modern signed fp/sp/pc/lr registers that we can get -- it sidesteps around the clearing of the non-addressable bits that we do when reading/writing them, and results in a crash. ( https://github.com/llvm/llvm-project/pull/132079 ) Instead of fixing that issue, I am removing g/G from debugserver because it's not needed by lldb, and it will would be easy for future bugs to creep in to this packet that lldb should not use, but it can accidentally fall back to and result in subtle bugs. This does mean that a debugger using debugserver on darwin which doesn't use QSaveRegisterState/QRestoreRegisterState will need to fall back to reading & writing each register individually. I'm open to re-evaluating this decision if this proves to be needed, and supporting these lldb extensions is onerous.
2025-03-13[debugserver] Fix mutex scope in RNBRemote::CommDataReceived (#131077)Jonas Devlieghere1-72/+70
The mutex in RNBRemote::CommDataReceived protects m_rx_packets and should extend to the end of the function to cover the read where we check if the list is empty.
2025-02-08[lldb] Upstream a few remaining Triple::XROS patches (#126335)Jason Molenda1-0/+4
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.
2024-12-19[lldb][debugserver] Read/write SME registers on arm64 (#119171)Jason Molenda1-57/+81
**Note:** The register reading and writing depends on new register flavor support in thread_get_state/thread_set_state in the kernel, which will be first available in macOS 15.4. The Apple M4 line of cores includes the Scalable Matrix Extension (SME) feature. The M4s do not implement Scalable Vector Extension (SVE), although the processor is in Streaming SVE Mode when the SME is being used. The most obvious side effects of being in SSVE Mode are that (on the M4 cores) NEON instructions cannot be used, and watchpoints may get false positives, the address comparisons are done at a lowered granularity. When SSVE mode is enabled, the kernel will provide the Streaming Vector Length register, which is a maximum of 64 bytes with the M4. Also provided are SVCR (with bits indicating if SSVE mode and SME mode are enabled), TPIDR2, SVL. Then the SVE registers Z0..31 (SVL bytes long), P0..15 (SVL/8 bytes), the ZA matrix register (SVL*SVL bytes), and the M4 supports SME2, so the ZT0 register (64 bytes). When SSVE/SME are disabled, none of these registers are provided by the kernel - reads and writes of them will fail. Unlike Linux, lldb cannot modify the SVL through a thread_set_state call, or change the processor state's SSVE/SME status. There is also no way for a process to request a lowered SVL size today, so the work that David did to handle VL/SVL changing while stepping through a process is not an issue on Darwin today. But debugserver should be providing everything necessary so we can reuse all of David's work on resizing the register contexts in lldb if it happens in the future. debugbserver sends svl, svcr, and tpidr2 in the expedited registers when a thread stops, if SSVE|SME mode are enabled (if the kernel allows it to read the ARM_SME_STATE register set). While the maximum SVL is 64 bytes on M4, the AArch64 maximum possible SVL is 256; this would give us a 64k ZA register. If debugserver sized all of its register contexts assuming the largest possible SVL, we could easily use 2MB more memory for the register contexts of all threads in a process -- and on iOS et al, processes must run within a small memory allotment and this would push us over that. Much of the work in debugserver was changing the arm64 register context from being a static compile-time array of register sets, to being initialized at runtime if debugserver is running on a machine with SME. The ZA is only created to the machine's actual maximum SVL. The size of the 32 SVE Z registers is less significant so I am statically allocating those to the architecturally largest possible SVL value today. Also, debugserver includes information about registers that share the same part of the register file. e.g. S0 and D0 are the lower parts of the NEON 128-bit V0 register. And when running on an SME machine, v0 is the lower 128 bits of the SVE Z0 register. So the register maps used when defining the VFP registers must differ depending on the capabilities of the cpu at runtime. I also changed register reading in debugserver, where formerly when debugserver was asked to read a register, and the thread_get_state read of that register failed, it would return all zero's. This is necessary when constructing a `g` packet that gets all registers - because there is no separation between register bytes, the offsets are fixed. But when we are asking for a single register (e.g. Z0) when not in SSVE/SME mode, this should return an error. This does mean that when you're running on an SME capabable machine, but not in SME mode, and do `register read -a`, lldb will report that 48 SVE registers were unavailable and 5 SME registers were unavailable. But that's only when `-a` is used. The register reading and writing depends on new register flavor support in thread_get_state/thread_set_state in the kernel, which is not yet in a release. The test case I wrote is skipped on current OSes. I pilfered the SME register setup from some of David's existing SME test files; there were a few Linux specific details in those tests that they weren't easy to reuse on Darwin. rdar://121608074
2024-10-16[lldb] Remove more mentions of ASLLogCallback (#112639)Jonas Devlieghere1-13/+3
2024-02-29[lldb] [debugserver] fix qLaunchSuccess error, add ↵Jason Molenda1-160/+159
QErrorStringInPacketSupported (#82593) Pavel added an extension to lldb's gdb remote serial protocol that allows the debug stub to append an error message (ascii hex encoded) after an error response packet Exx. This was added in 2017 in https://reviews.llvm.org/D34945 . lldb sends the QErrorStringInPacketSupported packet and then the remote stub may add these error strings. debugserver has two bugs in its use of extended error messages: the vAttach family would send the extended error string without checking if the mode had been enabled. And qLaunchSuccess would not properly format its error response packet (missing the hex digits, did not asciihex encode the string). There is also a bug in the HandlePacket_D (detach) packet where the error packets did not include hex digits, but this one does not append an error string. I'm adding a new RNBRemote::SendErrorPacket() and routing all error packet returns though this one method. It takes an optional second string which is the longer error message; it now handles appending it to the Exx response or not, depending on the QErrorStringInPacketSupported state. I updated all packets to send their errors via this method.
2024-02-26Change debugserver to report the cpu(sub)type of process, not the host.Adrian Prantl1-48/+58
This way debugserver can correctly report qProcessInfo for arm64 processes on arm64e-capable hosts. Patch implemented with help from Jason Molenda!
2024-02-07[lldb] [NFC] Remove min pkt size for compression setting (#81075)Jason Molenda1-24/+1
debugserver will not compress small packets; the overhead of the compression header makes this useful for larger packets. I default to 384 bytes in debugserver, and added an option for lldb to request a different cutoff. This option has never been used in lldb in the past nine years, so I don't think there's any point to keeping it around.
2024-02-05[lldb] Add QSupported key to report watchpoint types supported (#80376)Jason Molenda1-13/+17
debugserver on arm64 devices can manage both Byte Address Select watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes). This adds a SupportedWatchpointTypes key to the QSupported response from debugserver with a list of these, so lldb can take full advantage of them when creating larger regions with a single hardware watchpoint. Also add documentation for this, and two other lldb extensions, to the lldb-gdb-remote.txt documentation. Re-enable TestLargeWatchpoint.py on Darwin systems when testing with the in-tree built debugserver. I can remove the "in-tree built debugserver" in the future when this new key is handled by an Xcode debugserver.
2024-01-17[lldb] Upstream xros support in lldb (#78389)Jonas Devlieghere1-4/+7
Upstream support for debugging xros applications through LLDB.
2023-09-25[lldb] Protect RNBRemote from a data raceAugusto Noronha1-19/+21
Summary: Thread sanitizer reports the following data race: ``` Write of size 8 at 0x000103303e70 by thread T1 (mutexes: write M0): #0 RNBRemote::CommDataReceived(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) RNBRemote.cpp:1075 (debugserver:arm64+0x100038db8) (BuildId: f130b34f693c4f3eba96139104af2b7132000000200000000100000000000e00) #1 RNBRemote::ThreadFunctionReadRemoteData(void*) RNBRemote.cpp:1180 (debugserver:arm64+0x1000391dc) (BuildId: f130b34f693c4f3eba96139104af2b7132000000200000000100000000000e00) Previous read of size 8 at 0x000103303e70 by main thread: #0 RNBRemote::GetPacketPayload(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) RNBRemote.cpp:797 (debugserver:arm64+0x100037c5c) (BuildId: f130b34f693c4f3eba96139104af2b7132000000200000000100000000000e00) #1 RNBRemote::GetPacket(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, RNBRemote::Packet&, bool) RNBRemote.cpp:907 (debugserver:arm64+0x1000378cc) (BuildId: f130b34f693c4f3eba96139104af2b7132000000200000000100000000000e00) ``` RNBRemote already has a mutex, extend its usage to protect the read of m_rx_packets. Reviewers: jdevlieghere, bulbazord, jingham Subscribers:
2023-08-21[lldb][debugserver] Fix build after libcxx removed generic char_traits ↵David Spickett1-2/+2
implementation Which was done in https://reviews.llvm.org/D157058. This follows the fix for lldb-server in https://reviews.llvm.org/D157589. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D158391
2023-07-12Improve error messaging when debugserver fails to complete attachingJason Molenda1-8/+2
When debugserver is attaching to a process, it first task_for_pid()'s and then ptrace(PT_ATTACHEXC)'s. When that ptrace() fails to complete, we are in a semi-attached state that we need to give up from, and our error reporting isn't ideal -- we can even claim that the process is already being debugged (by ourselves). Differential Revision: https://reviews.llvm.org/D155037 rdar://101152233
2023-05-08Add a new report_load_commands option to jGetLoadedDynamicLibrariesInfosJason Molenda1-23/+12
jGetLoadedDynamicLibrariesInfos has a mode where it will list every binary in the process - the load address and filepath from dyld SPI, and the mach-o header and load commands from a scan by debugserver for perf reasons. With a large enough number of libraries, creating that StructuredData representation of all of this, and formatting it into an ascii string to send up to lldb, can grow debugserver's heap size too large for some environments. This patch adds a new report_load_commands:false boolean to the jGetLoadedDynamicLibrariesInfos packet, where debugserver will now only report the dyld SPI load address and filepath for all of the binaries. lldb can then ask for the detailed information on the process binaries in smaller chunks, and avoid debugserver having ever growing heap use as the number of binaries inevitably increases. This patch also removes a version of jGetLoadedDynamicLibrariesInfos for pre-iOS 10 and pre-macOS 10.12 systems where we did not use dyld SPI. We can't back compile to those OS builds any longer with modern Xcode. Finally, it removes a requirement in DynamicLoaderMacOS that the JSON reply from jGetLoadedDynamicLibrariesInfos include the mod_date field for each binary. This has always been reported as 0 in modern dyld, and is another reason for packet growth in the reply. debugserver still puts the mod_date field in its replies for interop with existing lldb's, but we will be able to remove it the field from debugserver's output after the next release cycle when this patch has had time to circulate. I'll add lldb support for requesting the load addresses only and splitting the request up into chunks in a separate patch. Differential Revision: https://reviews.llvm.org/D150158 rdar://107848326
2023-04-12AArch64 debugserver parse ESR register for watchpointsJason Molenda1-1/+70
Have debugserver parse the watchpoint flags out of the exception syndrome register when we get a watchpoint mach exception. Relay those fields up to lldb in the stop reply packet, if the watchpoint number was reported by the hardware, use the address from that as the watchpoint address. Change how watchpoints are reported to lldb from using the mach exception data, to using the `reason:watchpoint` and `description:asciihex` method that lldb-server uses, which can relay the actual trap address as well as the address of a watched memory region responsible for the trap, so lldb can step past it. Have debugserver look for the nearest watchpoint that it has set when it gets a watchpoint trap, so accesses that are reported as starting before the watched region are associated with the correct watchpoint to lldb. Add a test case for this specific issue. Differential Revision: https://reviews.llvm.org/D147820 rdar://83996471
2022-12-13Launch state discoverable in Darwin, use for SafeToCallFunctionsJason Molenda1-0/+20
The dynamic linker on Darwin, dyld, can provide status of the process state for a few significant points early on, most importantly, when libSystem has been initialized and it is safe to call functions behind the scenes. Pipe this information up from debugserver to DynamicLoaderMacOS, for the DynamicLoader::IsFullyInitialized() method, then have Thread::SafeToCallFunctions use this information. Finally, for the two utility functions in the AppleObjCRuntimeV2 LanguageRuntime plugin that I was fixing, call this method before running our utility functions to collect the list of objc classes registered in the runtime. User expressions will still be allowed to run any time - we assume the user knows what they are doing - but these two additional utility functions that they are unaware of will be limited by this state. Differential Revision: https://reviews.llvm.org/D139054 rdar://102436092 can probably make function calls.
2022-10-27Handle an unknown binary platform type in debugserverJason Molenda1-2/+2
debugserver parses the Mach-O header & load commands of binaries; if it does this with a binary whose LC_BUILD platform enum it does not recognize, it will currently crash. This patch changes MachProcss::GetPlatformString to return an optional platform string, and updates the callers to do the right thing when this optional could not be provided. Differential Revision: https://reviews.llvm.org/D136719 rdar://100452994
2022-10-25Change debugserver to clear PAC auth bits manuallyJason Molenda1-19/+1
debugserver is currently using kernel supplied macros, arm_thread_state64_get_{pc,fp,sp,lr} which can crash on an authorization failure when the inferior has crashed with an invalid pc value, for instance. debugserver needs to be resistant to crashing in this scenario, and we're merely clearing the bits, so do it with a bit mask operation instead. Differential Revision: https://reviews.llvm.org/D136620 rdar://98073271 rdar://100663221
2022-08-15[lldb][debugserver] Revert "Use llvm::all_of (NFC)" for debugserverMichael Buch1-2/+2
Commit [6d9cd9199a6fdeab0412117bcefc28f625510b61](https://reviews.llvm.org/rG6d9cd9199a6fdeab0412117bcefc28f625510b61) added a dependency on llvm to debugserver. This breaks the build. Since we don't want to add a dependency on llvm, this patch reverts the offending commit. Differential Revision: https://reviews.llvm.org/D131901
2022-08-14Use llvm::all_of (NFC)Kazu Hirata1-2/+2
2022-06-21Roll back Michał's changes to debugserver, not meant for thereJason Molenda1-3/+3
Michał's change in https://reviews.llvm.org/D127193 did a search & replace for a pattern that also appears in debugserver, but it shouldn't be done there.
2022-06-21[lldb] [llgs] Fix signo sent with fork/vfork/vforkdone eventsMichał Górny1-3/+3
Fix ThreadStopInfo struct to include the signal number for all events. Since signo was not included in the details for fork, vfork and vforkdone stops, the code incidentally referenced the wrong union member, resulting in wrong signo being sent. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D127193
2022-05-18Add a darwin platform setting to specify which exceptions debugserverJim Ingham1-6/+41
should not receive as exceptions (some will get converted to BSD signals instead). This is really the only stable way to ensure that a Mach exception gets converted to it's equivalent BSD signal. For programs that rely on BSD signal handlers, this has to happen or you can't even get the program to invoke the signal handler when under the debugger. This builds on a previous solution to this problem which required you start debugserver with the -U flag. This was not very discoverable and required lldb be the one to launch debugserver, which is not always the case. Differential Revision: https://reviews.llvm.org/D125434
2022-05-05Fix debugserver translation checkAlexandre Perez1-11/+11
Currently, debugserver has a test to check if it was launched in translation. The intent was to cover the case where an x86_64 debugserver attempts to control an arm64/arm64e process, returning an error. However, this check also covers the case where users are attaching to an x86_64 process, exiting out before attempting to hand off control to the translated debugserver at `/Library/Apple/usr/libexec/oah/debugserver`. This diff delays the debugserver translation check until after determining whether to hand off control to `/Library/Apple/usr/libexec/oah/debugserver`. Only when the process is not translated and thus has not been handed off do we check if the debugserver is translated, erroring out in that case. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D124814
2022-04-04Add DumpBinaryEscaped method to JSONGenerator, avoid extra copyJason Molenda1-13/+10
All uses of JSONGenerator in debugserver would create a JSON text dump of the object collection, then copy that string into a binary-escaped string, then send it up to the lldb side or make a compressed version and send that. This adds a DumpBinaryEscaped method to JSONGenerator which does the gdb remote serial protocol binary escaping directly, and removes the need to pass over the string and have an additional copy in memory. Differential Revision: https://reviews.llvm.org/D122882 rdar://91117456
2022-03-31Update callers to SendPacket with std::string's to not devolve to c-strsJason Molenda1-12/+15
Many callers of SendPacket() in RNBRemote.cpp have a local std::string object, call c_str() on it to pass a c-string, which is then copied into a std::string temporary object. Also free JSONGenerator objects once we've formatted them into ostringstream and don't need the objects any longer, to reduce max memory use in debugserver. Differential Revision: https://reviews.llvm.org/D122848 rdar://91117263
2022-02-17add missing includeAdrian Prantl1-0/+1
2021-11-10[debugserver] Remove varaible `ldb_set` which is set but not used.Jonas Devlieghere1-3/+0
Differential revision: https://reviews.llvm.org/D113598
2021-11-10[lldb] Support gdbserver signalsMichał Górny1-1/+2
GDB and LLDB use different signal models. GDB uses a predefined set of signal codes, and maps platform's signos to them. On the other hand, LLDB has historically simply passed native signos. In order to improve compatibility between LLDB and gdbserver, the GDB signal model should be used. However, GDB does not provide a mapping for all existing signals on Linux and unsupported signals are passed as 'unknown'. Limiting LLDB to this behavior could be considered a regression. To get the best of both worlds, use the LLDB signal model when talking to lldb-server, and the GDB signal model otherwise. For this purpose, new versions of lldb-server indicate "native-signals+" via qSupported. At the same time, we also detect older versions of lldb-server via QThreadSuffixSupported for backwards compatibility. If neither test succeeds, we assume gdbserver or another implementation using GDB model. Differential Revision: https://reviews.llvm.org/D108078
2021-10-11[lldb] Remove "0x" prefix from hex values in dirty-pagesMichał Górny1-1/+1
Remove the redudant "0x" prefix in the "dirty-pages" key of qMemoryRegionInfo packet. The client accepts hex values both with and without the prefix. Differential Revision: https://reviews.llvm.org/D110510
2021-08-11Fix two bugs with stack corefiles patch, restrict test built debugserverJason Molenda1-0/+1
These two tests, TestSkinnyCorefile.py and TestStackCorefile.py, require a new debugserver on darwin systems to run correctly; for now, skip them if the system debugserver is in use. There's no easy way to test if the debugserver being used supports either of these memory region info features. For end users, the fallback will be a full corefile and that's not the worst thing, but for the tests it is a problem.
2021-08-11Add the ability to process save-core stack-memory-only corefilesJason Molenda1-0/+8
Add a field to the qMemoryRegionInfo packet where the remote stub can describe the type of memory -- heap, stack. Keep track of memory regions that are stack memory in lldb. Add a new "--style stack" to process save-core to request that only stack memory be included in the corefile. Differential Revision: https://reviews.llvm.org/D107625
2021-07-20Remove the DarwinLog functionality from debguserverJason Molenda1-167/+0
Remove the DarwinLog and qStructuredDataPlugins support from debugserver. The DarwinLog plugin was never debugged fully and made reliable, and the underlying private APIs it uses have migrated since 2016 so none of them exist any longer. Differential Revision: https://reviews.llvm.org/D106324 rdar://75073283
2021-07-15[debugserver] Un-conditionalize code guarded by macOS 10.10 checksJonas Devlieghere1-3/+0
We've been requiring macOS 10.11 since 2018 so there's no point in keeping code for 10.10 around.
2021-06-20Add a corefile style option to process save-core; skinny corefilesJason Molenda1-1/+16
Add a new feature to process save-core on Darwin systems -- for lldb to create a user process corefile with only the dirty (modified memory) pages included. All of the binaries that were used in the corefile are assumed to still exist on the system for the duration of the use of the corefile. A new --style option to process save-core is added, so a full corefile can be requested if portability across systems, or across time, is needed for this corefile. debugserver can now identify the dirty pages in a memory region when queried with qMemoryRegionInfo, and the size of vm pages is given in qHostInfo. Create a new "all image infos" LC_NOTE for Mach-O which allows us to describe all of the binaries that were loaded in the process -- load address, UUID, file path, segment load addresses, and optionally whether code from the binary was executing on any thread. The old "read dyld_all_image_infos and then the in-memory Mach-O load commands to get segment load addresses" no longer works when we only have dirty memory. rdar://69670807 Differential Revision: https://reviews.llvm.org/D88387
2021-05-26[lldb][NFC] Use C++ versions of the deprecated C standard library headersRaphael Isemann1-2/+2
The C headers are deprecated so as requested in D102845, this is replacing them all with their (not deprecated) C++ equivalent. Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D103084
2021-05-12Add some warnings when debugserver is running in translationJason Molenda1-0/+11
A debugserver launched x86_64 cannot control an arm64/arm64e process on an Apple Silicon system. Warn when this situation has happened and return an error for the most common case of attach. I think there will be refinements to this in the future, but start out by making it easy to spot the problem when it happens. rdar://76630595
2021-01-22Change static buffer to be BSS instead of DATA in HandlePacket_qSpeedTestJason Molenda1-1/+2
Having this 4MB buffer with a compile-time initialized string forced it into the DATA section and it took up 4MB of space in the binary, which accounts for like 80% of debugserver's footprint on disk. Change it to BSS and strcpy in the initial value at runtime instead. <rdar://problem/73503892>
2021-01-11Add unconditional logging to debugserver for launch/attach processesJason Molenda1-1/+18
Debugging app launch/attach failures can be difficult because of all of the messages logged to the console on a darwin system; emitting specific messages around critical API calls can make it easier to narrow the search for the console messages related to the failure. <rdar://problem/67220442> Differential revision: https://reviews.llvm.org/D94357
2020-11-17[debugserver] Add option to propagate SIGSEGV to target processAlessandro Arzilli1-6/+7
Adds a command line option that makes debugserver propagate the SIGSEGV signal to the target process. Motivation: I'm one of the maintainers of Delve [1] a debugger for Go. We use debugserver as our backend on macOS and one of the most often reported bugs is that, on macOS, we don't propagate SIGSEGV back to the target process [2]. Sometimes some programs will actually cause a SIGSEGV, by design, and then handle it. Those programs can not be debugged at all. Since catching signals isn't very important for a Go debugger I'd much rather have a command line option in debugserver that causes it to let SIGSEGV go directly to the target process. [1] https://github.com/go-delve/delve/ [2] https://github.com/go-delve/delve/issues/852 Differential revision: https://reviews.llvm.org/D89315
2020-10-14Fix typeo in attach failed error message.Jason Molenda1-2/+2
<rdar://problem/70296751>
2020-09-03[debugserver] Fix that debugserver's stop reply packets always return signal ↵Raphael Isemann1-1/+1
code 0 If our process terminates due to an unhandled signal, we are supposed to get the signal code via WTERMSIG. However, we instead try to get the exit status via WEXITSTATUS which just ends up always calculating signal code 0 (at least on the macOS implementation where it just shifts the signal code bits away and we're left with only 0 bits). The exit status calculation on the LLDB side also seems a bit off as it claims an exit status that is just the signal code (instead of for example 128 + signal code), but that will be another patch. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D86336
2020-08-04Fix debugserver's qProcessInfo reporting of maccatalyst binariesAdrian Prantl1-3/+4
This patch is similar in spirit to https://reviews.llvm.org/D84480, but does the maccatalyst/macosx disambiguation. I also took the opportunity to factor out the gdb-remote packet log scanning used by several testcases into lldbutil functions. rdar://problem/66059257 Differential Revision: https://reviews.llvm.org/D84576
2020-06-23[debugserver] Initial support for Apple Silicon.Davide Italiano1-2/+6
Set the correct os type in the arch triple when running macOS. Debugserver currently always assumes macOS == x86_64. This patch generalizes the support to make sure it works on a different architecture. Differential Revision: https://reviews.llvm.org/D82394
2020-05-11Quote error string from qLaunchSuccessJason Molenda1-2/+5
If the error message from qLaunchSucess included a gdb RSP metacharacter, it could crash lldb. Apply the binary escaping to the string before sending it to lldb; lldb promiscuously applies the binary escaping protocol on packets it receives. Also fix a small bug in cstring_to_asciihex_string where a high bit character (eg utf-8 chars) would not be quoted correctly due to signed char fun. Differential Revision: https://reviews.llvm.org/D79614 rdar://problem/62873581