blob: 3b091c5919d6983667b306ac443a0e84f60b06dc (
plain) (
blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//===- DwarfTransformer.h ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
#define LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/GSYM/Range.h"
#include "llvm/Support/Error.h"
namespace llvm {
class raw_ostream;
namespace gsym {
struct CUInfo;
struct FunctionInfo;
class GsymCreator;
/// A class that transforms the DWARF in a DWARFContext into GSYM information
/// by populating the GsymCreator object that it is constructed with. This
/// class supports converting all DW_TAG_subprogram DIEs into
/// gsym::FunctionInfo objects that includes line table information and inline
/// function information. Creating a separate class to transform this data
/// allows this class to be unit tested.
class DwarfTransformer {
public:
/// Create a DWARF transformer.
///
/// \param D The DWARF to use when converting to GSYM.
///
/// \param OS The stream to log warnings and non fatal issues to.
///
/// \param G The GSYM creator to populate with the function information
/// from the debug info.
DwarfTransformer(DWARFContext &D, raw_ostream &OS, GsymCreator &G) :
DICtx(D), Log(OS), Gsym(G) {}
/// Extract the DWARF from the supplied object file and convert it into the
/// Gsym format in the GsymCreator object that is passed in. Returns an
/// error if something fatal is encountered.
///
/// \returns An error indicating any fatal issues that happen when parsing
/// the DWARF, or Error::success() if all goes well.
llvm::Error convert(uint32_t NumThreads);
llvm::Error verify(StringRef GsymPath);
private:
/// Parse the DWARF in the object file and convert it into the GsymCreator.
Error parse();
/// Handle any DIE (debug info entry) from the DWARF.
///
/// This function will find all DW_TAG_subprogram DIEs that convert them into
/// GSYM FuntionInfo objects and add them to the GsymCreator supplied during
/// construction. The DIE and all its children will be recursively parsed
/// with calls to this function.
///
/// \param Strm The thread specific log stream for any non fatal errors and
/// warnings. Once a thread has finished parsing an entire compile unit, all
/// information in this temporary stream will be forwarded to the member
/// variable log. This keeps logging thread safe.
///
/// \param CUI The compile unit specific information that contains the DWARF
/// line table, cached file list, and other compile unit specific
/// information.
///
/// \param Die The DWARF debug info entry to parse.
void handleDie(raw_ostream &Strm, CUInfo &CUI, DWARFDie Die);
DWARFContext &DICtx;
raw_ostream &Log;
GsymCreator &Gsym;
friend class DwarfTransformerTest;
};
} // namespace gsym
} // namespace llvm
#endif // #ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
|