LLDB  mainline
BreakpadRecords.h
Go to the documentation of this file.
1 //===-- BreakpadRecords.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 LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
11 
12 #include "lldb/Utility/UUID.h"
13 #include "lldb/lldb-types.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/Support/FormatProviders.h"
17 
18 namespace lldb_private {
19 namespace breakpad {
20 
21 class Record {
22 public:
23  enum Kind {
34  };
35 
36  /// Attempt to guess the kind of the record present in the argument without
37  /// doing a full parse. The returned kind will always be correct for valid
38  /// records, but the full parse can still fail in case of corrupted input.
39  static llvm::Optional<Kind> classify(llvm::StringRef Line);
40 
41 protected:
42  Record(Kind K) : TheKind(K) {}
43 
44  ~Record() = default;
45 
46 public:
47  Kind getKind() { return TheKind; }
48 
49 private:
51 };
52 
53 llvm::StringRef toString(Record::Kind K);
54 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Record::Kind K) {
55  OS << toString(K);
56  return OS;
57 }
58 
59 class ModuleRecord : public Record {
60 public:
61  static llvm::Optional<ModuleRecord> parse(llvm::StringRef Line);
62  ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
63  : Record(Module), OS(OS), Arch(Arch), ID(std::move(ID)) {}
64 
65  llvm::Triple::OSType OS;
66  llvm::Triple::ArchType Arch;
68 };
69 
70 inline bool operator==(const ModuleRecord &L, const ModuleRecord &R) {
71  return L.OS == R.OS && L.Arch == R.Arch && L.ID == R.ID;
72 }
73 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ModuleRecord &R);
74 
75 class InfoRecord : public Record {
76 public:
77  static llvm::Optional<InfoRecord> parse(llvm::StringRef Line);
78  InfoRecord(UUID ID) : Record(Info), ID(std::move(ID)) {}
79 
81 };
82 
83 inline bool operator==(const InfoRecord &L, const InfoRecord &R) {
84  return L.ID == R.ID;
85 }
86 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InfoRecord &R);
87 
88 class FileRecord : public Record {
89 public:
90  static llvm::Optional<FileRecord> parse(llvm::StringRef Line);
91  FileRecord(size_t Number, llvm::StringRef Name)
92  : Record(File), Number(Number), Name(Name) {}
93 
94  size_t Number;
95  llvm::StringRef Name;
96 };
97 
98 inline bool operator==(const FileRecord &L, const FileRecord &R) {
99  return L.Number == R.Number && L.Name == R.Name;
100 }
101 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FileRecord &R);
102 
103 class InlineOriginRecord : public Record {
104 public:
105  static llvm::Optional<InlineOriginRecord> parse(llvm::StringRef Line);
106  InlineOriginRecord(size_t Number, llvm::StringRef Name)
108 
109  size_t Number;
110  llvm::StringRef Name;
111 };
112 
113 inline bool operator==(const InlineOriginRecord &L,
114  const InlineOriginRecord &R) {
115  return L.Number == R.Number && L.Name == R.Name;
116 }
117 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
118  const InlineOriginRecord &R);
119 
120 class FuncRecord : public Record {
121 public:
122  static llvm::Optional<FuncRecord> parse(llvm::StringRef Line);
124  lldb::addr_t ParamSize, llvm::StringRef Name)
127 
128  bool Multiple;
132  llvm::StringRef Name;
133 };
134 
135 bool operator==(const FuncRecord &L, const FuncRecord &R);
136 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FuncRecord &R);
137 
138 class InlineRecord : public Record {
139 public:
140  static llvm::Optional<InlineRecord> parse(llvm::StringRef Line);
142  size_t CallSiteFileNum, size_t OriginNum)
145  OriginNum(OriginNum) {}
146 
150  size_t OriginNum;
151  // A vector of address range covered by this inline
152  std::vector<std::pair<lldb::addr_t, lldb::addr_t>> Ranges;
153 };
154 
155 bool operator==(const InlineRecord &L, const InlineRecord &R);
156 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InlineRecord &R);
157 
158 class LineRecord : public Record {
159 public:
160  static llvm::Optional<LineRecord> parse(llvm::StringRef Line);
162  size_t FileNum)
164  FileNum(FileNum) {}
165 
169  size_t FileNum;
170 };
171 
172 bool operator==(const LineRecord &L, const LineRecord &R);
173 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LineRecord &R);
174 
175 class PublicRecord : public Record {
176 public:
177  static llvm::Optional<PublicRecord> parse(llvm::StringRef Line);
179  llvm::StringRef Name)
182 
183  bool Multiple;
186  llvm::StringRef Name;
187 };
188 
189 bool operator==(const PublicRecord &L, const PublicRecord &R);
190 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PublicRecord &R);
191 
192 class StackCFIRecord : public Record {
193 public:
194  static llvm::Optional<StackCFIRecord> parse(llvm::StringRef Line);
195  StackCFIRecord(lldb::addr_t Address, llvm::Optional<lldb::addr_t> Size,
196  llvm::StringRef UnwindRules)
199 
201  llvm::Optional<lldb::addr_t> Size;
202  llvm::StringRef UnwindRules;
203 };
204 
205 bool operator==(const StackCFIRecord &L, const StackCFIRecord &R);
206 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackCFIRecord &R);
207 
208 class StackWinRecord : public Record {
209 public:
210  static llvm::Optional<StackWinRecord> parse(llvm::StringRef Line);
211 
214  lldb::addr_t LocalSize, llvm::StringRef ProgramString)
218 
219  enum class FrameType : uint8_t { FPO = 0, FrameData = 4 };
225  llvm::StringRef ProgramString;
226 };
227 
228 bool operator==(const StackWinRecord &L, const StackWinRecord &R);
229 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackWinRecord &R);
230 
231 } // namespace breakpad
232 } // namespace lldb_private
233 
234 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
lldb_private::breakpad::Record::Line
@ Line
Definition: BreakpadRecords.h:30
lldb_private::breakpad::Record::getKind
Kind getKind()
Definition: BreakpadRecords.h:47
lldb_private::breakpad::StackWinRecord::RVA
lldb::addr_t RVA
Definition: BreakpadRecords.h:220
lldb_private::breakpad::ModuleRecord::ModuleRecord
ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
Definition: BreakpadRecords.h:62
lldb_private::UUID
Definition: UUID.h:23
lldb_private::breakpad::Record::Module
@ Module
Definition: BreakpadRecords.h:24
lldb_private::breakpad::ModuleRecord::OS
llvm::Triple::OSType OS
Definition: BreakpadRecords.h:65
lldb_private::breakpad::StackWinRecord::StackWinRecord
StackWinRecord(lldb::addr_t RVA, lldb::addr_t CodeSize, lldb::addr_t ParameterSize, lldb::addr_t SavedRegisterSize, lldb::addr_t LocalSize, llvm::StringRef ProgramString)
Definition: BreakpadRecords.h:212
lldb_private::breakpad::FuncRecord
Definition: BreakpadRecords.h:120
lldb_private::breakpad::PublicRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:184
lldb_private::breakpad::StackWinRecord::parse
static llvm::Optional< StackWinRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:485
lldb_private::breakpad::Record
Definition: BreakpadRecords.h:21
lldb_private::breakpad::LineRecord::LineRecord
LineRecord(lldb::addr_t Address, lldb::addr_t Size, uint32_t LineNum, size_t FileNum)
Definition: BreakpadRecords.h:161
UUID.h
lldb_private::breakpad::StackCFIRecord::parse
static llvm::Optional< StackCFIRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:436
lldb_private::breakpad::LineRecord::FileNum
size_t FileNum
Definition: BreakpadRecords.h:169
lldb_private::breakpad::StackWinRecord::ParameterSize
lldb::addr_t ParameterSize
Definition: BreakpadRecords.h:222
lldb_private::breakpad::FuncRecord::Size
lldb::addr_t Size
Definition: BreakpadRecords.h:130
lldb_private::breakpad::StackWinRecord::FrameType::FPO
@ FPO
lldb_private::breakpad::Record::StackWin
@ StackWin
Definition: BreakpadRecords.h:33
lldb_private::breakpad::FileRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:95
lldb_private::breakpad::Record::StackCFI
@ StackCFI
Definition: BreakpadRecords.h:32
lldb_private::breakpad::StackWinRecord
Definition: BreakpadRecords.h:208
lldb_private::Module
Definition: Module.h:85
lldb_private::breakpad::StackWinRecord::FrameType::FrameData
@ FrameData
lldb_private::breakpad::InlineOriginRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:110
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::breakpad::FuncRecord::Multiple
bool Multiple
Definition: BreakpadRecords.h:128
lldb_private::breakpad::InfoRecord
Definition: BreakpadRecords.h:75
lldb_private::breakpad::ModuleRecord::Arch
llvm::Triple::ArchType Arch
Definition: BreakpadRecords.h:66
lldb_private::breakpad::StackCFIRecord
Definition: BreakpadRecords.h:192
lldb_private::breakpad::StackCFIRecord::Size
llvm::Optional< lldb::addr_t > Size
Definition: BreakpadRecords.h:201
lldb_private::breakpad::InlineRecord
Definition: BreakpadRecords.h:138
lldb_private::breakpad::PublicRecord::parse
static llvm::Optional< PublicRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:414
lldb_private::breakpad::Record::InlineOrigin
@ InlineOrigin
Definition: BreakpadRecords.h:29
lldb_private::breakpad::toString
llvm::StringRef toString(Record::Kind K)
Definition: BreakpadRecords.cpp:560
lldb_private::breakpad::Record::~Record
~Record()=default
lldb_private::breakpad::InlineOriginRecord::Number
size_t Number
Definition: BreakpadRecords.h:109
lldb_private::breakpad::FileRecord::parse
static llvm::Optional< FileRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:246
lldb_private::breakpad::InlineRecord::Ranges
std::vector< std::pair< lldb::addr_t, lldb::addr_t > > Ranges
Definition: BreakpadRecords.h:152
lldb_private::breakpad::LineRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:166
lldb_private::breakpad::InlineRecord::parse
static llvm::Optional< InlineRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:327
lldb_private::breakpad::operator<<
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, Record::Kind K)
Definition: BreakpadRecords.h:54
lldb_private::breakpad::Record::Inline
@ Inline
Definition: BreakpadRecords.h:28
lldb_private::breakpad::StackWinRecord::CodeSize
lldb::addr_t CodeSize
Definition: BreakpadRecords.h:221
lldb_private::breakpad::InlineOriginRecord::parse
static llvm::Optional< InlineOriginRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:257
lldb_private::breakpad::InlineRecord::CallSiteLineNum
uint32_t CallSiteLineNum
Definition: BreakpadRecords.h:148
lldb_private::breakpad::FileRecord::Number
size_t Number
Definition: BreakpadRecords.h:94
lldb_private::breakpad::PublicRecord::Multiple
bool Multiple
Definition: BreakpadRecords.h:183
lldb_private::breakpad::ModuleRecord::ID
UUID ID
Definition: BreakpadRecords.h:67
lldb_private::breakpad::InfoRecord::parse
static llvm::Optional< InfoRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:201
lldb_private::breakpad::FileRecord
Definition: BreakpadRecords.h:88
lldb_private::breakpad::Record::Public
@ Public
Definition: BreakpadRecords.h:31
lldb_private::File
Definition: File.h:35
lldb_private::breakpad::InlineRecord::InlineNestLevel
size_t InlineNestLevel
Definition: BreakpadRecords.h:147
lldb_private::breakpad::LineRecord::LineNum
uint32_t LineNum
Definition: BreakpadRecords.h:168
lldb_private::breakpad::LineRecord
Definition: BreakpadRecords.h:158
lldb_private::breakpad::StackWinRecord::ProgramString
llvm::StringRef ProgramString
Definition: BreakpadRecords.h:225
lldb-types.h
lldb_private::breakpad::Record::TheKind
Kind TheKind
Definition: BreakpadRecords.h:50
lldb_private::breakpad::StackWinRecord::FrameType
FrameType
Definition: BreakpadRecords.h:219
lldb_private::breakpad::FuncRecord::ParamSize
lldb::addr_t ParamSize
Definition: BreakpadRecords.h:131
lldb_private::breakpad::PublicRecord::PublicRecord
PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize, llvm::StringRef Name)
Definition: BreakpadRecords.h:178
lldb_private::breakpad::StackWinRecord::SavedRegisterSize
lldb::addr_t SavedRegisterSize
Definition: BreakpadRecords.h:223
lldb_private::breakpad::PublicRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:186
lldb_private::breakpad::InlineRecord::OriginNum
size_t OriginNum
Definition: BreakpadRecords.h:150
lldb_private::breakpad::Record::Record
Record(Kind K)
Definition: BreakpadRecords.h:42
lldb_private::breakpad::FuncRecord::parse
static llvm::Optional< FuncRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:305
uint32_t
lldb_private::breakpad::InlineRecord::InlineRecord
InlineRecord(size_t InlineNestLevel, uint32_t CallSiteLineNum, size_t CallSiteFileNum, size_t OriginNum)
Definition: BreakpadRecords.h:141
lldb_private::breakpad::FuncRecord::FuncRecord
FuncRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t Size, lldb::addr_t ParamSize, llvm::StringRef Name)
Definition: BreakpadRecords.h:123
lldb_private::Address
Definition: Address.h:59
lldb_private::breakpad::InfoRecord::InfoRecord
InfoRecord(UUID ID)
Definition: BreakpadRecords.h:78
lldb_private::breakpad::InfoRecord::ID
UUID ID
Definition: BreakpadRecords.h:80
lldb_private::breakpad::operator==
bool operator==(const ModuleRecord &L, const ModuleRecord &R)
Definition: BreakpadRecords.h:70
lldb_private::breakpad::InlineRecord::CallSiteFileNum
size_t CallSiteFileNum
Definition: BreakpadRecords.h:149
lldb_private::breakpad::StackCFIRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:200
lldb_private::breakpad::ModuleRecord::parse
static llvm::Optional< ModuleRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:172
lldb_private::breakpad::ModuleRecord
Definition: BreakpadRecords.h:59
lldb_private::breakpad::Record::File
@ File
Definition: BreakpadRecords.h:26
lldb_private::breakpad::PublicRecord::ParamSize
lldb::addr_t ParamSize
Definition: BreakpadRecords.h:185
lldb_private::breakpad::Record::Info
@ Info
Definition: BreakpadRecords.h:25
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::breakpad::Record::Kind
Kind
Definition: BreakpadRecords.h:23
lldb_private::breakpad::FuncRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:132
lldb_private::breakpad::PublicRecord
Definition: BreakpadRecords.h:175
lldb_private::breakpad::Record::Func
@ Func
Definition: BreakpadRecords.h:27
lldb_private::breakpad::LineRecord::parse
static llvm::Optional< LineRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:379
lldb_private::breakpad::StackCFIRecord::StackCFIRecord
StackCFIRecord(lldb::addr_t Address, llvm::Optional< lldb::addr_t > Size, llvm::StringRef UnwindRules)
Definition: BreakpadRecords.h:195
lldb_private::breakpad::Record::classify
static llvm::Optional< Kind > classify(llvm::StringRef Line)
Attempt to guess the kind of the record present in the argument without doing a full parse.
Definition: BreakpadRecords.cpp:129
lldb_private::breakpad::StackCFIRecord::UnwindRules
llvm::StringRef UnwindRules
Definition: BreakpadRecords.h:202
lldb_private::breakpad::LineRecord::Size
lldb::addr_t Size
Definition: BreakpadRecords.h:167
lldb_private::breakpad::InlineOriginRecord::InlineOriginRecord
InlineOriginRecord(size_t Number, llvm::StringRef Name)
Definition: BreakpadRecords.h:106
lldb_private::breakpad::FileRecord::FileRecord
FileRecord(size_t Number, llvm::StringRef Name)
Definition: BreakpadRecords.h:91
lldb_private::breakpad::FuncRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:129
lldb_private::breakpad::StackWinRecord::LocalSize
lldb::addr_t LocalSize
Definition: BreakpadRecords.h:224
lldb_private::breakpad::InlineOriginRecord
Definition: BreakpadRecords.h:103