LLVM 24.0.0git
DwarfTransformer.h
Go to the documentation of this file.
1//===- DwarfTransformer.h ---------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
10#define LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
11
12#include "llvm/ADT/StringRef.h"
16#include "llvm/Support/Error.h"
17
18namespace llvm {
19
20namespace gsym {
21
22struct CUInfo;
23struct FunctionInfo;
24class GsymCreator;
26
27/// A class that transforms the DWARF in a DWARFContext into GSYM information
28/// by populating the GsymCreator object that it is constructed with. This
29/// class supports converting all DW_TAG_subprogram DIEs into
30/// gsym::FunctionInfo objects that includes line table information and inline
31/// function information. Creating a separate class to transform this data
32/// allows this class to be unit tested.
34public:
35 /// Create a DWARF transformer.
36 ///
37 /// \param D The DWARF to use when converting to GSYM.
38 ///
39 /// \param G The GSYM creator to populate with the function information
40 /// from the debug info.
41 ///
42 /// \param LDCS Flag to indicate whether we should load the call site
43 /// information from DWARF `DW_TAG_call_site` entries
44 ///
45 /// \param MachO Flag to indicate if the object file is mach-o (Apple's
46 /// executable format). Apple has some compile unit attributes that look like
47 /// split DWARF, but they aren't and they can cause warnins to be emitted
48 /// about missing DWO files.
50 bool MachO = false)
51 : DICtx(D), Gsym(G), LoadDwarfCallSites(LDCS), IsMachO(MachO) {}
52
53 /// Extract the DWARF from the supplied object file and convert it into the
54 /// Gsym format in the GsymCreator object that is passed in. Returns an
55 /// error if something fatal is encountered.
56 ///
57 /// \param NumThreads The number of threads that the conversion process can
58 /// use.
59 ///
60 /// \param OS The stream to log warnings and non fatal issues to. If NULL
61 /// then don't log.
62 ///
63 /// \returns An error indicating any fatal issues that happen when parsing
64 /// the DWARF, or Error::success() if all goes well.
66
68
69private:
70 /// Handle any DIE (debug info entry) from the DWARF.
71 ///
72 /// This function will find all DW_TAG_subprogram DIEs that convert them into
73 /// GSYM FuntionInfo objects and add them to the GsymCreator supplied during
74 /// construction. The DIE and all its children will be recursively parsed
75 /// with calls to this function.
76 ///
77 /// \param Strm The thread specific log stream for any non fatal errors and
78 /// warnings. Once a thread has finished parsing an entire compile unit, all
79 /// information in this temporary stream will be forwarded to the member
80 /// variable log. This keeps logging thread safe. If the value is NULL, then
81 /// don't log.
82 ///
83 /// \param CUI The compile unit specific information that contains the DWARF
84 /// line table, cached file list, and other compile unit specific
85 /// information.
86 ///
87 /// \param Die The DWARF debug info entry to parse.
88 void handleDie(OutputAggregator &Strm, CUInfo &CUI, DWARFDie Die);
89
90 /// Parse call site information from DWARF
91 ///
92 /// \param CUI The compile unit info for the current CU.
93 /// \param Die The DWARFDie for the function.
94 /// \param FI The FunctionInfo for the function being populated.
95 void parseCallSiteInfoFromDwarf(CUInfo &CUI, DWARFDie Die, FunctionInfo &FI);
96
97 DWARFContext &DICtx;
98 GsymCreator &Gsym;
99 bool LoadDwarfCallSites;
100 bool IsMachO;
101};
102
103} // namespace gsym
104} // namespace llvm
105
106#endif // LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_ABI
Definition Compiler.h:211
#define G(x, y, z)
Definition MD5.cpp:55
ppc ctr loops verify
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition DWARFDie.h:43
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM_ABI llvm::Error convert(uint32_t NumThreads, OutputAggregator &OS)
Extract the DWARF from the supplied object file and convert it into the Gsym format in the GsymCreato...
DwarfTransformer(DWARFContext &D, GsymCreator &G, bool LDCS=false, bool MachO=false)
Create a DWARF transformer.
GsymCreator is used to emit GSYM data to a stand alone file or section within a file.
This is an optimization pass for GlobalISel generic memory operations.
Function information in GSYM files encodes information for one contiguous address range.