aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-11-17[DebugInfo] Remove unused includes (NFC) (#116551)Kazu Hirata1-2/+0
Identified with misc-include-cleaner.
2023-11-06[DebugInfo] Use StringRef::starts_with/ends_with instead of ↵Simon Pilgrim1-1/+1
startswith/endswith. NFC. startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2023-10-10Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata1-3/+3
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces llvm::support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-06-25[llvm] Add missing StringExtras.h includesElliot Goodrich1-0/+1
In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header.
2022-02-23Cleanup llvm/DebugInfo/PDB headersserge-sans-paille1-9/+17
accumulated preprocessed size: before: 1065515095 after: 1065629059 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D120195
2021-03-25[NFC] Reordering parameters in getFile and getFileOrSTDINAbhina Sreeskantharajan1-1/+1
In future patches I will be setting the IsText parameter frequently so I will refactor the args to be in the following order. I have removed the FileSize parameter because it is never used. ``` static ErrorOr<std::unique_ptr<MemoryBuffer>> getFile(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true, bool IsVolatile = false); static ErrorOr<std::unique_ptr<MemoryBuffer>> getFileOrSTDIN(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true); static ErrorOr<std::unique_ptr<MB>> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile); static ErrorOr<std::unique_ptr<WritableMemoryBuffer>> getFile(const Twine &Filename, bool IsVolatile = false); ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D99182
2020-11-17[llvm-symbolizer] Add inline stack traces for Windows.Amy Huang1-1/+76
This adds inline stack frames for symbolizing on Windows. Differential Revision: https://reviews.llvm.org/D88988
2020-07-21[PDB][NativeSession] Clean up some things in NativeSession.Amy Huang1-2/+2
-Use the actual sect/offset to keep track of symbols in the cache so they don't get created multiple times with different addresses. -Remove getSymTag from PDBFunctionSymbol/PDBPublicSymbol because it's already implemented in the base class -Merge the symbolizer test files for DIA and native, since the tests are the same. -Implement getCompilandId for NativeLineNumber Reviewed By: amccarth Differential Revision: https://reviews.llvm.org/D84208
2020-06-15[NativeSession] Implement findLineNumbersByAddress in NativeSession,Amy Huang1-5/+11
which takes an address and a length and returns all lines within that address range.
2020-06-11Re-land "Migrate the rest of COFFObjectFile to Error"Reid Kleckner1-2/+2
This reverts commit 101fbc01382edd89ea7b671104c68b30b2446cc0. Remove leftover debugging attribute. Update LLDB as well, which was missed before.
2020-06-05Revert "Migrate the rest of COFFObjectFile to Error"Nico Weber1-2/+2
This reverts commit b5289656b865d2a73cf90819e20a96fb8414ab0b. __attribute__((optnone)) doesn't build with msvc, see http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16326
2020-06-05Migrate the rest of COFFObjectFile to ErrorReid Kleckner1-2/+2
2020-05-13[NativeSession] Implement NativeSession::findSymbolByAddress.Amy Huang1-10/+38
Summary: This implements searching for function symbols and public symbols by address. More specifically, -Implements NativeSession::findSymbolByAddress for function symbols and public symbols. I think data symbols are also searched for, but isn't implemented in this patch. -Adds classes for NativeFunctionSymbol and NativePublicSymbol -Adds a '-use-native-pdb-reader' option to llvm-symbolizer, for testing purposes. Reviewers: rnk, amccarth, labath Subscribers: mgorny, hiraditya, MaskRay, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79269
2020-04-21Reland "Implement some functions in NativeSession." with fixes so thatAmy Huang1-7/+134
the tests pass on Linux. Summary: This change implements readFromExe, and calculating VA and RVA, which are some of the functionalities that will be used for native PDB reading for llvm symbolizer. bug: https://bugs.llvm.org/show_bug.cgi?id=41795
2020-04-21Revert "Implement some NativeSession functions" along with someAmy Huang1-130/+7
followup fixes. This reverts commits a6d8a055e92eb4853805d1ad1be0b1a6523524ef 4927ae085807731eb4052e0a682443fe9399b512 1e1f5eb7c978da3b062daaf3c32c459704e65a55
2020-04-21[NativeSession] Fix unchecked Expected typeAmy Huang1-1/+4
(followup to https://reviews.llvm.org/D78128)
2020-04-21Fix build. NFC.Michael Liao1-1/+1
2020-04-21[PDB] Change llvm/object/COFF.h to llvm/Object/COFF.h after D78128Fangrui Song1-1/+1
2020-04-21Implement some functions in NativeSession.Amy Huang1-7/+127
Summary: This change implements readFromExe, and calculating VA and RVA, which are some of the functionalities that will be used for native PDB reading for llvm symbolizer. bug: https://bugs.llvm.org/show_bug.cgi?id=41795 Reviewers: hans, amccarth, rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78128
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-5/+5
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-07-16Teach `llvm-pdbutil pretty -native` about `-injected-sources`Nico Weber1-1/+12
`pretty -native -injected-sources -injected-source-content` works with this patch, and produces identical output to the dia version. Differential Revision: https://reviews.llvm.org/D64428 llvm-svn: 366236
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-10-23Revert "Revert "[PDB] Extend IPDBSession's interface to retrieve frame data""Aleksandr Urakov1-0/+5
This reverts commit 466ce67d6ec444962e5cc0136243c16a453190c0. llvm-svn: 345010
2018-10-22Revert "[PDB] Extend IPDBSession's interface to retrieve frame data"Aleksandr Urakov1-5/+0
This reverts commit b5c7e2f9a4dbb34e3667c4bb4972735eadd3247a. llvm-svn: 344909
2018-10-22[PDB] Extend IPDBSession's interface to retrieve frame dataAleksandr Urakov1-0/+5
Summary: This patch just extends the `IPDBSession` interface to allow retrieving of frame data through it, and adds an implementation over DIA. It is needed for an implementation (for now with DIA) of the conversion from FPO programs to DWARF expressions mentioned in D53086. Reviewers: zturner, asmith, rnk Reviewed By: asmith Subscribers: mgorny, aprantl, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D53324 llvm-svn: 344886
2018-09-10[PDB] Change uint32_t to SymIndex wherever it makes sense.Zachary Turner1-1/+1
Although it's just a typedef, it helps for readability. NFC. llvm-svn: 341863
2018-09-07[PDB] Rename some files in the native reader.Zachary Turner1-2/+2
By calling these NativeType<foo>.cpp, they will all be sorted together, and it also distinguishes the types from the symbols. llvm-svn: 341609
2018-09-07[PDB] Create a SymbolCache class.Zachary Turner1-96/+21
Part of the responsibility of the native PDB reader is to cache symbols the first time they are accessed, so they can then be looked up by an ID. Furthermore, we need to resolve type indices to records that we vend to the user, and other things. Previously this code was all thrown together a bit haphazardly in the native session class, but it makes sense to collect all of this into a single class whose sole responsibility is to manage the collection of known symbols. llvm-svn: 341608
2018-09-05[PDB] Refactor the PDB symbol classes to fix a reuse bug.Zachary Turner1-20/+15
The way DIA SDK works is that when you request a symbol, it gets assigned an internal identifier that is unique for the life of the session. You can then use this identifier to get back the same symbol, with all of the same internal state that it had before, even if you "destroyed" the original copy of the object you had. This didn't work properly in our native implementation, and if you destroyed an object for a particular symbol, then requested the same symbol again, it would get assigned a new ID and you'd get a fresh copy of the object. In order to fix this some refactoring had to happen to properly reuse cached objects. Some unittests are added to verify that symbol reuse is taking place, making use of the new unittest input feature. llvm-svn: 341503
2018-08-31[DebugInfo] Common behavior for error typesAlexandre Ganea1-1/+0
Following D50807, and heading towards D50664, this intermediary change does the following: 1. Upgrade all custom Error types in llvm/trunk/lib/DebugInfo/ to use the new StringError behavior (D50807). 2. Implement std::is_error_code_enum and make_error_code() for DebugInfo error enumerations. 3. Rename GenericError -> PDBError (the file will be renamed in a subsequent commit) 4. Update custom error messages to follow the same formatting: (\w\s*)+\. 5. Keep generic "file not found" (ENOENT) errors as they are in PDB code. Previously, there used to be a custom enumeration for that purpose. 6. Remove a few extraneous LF in log() implementations. Printing LF is a responsability at a higher level, not at the error level. Differential Revision: https://reviews.llvm.org/D51499 llvm-svn: 341228
2018-04-10[DebugInfoPDB] Add DIA implementations of findSymbolByRVA and findSymbolByAddrAaron Smith1-0/+11
llvm-svn: 329724
2018-03-26[DebugInfoPDB] Add DIA implementation of findLineNumbersByRVAAaron Smith1-0/+5
This method is used to find line numbers for PDBSymbolData that have an invalid virtual address. llvm-svn: 328586
2018-03-26[DebugInfoPDB] Add DIA implementation of addressForVA and addressForRVAAaron Smith1-0/+10
These are used in finding line numbers for PDBSymbolData llvm-svn: 328585
2018-03-22[DIA] Add IPDBSectionContrib interfaces and DIA implementationAaron Smith1-0/+5
To resolve symbol context at a particular address, we need to determine the compiland for the address. We are able to determine the parent compiland of PDBSymbolFunc, PDBSymbolTypeUDT, PDBSymbolTypeEnum symbols indirectly through line information. However no such information is availabile for PDBSymbolData, i.e. variables. The Section Contribution table from PDBs has information about each compiland's contribution to sections by address. For example, a piece of a contribution looks like, VA RelativeVA Sect No. Offset Length Compiland 14000087B0 000087B0 0001 000077B0 000000BB exe_main.obj So given an address, it's possible to determine its compiland with this information. llvm-svn: 328178
2018-03-15[DebugInfo] Add a new method IPDBSession::findLineNumbersBySectOffsetAaron Smith1-0/+6
Summary: Some PDB symbols do not have a valid VA or RVA but have Addr by Section and Offset. For example, a variable in thread-local storage has the following properties: get_addressOffset: 0 get_addressSection: 5 get_lexicalParentId: 2 get_name: g_tls get_symIndexId: 12 get_typeId: 4 get_dataKind: 6 get_symTag: 7 get_locationType: 2 This change provides a new method to locate line numbers by Section and Offset from those symbols. Reviewers: zturner, rnk, llvm-commits Subscribers: asmith, JDevlieghere Differential Revision: https://reviews.llvm.org/D44407 llvm-svn: 327601
2018-03-13[PDB] Support dumping injected sources via the DIA reader.Zachary Turner1-0/+5
Injected sources are basically a way to add actual source file content to your PDB. Presumably you could use this for shipping your source code with your debug information, but in practice I can only find this being used for embedding natvis files inside of PDBs. In order to effectively test LLVM's natvis file injection, we need a way to dump the injected sources of a PDB in a way that is authoritative (i.e. based on Microsoft's understanding of the PDB format, and not LLVM's). To this end, I've added support for dumping injected sources via DIA. I made a PDB file that used the /natvis option to generate a test case. Differential Revision: https://reviews.llvm.org/D44405 llvm-svn: 327428
2018-02-23[PDB] Check the result of setLoadAddress()Aaron Smith1-1/+1
Summary: Change setLoadAddress() to return true or false on failure. Reviewers: zturner, llvm-commits Reviewed By: zturner Differential Revision: https://reviews.llvm.org/D43638 llvm-svn: 325843
2017-11-16[DebugInfo/PDB] Adding getUndecoratedNameEx and IPDB interfaces for ↵Aaron Smith1-0/+4
IDiaEnumTables and IDiaTable. Initial changes to support debugging PE/COFF files with LLDB on Windows through DIA SDK. There is another set of changes required on the LLDB side before this does anything. Differential Revision: https://reviews.llvm.org/D39517 llvm-svn: 318403
2017-10-20COFF: Add type server pdb files to linkrepro tar file.Peter Collingbourne1-8/+2
Differential Revision: https://reviews.llvm.org/D38977 llvm-svn: 316233
2017-08-04Enable llvm-pdbutil to list enumerations using native PDB readerAdrian McCarthy1-3/+38
This extends the native reader to enable llvm-pdbutil to list the enums in a PDB and it includes a simple test. It does not yet list the values in the enumerations, which requires an actual implementation of NativeEnumSymbol::FindChildren. To exercise this code, use a command like: llvm-pdbutil pretty -native -enums foo.pdb Differential Revision: https://reviews.llvm.org/D35738 llvm-svn: 310144
2017-07-12Fix non-Windows build after PDB native builtin type changeReid Kleckner1-5/+7
Some C++14 features slipped in along with an extra member qualification. llvm-svn: 307835
2017-07-12[PDB] Enable NativeSession to create symbols for built-in types on demandAdrian McCarthy1-2/+56
Summary: There is a reserved range of type indexes for built-in types (like integers). This will create a symbol for a built-in type if the caller askes for one by type index. This is also plumbing for being able to recall symbols by type index in general, but user-defined types will come in subsequent patches. Reviewers: rnk, zturner Subscribers: mgorny, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D35163 llvm-svn: 307834
2017-06-28Introduce symbol cache to PDB NativeSessionAdrian McCarthy1-2/+19
Instead of creating symbols directly in the findChildren methods of the native symbol implementations, they will rely on the NativeSession to act as a factory for these types. This lets NativeSession cache the NativeRawSymbols in its new symbol cache and makes that cache the source of unique IDs for the symbols. Right now, this affects only NativeCompilandSymbols. There's no external change yet, so I think the existing tests are still sufficient. Coming soon are patches to extend this to built-in types and enums. llvm-svn: 306610
2017-06-22Add IDs and clone methods to NativeRawSymbolAdrian McCarthy1-1/+1
All NativeRawSymbols will have a unique symbol ID (retrievable via getSymIndexId). For now, these are initialized to 0, but soon the NativeSession will be responsible for creating the raw symbols, and it will assign unique IDs. The symbol cache in the NativeSession will also require the ability to clone raw symbols, so I've provided implementations for that as well. llvm-svn: 306042
2017-06-22Make IPDBSession::getGlobalScope a non-const methodAdrian McCarthy1-4/+3
There doesn't seem to be a compelling reason why this method should be const other than it was possible with the DIA implementation. The native session is going to act as a symbol factory and cache. This could be acheived with mutable (and the existing const_cast), but it seems cleaner to accept that this method affects the state of the session. This change eliminates an existing const_cast. llvm-svn: 306041
2017-04-12[llvm-pdbdump] More advanced class definition dumping.Zachary Turner1-2/+3
Previously the dumping of class definitions was very primitive, and it made it hard to do more than the most trivial of output formats when dumping. As such, we would only dump one line for each field, and then dump non-layout items like nested types and enums. With this patch, we do a complete analysis of the object hierarchy including aggregate types, bases, virtual bases, vftable analysis, etc. The only immediately visible effects of this are that a) we can now dump a line for the vfptr where before we would treat that as padding, and b) we now don't treat virtual bases that come at the end of a class as padding since we have a more detailed analysis of the class's storage usage. In subsequent patches, we should be able to use this analysis to display a complete graphical view of a class's layout including recursing arbitrarily deep into an object's base class / aggregate member hierarchy. llvm-svn: 300133
2017-03-29Re-land: "Make NativeExeSymbol a concrete subclass of NativeRawSymbol [PDB]"Adrian McCarthy1-2/+2
This should work on all platforms now that r299006 has landed. Tested locally on Windows and Linux. This moves exe symbol-specific method implementations out of NativeRawSymbol into a concrete subclass. Also adds implementations for hasCTypes and hasPrivateSymbols and a simple test to ensure the native reader can access the summary information for the executable from the PDB. Original Differential Revision: https://reviews.llvm.org/D31059 llvm-svn: 299019
2017-03-23Somehow this still breaks because of ANSI color codes in test output on Linux.Adrian McCarthy1-2/+2
Reverting until I can figure out the root cause. Revert "Re-land: Make NativeExeSymbol a concrete subclass of NativeRawSymbol [PDB]" This reverts commit f461a70cc376f0f91c8b4917be79479cc86330a5. llvm-svn: 298626
2017-03-23Re-land: Make NativeExeSymbol a concrete subclass of NativeRawSymbol [PDB]Adrian McCarthy1-2/+2
The new test should pass on all platforms now that llvm-pdbdump has the `-color-output` option. This moves exe symbol-specific method implementations out of NativeRawSymbol into a concrete subclass. Also adds implementations for hasCTypes and hasPrivateSymbols and a simple test to ensure the native reader can access the summary information for the executable from the PDB. Original Differential Revision: https://reviews.llvm.org/D31059 llvm-svn: 298623
2017-03-17Revert "Make NativeExeSymbol a concrete subclass of NativeRawSymbol [PDB]"Zachary Turner1-2/+2
For some reason this is causing ANSI color codes to be printed even when run through FileCheck. llvm-svn: 298026