aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/FreeBSD
AgeCommit message (Collapse)AuthorFilesLines
2025-07-28[lldb][AArch64] Add HWCAP3 to register field detection (#145029)David Spickett1-1/+2
This will be used to detect the presence of Arm's new Memory Tagging store only checking feature. This commit just adds the plumbing to get that value into the detection function. FreeBSD has not allocated a number for HWCAP3 and already has AT_ARGV defined as 29. So instead of attempting to read from FreeBSD processes, I've explicitly passed 0. We don't want to be reading some other entry accidentally. If/when FreeBSD adds HWCAP3 we can handle it like we do for AUXV_FREEBSD_AT_HWCAP. No extra tests here, those will be coming with the next change for MTE support.
2025-06-30[lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (#146072)dlav-sc1-5/+7
lldb-server had limited support for single-stepping through the lr/sc atomic sequence. This patch enhances that support for all possible atomic sequences. The previous version contained an incorrect regex pattern in the test, causing the riscv-specific test to run on other platforms. This reland fixes the regex (see lldb/test/API/riscv/step/TestSoftwareStep.py)
2025-06-24Revert "[lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server" ↵Jonas Devlieghere1-7/+5
(#145597) Reverts llvm/llvm-project#127505 because `riscv/step/TestSoftwareStep.py` is failing on the bots.
2025-06-24[lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (#127505)dlav-sc1-5/+7
lldb-server had limited support for single-stepping through the lr/sc atomic sequence. This patch enhances that support for all possible atomic sequences.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath1-2/+2
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).
2024-10-16[llbd] Finish Turn lldb_private::Status into a value type. (#10616) (#112420)Brooks Davis1-11/+9
Fix a few bare Status() invocations that were missed in the conversion. This is sufficent to build lldb on FreeBSD/aaarch64. Fixes: 0642cd768b80
2024-09-23[lldb][FreeBSD] Fix a typo in NativeProcessFreeBSD::MonitorSIGTRAP() (#109643)Kelvin Lee1-1/+1
Apparently a typo is causing compile error, added by https://github.com/llvm/llvm-project/pull/108504.
2024-09-13[lldb] Add pc check for thread-step-by-bp algorithms (#108504)Jason Molenda1-1/+4
lldb-server built with NativeProcessLinux.cpp and NativeProcessFreeBSD.cpp can use breakpoints to implement instruction stepping on cores where there is no native instruction-step primitive. Currently these set a breakpoint, continue, and if we hit the breakpoint with the original thread, set the stop reason to be "trace". I am wrapping up a change to lldb's breakpoint algorithm where I change its current behavior of "if a thread stops at a breakpoint site, we set the thread's stop reason to breakpoint-hit, even if the breakpoint hasn't been executed" + "when resuming any thread at a breakpoint site, instruction-step past the breakpoint before resuming" to a behavior of "when a thread executes a breakpoint, set the stop reason to breakpoint-hit" + "when a thread has hit a breakpoint, when the thread resumes, we silently step past the breakpoint and then resume the thread". For these lldb-server targets doing breakpoint stepping, this means that if we are sitting on a breakpoint that has not yet executed, and instruction-step the thread, we will execute the breakpoint instruction at $pc (instead of $next-pc where it meant to go), and stop again -- at the same pc value. Then we will rewrite the stop reason to 'trace'. The higher level logic will see that we haven't hit the breakpoint instruction again, so it will try to instruction step again, hitting the breakpoint again forever. To fix this, I'm checking that the thread matches the one we are instruction-stepping-by-breakpoint AND that we've stopped at the breakpoint address we are stepping to. Only in that case will the stop reason be rewritten to "trace" hiding the implementation detail that the step was done by breakpoints.
2024-08-27[lldb] Update NativeProcess*BSD to new Status APIAdrian Prantl1-5/+5
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl7-86/+97
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
2024-08-01[lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm,mips64,powerpc} ↵Dimitry Andric3-3/+3
declarations (#101403) Similar to #97796, fix the type of the `native_thread` parameter for the arm, mips64 and powerpc variants of `NativeRegisterContextFreeBSD_*`. Otherwise, this leads to compile errors similar to: ``` lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp:85:39: error: out-of-line definition of 'NativeRegisterContextFreeBSD_powerpc' does not match any declaration in 'lldb_private::process_freebsd::NativeRegisterContextFreeBSD_powerpc' 85 | NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
2024-07-05[lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (#97796)Kelvin Lee1-1/+1
Supposingly this is a typo.
2024-07-01[lldb][FreeBSD][AArch64] Enable register field detection (#85058)David Spickett9-14/+39
This extends the existing register fields support from AArch64 Linux to AArch64 FreeBSD. So you will now see output like this: ``` (lldb) register read cpsr cpsr = 0x60000200 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0) ``` Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism is the same and I've renamed the detector class to reflect that. I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel calls it) is similair enough that we can use the same field information. (see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`) For testing I've enabled the same live process test as Linux and added a shell test using an existing FreeBSD core file. Note that the latter does not need XML support because when reading a core file we are not sending the information via target.xml, it's just internal to LLDB.
2024-03-08[lldb][FreeBSD] Fix crash when execve fails with asserts enabledDavid Spickett1-2/+2
535da10842c7309e9eeaf9828cf6bb034fecaf16 introduced a check, when execve fails, to see if we are allowed to trace programs at all. Unfortunately because we like to call Status vars "error" and "status" in various combinations, one got misnamed. This lead to lldb-server trying to make an error value out of a success value when you did the following: ``` $ ./bin/lldb-server gdbserver 127.0.0.1:1234 -- is_not_a_file Assertion failed: (Err && "Cannot create Expected<T> from Error success value."), function Expected... ``` This happened because the execve fails, but the check whether we can trace says yes we can trace, but then we use the Status from the check to create the return value. That Status is in fact a success value not the failed Status we got from the execve attempt. With the name corrected you now get: ``` $ ./bin/lldb-server gdbserver 127.0.0.1:1234 -- is_not_a_file error: failed to launch 'is_not_a_file': execve failed: No such file or directory ``` Which is what we expect to see. This also fixes the test `TestGDBRemoteLaunch.py` when asserts are enabled.
2024-02-11[lldb] checks if lldb can trace/attach/set a breakpoint a process or load a ↵David CARLIER1-5/+34
file to debug on FreeBSD. before having the generic EINVAL message, we check if the `security.bsd.unprivileged_proc_debug` allows process debugging. close #79634
2023-11-03[lldb][NFC] Use UNUSED_IF_ASSERT_DISABLED instead of (void) castDavid Spickett1-1/+1
Uses of (void) remain where they are for purposes other than an assert variable.
2023-03-30[lldb-server/linux] Use waitpid(-1) to collect inferior eventsPavel Labath2-14/+13
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
2023-03-15Reland "[lldb] Refactor CrashReason"David Spickett1-2/+1
This reverts commit 71c4d186f1cf247f1aa45f4fd1b38f350b68d123. The reinterpret casts were not needed.
2023-03-15Revert "[lldb] Refactor CrashReason"David Spickett1-1/+2
This reverts commit af38530ee29c285f3827e33a41edf27c9c3a6767 due to a build failure on 32 bit.
2023-03-15[lldb] Refactor CrashReasonDavid Spickett1-2/+1
So that there is only one function that NativeThreads call, which takes a siginfo. Everything else is an internal detail. Reviewed By: labath, JDevlieghere Differential Revision: https://reviews.llvm.org/D146043
2023-01-30[lldb,FreeBSD] getValue => operator* for Optional migrationFangrui Song2-4/+4
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille1-2/+2
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata6-16/+16
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata6-0/+6
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-05[lldb] Use std::nullopt instead of llvm::None (NFC)Kazu Hirata1-5/+5
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[LLDB] Change getValue to value in NativeRegisterContextFreeBSD_x86_64.cppKrzysztof Parzyszek1-2/+2
Optional::getValue has been removed.
2022-06-21[lldb] [llgs] Fix signo sent with fork/vfork/vforkdone eventsMichał Górny1-6/+9
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-06-03[lldb] [Process/FreeBSD] Do not send SIGSTOP to stopped processMichał Górny1-0/+4
Do not send SIGSTOP when requested to halt a process that's already stopped. This results in the signal being queued for delivery once the process is resumed, and unexpectedly stopping it again. This is necessary for non-stop protocol patches to land. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D126770
2022-04-05[lldb] Add more missing consts in NativeRegisterContextsJonas Devlieghere5-5/+5
2022-04-05[lldb] Update the NativeRegisterContext to take a WritableMemoryBufferJonas Devlieghere10-10/+10
2022-01-26[lldb] Convert POSIXLog to use the new APIPavel Labath3-20/+20
2022-01-13[lldb] [llgs] Implement qXfer:siginfo:readMichał Górny3-1/+29
Implement the qXfer:siginfo:read that is used to read the siginfo_t (extended signal information) for the current thread. This is currently implemented on FreeBSD and Linux. Differential Revision: https://reviews.llvm.org/D117113
2022-01-12[lldb] [Process/FreeBSD] Set current thread ID on eventsMichał Górny1-2/+10
Set the current thread ID to the thread where an event happened. As a result, e.g. when a signal is delivered to a thread other than the first one, the respective T packet refers to the signaled thread rather than the first thread (with no stop reason). While this doesn't strictly make a difference to the LLDB client, it is the expected behavior. Differential Revision: https://reviews.llvm.org/D117103
2021-10-06[lldb] [FreeBSD] Fix building on systems without PT_COREDUMPMichał Górny1-3/+12
PT_COREDUMP is a relatively recent addition. Use an #ifdef to skip it if the underlying system does not support it. Differential Revision: https://reviews.llvm.org/D111214
2021-09-10[lldb] [Process/FreeBSD] Introduce mips64 FPU reg supportMichał Górny2-4/+59
Differential Revision: https://reviews.llvm.org/D96766
2021-09-08[lldb] [Process/FreeBSD] Support SaveCore() using PT_COREDUMPMichał Górny2-1/+31
Differential Revision: https://reviews.llvm.org/D109326
2021-05-01[lldb] [Process/FreeBSD] Fix arm64 build after RegisterInfoPOSIX_arm64 changesMichał Górny1-7/+1
Commit 88a5b35d63f927db69ec953ff487a7ba2504a610 changed the API of RegisterInfoPOSIX_arm64 and effectively broke the FreeBSD plugin. Update it to work with the new API. Differential Revision: https://reviews.llvm.org/D101521
2021-04-27[lldb] [gdb-remote] Report QPassSignals and qXfer via extensions APIMichał Górny1-1/+2
Remove hardcoded platform list for QPassSignals, qXfer:auxv:read and qXfer:libraries-svr4:read and instead query the process plugin via the GetSupportedExtensions() API. Differential Revision: https://reviews.llvm.org/D101241
2021-04-25[lldb] [Process/FreeBSD] Report fork/vfork events to LLGSMichał Górny4-27/+98
Differential Revision: https://reviews.llvm.org/D100547
2021-04-13Reland "[lldb] [Process] Watch for fork/vfork notifications" for FreeBSDMichał Górny2-3/+53
The original commit was reverted because of the problems it introduced on Linux. However, FreeBSD should not be affected, so restore that part and we will address Linux separately. While at it, remove the dbreg hack as the underlying issue has been fixed in the FreeBSD kernel and the problem is unlikely to happen in real life use anyway. Differential Revision: https://reviews.llvm.org/D98822
2021-04-13Revert "[lldb] [Process] Watch for fork/vfork notifications" and associated ↵Pavel Labath7-94/+3
followups This commit has caused the following tests to be flaky: TestThreadSpecificBpPlusCondition.py TestExitDuringExpression.py The exact cause is not known yet, but since both tests deal with threads, my guess is it has something to do with the tracking of creation of new threads (which the commit touches upon). This reverts the following commits: d01bff8cbdc98fb8751f7bf10af19b47ae5c445d, ba62ebc48e8c424ce3a78ba01acda679d536dd47, e761b6b4c58d4f7ae1073d925d7cb321d68ee93a, a345419ee03095c8cdfbe1c2728467c4da8fa0a4.
2021-04-13[lldb] Replace NativeProcess delegate list with a single delegatePavel Labath1-1/+1
In all this time, we've never used more than one delegate. The logic to support multiple delegates is therefore untested, and becomes particularly unwieldy once we need to support multiple processes. Just remove it.
2021-04-08[lldb] [Process] Watch for fork/vfork notificationsMichał Górny7-3/+94
Watch for fork(2)/vfork(2) (also fork/vfork-style clone(2) on Linux) notifications and explicitly detach the forked child process, and add initial tests for these cases. The code covers FreeBSD, Linux and NetBSD process plugins. There is no new user-visible functionality provided -- this change lays foundations over subsequent work on fork support. Differential Revision: https://reviews.llvm.org/D98822
2021-04-01[lldb] Fix build errors from 3bea7306e8Pavel Labath1-1/+1
The addition of the dummy constructors requires matching changes in os- and arch-specific files, which I forgot about.
2021-03-10[lldb] [Process/FreeBSD] Introduce aarch64 hw break/watchpoint supportMichał Górny3-7/+106
Split out the common base of Linux hardware breakpoint/watchpoint support for AArch64 into a Utility class, and use it to implement the matching support on FreeBSD. Differential Revision: https://reviews.llvm.org/D96548
2021-03-01[lldb] Rename NativeRegisterContext{Watchpoint => DBReg}_x86Michał Górny1-2/+2
Differential Revision: https://reviews.llvm.org/D97210
2021-02-16[lldb] [Process/FreeBSD] Ensure that errors are always handledMichał Górny1-2/+3
Ensure that the llvm::Error instances are always considered handled by replacing LLDB_LOG with LLDB_LOG_ERROR. Differential Revision: https://reviews.llvm.org/D96558
2021-02-15[lldb] Rename FreeBSDRemote to FreeBSD (NFC)Michał Górny17-0/+3431
Differential Revision: https://reviews.llvm.org/D96557
2021-02-15[lldb] Remove the legacy FreeBSD pluginMichał Górny20-6013/+0
The new FreeBSDRemote plugin has reached feature parity with the legacy plugin, so we can finally remove the latter. The new plugin will be renamed to FreeBSD in a separate commit to avoid confusion. Differential Revision: https://reviews.llvm.org/D96555
2021-01-25[ThreadPlan] fix exec on LinuxWalter Erquinigo2-4/+4