summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/Breakpad
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-04-09 08:05:11 +0000
committerPavel Labath <pavel@labath.sk>2019-04-09 08:05:11 +0000
commit9837f54843df864092be162823c6cdd0607dced0 (patch)
tree4d6903e09ac561742240a659b6e29693620876d2 /lldb/source/Plugins/ObjectFile/Breakpad
parent93b497a61d205088ad14e3ec7e7abc91e33592fe (diff)
downloadbcm5719-llvm-9837f54843df864092be162823c6cdd0607dced0.tar.gz
bcm5719-llvm-9837f54843df864092be162823c6cdd0607dced0.zip
Breakpad: Parse Stack CFI records
Summary: This patch adds support for parsing STACK CFI records from breakpad files. The expressions specifying the values of registers are not parsed.The idea is that these will be handed off to the postfix expression -> dwarf compiler, once it is extracted from the internals of the NativePDB plugin. Reviewers: clayborg, amccarth, markmentovai Subscribers: aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D60268 llvm-svn: 357975
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Breakpad')
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp54
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h18
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp3
3 files changed, 67 insertions, 8 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
index 6807563b86c..d5b87e387d8 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
@@ -143,8 +143,7 @@ llvm::Optional<Record::Kind> Record::classify(llvm::StringRef Line) {
Tok = consume<Token>(Line);
switch (Tok) {
case Token::CFI:
- Tok = consume<Token>(Line);
- return Tok == Token::Init ? Record::StackCFIInit : Record::StackCFI;
+ return Record::StackCFI;
default:
return llvm::None;
}
@@ -359,6 +358,55 @@ llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
R.Name);
}
+llvm::Optional<StackCFIRecord> StackCFIRecord::parse(llvm::StringRef Line) {
+ // STACK CFI INIT address size reg1: expr1 reg2: expr2 ...
+ // or
+ // STACK CFI address reg1: expr1 reg2: expr2 ...
+ // No token in exprN ends with a colon.
+
+ if (consume<Token>(Line) != Token::Stack)
+ return llvm::None;
+ if (consume<Token>(Line) != Token::CFI)
+ return llvm::None;
+
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+
+ bool IsInitRecord = stringTo<Token>(Str) == Token::Init;
+ if (IsInitRecord)
+ std::tie(Str, Line) = getToken(Line);
+
+ lldb::addr_t Address;
+ if (!to_integer(Str, Address, 16))
+ return llvm::None;
+
+ llvm::Optional<lldb::addr_t> Size;
+ if (IsInitRecord) {
+ Size.emplace();
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, *Size, 16))
+ return llvm::None;
+ }
+
+ return StackCFIRecord(Address, Size, Line.trim());
+}
+
+bool breakpad::operator==(const StackCFIRecord &L, const StackCFIRecord &R) {
+ return L.Address == R.Address && L.Size == R.Size &&
+ L.UnwindRules == R.UnwindRules;
+}
+
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const StackCFIRecord &R) {
+ OS << "STACK CFI ";
+ if (R.Size)
+ OS << "INIT ";
+ OS << llvm::formatv("{0:x-} ", R.Address);
+ if (R.Size)
+ OS << llvm::formatv("{0:x-} ", *R.Size);
+ return OS << " " << R.UnwindRules;
+}
+
llvm::StringRef breakpad::toString(Record::Kind K) {
switch (K) {
case Record::Module:
@@ -373,8 +421,6 @@ llvm::StringRef breakpad::toString(Record::Kind K) {
return "LINE";
case Record::Public:
return "PUBLIC";
- case Record::StackCFIInit:
- return "STACK CFI INIT";
case Record::StackCFI:
return "STACK CFI";
}
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
index e80cc22b3d0..5d5cdb319c1 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
@@ -20,7 +20,7 @@ namespace breakpad {
class Record {
public:
- enum Kind { Module, Info, File, Func, Line, Public, StackCFIInit, StackCFI };
+ enum Kind { Module, Info, File, Func, Line, Public, StackCFI };
/// Attempt to guess the kind of the record present in the argument without
/// doing a full parse. The returned kind will always be correct for valid
@@ -141,6 +141,22 @@ public:
bool operator==(const PublicRecord &L, const PublicRecord &R);
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PublicRecord &R);
+class StackCFIRecord : public Record {
+public:
+ static llvm::Optional<StackCFIRecord> parse(llvm::StringRef Line);
+ StackCFIRecord(lldb::addr_t Address, llvm::Optional<lldb::addr_t> Size,
+ llvm::StringRef UnwindRules)
+ : Record(StackCFI), Address(Address), Size(Size),
+ UnwindRules(UnwindRules) {}
+
+ lldb::addr_t Address;
+ llvm::Optional<lldb::addr_t> Size;
+ llvm::StringRef UnwindRules;
+};
+
+bool operator==(const StackCFIRecord &L, const StackCFIRecord &R);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackCFIRecord &R);
+
} // namespace breakpad
} // namespace lldb_private
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
index e68d80cdc72..60dd9f9cecf 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -153,9 +153,6 @@ void ObjectFileBreakpad::CreateSections(SectionList &unified_section_list) {
// Line records logically belong to the preceding Func record, so we put
// them in the same section.
next_section = Record::Func;
- } else if (next_section == Record::StackCFI) {
- // Same goes for StackCFI and StackCFIInit
- next_section = Record::StackCFIInit;
}
if (next_section == current_section)
continue;
OpenPOWER on IntegriCloud