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:
24 
25  /// Attempt to guess the kind of the record present in the argument without
26  /// doing a full parse. The returned kind will always be correct for valid
27  /// records, but the full parse can still fail in case of corrupted input.
28  static llvm::Optional<Kind> classify(llvm::StringRef Line);
29 
30 protected:
31  Record(Kind K) : TheKind(K) {}
32 
33  ~Record() = default;
34 
35 public:
36  Kind getKind() { return TheKind; }
37 
38 private:
40 };
41 
42 llvm::StringRef toString(Record::Kind K);
43 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Record::Kind K) {
44  OS << toString(K);
45  return OS;
46 }
47 
48 class ModuleRecord : public Record {
49 public:
50  static llvm::Optional<ModuleRecord> parse(llvm::StringRef Line);
51  ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
52  : Record(Module), OS(OS), Arch(Arch), ID(std::move(ID)) {}
53 
54  llvm::Triple::OSType OS;
55  llvm::Triple::ArchType Arch;
57 };
58 
59 inline bool operator==(const ModuleRecord &L, const ModuleRecord &R) {
60  return L.OS == R.OS && L.Arch == R.Arch && L.ID == R.ID;
61 }
62 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ModuleRecord &R);
63 
64 class InfoRecord : public Record {
65 public:
66  static llvm::Optional<InfoRecord> parse(llvm::StringRef Line);
67  InfoRecord(UUID ID) : Record(Info), ID(std::move(ID)) {}
68 
70 };
71 
72 inline bool operator==(const InfoRecord &L, const InfoRecord &R) {
73  return L.ID == R.ID;
74 }
75 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InfoRecord &R);
76 
77 class FileRecord : public Record {
78 public:
79  static llvm::Optional<FileRecord> parse(llvm::StringRef Line);
80  FileRecord(size_t Number, llvm::StringRef Name)
81  : Record(File), Number(Number), Name(Name) {}
82 
83  size_t Number;
84  llvm::StringRef Name;
85 };
86 
87 inline bool operator==(const FileRecord &L, const FileRecord &R) {
88  return L.Number == R.Number && L.Name == R.Name;
89 }
90 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FileRecord &R);
91 
92 class FuncRecord : public Record {
93 public:
94  static llvm::Optional<FuncRecord> parse(llvm::StringRef Line);
96  lldb::addr_t ParamSize, llvm::StringRef Name)
99 
100  bool Multiple;
104  llvm::StringRef Name;
105 };
106 
107 bool operator==(const FuncRecord &L, const FuncRecord &R);
108 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FuncRecord &R);
109 
110 class LineRecord : public Record {
111 public:
112  static llvm::Optional<LineRecord> parse(llvm::StringRef Line);
114  size_t FileNum)
116  FileNum(FileNum) {}
117 
121  size_t FileNum;
122 };
123 
124 bool operator==(const LineRecord &L, const LineRecord &R);
125 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LineRecord &R);
126 
127 class PublicRecord : public Record {
128 public:
129  static llvm::Optional<PublicRecord> parse(llvm::StringRef Line);
131  llvm::StringRef Name)
134 
135  bool Multiple;
138  llvm::StringRef Name;
139 };
140 
141 bool operator==(const PublicRecord &L, const PublicRecord &R);
142 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PublicRecord &R);
143 
144 class StackCFIRecord : public Record {
145 public:
146  static llvm::Optional<StackCFIRecord> parse(llvm::StringRef Line);
147  StackCFIRecord(lldb::addr_t Address, llvm::Optional<lldb::addr_t> Size,
148  llvm::StringRef UnwindRules)
151 
153  llvm::Optional<lldb::addr_t> Size;
154  llvm::StringRef UnwindRules;
155 };
156 
157 bool operator==(const StackCFIRecord &L, const StackCFIRecord &R);
158 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackCFIRecord &R);
159 
160 class StackWinRecord : public Record {
161 public:
162  static llvm::Optional<StackWinRecord> parse(llvm::StringRef Line);
163 
166  lldb::addr_t LocalSize, llvm::StringRef ProgramString)
170 
171  enum class FrameType : uint8_t { FPO = 0, FrameData = 4 };
177  llvm::StringRef ProgramString;
178 };
179 
180 bool operator==(const StackWinRecord &L, const StackWinRecord &R);
181 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackWinRecord &R);
182 
183 } // namespace breakpad
184 } // namespace lldb_private
185 
186 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
lldb_private::breakpad::Record::Line
@ Line
Definition: BreakpadRecords.h:23
lldb_private::breakpad::Record::getKind
Kind getKind()
Definition: BreakpadRecords.h:36
lldb_private::breakpad::StackWinRecord::RVA
lldb::addr_t RVA
Definition: BreakpadRecords.h:172
lldb_private::breakpad::ModuleRecord::ModuleRecord
ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
Definition: BreakpadRecords.h:51
lldb_private::UUID
Definition: UUID.h:23
lldb_private::breakpad::Record::Module
@ Module
Definition: BreakpadRecords.h:23
lldb_private::breakpad::ModuleRecord::OS
llvm::Triple::OSType OS
Definition: BreakpadRecords.h:54
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:164
lldb_private::breakpad::FuncRecord
Definition: BreakpadRecords.h:92
lldb_private::breakpad::PublicRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:136
lldb_private::breakpad::StackWinRecord::parse
static llvm::Optional< StackWinRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:408
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:113
UUID.h
lldb_private::breakpad::StackCFIRecord::parse
static llvm::Optional< StackCFIRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:359
lldb_private::breakpad::LineRecord::FileNum
size_t FileNum
Definition: BreakpadRecords.h:121
lldb_private::breakpad::StackWinRecord::ParameterSize
lldb::addr_t ParameterSize
Definition: BreakpadRecords.h:174
lldb_private::breakpad::FuncRecord::Size
lldb::addr_t Size
Definition: BreakpadRecords.h:102
lldb_private::breakpad::StackWinRecord::FrameType::FPO
@ FPO
lldb_private::breakpad::Record::StackWin
@ StackWin
Definition: BreakpadRecords.h:23
lldb_private::breakpad::FileRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:84
lldb_private::breakpad::Record::StackCFI
@ StackCFI
Definition: BreakpadRecords.h:23
lldb_private::breakpad::StackWinRecord
Definition: BreakpadRecords.h:160
lldb_private::Module
Definition: Module.h:75
lldb_private::breakpad::StackWinRecord::FrameType::FrameData
@ FrameData
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::breakpad::FuncRecord::Multiple
bool Multiple
Definition: BreakpadRecords.h:100
lldb_private::breakpad::InfoRecord
Definition: BreakpadRecords.h:64
lldb_private::breakpad::ModuleRecord::Arch
llvm::Triple::ArchType Arch
Definition: BreakpadRecords.h:55
lldb_private::breakpad::StackCFIRecord
Definition: BreakpadRecords.h:144
lldb_private::breakpad::StackCFIRecord::Size
llvm::Optional< lldb::addr_t > Size
Definition: BreakpadRecords.h:153
lldb_private::breakpad::PublicRecord::parse
static llvm::Optional< PublicRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:337
lldb_private::breakpad::toString
llvm::StringRef toString(Record::Kind K)
Definition: BreakpadRecords.cpp:483
lldb_private::breakpad::Record::~Record
~Record()=default
lldb_private::breakpad::FileRecord::parse
static llvm::Optional< FileRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:219
lldb_private::breakpad::LineRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:118
lldb_private::breakpad::operator<<
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, Record::Kind K)
Definition: BreakpadRecords.h:43
lldb_private::breakpad::StackWinRecord::CodeSize
lldb::addr_t CodeSize
Definition: BreakpadRecords.h:173
lldb_private::breakpad::FileRecord::Number
size_t Number
Definition: BreakpadRecords.h:83
lldb_private::breakpad::PublicRecord::Multiple
bool Multiple
Definition: BreakpadRecords.h:135
lldb_private::breakpad::ModuleRecord::ID
UUID ID
Definition: BreakpadRecords.h:56
lldb_private::breakpad::InfoRecord::parse
static llvm::Optional< InfoRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:194
lldb_private::breakpad::FileRecord
Definition: BreakpadRecords.h:77
lldb_private::breakpad::Record::Public
@ Public
Definition: BreakpadRecords.h:23
lldb_private::File
Definition: File.h:34
lldb_private::breakpad::LineRecord::LineNum
uint32_t LineNum
Definition: BreakpadRecords.h:120
lldb_private::breakpad::LineRecord
Definition: BreakpadRecords.h:110
lldb_private::breakpad::StackWinRecord::ProgramString
llvm::StringRef ProgramString
Definition: BreakpadRecords.h:177
lldb-types.h
lldb_private::breakpad::Record::TheKind
Kind TheKind
Definition: BreakpadRecords.h:39
lldb_private::breakpad::StackWinRecord::FrameType
FrameType
Definition: BreakpadRecords.h:171
lldb_private::breakpad::FuncRecord::ParamSize
lldb::addr_t ParamSize
Definition: BreakpadRecords.h:103
lldb_private::breakpad::PublicRecord::PublicRecord
PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize, llvm::StringRef Name)
Definition: BreakpadRecords.h:130
lldb_private::breakpad::StackWinRecord::SavedRegisterSize
lldb::addr_t SavedRegisterSize
Definition: BreakpadRecords.h:175
lldb_private::breakpad::PublicRecord::Name
llvm::StringRef Name
Definition: BreakpadRecords.h:138
lldb_private::breakpad::Record::Record
Record(Kind K)
Definition: BreakpadRecords.h:31
lldb_private::breakpad::FuncRecord::parse
static llvm::Optional< FuncRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:280
uint32_t
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:95
lldb_private::Address
Definition: Address.h:59
lldb_private::breakpad::InfoRecord::InfoRecord
InfoRecord(UUID ID)
Definition: BreakpadRecords.h:67
lldb_private::breakpad::InfoRecord::ID
UUID ID
Definition: BreakpadRecords.h:69
lldb_private::breakpad::operator==
bool operator==(const ModuleRecord &L, const ModuleRecord &R)
Definition: BreakpadRecords.h:59
lldb_private::breakpad::StackCFIRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:152
lldb_private::breakpad::ModuleRecord::parse
static llvm::Optional< ModuleRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:165
lldb_private::breakpad::ModuleRecord
Definition: BreakpadRecords.h:48
lldb_private::breakpad::Record::File
@ File
Definition: BreakpadRecords.h:23
lldb_private::breakpad::PublicRecord::ParamSize
lldb::addr_t ParamSize
Definition: BreakpadRecords.h:137
lldb_private::breakpad::Record::Info
@ Info
Definition: BreakpadRecords.h:23
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:104
lldb_private::breakpad::PublicRecord
Definition: BreakpadRecords.h:127
lldb_private::breakpad::Record::Func
@ Func
Definition: BreakpadRecords.h:23
lldb_private::breakpad::LineRecord::parse
static llvm::Optional< LineRecord > parse(llvm::StringRef Line)
Definition: BreakpadRecords.cpp:302
lldb_private::breakpad::StackCFIRecord::StackCFIRecord
StackCFIRecord(lldb::addr_t Address, llvm::Optional< lldb::addr_t > Size, llvm::StringRef UnwindRules)
Definition: BreakpadRecords.h:147
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:125
lldb_private::breakpad::StackCFIRecord::UnwindRules
llvm::StringRef UnwindRules
Definition: BreakpadRecords.h:154
lldb_private::breakpad::LineRecord::Size
lldb::addr_t Size
Definition: BreakpadRecords.h:119
lldb_private::breakpad::FileRecord::FileRecord
FileRecord(size_t Number, llvm::StringRef Name)
Definition: BreakpadRecords.h:80
lldb_private::breakpad::FuncRecord::Address
lldb::addr_t Address
Definition: BreakpadRecords.h:101
lldb_private::breakpad::StackWinRecord::LocalSize
lldb::addr_t LocalSize
Definition: BreakpadRecords.h:176