aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ObjectFile/PECOFF
AgeCommit message (Collapse)AuthorFilesLines
2025-06-09[LLDB] Unify DWARF section name matching (#141344)nerix1-14/+3
Different object file formats support DWARF sections (COFF, ELF, MachO, PE/COFF, WASM). COFF and PE/COFF only matched a subset. This caused some GCC executables produced on MinGW to have issue later on when debugging. One example is that `.debug_rnglists` was not matched, which caused range-extraction to fail when printing a backtrace. This unifies the parsing of section names in `ObjectFile::GetDWARFSectionTypeFromName`, so all file formats can use the same naming convention. Since the prefixes are different, `GetDWARFSectionTypeFromName` only matches the suffixes (i.e. `.debug_` needs to be stripped before). I added two tests to ensure the sections are correctly identified on Windows executables.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath1-4/+4
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-24[lldb] Use llvm::stable_sort (NFC) (#141352)Kazu Hirata1-2/+1
2025-05-22[lldb] Disable some unwind plans for discontinuous functions (#140927)Pavel Labath2-22/+27
Basically, disable everything except the eh_frame unwind plan, as that's the only one which supports this right now. The other plans are working with now trying the interpret everything in between the function parts as a part of the function, which is more likely to produce wrong results than correct ones. I changed the interface for object file plans, to give the implementations a chance to implement this correctly, but I haven't actually converted PECallFrameInfo (its only implementation) to handle that. (from the looks of things, it should be relatively easy to do, if it becomes necessary) I'm also deleting UnwindPlan::GetFirstNonPrologueInsn, as it's not used, and it doesn't work for discontinuous functions.
2025-03-21 [lldb] s/ValidRange/ValidRanges in UnwindPlan (#127661)Pavel Labath1-2/+2
To be able to describe discontinuous functions, this patch changes the UnwindPlan to accept more than one address range. I've also squeezed in a couple improvements/modernizations, for example using the lower_bound function instead of a linear scan.
2025-03-19[lldb] Use UnwindPlan::Row as values (#131150)Pavel Labath1-13/+13
In most places, the rows are copied anyway (because they are generated by cumulating modifications) immediately after adding them to the unwind plans. In others, they can be moved into the unwind plan. This lets us remove some backflip copies and make `const UnwindPlan` actually mean something. I've split this patch into two (and temporarily left both APIs) as this patch was getting a bit big. This patch covers all the interesting cases. Part two all about converting "architecture default" unwind plans from ABI and InstructionEmulation plugins.
2025-02-13[lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC) (#126972)Dave Lee1-22/+11
2025-01-14[lldb][NFC] Make the target's SectionLoadList private. (#113278)Greg Clayton1-1/+1
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.
2024-12-10Reland: [lldb] Implement a formatter bytecode interpreter in C++Adrian Prantl1-0/+1
Compared to the python version, this also does type checking and error handling, so it's slightly longer, however, it's still comfortably under 500 lines. Relanding with more explicit type conversions.
2024-12-11Revert "[lldb] Add cast to fix compile error on 32-bit platforms"Sylvestre Ledru1-1/+0
This reverts commit f6012a209dca6b1866d00e6b4f96279469884320. Revert "[lldb] Add cast to fix compile error on 32-but platforms" This reverts commit d300337e93da4ed96b044557e4b0a30001967cf0. Revert "[lldb] Improve log message to include missing strings" This reverts commit 0be33484853557bc0fd9dfb94e0b6c15dda136ce. Revert "[lldb] Add comment" This reverts commit e2bb47443d2e5c022c7851dd6029e3869fc8835c. Revert "[lldb] Implement a formatter bytecode interpreter in C++" This reverts commit 9a9c1d4a6155a96ce9be494cec7e25731d36b33e.
2024-12-10[lldb] Implement a formatter bytecode interpreter in C++Adrian Prantl1-0/+1
Compared to the python version, this also does type checking and error handling, so it's slightly longer, however, it's still comfortably under 500 lines.
2024-12-10[lldb] Load embedded type summary section (#7859) (#8040)Dave Lee1-0/+1
Add support for type summaries embedded into the binary. These embedded summaries will typically be generated by Swift macros, but can also be generated by any other means. rdar://115184658
2024-09-11[LLDB] Reapply SBSaveCore Add Memory List (#107937)Jacob Lalonde2-0/+2
Recently in #107731 this change was revereted due to excess memory size in `TestSkinnyCore`. This was due to a bug where a range's end was being passed as size. Creating massive memory ranges. Additionally, and requiring additional review, I added more unit tests and more verbose logic to the merging of save core memory regions. @jasonmolenda as an FYI.
2024-09-07Revert "[LLDB] Reappply SBSaveCore AddMemoryList" (#107731)Jonas Devlieghere2-2/+0
Reverts llvm/llvm-project#107159 as this is still causing `TestSkinnyCorefile.py` to time out. https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/as-lldb-cmake/11099/ https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/lldb-cmake/5544/
2024-09-06[LLDB] Reappply SBSaveCore AddMemoryList (#107159)Jacob Lalonde2-0/+2
Reapplies #106293, testing identified issue in the merging code. I used this opportunity to strip CoreFileMemoryRanges to it's own file and then add unit tests on it's behavior.
2024-08-27[lldb] Adapt WindowsMiniDump to new Status APIAdrian Prantl1-1/+1
2024-08-27Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… ↵Jacob Lalonde2-2/+0
(#106293) Reverts #105442. Due to `TestSkinnyCoreFailing` and root causing of the failure will likely take longer than EOD.
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl1-1/+1
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-27[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (#105442)Jacob Lalonde2-0/+2
This patch adds the option to specify specific memory ranges to be included in a given core file. The current implementation lets user specified ranges either be in addition to a certain save style, or independent of them via the newly added custom enum. To achieve being inclusive of save style, I've moved from a std::vector of ranges to a RangeDataVector, and to join overlapping ranges to prevent duplication of memory ranges in the core file. As a non function bonus, when SBSavecore was initially created, the header was included in the lldb-private interfaces, and I've fixed that and moved it the forward declare as an oversight. CC @bulbazord in case we need to include that into swift.
2024-08-15[LLDB] Reapply #100443 SBSaveCore Thread list (#104497)Jacob Lalonde4-6/+4
Reapply #100443 and #101770. These were originally reverted due to a test failure and an MSAN failure. I changed the test attribute to restrict to x86 (following the other existing tests). I could not reproduce the test or the MSAN failure and no repo steps were provided.
2024-08-11[lldb] Fix dangling expressionAlexandre Ganea1-1/+2
This fixes the following: ``` [6603/7618] Building CXX object tools\lldb\source\Plugins\ObjectFile\PECOFF\CMakeFiles\lldbPluginObjectFilePECOFF.dir\WindowsMiniDump.cpp.obj C:\src\git\llvm-project\lldb\source\Plugins\ObjectFile\PECOFF\WindowsMiniDump.cpp(29,25): warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl] 29 | const auto &outfile = core_options.GetOutputFile().value(); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. ```
2024-08-05Revert "[LLDB][SBSaveCore] Fix bug where default values are not propagated. ↵Haojian Wu4-4/+6
(#101770)" This reverts commit 34766d0d488ba2fbefa80dcd0cc8720a0e753448 which caused a msan failure, see comment https://github.com/llvm/llvm-project/pull/101770#issuecomment-2268373325 for details.
2024-08-02[LLDB][SBSaveCore] Fix bug where default values are not propagated. (#101770)Jacob Lalonde4-6/+4
In #100443, Mach-o and Minidump now only call process API's that take a `SaveCoreOption` as the container for the style and information if a thread should be included in the core or not. This introduced a bug where in subsequent method calls we were not honoring the defaults of both implementations. ~~To solve this I have made a copy of each SaveCoreOptions that is mutable by the respective plugin. Originally I wanted to leave the SaveCoreOptions as non const so these default value mutations could be shown back to the user. Changing that behavior is outside of the scope of this bugfix, but is context for why we are making a copy.~~ Removed const on the savecoreoptions so defaults can be inspected by the user CC: @Michael137
2024-07-18[LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() ↵Jacob Lalonde4-8/+9
overload (#98403) This PR adds `SBSaveCoreOptions`, which is a container class for options when LLDB is taking coredumps. For this first iteration this container just keeps parity with the extant API of `file, style, plugin`. In the future this options object can be extended to allow users to take a subset of their core dumps.
2023-11-01[lldb] Fix missing comsumeError() with LLDB_LOG in ObjectFileCOFF/PECOFF ↵Stefan Gränitz1-5/+4
(#70793) All `llvm::Error`s must be checked/consumed before destruction. Previously, the errors in this patch were only consumed when logging was enabled. Using `LLDB_LOG_ERROR` instead of `LLDB_LOG` fixes that, because it calls `llvm::consumeError()` explicitly when logging is disabled.
2023-08-31[lldb] Add support for recognizing swift ast sections in object filesAlex Langford1-0/+1
In Apple's downstream fork, there is support for understanding the swift AST sections in various binaries. Even though the lldb on llvm.org does not have support for debugging swift, I think it makes sense to move support for recognizing swift ast sections upstream. Differential Revision: https://reviews.llvm.org/D159142
2023-08-31[lldb][NFCI] Remove unneeded ConstString conversionsAlex Langford1-2/+2
ConstString can be implicitly converted into a llvm::StringRef. This is very useful in many places, but it also hides places where we are creating a ConstString only to use it as a StringRef for the entire lifespan of the ConstString object. I locally removed the implicit conversion and found some of the places we were doing this. Differential Revision: https://reviews.llvm.org/D159237
2023-08-09[lldb] Sink StreamFile into lldbHostAlex Langford1-1/+0
StreamFile subclasses Stream (from lldbUtility) and is backed by a File (from lldbHost). It does not depend on anything from lldbCore or any of its sibling libraries, so I think it makes sense for this to live in lldbHost instead. Differential Revision: https://reviews.llvm.org/D157460
2023-08-04[lldb][PECOFF] Exclude alignment padding when reading section dataHiroshi Yamauchi2-0/+11
There can be zero padding bytes at a section end for file alignment in PECOFF. Exclude those padding bytes when reading the section data. Differential Revision: https://reviews.llvm.org/D157059
2023-07-26[lldb] Treat ARM64X images as ARM64.Jacek Caban2-0/+2
With D149091, ARM64X binaries are no longer reported as ARM64. This broke lldb tests as Windows 11 system DLLs are mostly ARM64X binaries and lldb doesn't know how to handle them. Ideally lldb would understand a bit more about ARM64X and handle them as AMD64 in x64 processes, but this is enough to preserve previous behavior and fix tests. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D156268
2023-05-14[lldb] Complete OptionValue cleanup (NFC)Jonas Devlieghere1-2/+2
Make the `Get.*Value` and `Set.*Value` function private and migrate the last remaining call sites to the new overloaded/templated functions.
2023-05-05ObjectFile: remove extraneous shadowed variable (NFCI)Saleem Abdulrasool1-1/+0
We already construct the shared pointer for the module. Avoid creating a shadow copy and use the original definition.
2023-05-04[lldb] Move Core/FileSpecList -> Utility/FileSpecList (NFC)Jonas Devlieghere1-1/+1
There's no reason for FileSpecList to live in lldb/Core while FileSpec lives in lldb/Utility. Move FileSpecList next to FileSpec.
2023-05-04[lldb] Use templates to simplify {Get,Set}PropertyAtIndex (NFC)Jonas Devlieghere1-3/+2
Use templates to simplify {Get,Set}PropertyAtIndex. It has always bothered me how cumbersome those calls are when adding new properties. After this patch, SetPropertyAtIndex infers the type from its arguments and GetPropertyAtIndex required a single template argument for the return value. As an added benefit, this enables us to remove a bunch of wrappers from UserSettingsController and OptionValueProperties. Differential revision: https://reviews.llvm.org/D149774
2023-05-02[lldb] Remove FileSpec::GetLastPathComponentAlex Langford1-2/+2
As far as I can tell, this just computes the filename of the FileSpec, which is already conveniently stored in m_filename. We can use FileSpec::GetFilename() instead. Differential Revision: https://reviews.llvm.org/D149663
2023-05-02[lldb] Make exe_ctx an optional argument in OptionValueProperties (NFC)Jonas Devlieghere1-2/+2
The majority of call sites are nullptr as the execution context. Refactor OptionValueProperties to make the argument optional and simplify all the callers.
2023-05-01[lldb] Refactor OptionValueProperties to return a std::optional (NFC)Jonas Devlieghere1-3/+3
Similar to fdbe7c7faa54, refactor OptionValueProperties to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality.
2023-05-01[lldb] Refactor OptionValue to return a std::optional (NFC)Jonas Devlieghere1-1/+2
Refactor OptionValue to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality.
2023-05-01[lldb] Change ObjectValueDictionary to use a StringMapAlex Langford1-5/+3
llvm has a structure for maps where the key's type is a string. Using that also means that the keys for OptionValueDictionary don't stick around forever in ConstString's StringPool (even after they are gone). The only thing we lose here is ordering: iterating over the map where the keys are ConstStrings guarantees that we iterate in alphabetical order. StringMap makes no guarantees about the ordering when you iterate over the entire map. Differential Revision: https://reviews.llvm.org/D149482
2023-04-19[lldb] Change setting descriptions to use StringRef instead of ConstStringAlex Langford1-2/+1
These probably do not need to be in the ConstString StringPool as they don't really need any of the advantages that ConstStrings offer. Lifetime for these things is always static and we never need to perform comparisons for setting descriptions. Differential Revision: https://reviews.llvm.org/D148679
2023-04-17PECOFF: consume errors properlySaleem Abdulrasool1-12/+22
We would not ensure that the error is consumed in the case that logging is disabled. Ensure that we properly drop the error on the floor or we would re-trigger the checked failure. Differential Revision: https://reviews.llvm.org/D147669 Reviewed By: sgraenitz
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott1-1/+1
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata2-3/+3
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 Hirata2-0/+2
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-20[Support] Move TargetParsers to new componentArchibald Elliott1-0/+1
This is a fairly large changeset, but it can be broken into a few pieces: - `llvm/Support/*TargetParser*` are all moved from the LLVM Support component into a new LLVM Component called "TargetParser". This potentially enables using tablegen to maintain this information, as is shown in https://reviews.llvm.org/D137517. This cannot currently be done, as llvm-tblgen relies on LLVM's Support component. - This also moves two files from Support which use and depend on information in the TargetParser: - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting the current Host machine for info about it, primarily to support getting the host triple, but also for `-mcpu=native` support in e.g. Clang. This is fairly tightly intertwined with the information in `X86TargetParser.h`, so keeping them in the same component makes sense. - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains the target triple parser and representation. This is very intertwined with the Arm target parser, because the arm architecture version appears in canonical triples on arm platforms. - I moved the relevant unittests to their own directory. And so, we end up with a single component that has all the information about the following, which to me seems like a unified component: - Triples that LLVM Knows about - Architecture names and CPUs that LLVM knows about - CPU detection logic for LLVM Given this, I have also moved `RISCVISAInfo.h` into this component, as it seems to me to be part of that same set of functionality. If you get link errors in your components after this patch, you likely need to add TargetParser into LLVM_LINK_COMPONENTS in CMake. Differential Revision: https://reviews.llvm.org/D137838
2022-12-04[lldb] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to 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-10-13[lldb] Place PlatformQemu Properties into anonymous namespacePavel Labath1-2/+2
It's fine right now, but will break as soon as someone else declares a PluginProperties class in the same way. Also tighten up the scope of the anonymous namespaces surrounding the other PluginProperties classes.
2022-09-28[lldb][COFF] Map symbols without base+complex type as 'Data' typeAlvin Wong1-0/+7
Both LLD and GNU ld write global/static variables to the COFF symbol table with `IMAGE_SYM_TYPE_NULL` and `IMAGE_SYM_DTYPE_NULL` type. Map these symbols as 'Data' type in the symtab to allow these symbols to be used in expressions and printable. Reviewed By: labath, DavidSpickett Differential Revision: https://reviews.llvm.org/D134585
2022-09-28[lldb][COFF] Add note to forwarder export symbols in symtabAlvin Wong1-3/+24
Forwarder exports do not point to a real function or variable. Instead they point to a string describing which DLL and symbol to forward to. Any imports which uses them will be redirected by the loader transparently. These symbols do not have much use in LLDB, but keep them just in case someone find it useful. Also set a synthesized name with the forwarder string for informational purpose. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D134518
2022-09-28[lldb][COFF] Load absolute symbols from COFF symbol tableAlvin Wong1-0/+3
Reviewed By: labath Differential Revision: https://reviews.llvm.org/D134517