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_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
10 #define LLDB_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:
39  Kind TheKind;
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)
97  : Record(Module), Multiple(Multiple), Address(Address), Size(Size),
98  ParamSize(ParamSize), Name(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)
115  : Record(Line), Address(Address), Size(Size), LineNum(LineNum),
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);
130  PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize,
131  llvm::StringRef Name)
132  : Record(Module), Multiple(Multiple), Address(Address),
133  ParamSize(ParamSize), Name(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)
149  : Record(StackCFI), Address(Address), Size(Size),
150  UnwindRules(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 } // namespace breakpad
161 } // namespace lldb_private
162 
163 #endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
llvm::Optional< lldb::addr_t > Size
FileRecord(size_t Number, llvm::StringRef Name)
ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, Record::Kind K)
LineRecord(lldb::addr_t Address, lldb::addr_t Size, uint32_t LineNum, size_t FileNum)
A file class.
Definition: File.h:29
llvm::StringRef toString(Record::Kind K)
FuncRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t Size, lldb::addr_t ParamSize, llvm::StringRef Name)
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize, llvm::StringRef Name)
static char ID
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...
A section + offset based address class.
Definition: Address.h:80
StackCFIRecord(lldb::addr_t Address, llvm::Optional< lldb::addr_t > Size, llvm::StringRef UnwindRules)
bool operator==(const ModuleRecord &L, const ModuleRecord &R)
uint64_t addr_t
Definition: lldb-types.h:83