aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-20 21:50:41 +0200
committerGitHub Enterprise <[email protected]>2026-04-20 21:50:41 +0200
commit2dfb5da16b97a6c12e01977af5b5188522178a4e (patch)
tree428aa0aa8e6079c64438931e0fd4f828c613c94d /thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h
parentAdd CompactString utility type (#990) (diff)
downloadarchived-zen-2dfb5da16b97a6c12e01977af5b5188522178a4e.tar.xz
archived-zen-2dfb5da16b97a6c12e01977af5b5188522178a4e.zip
zen trace analysis support (#945)
Integrates the **tourist** trace analysis library and builds a full `zen trace` command suite for working with Unreal Engine `.utrace` files. ### Trace analysis library (`thirdparty/tourist/`) - Adds the tourist library as a third-party dependency with three modules: **foundation** (platform primitives, memory, scheduling), **trace** (UE Trace protocol decoding), and **analysis** (event dispatching and analyzer framework). - Cross-platform support for Windows, Linux, and macOS. ### `zen trace` CLI commands (`src/zen/cmds/`, `src/zen/trace/`) - **`zen trace analyze`** — Summarize a `.utrace` file: session metadata, thread inventory, command line + build configuration, CPU profiling scopes, timing, event rates, log messages, and (with symbols) memory allocation metrics including live-allocs dumps, callstack-keyed aggregation, and allocation churn. Optional HTML output for memory reports. - **`zen trace inspect`** — Dump the event schema (declared types, fields, sizes) from a trace file. - **`zen trace trim`** — Extract a time-window from a trace into a new `.utrace` file. - **`zen trace serve`** — Launch a local HTTP server hosting an interactive trace viewer; opens in the default browser. ### Symbolication (`src/zen/trace/symbol_resolver.*`, `thirdparty/raw_pdb/`) - Pluggable resolver with multiple backends: `pdb` (in-tree raw_pdb), `dbghelp` (Windows), `llvm-symbolizer` (all platforms), `atos` (macOS). An `auto` backend picks the best available tool per platform. - Microsoft Symbol Server support: downloads PDBs on demand using a redirect-aware HTTP client. - Local PDB cache keyed by image GUID preserves symbols across binary recompilation. - Callstack trimming heuristic strips UE internal noise from reports. - Binary analysis cache (`.ucache_z`) avoids re-resolving the same trace. ### Interactive trace viewer (`src/zen/frontend/html/`, `src/zen/trace/trace_viewer_service.*`) - Timeline: scope-level detail, horizontal zoom/pan, vertical scrolling, viewport-driven loading with pre-computed LOD for responsive navigation of large traces. - Thread grouping (collapsible sidebar sections) synthesized from name suffixes, natural sort order, visual distinction between lane threads and OS threads. - Bookmark and region annotations; region categories with per-category toggles; bookmark marker toggle in the toolbar. - Filterable Logs tab showing captured `UE_LOG` output. - Stats tab with per-scope aggregate statistics. - Memory tab with interactive allocation analysis and an allocation size histogram. - CsvProfiler event parsing and chart UI. ### Other in-branch supporting changes - **Cross-platform browser launcher** (`browser_launcher.{h,cpp}`) used by `trace serve`. - **`ReciprocalU64`** fast 64-bit integer division (zencore/intmath) for trace analyzers. - **`parallelsort`** cross-platform parallel sort helper (zenutil). - Frontend zip build rule so the viewer's HTML assets are bundled into `zen.exe`. - `/Zo` flag for better optimized debug info on Windows release builds. - `trace-tests.cpp` in the `zen-test` harness (harness itself landed on main via #985).
Diffstat (limited to 'thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h')
-rw-r--r--thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h b/thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h
new file mode 100644
index 000000000..4fef0fe3b
--- /dev/null
+++ b/thirdparty/raw_pdb/src/PDB_ModuleInfoStream.h
@@ -0,0 +1,104 @@
+// 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_ArrayView.h"
+#include "PDB_CoalescedMSFStream.h"
+#include "PDB_ModuleSymbolStream.h"
+#include "PDB_ModuleLineStream.h"
+
+namespace PDB
+{
+ class PDB_NO_DISCARD DirectMSFStream;
+
+ class PDB_NO_DISCARD ModuleInfoStream
+ {
+ public:
+ class PDB_NO_DISCARD Module
+ {
+ public:
+ Module(void) PDB_NO_EXCEPT;
+ explicit Module(const DBI::ModuleInfo* info, const char* name, size_t nameLength, const char* objectName, size_t objectNameLength) PDB_NO_EXCEPT;
+
+ PDB_DEFAULT_MOVE(Module);
+
+ // Returns whether the module has a symbol stream.
+ PDB_NO_DISCARD bool HasSymbolStream(void) const PDB_NO_EXCEPT;
+
+ // Returns whether the module has a line stream.
+ PDB_NO_DISCARD bool HasLineStream(void) const PDB_NO_EXCEPT;
+
+ // Creates a symbol stream for the module.
+ PDB_NO_DISCARD ModuleSymbolStream CreateSymbolStream(const RawFile& file) const PDB_NO_EXCEPT;
+
+ // Create a line stream for the module
+ PDB_NO_DISCARD ModuleLineStream CreateLineStream(const RawFile& file) const PDB_NO_EXCEPT;
+
+
+ // Returns the PDB module info.
+ PDB_NO_DISCARD inline const DBI::ModuleInfo* GetInfo(void) const PDB_NO_EXCEPT
+ {
+ return m_info;
+ }
+
+ // Returns the name of the module.
+ PDB_NO_DISCARD inline ArrayView<char> GetName(void) const PDB_NO_EXCEPT
+ {
+ return ArrayView<char>(m_name, m_nameLength);
+ }
+
+ // Returns the name of the object file of the module.
+ PDB_NO_DISCARD inline ArrayView<char> GetObjectName(void) const PDB_NO_EXCEPT
+ {
+ return ArrayView<char>(m_objectName, m_objectNameLength);
+ }
+
+ private:
+ // the module info is stored in variable-length arrays inside the stream, so rather than store an array directly,
+ // we need to store pointers to the individual data items inside the stream.
+ const DBI::ModuleInfo* m_info;
+
+ // the module name, e.g. the path to an object file or import library such as "Import:kernel32.dll"
+ const char* m_name;
+ size_t m_nameLength;
+
+ // the name of the object file. either the same as the module name, or the path to the archive that contained the module
+ const char* m_objectName;
+ size_t m_objectNameLength;
+
+ PDB_DISABLE_COPY(Module);
+ };
+
+ ModuleInfoStream(void) PDB_NO_EXCEPT;
+ ModuleInfoStream(ModuleInfoStream&& other) PDB_NO_EXCEPT;
+ ModuleInfoStream& operator=(ModuleInfoStream&& other) PDB_NO_EXCEPT;
+
+ explicit ModuleInfoStream(const DirectMSFStream& directStream, uint32_t size, uint32_t offset) PDB_NO_EXCEPT;
+
+ ~ModuleInfoStream(void) PDB_NO_EXCEPT;
+
+ // Tries to find the linker module corresponding to the linker, i.e. the module named "* Linker *".
+ PDB_NO_DISCARD const Module* FindLinkerModule(void) const PDB_NO_EXCEPT;
+
+ // Returns the module with the given index.
+ PDB_NO_DISCARD inline const Module& GetModule(uint32_t index) const PDB_NO_EXCEPT
+ {
+ return m_modules[index];
+ }
+
+ // Returns a view of all modules in the info stream.
+ PDB_NO_DISCARD inline ArrayView<Module> GetModules(void) const PDB_NO_EXCEPT
+ {
+ return ArrayView<Module>(m_modules, m_moduleCount);
+ }
+
+ private:
+ CoalescedMSFStream m_stream;
+ Module* m_modules;
+ size_t m_moduleCount;
+
+ PDB_DISABLE_COPY(ModuleInfoStream);
+ };
+}