diff options
| author | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
| commit | 0232b991cd7d8e3a2114ea30e4591dd3e7b65c36 (patch) | |
| tree | 94730e7594fd09ae1fa820391ce311f6daf13905 /thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h | |
| parent | Fix forward declaration order for s_GotSigWinch and SigWinchHandler (diff) | |
| parent | trace: declare Region event name fields as AnsiString (#1012) (diff) | |
| download | archived-zen-sb/zen-help.tar.xz archived-zen-sb/zen-help.zip | |
Merge branch 'main' into sb/zen-helpsb/zen-help
- Combine HelpCommand (this branch) with HistoryCommand (main) in zen CLI dispatcher
- Keep filter-aware TuiPickOne rewrite; adopt main's ASCII arrow glyphs in doc comment
Diffstat (limited to 'thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h')
| -rw-r--r-- | thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h b/thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h new file mode 100644 index 000000000..213870824 --- /dev/null +++ b/thirdparty/raw_pdb/src/PDB_ModuleSymbolStream.h @@ -0,0 +1,70 @@ +// Copyright 2011-2022, Molecular Matters GmbH <[email protected]> +// See LICENSE.txt for licensing details (2-clause BSD License: https://opensource.org/licenses/BSD-2-Clause) + +#pragma once + +#include "Foundation/PDB_Macros.h" +#include "Foundation/PDB_BitUtil.h" +#include "PDB_DBITypes.h" +#include "PDB_Util.h" +#include "PDB_CoalescedMSFStream.h" + + +namespace PDB +{ + class RawFile; + + + class PDB_NO_DISCARD ModuleSymbolStream + { + public: + ModuleSymbolStream(void) PDB_NO_EXCEPT; + explicit ModuleSymbolStream(const RawFile& file, uint16_t streamIndex, uint32_t symbolStreamSize) PDB_NO_EXCEPT; + + PDB_DEFAULT_MOVE(ModuleSymbolStream); + + // Returns a record's parent record. + template <typename T> + PDB_NO_DISCARD inline const CodeView::DBI::Record* GetParentRecord(const T& record) const PDB_NO_EXCEPT + { + return m_stream.GetDataAtOffset<const CodeView::DBI::Record>(record.parent); + } + + // Returns a record's end record. + template <typename T> + PDB_NO_DISCARD inline const CodeView::DBI::Record* GetEndRecord(const T& record) const PDB_NO_EXCEPT + { + return m_stream.GetDataAtOffset<const CodeView::DBI::Record>(record.end); + } + + // Finds a record of a certain kind. + PDB_NO_DISCARD const CodeView::DBI::Record* FindRecord(CodeView::DBI::SymbolRecordKind Kind) const PDB_NO_EXCEPT; + + + // Iterates all records in the stream. + template <typename F> + void ForEachSymbol(F&& functor) const PDB_NO_EXCEPT + { + // ignore the stream's 4-byte signature + size_t offset = sizeof(uint32_t); + + // parse the CodeView records + while (offset < m_stream.GetSize()) + { + // https://llvm.org/docs/PDB/CodeViewTypes.html + const CodeView::DBI::Record* record = m_stream.GetDataAtOffset<const CodeView::DBI::Record>(offset); + const uint32_t recordSize = GetCodeViewRecordSize(record); + + functor(record); + + // position the module stream offset at the next record + offset = BitUtil::RoundUpToMultiple<size_t>(offset + sizeof(CodeView::DBI::RecordHeader) + recordSize, 4u); + } + } + + private: + CoalescedMSFStream m_stream; + + PDB_DISABLE_COPY(ModuleSymbolStream); + }; +} |