summaryrefslogtreecommitdiff
path: root/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h')
-rw-r--r--source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h116
1 files changed, 96 insertions, 20 deletions
diff --git a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
index 68e8d11c7dd7..8a0b7645fd0a 100644
--- a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -1,16 +1,19 @@
//===-- SymbolFileBreakpad.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
#define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/UnwindPlan.h"
namespace lldb_private {
@@ -18,9 +21,7 @@ namespace breakpad {
class SymbolFileBreakpad : public SymbolFile {
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
static void DebuggerInitialize(Debugger &debugger) {}
@@ -34,9 +35,7 @@ public:
return new SymbolFileBreakpad(obj_file);
}
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFileBreakpad(ObjectFile *object_file) : SymbolFile(object_file) {}
~SymbolFileBreakpad() override {}
@@ -45,9 +44,7 @@ public:
void InitializeObject() override {}
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
@@ -64,20 +61,18 @@ public:
bool ParseDebugMacros(CompileUnit &comp_unit) override { return false; }
bool ParseSupportFiles(CompileUnit &comp_unit,
- FileSpecList &support_files) override {
- return false;
- }
+ FileSpecList &support_files) override;
size_t ParseTypes(CompileUnit &cu) override { return 0; }
- bool
- ParseImportedModules(const SymbolContext &sc,
- std::vector<ConstString> &imported_modules) override {
+ bool ParseImportedModules(
+ const SymbolContext &sc,
+ std::vector<lldb_private::SourceModule> &imported_modules) override {
return false;
}
size_t ParseBlocksRecursive(Function &func) override { return 0; }
- uint32_t FindGlobalVariables(const ConstString &name,
+ uint32_t FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override {
@@ -99,12 +94,17 @@ public:
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) override;
+ uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ bool check_inlines,
+ lldb::SymbolContextItem resolve_scope,
+ SymbolContextList &sc_list) override;
+
size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override {
return 0;
}
- uint32_t FindFunctions(const ConstString &name,
+ uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -113,7 +113,7 @@ public:
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
- uint32_t FindTypes(const ConstString &name,
+ uint32_t FindTypes(ConstString name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
@@ -127,17 +127,93 @@ public:
}
CompilerDeclContext
- FindNamespace(const ConstString &name,
+ FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override {
return CompilerDeclContext();
}
void AddSymbols(Symtab &symtab) override;
+ lldb::UnwindPlanSP
+ GetUnwindPlan(const Address &address,
+ const RegisterInfoResolver &resolver) override;
+
ConstString GetPluginName() override { return GetPluginNameStatic(); }
uint32_t GetPluginVersion() override { return 1; }
private:
+ // A class representing a position in the breakpad file. Useful for
+ // remembering the position so we can go back to it later and parse more data.
+ // Can be converted to/from a LineIterator, but it has a much smaller memory
+ // footprint.
+ struct Bookmark {
+ uint32_t section;
+ size_t offset;
+
+ friend bool operator<(const Bookmark &lhs, const Bookmark &rhs) {
+ return std::tie(lhs.section, lhs.offset) <
+ std::tie(rhs.section, rhs.offset);
+ }
+ };
+
+ // At iterator class for simplifying algorithms reading data from the breakpad
+ // file. It iterates over all records (lines) in the sections of a given type.
+ // It also supports saving a specific position (via the GetBookmark() method)
+ // and then resuming from it afterwards.
+ class LineIterator;
+
+ // Return an iterator range for all records in the given object file of the
+ // given type.
+ llvm::iterator_range<LineIterator> lines(Record::Kind section_type);
+
+ // Breakpad files do not contain sufficient information to correctly
+ // reconstruct compile units. The approach chosen here is to treat each
+ // function as a compile unit. The compile unit name is the name if the first
+ // line entry belonging to this function.
+ // This class is our internal representation of a compile unit. It stores the
+ // CompileUnit object and a bookmark pointing to the FUNC record of the
+ // compile unit function. It also lazily construct the list of support files
+ // and line table entries for the compile unit, when these are needed.
+ class CompUnitData {
+ public:
+ CompUnitData(Bookmark bookmark) : bookmark(bookmark) {}
+
+ CompUnitData() = default;
+ CompUnitData(const CompUnitData &rhs) : bookmark(rhs.bookmark) {}
+ CompUnitData &operator=(const CompUnitData &rhs) {
+ bookmark = rhs.bookmark;
+ support_files.reset();
+ line_table_up.reset();
+ return *this;
+ }
+ friend bool operator<(const CompUnitData &lhs, const CompUnitData &rhs) {
+ return lhs.bookmark < rhs.bookmark;
+ }
+
+ Bookmark bookmark;
+ llvm::Optional<FileSpecList> support_files;
+ std::unique_ptr<LineTable> line_table_up;
+
+ };
+
+ SymbolVendor &GetSymbolVendor();
+ lldb::addr_t GetBaseFileAddress();
+ void ParseFileRecords();
+ void ParseCUData();
+ void ParseLineTableAndSupportFiles(CompileUnit &cu, CompUnitData &data);
+ void ParseUnwindData();
+ bool ParseUnwindRow(llvm::StringRef unwind_rules,
+ const RegisterInfoResolver &resolver,
+ UnwindPlan::Row &row);
+
+ using CompUnitMap = RangeDataVector<lldb::addr_t, lldb::addr_t, CompUnitData>;
+
+ llvm::Optional<std::vector<FileSpec>> m_files;
+ llvm::Optional<CompUnitMap> m_cu_data;
+
+ using UnwindMap = RangeDataVector<lldb::addr_t, lldb::addr_t, Bookmark>;
+ llvm::Optional<UnwindMap> m_unwind_data;
+ llvm::BumpPtrAllocator m_allocator;
};
} // namespace breakpad