Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dwarfGen.h « dwarf « debugInfo « ObjWriter « Native « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2fd78a5c682f8addeebc7eef0636a88e55e08ee6 (plain)
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
103
104
105
106
//===---- dwarfGen.h --------------------------------------------*- C++ -*-===//
//
// dwarf generator is used to generate dwarf debuginfo.
//
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
//===----------------------------------------------------------------------===//

#pragma once

#include "llvm/MC/MCObjectStreamer.h"

#include "dwarfTypeBuilder.h"
#include "jitDebugInfo.h"

#include <vector>

class VarInfo : public DwarfInfo
{
public:
  VarInfo(const DebugVarInfo &Info, bool IsThis);

  bool IsDebugLocNeeded() const { return DebugInfo.Ranges.size() > 1; }

  void DumpLocsIfNeeded(MCObjectStreamer *Streamer, MCSection *LocSection, const MCExpr *SymExpr);

  uint64_t GetStartOffset() const { return StartOffset; }

  uint64_t GetEndOffset() const { return EndOffset; }

  bool IsParam() const { return DebugInfo.IsParam; }

protected:
  void DumpStrings(MCObjectStreamer *Streamer) override;
  void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override;

private:
  DebugVarInfo DebugInfo;
  MCSymbol *LocSymbol;
  bool IsThis;
  uint64_t StartOffset;
  uint64_t EndOffset;
};

class SubprogramInfo : public DwarfInfo
{
public:
  using DwarfInfo::Dump;

  SubprogramInfo(const char *Name,
                 int Size,
                 DwarfMemberFunctionIdTypeInfo *MethodTypeInfo,
                 const std::vector<DebugVarInfo> &DebugVarInfos,
                 const std::vector<DebugEHClauseInfo> &DebugEHClauseInfos);

  void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer,
      MCSection *TypeSection, MCSection *StrSection, MCSection *LocSection);

protected:
  void DumpStrings(MCObjectStreamer *Streamer) override {}
  void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override;

private:
  void DumpDebugLoc(MCObjectStreamer *Streamer, MCSection *LocSection);
  void DumpVars(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer,
      MCSection *TypeSection, MCSection *StrSection);
  void DumpEHClauses(MCObjectStreamer *Streamer, MCSection *TypeSection);

  std::string Name;
  int Size;
  DwarfMemberFunctionIdTypeInfo *MethodTypeInfo;
  std::vector<DebugEHClauseInfo> DebugEHClauseInfos;
  std::vector<VarInfo> VarInfos;
};

class DwarfGen
{
public:
  DwarfGen() : Streamer(nullptr),
               TypeBuilder(nullptr),
               InfoStart(nullptr),
               InfoEnd(nullptr) {}

  void SetTypeBuilder(UserDefinedDwarfTypesBuilder *TypeBuilder);
  void EmitCompileUnit();
  void EmitSubprogramInfo(const char *FunctionName,
                          int FunctionSize,
                          unsigned MethodTypeIndex,
                          const std::vector<DebugVarInfo> &VarsInfo,
                          const std::vector<DebugEHClauseInfo> &DebugEHClauseInfos);

  void EmitAbbrev();
  void EmitAranges();
  void Finish();

private:
  MCObjectStreamer *Streamer;
  UserDefinedDwarfTypesBuilder *TypeBuilder;

  MCSymbol *InfoStart;
  MCSymbol *InfoEnd;

  std::vector<SubprogramInfo> Subprograms;
};