1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "trace_model.h"
#include <cstdint>
#include <memory>
#include <string>
namespace zen::trace_detail {
enum class SymbolBackend : uint8_t
{
Off,
Auto, // Probe PATH and pick the best available backend for the platform
Pdb, // Windows only: RawPdb — fast, reads PDB files directly
DbgHelp, // Windows only: DbgHelp API — supports symbol servers and _NT_SYMBOL_PATH
LlvmSymbolizer, // Any platform: shells out to `llvm-symbolizer`, resolves dSYM (Mac) / DWARF (Linux) / PDB (Windows)
Atos // macOS only: shells out to `atos`, resolves Mach-O binaries and adjacent .dSYM bundles
};
// Resolves virtual addresses captured in a trace to function names.
// Use CreateSymbolResolver() to obtain a concrete implementation.
class SymbolResolver
{
public:
virtual ~SymbolResolver() = default;
// Load symbols for a module.
virtual void LoadModule(const ModuleInfo& Module) = 0;
// Resolve an absolute virtual address to "FunctionName + 0xNN" (or just
// "FunctionName" when the displacement is zero). Returns an empty string
// when the address cannot be resolved.
virtual std::string Resolve(uint64_t Address) const = 0;
};
std::unique_ptr<SymbolResolver> CreateSymbolResolver(SymbolBackend Backend);
// Parse a string ("auto", "pdb", "dbghelp", "llvm", "llvm-symbolizer",
// "atos", "off") into a SymbolBackend enum. Returns Off on unrecognised input.
SymbolBackend ParseSymbolBackend(std::string_view Name);
} // namespace zen::trace_detail
|