aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/DynamicLoader
AgeCommit message (Collapse)AuthorFilesLines
2025-09-04[lldb] Use weak pointers instead of shared pointers in DynamicLoader (#156446)Andrew Savonichev1-1/+2
DynamicLoaderWindowsDYLD uses pointers to Modules to maintain a map from modules to their addresses, but it does not need to keep "strong" references to them. Weak pointers should be enough, and would allow modules to be released elsewhere. Other DynamicLoader classes do not use shared pointers as well. For example, DynamicLoaderPOSIXDYLD has a similar map with weak pointers. Actually testing for modules being completely released can be tricky. The test here is just to illustrate the case where shared pointers kept modules in DynamicLoaderWindowsDYLD and prevented them from being released. The test executes the following sequence: 1. Create a target, load an executable and run it. 2. Remove one module from the target. The target should be the last actual use of the module, but we have another reference to it in the shared module cache. 3. Call MemoryPressureDetected to remove this last reference from the cache. 4. Replace the corresponding DLL file. LLDB memory maps DLLs, and this makes files read-only on Windows. Unless the modules are completely released (and therefore unmapped), (4) is going to fail with "access denied". However, the test does not trigger the bug completely - it passes with and without the change.
2025-08-08[lldb-dap] persistent assembly breakpoints (#148061)Ely Ronnen2-4/+6
Resolves #141955 - Adds data to breakpoints `Source` object, in order for assembly breakpoints, which rely on a temporary `sourceReference` value, to be able to resolve in future sessions like normal path+line breakpoints - Adds optional `instructions_offset` parameter to `BreakpointResolver`
2025-08-04[lldb] Fix TLS support on Darwin platforms (#151601)Alex Langford1-4/+3
When I wrote this previously, I was unaware that the TLS function already adds the offset. The test was working previously because the offset was 0 in this case (only 1 thread-local variable). I added another thread-local variable to the test to make sure the offset is indeed handled correctly. rdar://156547548
2025-06-24Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (#145305)Pavel Labath1-0/+7
The only difference from the original PR are the added BRIEF and FULL_DOCS arguments to define_property, which are required for cmake<3.23.
2025-06-23Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"Pavel Labath1-7/+0
Causes failures on several bots. This reverts commits 714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8 and e7c1da7c8ef31c258619c1668062985e7ae83b70.
2025-06-23[lldb/cmake] Plugin layering enforcement mechanism (#144543)Pavel Labath1-0/+7
Some inter-plugin dependencies are okay, others are not. Yet others not, but we're sort of stuck with them. The idea is to be able to prevent backsliding while making sure that acceptable dependencies are.. accepted. For context, see https://github.com/llvm/llvm-project/pull/139170 and the attached changes to the documentation.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath4-10/+10
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-29[LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir ↵Akash Agrawal1-4/+1
& 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-05-22[lldb] Call Target::ClearAllLoadedSections even earlier (#140228)Pavel Labath1-1/+0
This reapplies https://github.com/llvm/llvm-project/pull/138892, which was reverted in https://github.com/llvm/llvm-project/commit/5fb9dca14aeaf12219ff149bf3a4f94c8dc58d8b due to failures on windows. Windows loads modules from the Process class, and it does that quite early, and it kinda makes sense which is why I'm moving the clearing code even earlier. The original commit message was: Minidump files contain explicit information about load addresses of modules, so it can load them itself. This works on other platforms, but fails on darwin because DynamicLoaderDarwin nukes the loaded module list on initialization (which happens after the core file plugin has done its work). This used to work until https://github.com/llvm/llvm-project/pull/109477, which enabled the dynamic loader plugins for minidump files in order to get them to provide access to TLS. Clearing the load list makes sense, but I think we could do it earlier in the process, so that both Process and DynamicLoader plugins get a chance to load modules. This patch does that by calling the function early in the launch/attach/load core flows. This fixes TestDynamicValue.py:test_from_core_file on darwin.
2025-05-14Revert "[lldb] Call Target::ClearAllLoadedSections earlier (#138892)"Pavel Labath1-0/+1
This reverts commit 97aa01bef770ec651c86978d137933e09221dd00 and 7e7871d3f58b9da72ca180fcd7f0d2da3f92ec4a due to failures on windows.
2025-05-14[lldb] Call Target::ClearAllLoadedSections earlier (#138892)Pavel Labath1-1/+0
Minidump files contain explicit information about load addresses of modules, so it can load them itself. This works on other platforms, but fails on darwin because DynamicLoaderDarwin nukes the loaded module list on initialization (which happens after the core file plugin has done its work). This used to work until #109477, which enabled the dynamic loader plugins for minidump files in order to get them to provide access to TLS. Clearing the load list makes sense, but I think we could do it earlier in the process, so that both Process and DynamicLoader plugins get a chance to load modules. This patch does that by calling the function early in the launch/attach/load core flows. This fixes TestDynamicValue.py:test_from_core_file on darwin.
2025-05-13Support stepping through Darwin "branch islands" (#139301)jimingham1-7/+25
When an intra-module jump doesn't fit in the immediate branch slot, the Darwin linker inserts "branch island" symbols, and emits code to jump from branch island to branch island till it makes it to the actual function. The previous submissions failed because in that environment the linker was putting the `foo.island` symbol at the same address as the `padding` symbol we we emitting to make our faked-up large binary. This submission jams a byte after the padding symbol so that the other symbols can't overlap it.
2025-05-08Revert branch island experiments (#139192)jimingham1-34/+7
This test is failing because when we step to what is the branch island address and ask for its symbol, we can't resolve the symbol, and just call it the last padding symbol plus a bajillion. That has nothing to do with the changes in this patch, but I'll revert this and keep trying to figure out why symbol reading on this bot is wrong.
2025-05-08Add more logging so I can figure out why TestBranchIslands.py is (#139178)jimingham1-0/+9
failing but only on the bot.
2025-05-08Branch island debug (#139166)jimingham1-7/+25
This patch allows lldb to step in across "branch islands" which is the Darwin linker's way of dealing with immediate branches to targets that are too far away for the immediate slot to make the jump. I submitted this a couple days ago and it failed on the arm64 bot. I was able to match the bot OS and Tool versions (they are a bit old at this point) and ran the test there but sadly it succeeded. The x86_64 bot also failed but that was my bad, I did @skipUnlessDarwin when I should have done @skipUnlessAppleSilicon. So this resubmission is with the proper decoration for the test, and with a bunch of debug output printed in case of failure. With any luck, if this resubmission fails again I'll be able to see what's going on.
2025-05-06Revert "Branch island with numbers (#138781)"Felipe de Azevedo Piovezan1-25/+7
This reverts commit 11f33ab3850886510a831122078a155be7dc1167. This is failing on CI.
2025-05-06Branch island with numbers (#138781)jimingham1-7/+25
Reapply the support for stepping through branch islands, add support for a branch that takes multiple hops to get to the target.
2025-05-05Revert "Handle step-in over a Darwin "branch island". (#138330)" (#138569)jimingham1-20/+7
This reverts commit 1ba89ad2c6e405bd5ac0c44e2ee5aa5504c7aba1. This was failing on the Green Dragon bot, which has an older OS than have on hand, so I'll have to dig up one and see why it's failing there.
2025-05-05Handle step-in over a Darwin "branch island". (#138330)jimingham1-7/+20
2025-04-07Control Darwin parallel image loading with target.parallel-module-load (#134437)Tom Yang8-133/+2
A requested follow-up from https://github.com/llvm/llvm-project/pull/130912 by @JDevlieghere to control Darwin parallel image loading with the same `target.parallel-module-load` that controls the POSIX dyld parallel image loading. Darwin parallel image loading was introduced by https://github.com/llvm/llvm-project/pull/110646. This small change: * removes `plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load` and associated code. * changes setting call site in `DynamicLoaderDarwin::PreloadModulesFromImageInfos` to use the new setting. Tested by running `ninja check-lldb` and loading some targets. Co-authored-by: Tom Yang <toyang@fb.com>
2025-03-31Parallelize module loading in POSIX dyld code (#130912)Tom Yang2-42/+122
This patch improves LLDB launch time on Linux machines for **preload scenarios**, particularly for executables with a lot of shared library dependencies (or modules). Specifically: * Launching a binary with `target.preload-symbols = true` * Attaching to a process with `target.preload-symbols = true`. It's completely controlled by a new flag added in the first commit `plugin.dynamic-loader.posix-dyld.parallel-module-load`, which *defaults to false*. This was inspired by similar work on Darwin #110646. Some rough numbers to showcase perf improvement, run on a very beefy machine: * Executable with ~5600 modules: baseline 45s, improvement 15s * Executable with ~3800 modules: baseline 25s, improvement 10s * Executable with ~6650 modules: baseline 67s, improvement 20s * Executable with ~12500 modules: baseline 185s, improvement 85s * Executable with ~14700 modules: baseline 235s, improvement 120s A lot of targets we deal with have a *ton* of modules, and unfortunately we're unable to convince other folks to reduce the number of modules, so performance improvements like this can be very impactful for user experience. This patch achieves the performance improvement by parallelizing `DynamicLoaderPOSIXDYLD::RefreshModules` for the launch scenario, and `DynamicLoaderPOSIXDYLD::LoadAllCurrentModules` for the attach scenario. The commits have some context on their specific changes as well -- hopefully this helps the review. # More context on implementation We discovered the bottlenecks by via `perf record -g -p <lldb's pid>` on a Linux machine. With an executable known to have 1000s of shared library dependencies, I ran ``` (lldb) b main (lldb) r # taking a while ``` and showed the resulting perf trace (snippet shown) ``` Samples: 85K of event 'cycles:P', Event count (approx.): 54615855812 Children Self Command Shared Object Symbol - 93.54% 0.00% intern-state libc.so.6 [.] clone3 clone3 start_thread lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) r std::_Function_handler<void* (), lldb_private::Process::StartPrivateStateThread(bool)::$_0>::_M_invoke(std::_Any_data const&) lldb_private::Process::RunPrivateStateThread(bool) n - lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&) - 93.54% lldb_private::Process::ShouldBroadcastEvent(lldb_private::Event*) - 93.54% lldb_private::ThreadList::ShouldStop(lldb_private::Event*) - lldb_private::Thread::ShouldStop(lldb_private::Event*) * - 93.53% lldb_private::StopInfoBreakpoint::ShouldStopSynchronous(lldb_private::Event*) t - 93.52% lldb_private::BreakpointSite::ShouldStop(lldb_private::StoppointCallbackContext*) i lldb_private::BreakpointLocationCollection::ShouldStop(lldb_private::StoppointCallbackContext*) k lldb_private::BreakpointLocation::ShouldStop(lldb_private::StoppointCallbackContext*) b lldb_private::BreakpointOptions::InvokeCallback(lldb_private::StoppointCallbackContext*, unsigned long, unsigned long) i DynamicLoaderPOSIXDYLD::RendezvousBreakpointHit(void*, lldb_private::StoppointCallbackContext*, unsigned long, unsigned lo - DynamicLoaderPOSIXDYLD::RefreshModules() O - 93.42% DynamicLoaderPOSIXDYLD::RefreshModules()::$_0::operator()(DYLDRendezvous::SOEntry const&) const u - 93.40% DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(lldb_private::FileSpec const&, unsigned long, unsigned long, bools - lldb_private::DynamicLoader::LoadModuleAtAddress(lldb_private::FileSpec const&, unsigned long, unsigned long, boos - 83.90% lldb_private::DynamicLoader::FindModuleViaTarget(lldb_private::FileSpec const&) o - 83.01% lldb_private::Target::GetOrCreateModule(lldb_private::ModuleSpec const&, bool, lldb_private::Status* - 77.89% lldb_private::Module::PreloadSymbols() - 44.06% lldb_private::Symtab::PreloadSymbols() - 43.66% lldb_private::Symtab::InitNameIndexes() ... ``` We saw that majority of time was spent in `RefreshModules`, with the main culprit within it `LoadModuleAtAddress` which eventually calls `PreloadSymbols`. At first, `DynamicLoaderPOSIXDYLD::LoadModuleAtAddress` appears fairly independent -- most of it deals with different files and then getting or creating Modules from these files. The portions that aren't independent seem to deal with ModuleLists, which appear concurrency safe. There were members of `DynamicLoaderPOSIXDYLD` I had to synchronize though: namely `m_loaded_modules` which `DynamicLoaderPOSIXDYLD` maintains to map its loaded modules to their link addresses. Without synchronizing this, I ran into SEGFAULTS and other issues when running `check-lldb`. I also locked the assignment and comparison of `m_interpreter_module`, which may be unnecessary. # Alternate implementations When creating this patch, another implementation I considered was directly background-ing the call to `Module::PreloadSymbol` in `Target::GetOrCreateModule`. It would have the added benefit of working across platforms generically, and appeared to be concurrency safe. It was done via `Debugger::GetThreadPool().async` directly. However, there were a ton of concurrency issues, so I abandoned that approach for now. # Testing With the feature active, I tested via `ninja check-lldb` on both Debug and Release builds several times (~5 or 6 altogether?), and didn't spot additional failing or flaky tests. I also tested manually on several different binaries, some with around 14000 modules, but just basic operations: launching, reaching main, setting breakpoint, stepping, showing some backtraces. I've also tested with the flag off just to make sure things behave properly synchronously.
2025-03-13[lldb][NFC] Correct whitespace in SearchForKernelWithDebugHintsJason Molenda1-20/+22
2025-02-20[lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (#127961)Jonas Devlieghere2-8/+8
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-19[lldb] Make GetOutputStreamSP and GetErrorStreamSP protected (#127682)Jonas Devlieghere1-4/+5
This makes GetOutputStreamSP and GetErrorStreamSP protected members of Debugger. Users who want to print to the debugger's stream should use GetAsyncOutputStreamSP and GetAsyncErrorStreamSP instead and the few remaining stragglers have been migrated.
2025-02-12[lldb] Remove Debugger::Get{Output,Error}Stream (NFC) (#126821)Jonas Devlieghere2-53/+51
Remove Debugger::GetOutputStream and Debugger::GetErrorStream in preparation for replacing both with a new variant that needs to be locked and hence can't be handed out like we do right now. The patch replaces most uses with GetAsyncOutputStream and GetAsyncErrorStream respectively. There methods return new StreamSP objects that automatically get flushed on destruction. See #126630 for more details.
2025-02-10[lldb] [darwin] Upstream a few DriverKit cases (#126604)Jason Molenda4-4/+10
A DriverKit process is a kernel extension that runs in userland, instead of running in the kernel address space/priv levels, they've been around a couple of years. From lldb's perspective a DriverKit process is no different from any other userland level process, but it has a different Triple so we need to handle those cases in the lldb codebase. Some of the DriverKit triple handling had been upstreamed to llvm-project, but I noticed a few cases that had not yet. Cleaning that up.
2025-02-08[lldb] Upstream a few remaining Triple::XROS patches (#126335)Jason Molenda1-2/+8
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-06[lldb] Use Lambda to simplify repeptitive code in DynamicLoaderDarwin (NFC) ↵Jonas Devlieghere1-9/+11
(#126175) I suggested using a lambda in #126171 but @jasonmolenda missed it.
2025-02-06[lldb][Darwin] Change DynamicLoaderDarwin to default to new SPI (#126171)Jason Molenda1-17/+26
In Sep 2016 and newer Darwin releases, debugserver uses libdyld SPI to gather information about the binaries loaded in a process. Before Sep 2016, lldb would inspect the dyld internal data structures directly itself to find this information. DynamicLoaderDarwin::UseDYLDSPI currently defaults to the old inspect-dyld-internal-structures method for binaries (DynamicLoaderMacOSXDYLD). If it detects that the Process' host OS version is new enough, it enables the newer libdyld SPI methods in debugserver (DynamicLoaderMacOS). This patch changes the default to use the new libdyld SPI interfaces. If the Process has a HostOS and it is one of the four specific OSes that existed in 2015 (Mac OS X, iOS, tvOS, watchOS) with an old version number, then we will enable the old DynamicLoader plugin. If this debug session is a corefile, we will always use the old DynamicLoader plugin -- the libdyld SPI cannot run against a corefile, lldb must read metadata or the dyld internal data structures in the corefile to find the loaded binaries.
2025-02-06[lldb] Add SymbolContext::GetFunctionOrSymbolAddress (#123340)Pavel Labath3-18/+8
Many uses of SC::GetAddressRange were not interested in the range, but in the address of the function/symbol contained inside the symbol context. They were getting that by calling the GetBaseAddress on the returned range, which worked well enough so far, but isn't compatible with discontinuous functions, whose address (entry point) may not be the lowest address in the range. To resolve this problem, this PR creates a new function whose purpose is return the address of the function or symbol inside the symbol context. It also changes all of the callers of GetAddressRange which do not actually care about the range to call this function instead.
2025-01-14[lldb][NFC] Make the target's SectionLoadList private. (#113278)Greg Clayton2-3/+3
Lots of code around LLDB was directly accessing the target's section load list. This NFC patch makes the section load list private so the Target class can access it, but everyone else now uses accessor functions. This allows us to control the resolving of addresses and will allow for functionality in LLDB which can lazily resolve addresses in JIT plug-ins with a future patch.
2025-01-10[lldb] Add Function::GetAddress and redirect some uses (#115836)Pavel Labath2-6/+3
Many calls to Function::GetAddressRange() were not interested in the range itself. Instead they wanted to find the address of the function (its entry point) or the base address for relocation of function-scoped entities (technically, the two don't need to be the same, but there's isn't good reason for them not to be). This PR creates a separate function for retrieving this, and changes the existing (non-controversial) uses to call that instead.
2024-11-11[lldb] Support overriding the disassembly CPU & features (#115382)Jonas Devlieghere1-1/+1
Add the ability to override the disassembly CPU and CPU features through a target setting (`target.disassembly-cpu` and `target.disassembly-features`) and a `disassemble` command option (`--cpu` and `--features`). This is especially relevant for architectures like RISC-V which relies heavily on CPU extensions. The majority of this patch is plumbing the options through. I recommend looking at DisassemblerLLVMC and the test for the observable change in behavior.
2024-10-22[lldb] Avoid repeated hash lookups (NFC) (#113248)Kazu Hirata1-3/+3
2024-10-15DynamicLoaderDarwin load images in parallel with preload (#110646)Dmitrii Galimzianov9-43/+215
This change enables `DynamicLoaderDarwin` to load modules in parallel using the thread pool. This new behavior is controlled by a new setting `plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load`, which is enabled by default. When disabled, DynamicLoaderDarwin will load modules sequentially as before.
2024-10-10[LLDB][Minidump] Have Minidumps save off and properly read TLS data (#109477)Jacob Lalonde2-0/+86
This patch adds the support to `Process.cpp` to automatically save off TLS sections, either via loading the memory region for the module, or via reading `fs_base` via generic register. Then when Minidumps are loaded, we now specify we want the dynamic loader to be the `POSIXDYLD` so we can leverage the same TLS accessor code as `ProcessELFCore`. Being able to access TLS Data is an important step for LLDB generated minidumps to have feature parity with ELF Core dumps.
2024-10-07[LLDB][DYLD] Remove logic around not rebasing when main executable has a ↵Jacob Lalonde1-15/+0
load address (#110885) This is a part of #109477 that I'm making into it's own patch. Here we remove logic from the DYLD that prevents it's logic from running if the main executable already has a load address. Instead we let the DYLD fully determine what should be loaded and what shouldn't.
2024-09-25[lldb] [Mach-O corefiles] Sanity check malformed dyldJason Molenda3-3/+8
lldb scans the corefile for dyld, the dynamic loader, and when it finds a mach-o header that looks like dyld, it tries to read all of the load commands and symbol table out of the corefile memory. If the load comamnds and symbol table are absent or malformed, it doesn't handle this case and can crash. Back out when we fail to create a Module from the dyld binary. rdar://136659551
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl5-10/+9
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-20[lldb][AIX] 1. Avoid namespace collision on other platforms (#104679)Dhruv Srivastava2-3/+3
This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. #101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 The changes on this PR are intended to avoid namespace collision for certain typedefs between lldb and other platforms: 1. tid_t --> lldb::tid_t 2. offset_t --> lldb::offset_t
2024-07-22[lldb] Change GetStartSymbol to GetStartAddress in DynamicLoader (#99909)Med Ismail Bennani2-4/+4
On linux, the start address doesn't necessarily have a symbol attached to it. This is why this patch replaces `DynamicLoader::GetStartSymbol` with `DynamicLoader::GetStartAddress` instead to make it more generic. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-19[lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (#99673)Med Ismail Bennani2-0/+22
This patch introduces a new method to the dynamic loader plugin, to fetch its `start` symbol. This can be useful to resolve the `start` symbol address for instance. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-17[lldb] progressive progress reporting for darwin kernel/firmware (#98845)Jason Molenda2-29/+39
When doing firmware/kernel debugging, it is frequent that binaries and debug info need to be retrieved / downloaded, and the lack of progress reports made for a poor experience, with lldb seemingly hung while downloading things over the network. This PR adds progress reports to the critical sites for these use cases.
2024-05-07[lldb] fix step in AArch64 trampoline (#90783)Vincent Belliard1-0/+13
Detects AArch64 trampolines in order to be able to step in a function through a trampoline on AArch64. --------- Co-authored-by: Vincent Belliard <v-bulle@github.com>
2024-04-17[lldb][DynamicLoader] Fix lldb unable to stop at _dl_debug_state if user set ↵Zequan Wu1-2/+9
it before the process launched. (#88792) If user sets a breakpoint at `_dl_debug_state` before the process launched, the breakpoint is not resolved yet. When lldb loads dynamic loader module, it's created with `Target::GetOrCreateModule` which notifies any pending breakpoint to resolve. However, the module's sections are not loaded at this time. They are loaded after returned from [Target::GetOrCreateModule](https://github.com/llvm/llvm-project/blob/0287a5cc4e2a5ded1ae2e4079f91052e6a6b8d9b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp#L574-L577). This change fixes it by manually resolving breakpoints after creating dynamic loader module.
2024-04-03[lldb] Set static Module's load addresses via ObjectFile (#87439)Jason Molenda1-24/+16
This is a followup to https://github.com/llvm/llvm-project/pull/86359 "[lldb] [ObjectFileMachO] LLVM_COV is not mapped into firmware memory (#86359)" where I treat LLVM_COV segments in a Mach-O binary as non-loadable. There is another codepath in `DynamicLoaderStatic::LoadAllImagesAtFileAddresses` which is called to set the load addresses for a Module to the file addresses. It has no logic to detect a segment that is not loaded in virtual memory (ObjectFileMachO::SectionIsLoadable), so it would set the load address for this LLVM_COV segment to the file address and shadow actual code, breaking lldb behavior. This method currently sets the load address for any section that doesn't have a load address set already. This presumes that a Module was added to the Target, some mechanism set the correct load address for SOME segments, and then this method is going to set the other segments to a no-slide value, assuming they were forgotten. ObjectFile base class doesn't, today, vend a SectionIsLoadable method, but we do have ObjectFile::SetLoadAddress and at a higher level, Module::SetLoadAddress, when we're setting the same slide to all segments. That's the behavior we want in this method. If any section has a load address, we don't touch this Module. Otherwise we set all sections to have a load address that is the same as the file address. I also audited the other parts of lldb that are calling SectionList::SectionLoadAddress and looked if they should be more correctly using Module::SetLoadAddress for the entire binary. But in most cases, we have the potential for different slides for different sections so this section-by-section approach must be taken. rdar://125800290
2024-03-06[lldb] Address mask sbprocess apis and new mask invalid const (#83663)Jason Molenda1-1/+2
[lldb] Add SBProcess methods for get/set/use address masks (#83095) I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. I originally landed this via https://github.com/llvm/llvm-project/pull/83095 but it failed on CIs outside of arm64 Darwin so I had to debug it on more environments and update the patch. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. This patch changes the value of "no mask set" from 0 to LLDB_INVALID_ADDRESS_MASK, which is UINT64_MAX. A mask of all 1's means "no bits are used for addressing" which is an impossible mask, whereas a mask of 0 means "all bits are used for addressing" which is possible. I added a base class implementation of ABI::FixCodeAddress and ABI::FixDataAddress that will apply the Process mask values if they are set to a value other than LLDB_INVALID_ADDRESS_MASK. I updated all the callers/users of the Mask methods which were handling a value of 0 to mean invalid mask to use LLDB_INVALID_ADDRESS_MASK. I added code to the all AArch64 ABI Fix* methods to apply the Highmem masks if they have been set. These will not be set on a Linux environment, but in TestAddressMasks.py I test the highmem masks feature for any AArch64 target, so all AArch64 ABI plugins must handle it. rdar://123530562
2024-02-19[llvm] Upstream the BridgeOS triple enum value (NFC)Jonas Devlieghere4-5/+5
This upstreams the BridgeOS target triple enum value.
2024-01-26[lldb][FreeBSD] Fix unused variable warningDavid Spickett1-2/+1
2024-01-17[lldb] Support changes to TLS on macOS (#77988)Alex Langford1-64/+94
The TLS implementation on apple platforms has changed. Instead of invoking pthread_getspecific with a pthread_key_t, we instead perform a virtual function call. Note: Some versions of Apple's new linker do not emit debug symbols for TLS symbols. This causes the TLS tests to fail because LLDB and dsymutil expects there to be debug symbols to resolve the relevant TLS block. You may work around this by switching to the older linker (ld-classic) or by disabling the TLS tests until you have a newer version of the new linker. rdar://120676969