summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/crashreporter/google-breakpad/src/google_breakpad/processor')
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/basic_source_line_resolver.h148
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/call_stack.h97
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_module.h104
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_modules.h108
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_context.h116
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_object.h53
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exception_record.h124
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exploitability.h82
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/fast_source_line_resolver.h100
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/memory_region.h79
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump.h135
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump_processor.h64
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump.h1498
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump_processor.h147
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/proc_maps_linux.h60
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_result.h66
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_state.h220
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_base.h128
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_interface.h117
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame.h144
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_cpu.h405
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_symbolizer.h110
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stackwalker.h257
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/symbol_supplier.h99
-rw-r--r--toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/system_info.h106
25 files changed, 4567 insertions, 0 deletions
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/basic_source_line_resolver.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/basic_source_line_resolver.h
new file mode 100644
index 0000000000..91fb784173
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/basic_source_line_resolver.h
@@ -0,0 +1,148 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// basic_source_line_resolver.h: BasicSourceLineResolver is derived from
+// SourceLineResolverBase, and is a concrete implementation of
+// SourceLineResolverInterface, using address map files produced by a
+// compatible writer, e.g. PDBSourceLineWriter.
+//
+// see "processor/source_line_resolver_base.h"
+// and "source_line_resolver_interface.h" for more documentation.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+
+#include <map>
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/processor/source_line_resolver_base.h"
+
+namespace google_breakpad {
+
+using std::map;
+
+class BasicSourceLineResolver : public SourceLineResolverBase {
+ public:
+ BasicSourceLineResolver();
+ virtual ~BasicSourceLineResolver() { }
+
+ using SourceLineResolverBase::LoadModule;
+ using SourceLineResolverBase::LoadModuleUsingMapBuffer;
+ using SourceLineResolverBase::LoadModuleUsingMemoryBuffer;
+ using SourceLineResolverBase::ShouldDeleteMemoryBufferAfterLoadModule;
+ using SourceLineResolverBase::UnloadModule;
+ using SourceLineResolverBase::HasModule;
+ using SourceLineResolverBase::IsModuleCorrupt;
+ using SourceLineResolverBase::FillSourceLineInfo;
+ using SourceLineResolverBase::FindWindowsFrameInfo;
+ using SourceLineResolverBase::FindCFIFrameInfo;
+
+ private:
+ // friend declarations:
+ friend class BasicModuleFactory;
+ friend class ModuleComparer;
+ friend class ModuleSerializer;
+ template<class> friend class SimpleSerializer;
+
+ // Function derives from SourceLineResolverBase::Function.
+ struct Function;
+ // Module implements SourceLineResolverBase::Module interface.
+ class Module;
+
+ // Disallow unwanted copy ctor and assignment operator
+ BasicSourceLineResolver(const BasicSourceLineResolver&);
+ void operator=(const BasicSourceLineResolver&);
+};
+
+// Helper class, containing useful methods for parsing of Breakpad symbol files.
+class SymbolParseHelper {
+ public:
+ // Parses a |file_line| declaration. Returns true on success.
+ // Format: FILE <id> <filename>.
+ // Notice, that this method modifies the input |file_line| which is why it
+ // can't be const. On success, <id>, and <filename> are stored in |*index|,
+ // and |*filename|. No allocation is done, |*filename| simply points inside
+ // |file_line|.
+ static bool ParseFile(char *file_line, // in
+ long *index, // out
+ char **filename); // out
+
+ // Parses a |function_line| declaration. Returns true on success.
+ // Format: FUNC [<multiple>] <address> <size> <stack_param_size> <name>.
+ // Notice, that this method modifies the input |function_line| which is why it
+ // can't be const. On success, the presence of <multiple>, <address>, <size>,
+ // <stack_param_size>, and <name> are stored in |*is_multiple|, |*address|,
+ // |*size|, |*stack_param_size|, and |*name|. No allocation is done, |*name|
+ // simply points inside |function_line|.
+ static bool ParseFunction(char *function_line, // in
+ bool *is_multiple, // out
+ uint64_t *address, // out
+ uint64_t *size, // out
+ long *stack_param_size, // out
+ char **name); // out
+
+ // Parses a |line| declaration. Returns true on success.
+ // Format: <address> <size> <line number> <source file id>
+ // Notice, that this method modifies the input |function_line| which is why
+ // it can't be const. On success, <address>, <size>, <line number>, and
+ // <source file id> are stored in |*address|, |*size|, |*line_number|, and
+ // |*source_file|.
+ static bool ParseLine(char *line_line, // in
+ uint64_t *address, // out
+ uint64_t *size, // out
+ long *line_number, // out
+ long *source_file); // out
+
+ // Parses a |public_line| declaration. Returns true on success.
+ // Format: PUBLIC [<multiple>] <address> <stack_param_size> <name>
+ // Notice, that this method modifies the input |function_line| which is why
+ // it can't be const. On success, the presence of <multiple>, <address>,
+ // <stack_param_size>, <name> are stored in |*is_multiple|, |*address|,
+ // |*stack_param_size|, and |*name|. No allocation is done, |*name| simply
+ // points inside |public_line|.
+ static bool ParsePublicSymbol(char *public_line, // in
+ bool *is_multiple, // out
+ uint64_t *address, // out
+ long *stack_param_size, // out
+ char **name); // out
+
+ private:
+ // Used for success checks after strtoull and strtol.
+ static bool IsValidAfterNumber(char *after_number);
+
+ // Only allow static methods.
+ SymbolParseHelper();
+ SymbolParseHelper(const SymbolParseHelper&);
+ void operator=(const SymbolParseHelper&);
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/call_stack.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/call_stack.h
new file mode 100644
index 0000000000..bf45e71bd1
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/call_stack.h
@@ -0,0 +1,97 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// call_stack.h: A call stack comprised of stack frames.
+//
+// This class manages a vector of stack frames. It is used instead of
+// exposing the vector directly to allow the CallStack to own StackFrame
+// pointers without having to publicly export the linked_ptr class. A
+// CallStack must be composed of pointers instead of objects to allow for
+// CPU-specific StackFrame subclasses.
+//
+// By convention, the stack frame at index 0 is the innermost callee frame,
+// and the frame at the highest index in a call stack is the outermost
+// caller. CallStack only allows stacks to be built by pushing frames,
+// beginning with the innermost callee frame.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace google_breakpad {
+
+using std::vector;
+using std::string;
+
+struct StackFrame;
+template<typename T> class linked_ptr;
+
+class CallStack {
+ public:
+ CallStack() { Clear(); }
+ ~CallStack();
+
+ // Resets the CallStack to its initial empty state
+ void Clear();
+
+ const vector<StackFrame*>* frames() const { return &frames_; }
+
+ // Set the TID associated with this call stack.
+ void set_tid(uint32_t tid) { tid_ = tid; }
+ void set_last_error(uint32_t last_error) { last_error_ = last_error; }
+ void set_name(const string& name) { name_ = name; }
+
+ uint32_t tid() const { return tid_; }
+ uint32_t last_error() const { return last_error_; }
+ const string name() const { return name_; }
+
+ private:
+ // Stackwalker is responsible for building the frames_ vector.
+ friend class Stackwalker;
+
+ // Storage for pushed frames.
+ vector<StackFrame*> frames_;
+
+ // The TID associated with this call stack. Default to 0 if it's not
+ // available.
+ uint32_t tid_;
+ // The last error the OS set for this thread (win32's GetLastError())
+ uint32_t last_error_;
+ // The name of this thread, empty if it's not available
+ string name_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCSSOR_CALL_STACK_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_module.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_module.h
new file mode 100644
index 0000000000..29b8d9c9ab
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_module.h
@@ -0,0 +1,104 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// code_module.h: Carries information about code modules that are loaded
+// into a process.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
+
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+class CodeModule {
+ public:
+ virtual ~CodeModule() {}
+
+ // The base address of this code module as it was loaded by the process.
+ // (uint64_t)-1 on error.
+ virtual uint64_t base_address() const = 0;
+
+ // The size of the code module. 0 on error.
+ virtual uint64_t size() const = 0;
+
+ // The path or file name that the code module was loaded from. Empty on
+ // error.
+ virtual string code_file() const = 0;
+
+ // An identifying string used to discriminate between multiple versions and
+ // builds of the same code module. This may contain a uuid, timestamp,
+ // version number, or any combination of this or other information, in an
+ // implementation-defined format. Empty on error.
+ virtual string code_identifier() const = 0;
+
+ // The filename containing debugging information associated with the code
+ // module. If debugging information is stored in a file separate from the
+ // code module itself (as is the case when .pdb or .dSYM files are used),
+ // this will be different from code_file. If debugging information is
+ // stored in the code module itself (possibly prior to stripping), this
+ // will be the same as code_file. Empty on error.
+ virtual string debug_file() const = 0;
+
+ // An identifying string similar to code_identifier, but identifies a
+ // specific version and build of the associated debug file. This may be
+ // the same as code_identifier when the debug_file and code_file are
+ // identical or when the same identifier is used to identify distinct
+ // debug and code files.
+ virtual string debug_identifier() const = 0;
+
+ // A human-readable representation of the code module's version. Empty on
+ // error.
+ virtual string version() const = 0;
+
+ // Creates a new copy of this CodeModule object, which the caller takes
+ // ownership of. The new CodeModule may be of a different concrete class
+ // than the CodeModule being copied, but will behave identically to the
+ // copied CodeModule as far as the CodeModule interface is concerned.
+ virtual CodeModule* Copy() const = 0;
+
+ // Getter and setter for shrink_down_delta. This is used when the address
+ // range for a module is shrunk down due to address range conflicts with
+ // other modules. The base_address and size fields are not updated and they
+ // should always reflect the original values (reported in the minidump).
+ virtual uint64_t shrink_down_delta() const = 0;
+ virtual void SetShrinkDownDelta(uint64_t shrink_down_delta) = 0;
+
+ // Whether the module was unloaded from memory.
+ virtual bool is_unloaded() const = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_modules.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_modules.h
new file mode 100644
index 0000000000..74f113c19c
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/code_modules.h
@@ -0,0 +1,108 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// code_modules.h: Contains all of the CodeModule objects that were loaded
+// into a single process.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
+
+#include <stddef.h>
+
+#include <vector>
+
+#include "google_breakpad/common/breakpad_types.h"
+#include "processor/linked_ptr.h"
+
+namespace google_breakpad {
+
+class CodeModule;
+
+class CodeModules {
+ public:
+ virtual ~CodeModules() {}
+
+ // The number of contained CodeModule objects.
+ virtual unsigned int module_count() const = 0;
+
+ // Random access to modules. Returns the module whose code is present
+ // at the address indicated by |address|. If no module is present at this
+ // address, returns NULL. Ownership of the returned CodeModule is retained
+ // by the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleForAddress(uint64_t address) const = 0;
+
+ // Returns the module corresponding to the main executable. If there is
+ // no main executable, returns NULL. Ownership of the returned CodeModule
+ // is retained by the CodeModules object; pointers returned by this method
+ // are valid for comparison with pointers returned by the other Get
+ // methods.
+ virtual const CodeModule* GetMainModule() const = 0;
+
+ // Sequential access to modules. A sequence number of 0 corresponds to the
+ // module residing lowest in memory. If the sequence number is out of
+ // range, returns NULL. Ownership of the returned CodeModule is retained
+ // by the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleAtSequence(
+ unsigned int sequence) const = 0;
+
+ // Sequential access to modules. This is similar to GetModuleAtSequence,
+ // except no ordering requirement is enforced. A CodeModules implementation
+ // may return CodeModule objects from GetModuleAtIndex in any order it
+ // wishes, provided that the order remain the same throughout the life of
+ // the CodeModules object. Typically, GetModuleAtIndex would be used by
+ // a caller to enumerate all CodeModule objects quickly when the enumeration
+ // does not require any ordering. If the index argument is out of range,
+ // returns NULL. Ownership of the returned CodeModule is retained by
+ // the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleAtIndex(unsigned int index) const = 0;
+
+ // Creates a new copy of this CodeModules object, which the caller takes
+ // ownership of. The new object will also contain copies of the existing
+ // object's child CodeModule objects. The new CodeModules object may be of
+ // a different concrete class than the object being copied, but will behave
+ // identically to the copied object as far as the CodeModules and CodeModule
+ // interfaces are concerned, except that the order that GetModuleAtIndex
+ // returns objects in may differ between a copy and the original CodeModules
+ // object.
+ virtual const CodeModules* Copy() const = 0;
+
+ // Returns a vector of all modules which address ranges needed to be shrunk
+ // down due to address range conflicts with other modules.
+ virtual std::vector<linked_ptr<const CodeModule> >
+ GetShrunkRangeModules() const = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_context.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_context.h
new file mode 100644
index 0000000000..df80bf7ef7
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_context.h
@@ -0,0 +1,116 @@
+// Copyright (c) 2014 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// dump_context.h: A (mini/micro) dump CPU-specific context.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_DUMP_CONTEXT_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_DUMP_CONTEXT_H__
+
+#include "google_breakpad/common/minidump_format.h"
+#include "google_breakpad/processor/dump_object.h"
+
+namespace google_breakpad {
+
+// DumpContext carries a CPU-specific MDRawContext structure, which contains CPU
+// context such as register states.
+class DumpContext : public DumpObject {
+ public:
+ virtual ~DumpContext();
+
+ // Returns an MD_CONTEXT_* value such as MD_CONTEXT_X86 or MD_CONTEXT_PPC
+ // identifying the CPU type that the context was collected from. The
+ // returned value will identify the CPU only, and will have any other
+ // MD_CONTEXT_* bits masked out. Returns 0 on failure.
+ uint32_t GetContextCPU() const;
+
+ // Return the raw value of |context_flags_|
+ uint32_t GetContextFlags() const;
+
+ // Returns raw CPU-specific context data for the named CPU type. If the
+ // context data does not match the CPU type or does not exist, returns NULL.
+ const MDRawContextAMD64* GetContextAMD64() const;
+ const MDRawContextARM* GetContextARM() const;
+ const MDRawContextARM64* GetContextARM64() const;
+ const MDRawContextMIPS* GetContextMIPS() const;
+ const MDRawContextPPC* GetContextPPC() const;
+ const MDRawContextPPC64* GetContextPPC64() const;
+ const MDRawContextSPARC* GetContextSPARC() const;
+ const MDRawContextX86* GetContextX86() const;
+
+ // A convenience method to get the instruction pointer out of the
+ // MDRawContext, since it varies per-CPU architecture.
+ bool GetInstructionPointer(uint64_t* ip) const;
+
+ // Similar to the GetInstructionPointer method, this method gets the stack
+ // pointer for all CPU architectures.
+ bool GetStackPointer(uint64_t* sp) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ DumpContext();
+
+ // Sets row CPU-specific context data for the names CPU type.
+ void SetContextFlags(uint32_t context_flags);
+ void SetContextX86(MDRawContextX86* x86);
+ void SetContextPPC(MDRawContextPPC* ppc);
+ void SetContextPPC64(MDRawContextPPC64* ppc64);
+ void SetContextAMD64(MDRawContextAMD64* amd64);
+ void SetContextSPARC(MDRawContextSPARC* ctx_sparc);
+ void SetContextARM(MDRawContextARM* arm);
+ void SetContextARM64(MDRawContextARM64* arm64);
+ void SetContextMIPS(MDRawContextMIPS* ctx_mips);
+
+ // Free the CPU-specific context structure.
+ void FreeContext();
+
+ private:
+ // The CPU-specific context structure.
+ union {
+ MDRawContextBase* base;
+ MDRawContextX86* x86;
+ MDRawContextPPC* ppc;
+ MDRawContextPPC64* ppc64;
+ MDRawContextAMD64* amd64;
+ // on Solaris SPARC, sparc is defined as a numeric constant,
+ // so variables can NOT be named as sparc
+ MDRawContextSPARC* ctx_sparc;
+ MDRawContextARM* arm;
+ MDRawContextARM64* arm64;
+ MDRawContextMIPS* ctx_mips;
+ } context_;
+
+ // Store this separately because of the weirdo AMD64 context
+ uint32_t context_flags_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_DUMP_CONTEXT_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_object.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_object.h
new file mode 100644
index 0000000000..112f687f4c
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/dump_object.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2014 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// dump_object.h: A base class for all mini/micro dump object.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_DUMP_OBJECT_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_DUMP_OBJECT_H__
+
+namespace google_breakpad {
+
+// DumpObject is the base of various mini/micro dump's objects.
+class DumpObject {
+ public:
+ DumpObject();
+
+ bool valid() const { return valid_; }
+
+ protected:
+ // DumpObjects are not valid when created. When a subclass populates its own
+ // fields, it can set valid_ to true. Accessors and mutators may wish to
+ // consider or alter the valid_ state as they interact with objects.
+ bool valid_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_DUMP_OBJECT_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exception_record.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exception_record.h
new file mode 100644
index 0000000000..eac6c90ae2
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exception_record.h
@@ -0,0 +1,124 @@
+// Copyright (c) 2019 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// exception_record.h: A snapshot of an exception record.
+//
+// Author: Ivan Penkov
+
+#ifndef THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
+#define THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
+
+#include <vector>
+
+namespace google_breakpad {
+
+// Additional argument that describes the exception.
+class ExceptionParameter {
+ public:
+ ExceptionParameter(uint64_t value, const string& description)
+ : value_(value), description_(description) {}
+ // Accessors. See the data declarations below.
+ uint64_t value() const { return value_; }
+ void set_value(uint64_t value) { value_ = value; }
+ const string& description() const { return description_; }
+ void set_description(const string& description) {
+ description_ = description;
+ }
+
+ private:
+ // Parameter value.
+ uint64_t value_;
+ // Human readable description/interpretation of the above value.
+ string description_;
+};
+
+// A snapshot of an exception record. Contains exception record details: code,
+// flags, address, parameters.
+class ExceptionRecord {
+ public:
+ // Accessors. See the data declarations below.
+ uint32_t code() const { return code_; }
+ const string& code_description() const { return code_description_; }
+ void set_code(uint32_t code, const string& description) {
+ code_ = code;
+ code_description_ = description;
+ }
+
+ uint32_t flags() const { return flags_; }
+ const string& flags_description() const { return flags_description_; }
+ void set_flags(uint32_t flags, const string& description) {
+ flags_ = flags;
+ flags_description_ = description;
+ }
+
+ uint64_t nested_exception_record_address() const {
+ return nested_exception_record_address_;
+ }
+ void set_nested_exception_record_address(
+ uint64_t nested_exception_record_address) {
+ nested_exception_record_address_ = nested_exception_record_address;
+ }
+
+ uint64_t address() const { return address_; }
+ void set_address(uint64_t address) { address_ = address; }
+
+ const std::vector<ExceptionParameter>* parameters() const {
+ return &parameters_;
+ }
+ void add_parameter(uint64_t value, const string& description) {
+ parameters_.push_back(ExceptionParameter(value, description));
+ }
+
+ private:
+ // Exception code.
+ uint32_t code_;
+ string code_description_;
+
+ // Exception flags.
+ uint32_t flags_;
+ string flags_description_;
+
+ // The address of an associated MDException structure. Exception records can
+ // be chained together to provide additional information when nested
+ // exceptions occur.
+ uint64_t nested_exception_record_address_;
+
+ // The memory address that caused the exception. For data access errors,
+ // this will be the data address that caused the fault. For code errors,
+ // this will be the address of the instruction that caused the fault.
+ uint64_t address_;
+
+ // An array of additional arguments that describe the exception.
+ std::vector<ExceptionParameter> parameters_;
+};
+
+} // namespace google_breakpad
+
+
+#endif // THIRD_PARTY_BREAKPAD_SRC_GOOGLE_BREAKPAD_PROCESSOR_EXCEPTION_RECORD_H_
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exploitability.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exploitability.h
new file mode 100644
index 0000000000..014413c944
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/exploitability.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// exploitability_engine.h: Generic exploitability engine.
+//
+// The Exploitability class is an abstract base class providing common
+// generic methods that apply to exploitability engines for specific platforms.
+// Specific implementations will extend this class by providing run
+// methods to fill in the exploitability_ enumeration of the ProcessState
+// for a crash.
+//
+// Author: Cris Neckar
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
+#define GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
+
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/minidump.h"
+#include "google_breakpad/processor/process_state.h"
+
+namespace google_breakpad {
+
+class Exploitability {
+ public:
+ virtual ~Exploitability() {}
+
+ static Exploitability *ExploitabilityForPlatform(Minidump *dump,
+ ProcessState *process_state);
+
+ // The boolean parameter signals whether the exploitability engine is
+ // enabled to call out to objdump for disassembly. This is disabled by
+ // default. It is used to check the identity of the instruction that
+ // caused the program to crash. This should not be enabled if there are
+ // portability concerns.
+ static Exploitability *ExploitabilityForPlatform(Minidump *dump,
+ ProcessState *process_state,
+ bool enable_objdump);
+
+ ExploitabilityRating CheckExploitability();
+ bool AddressIsAscii(uint64_t);
+
+ protected:
+ Exploitability(Minidump *dump,
+ ProcessState *process_state);
+
+ Minidump *dump_;
+ ProcessState *process_state_;
+ SystemInfo *system_info_;
+
+ private:
+ virtual ExploitabilityRating CheckPlatformExploitability() = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/fast_source_line_resolver.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/fast_source_line_resolver.h
new file mode 100644
index 0000000000..fdf9107766
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/fast_source_line_resolver.h
@@ -0,0 +1,100 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// fast_source_line_resolver.h: FastSourceLineResolver is derived from
+// SourceLineResolverBase, and is a concrete implementation of
+// SourceLineResolverInterface.
+//
+// FastSourceLineResolver is a sibling class of BasicSourceLineResolver. The
+// difference is FastSourceLineResolver loads a serialized memory chunk of data
+// which can be used directly a Module without parsing or copying of underlying
+// data. Therefore loading a symbol in FastSourceLineResolver is much faster
+// and more memory-efficient than BasicSourceLineResolver.
+//
+// See "source_line_resolver_base.h" and
+// "google_breakpad/source_line_resolver_interface.h" for more reference.
+//
+// Author: Siyang Xie (lambxsy@google.com)
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__
+
+#include <map>
+#include <string>
+
+#include "google_breakpad/processor/source_line_resolver_base.h"
+
+namespace google_breakpad {
+
+using std::map;
+
+class FastSourceLineResolver : public SourceLineResolverBase {
+ public:
+ FastSourceLineResolver();
+ virtual ~FastSourceLineResolver() { }
+
+ using SourceLineResolverBase::FillSourceLineInfo;
+ using SourceLineResolverBase::FindCFIFrameInfo;
+ using SourceLineResolverBase::FindWindowsFrameInfo;
+ using SourceLineResolverBase::HasModule;
+ using SourceLineResolverBase::IsModuleCorrupt;
+ using SourceLineResolverBase::LoadModule;
+ using SourceLineResolverBase::LoadModuleUsingMapBuffer;
+ using SourceLineResolverBase::LoadModuleUsingMemoryBuffer;
+ using SourceLineResolverBase::UnloadModule;
+
+ private:
+ // Friend declarations.
+ friend class ModuleComparer;
+ friend class ModuleSerializer;
+ friend class FastModuleFactory;
+
+ // Nested types that will derive from corresponding nested types defined in
+ // SourceLineResolverBase.
+ struct Line;
+ struct Function;
+ struct PublicSymbol;
+ class Module;
+
+ // Deserialize raw memory data to construct a WindowsFrameInfo object.
+ static WindowsFrameInfo CopyWFI(const char *raw_memory);
+
+ // FastSourceLineResolver requires the memory buffer stays alive during the
+ // lifetime of a corresponding module, therefore it needs to redefine this
+ // virtual method.
+ virtual bool ShouldDeleteMemoryBufferAfterLoadModule();
+
+ // Disallow unwanted copy ctor and assignment operator
+ FastSourceLineResolver(const FastSourceLineResolver&);
+ void operator=(const FastSourceLineResolver&);
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/memory_region.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/memory_region.h
new file mode 100644
index 0000000000..30f88df490
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/memory_region.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// memory_region.h: Access to memory regions.
+//
+// A MemoryRegion provides virtual access to a range of memory. It is an
+// abstraction allowing the actual source of memory to be independent of
+// methods which need to access a virtual memory space.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
+
+
+#include "google_breakpad/common/breakpad_types.h"
+
+
+namespace google_breakpad {
+
+
+class MemoryRegion {
+ public:
+ virtual ~MemoryRegion() {}
+
+ // The base address of this memory region.
+ virtual uint64_t GetBase() const = 0;
+
+ // The size of this memory region.
+ virtual uint32_t GetSize() const = 0;
+
+ // Access to data of various sizes within the memory region. address
+ // is a pointer to read, and it must lie within the memory region as
+ // defined by its base address and size. The location pointed to by
+ // value is set to the value at address. Byte-swapping is performed
+ // if necessary so that the value is appropriate for the running
+ // program. Returns true on success. Fails and returns false if address
+ // is out of the region's bounds (after considering the width of value),
+ // or for other types of errors.
+ virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const = 0;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const = 0;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const = 0;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const = 0;
+
+ // Print a human-readable representation of the object to stdout.
+ virtual void Print() const = 0;
+};
+
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump.h
new file mode 100644
index 0000000000..02ebdcd79b
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump.h
@@ -0,0 +1,135 @@
+// Copyright (c) 2014 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// microdump.h: A microdump reader. Microdump is a minified variant of a
+// minidump (see minidump.h for documentation) which contains the minimum
+// amount of information required to get a stack trace for the crashing thread.
+// The information contained in a microdump is:
+// - the crashing thread stack
+// - system information (os type / version)
+// - cpu context (state of the registers)
+// - list of mmaps
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_H__
+
+#include <string>
+#include <vector>
+
+#include "common/scoped_ptr.h"
+#include "common/using_std_string.h"
+#include "google_breakpad/processor/dump_context.h"
+#include "google_breakpad/processor/memory_region.h"
+#include "google_breakpad/processor/system_info.h"
+#include "processor/basic_code_modules.h"
+
+namespace google_breakpad {
+
+// MicrodumpModuleList contains all of the loaded code modules for a process
+// in the form of MicrodumpModules. It maintains a vector of these modules
+// and provides access to a code module corresponding to a specific address.
+class MicrodumpModules : public BasicCodeModules {
+ public:
+ // Takes over ownership of |module|.
+ void Add(const CodeModule* module);
+
+ // Enables/disables module address range shrink.
+ void SetEnableModuleShrink(bool is_enabled);
+};
+
+// MicrodumpContext carries a CPU-specific context.
+// See dump_context.h for documentation.
+class MicrodumpContext : public DumpContext {
+ public:
+ virtual void SetContextARM(MDRawContextARM* arm);
+ virtual void SetContextARM64(MDRawContextARM64* arm64);
+ virtual void SetContextX86(MDRawContextX86* x86);
+ virtual void SetContextMIPS(MDRawContextMIPS* mips32);
+ virtual void SetContextMIPS64(MDRawContextMIPS* mips64);
+};
+
+// This class provides access to microdump memory regions.
+// See memory_region.h for documentation.
+class MicrodumpMemoryRegion : public MemoryRegion {
+ public:
+ MicrodumpMemoryRegion();
+ virtual ~MicrodumpMemoryRegion() {}
+
+ // Set this region's address and contents. If we have placed an
+ // instance of this class in a test fixture class, individual tests
+ // can use this to provide the region's contents.
+ void Init(uint64_t base_address, const std::vector<uint8_t>& contents);
+
+ virtual uint64_t GetBase() const;
+ virtual uint32_t GetSize() const;
+
+ virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const;
+ virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const;
+
+ // Print a human-readable representation of the object to stdout.
+ virtual void Print() const;
+
+ private:
+ // Fetch a little-endian value from ADDRESS in contents_ whose size
+ // is BYTES, and store it in *VALUE. Returns true on success.
+ template<typename ValueType>
+ bool GetMemoryLittleEndian(uint64_t address, ValueType* value) const;
+
+ uint64_t base_address_;
+ std::vector<uint8_t> contents_;
+};
+
+// Microdump is the user's interface to a microdump file. It provides access to
+// the microdump's context, memory regions and modules.
+class Microdump {
+ public:
+ explicit Microdump(const string& contents);
+ virtual ~Microdump() {}
+
+ DumpContext* GetContext() { return context_.get(); }
+ MicrodumpMemoryRegion* GetMemory() { return stack_region_.get(); }
+ MicrodumpModules* GetModules() { return modules_.get(); }
+ SystemInfo* GetSystemInfo() { return system_info_.get(); }
+
+ string GetCrashReason() { return crash_reason_; }
+ uint64_t GetCrashAddress() { return crash_address_; }
+ private:
+ scoped_ptr<MicrodumpContext> context_;
+ scoped_ptr<MicrodumpMemoryRegion> stack_region_;
+ scoped_ptr<MicrodumpModules> modules_;
+ scoped_ptr<SystemInfo> system_info_;
+ string crash_reason_;
+ uint64_t crash_address_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump_processor.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump_processor.h
new file mode 100644
index 0000000000..60d14a541f
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/microdump_processor.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2014, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The processor for microdump (a reduced dump containing only the state of the
+// crashing thread). See crbug.com/410294 for more info and design docs.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_PROCESSOR_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_PROCESSOR_H__
+
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/processor/process_result.h"
+
+namespace google_breakpad {
+
+class Microdump;
+class ProcessState;
+class StackFrameSymbolizer;
+
+class MicrodumpProcessor {
+ public:
+ // Initializes the MicrodumpProcessor with a stack frame symbolizer.
+ // Does not take ownership of frame_symbolizer, which must NOT be NULL.
+ explicit MicrodumpProcessor(StackFrameSymbolizer* frame_symbolizer);
+
+ virtual ~MicrodumpProcessor();
+
+ // Processes the microdump contents and fills process_state with the result.
+ google_breakpad::ProcessResult Process(Microdump* microdump,
+ ProcessState* process_state);
+ private:
+ StackFrameSymbolizer* frame_symbolizer_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_PROCESSOR_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump.h
new file mode 100644
index 0000000000..b2eab95d8a
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump.h
@@ -0,0 +1,1498 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// minidump.h: A minidump reader.
+//
+// The basic structure of this module tracks the structure of the minidump
+// file itself. At the top level, a minidump file is represented by a
+// Minidump object. Like most other classes in this module, Minidump
+// provides a Read method that initializes the object with information from
+// the file. Most of the classes in this file are wrappers around the
+// "raw" structures found in the minidump file itself, and defined in
+// minidump_format.h. For example, each thread is represented by a
+// MinidumpThread object, whose parameters are specified in an MDRawThread
+// structure. A properly byte-swapped MDRawThread can be obtained from a
+// MinidumpThread easily by calling its thread() method.
+//
+// Most of the module lazily reads only the portion of the minidump file
+// necessary to fulfill the user's request. Calling Minidump::Read
+// only reads the minidump's directory. The thread list is not read until
+// it is needed, and even once it's read, the memory regions for each
+// thread's stack aren't read until they're needed. This strategy avoids
+// unnecessary file input, and allocating memory for data in which the user
+// has no interest. Note that although memory allocations for a typical
+// minidump file are not particularly large, it is possible for legitimate
+// minidumps to be sizable. A full-memory minidump, for example, contains
+// a snapshot of the entire mapped memory space. Even a normal minidump,
+// with stack memory only, can be large if, for example, the dump was
+// generated in response to a crash that occurred due to an infinite-
+// recursion bug that caused the stack's limits to be exceeded. Finally,
+// some users of this library will unfortunately find themselves in the
+// position of having to process potentially-hostile minidumps that might
+// attempt to cause problems by forcing the minidump processor to over-
+// allocate memory.
+//
+// Memory management in this module is based on a strict
+// you-don't-own-anything policy. The only object owned by the user is
+// the top-level Minidump object, the creation and destruction of which
+// must be the user's own responsibility. All other objects obtained
+// through interaction with this module are ultimately owned by the
+// Minidump object, and will be freed upon the Minidump object's destruction.
+// Because memory regions can potentially involve large allocations, a
+// FreeMemory method is provided by MinidumpMemoryRegion, allowing the user
+// to release data when it is no longer needed. Use of this method is
+// optional but recommended. If freed data is later required, it will
+// be read back in from the minidump file again.
+//
+// There is one exception to this memory management policy:
+// Minidump::ReadString will return a string object to the user, and the user
+// is responsible for its deletion.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
+
+#include <stdint.h>
+
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "common/basictypes.h"
+#include "common/using_std_string.h"
+#include "google_breakpad/processor/code_module.h"
+#include "google_breakpad/processor/code_modules.h"
+#include "google_breakpad/processor/dump_context.h"
+#include "google_breakpad/processor/dump_object.h"
+#include "google_breakpad/processor/memory_region.h"
+#include "google_breakpad/processor/proc_maps_linux.h"
+
+
+namespace google_breakpad {
+
+
+using std::map;
+using std::vector;
+
+
+class Minidump;
+template<typename AddressType, typename EntryType> class RangeMap;
+
+
+// MinidumpObject is the base of all Minidump* objects except for Minidump
+// itself.
+class MinidumpObject : public DumpObject {
+ public:
+ virtual ~MinidumpObject() {}
+
+ protected:
+ explicit MinidumpObject(Minidump* minidump);
+
+ // Refers to the Minidump object that is the ultimate parent of this
+ // Some MinidumpObjects are owned by other MinidumpObjects, but at the
+ // root of the ownership tree is always a Minidump. The Minidump object
+ // is kept here for access to its seeking and reading facilities, and
+ // for access to data about the minidump file itself, such as whether
+ // it should be byte-swapped.
+ Minidump* minidump_;
+};
+
+
+// This class exists primarily to provide a virtual destructor in a base
+// class common to all objects that might be stored in
+// Minidump::mStreamObjects. Some object types will never be stored in
+// Minidump::mStreamObjects, but are represented as streams and adhere to the
+// same interface, and may be derived from this class.
+class MinidumpStream : public MinidumpObject {
+ public:
+ virtual ~MinidumpStream() {}
+
+ protected:
+ explicit MinidumpStream(Minidump* minidump);
+
+ private:
+ // Populate (and validate) the MinidumpStream. minidump_ is expected
+ // to be positioned at the beginning of the stream, so that the next
+ // read from the minidump will be at the beginning of the stream.
+ // expected_size should be set to the stream's length as contained in
+ // the MDRawDirectory record or other identifying record. A class
+ // that implements MinidumpStream can compare expected_size to a
+ // known size as an integrity check.
+ virtual bool Read(uint32_t expected_size) = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpStream);
+};
+
+
+// MinidumpContext carries a CPU-specific MDRawContext structure, which
+// contains CPU context such as register states. Each thread has its
+// own context, and the exception record, if present, also has its own
+// context. Note that if the exception record is present, the context it
+// refers to is probably what the user wants to use for the exception
+// thread, instead of that thread's own context. The exception thread's
+// context (as opposed to the exception record's context) will contain
+// context for the exception handler (which performs minidump generation),
+// and not the context that caused the exception (which is probably what the
+// user wants).
+class MinidumpContext : public DumpContext {
+ public:
+ virtual ~MinidumpContext();
+
+ protected:
+ explicit MinidumpContext(Minidump* minidump);
+
+ private:
+ friend class MinidumpThread;
+ friend class MinidumpException;
+
+ bool Read(uint32_t expected_size);
+
+ // If the minidump contains a SYSTEM_INFO_STREAM, makes sure that the
+ // system info stream gives an appropriate CPU type matching the context
+ // CPU type in context_cpu_type. Returns false if the CPU type does not
+ // match. Returns true if the CPU type matches or if the minidump does
+ // not contain a system info stream.
+ bool CheckAgainstSystemInfo(uint32_t context_cpu_type);
+
+ // Refers to the Minidump object that is the ultimate parent of this
+ // Some MinidumpObjects are owned by other MinidumpObjects, but at the
+ // root of the ownership tree is always a Minidump. The Minidump object
+ // is kept here for access to its seeking and reading facilities, and
+ // for access to data about the minidump file itself, such as whether
+ // it should be byte-swapped.
+ Minidump* minidump_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpContext);
+};
+
+
+// MinidumpMemoryRegion does not wrap any MDRaw structure, and only contains
+// a reference to an MDMemoryDescriptor. This object is intended to wrap
+// portions of a minidump file that contain memory dumps. In normal
+// minidumps, each MinidumpThread owns a MinidumpMemoryRegion corresponding
+// to the thread's stack memory. MinidumpMemoryList also gives access to
+// memory regions in its list as MinidumpMemoryRegions. This class
+// adheres to MemoryRegion so that it may be used as a data provider to
+// the Stackwalker family of classes.
+class MinidumpMemoryRegion : public MinidumpObject,
+ public MemoryRegion {
+ public:
+ virtual ~MinidumpMemoryRegion();
+
+ static void set_max_bytes(uint32_t max_bytes) { max_bytes_ = max_bytes; }
+ static uint32_t max_bytes() { return max_bytes_; }
+
+ // Returns a pointer to the base of the memory region. Returns the
+ // cached value if available, otherwise, reads the minidump file and
+ // caches the memory region.
+ const uint8_t* GetMemory() const;
+
+ // The address of the base of the memory region.
+ uint64_t GetBase() const;
+
+ // The size, in bytes, of the memory region.
+ uint32_t GetSize() const;
+
+ // Frees the cached memory region, if cached.
+ void FreeMemory();
+
+ // Obtains the value of memory at the pointer specified by address.
+ bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const;
+ bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const;
+ bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const;
+ bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print() const;
+ void SetPrintMode(bool hexdump, unsigned int width);
+
+ protected:
+ explicit MinidumpMemoryRegion(Minidump* minidump);
+
+ private:
+ friend class MinidumpThread;
+ friend class MinidumpMemoryList;
+
+ // Identify the base address and size of the memory region, and the
+ // location it may be found in the minidump file.
+ void SetDescriptor(MDMemoryDescriptor* descriptor);
+
+ // Implementation for GetMemoryAtAddress
+ template<typename T> bool GetMemoryAtAddressInternal(uint64_t address,
+ T* value) const;
+
+ // Knobs for controlling display of memory printing.
+ bool hexdump_;
+ unsigned int hexdump_width_;
+
+ // The largest memory region that will be read from a minidump.
+ static uint32_t max_bytes_;
+
+ // Base address and size of the memory region, and its position in the
+ // minidump file.
+ MDMemoryDescriptor* descriptor_;
+
+ // Cached memory.
+ mutable vector<uint8_t>* memory_;
+};
+
+
+// MinidumpThread contains information about a thread of execution,
+// including a snapshot of the thread's stack and CPU context. For
+// the thread that caused an exception, the context carried by
+// MinidumpException is probably desired instead of the CPU context
+// provided here.
+// Note that a MinidumpThread may be valid() even if it does not
+// contain a memory region or context.
+class MinidumpThread : public MinidumpObject {
+ public:
+ virtual ~MinidumpThread();
+
+ const MDRawThread* thread() const { return valid_ ? &thread_ : NULL; }
+ // GetMemory may return NULL even if the MinidumpThread is valid,
+ // if the thread memory cannot be read.
+ virtual MinidumpMemoryRegion* GetMemory();
+ // Corresponds to win32's GetLastError function, which records the last
+ // error value set by the OS for this thread. A more useful error message
+ // can be produced by passing this value to FormatMessage:
+ //
+ // https://docs.microsoft.com/windows/win32/debug/retrieving-the-last-error-code
+ //
+ // The value may also be looked up in Microsoft's System Error Codes listing:
+ //
+ // https://docs.microsoft.com/windows/win32/debug/system-error-codes
+ virtual uint32_t GetLastError();
+ // GetContext may return NULL even if the MinidumpThread is valid.
+ virtual MinidumpContext* GetContext();
+
+ // The thread ID is used to determine if a thread is the exception thread,
+ // so a special getter is provided to retrieve this data from the
+ // MDRawThread structure. Returns false if the thread ID cannot be
+ // determined.
+ virtual bool GetThreadID(uint32_t *thread_id) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ // Returns the start address of the thread stack memory region. Returns 0 if
+ // MinidumpThread is invalid. Note that this method can be called even when
+ // the thread memory cannot be read and GetMemory returns NULL.
+ virtual uint64_t GetStartOfStackMemoryRange() const;
+
+ protected:
+ explicit MinidumpThread(Minidump* minidump);
+
+ private:
+ // These objects are managed by MinidumpThreadList.
+ friend class MinidumpThreadList;
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpThreadList. No size checking is done, because
+ // MinidumpThreadList handles that directly.
+ bool Read();
+
+ MDRawThread thread_;
+ MinidumpMemoryRegion* memory_;
+ MinidumpContext* context_;
+};
+
+
+// MinidumpThreadList contains all of the threads (as MinidumpThreads) in
+// a process.
+class MinidumpThreadList : public MinidumpStream {
+ public:
+ virtual ~MinidumpThreadList();
+
+ static void set_max_threads(uint32_t max_threads) {
+ max_threads_ = max_threads;
+ }
+ static uint32_t max_threads() { return max_threads_; }
+
+ virtual unsigned int thread_count() const {
+ return valid_ ? thread_count_ : 0;
+ }
+
+ // Sequential access to threads.
+ virtual MinidumpThread* GetThreadAtIndex(unsigned int index) const;
+
+ // Random access to threads.
+ MinidumpThread* GetThreadByID(uint32_t thread_id);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpThreadList(Minidump* aMinidump);
+
+ private:
+ friend class Minidump;
+
+ typedef map<uint32_t, MinidumpThread*> IDToThreadMap;
+ typedef vector<MinidumpThread> MinidumpThreads;
+
+ static const uint32_t kStreamType = MD_THREAD_LIST_STREAM;
+
+ bool Read(uint32_t aExpectedSize) override;
+
+ // The largest number of threads that will be read from a minidump. The
+ // default is 256.
+ static uint32_t max_threads_;
+
+ // Access to threads using the thread ID as the key.
+ IDToThreadMap id_to_thread_map_;
+
+ // The list of threads.
+ MinidumpThreads* threads_;
+ uint32_t thread_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpThreadList);
+};
+
+
+// MinidumpModule wraps MDRawModule, which contains information about loaded
+// code modules. Access is provided to various data referenced indirectly
+// by MDRawModule, such as the module's name and a specification for where
+// to locate debugging information for the module.
+class MinidumpModule : public MinidumpObject,
+ public CodeModule {
+ public:
+ virtual ~MinidumpModule();
+
+ static void set_max_cv_bytes(uint32_t max_cv_bytes) {
+ max_cv_bytes_ = max_cv_bytes;
+ }
+ static uint32_t max_cv_bytes() { return max_cv_bytes_; }
+
+ static void set_max_misc_bytes(uint32_t max_misc_bytes) {
+ max_misc_bytes_ = max_misc_bytes;
+ }
+ static uint32_t max_misc_bytes() { return max_misc_bytes_; }
+
+ const MDRawModule* module() const { return valid_ ? &module_ : NULL; }
+
+ // CodeModule implementation
+ virtual uint64_t base_address() const {
+ return valid_ ? module_.base_of_image : static_cast<uint64_t>(-1);
+ }
+ virtual uint64_t size() const { return valid_ ? module_.size_of_image : 0; }
+ virtual string code_file() const;
+ virtual string code_identifier() const;
+ virtual string debug_file() const;
+ virtual string debug_identifier() const;
+ virtual string version() const;
+ virtual CodeModule* Copy() const;
+ virtual bool is_unloaded() const { return false; }
+
+ // Getter and setter for shrink_down_delta. This is used when the address
+ // range for a module is shrunk down due to address range conflicts with
+ // other modules. The base_address and size fields are not updated and they
+ // should always reflect the original values (reported in the minidump).
+ virtual uint64_t shrink_down_delta() const;
+ virtual void SetShrinkDownDelta(uint64_t shrink_down_delta);
+
+ // The CodeView record, which contains information to locate the module's
+ // debugging information (pdb). This is returned as uint8_t* because
+ // the data can be of types MDCVInfoPDB20* or MDCVInfoPDB70*, or it may be
+ // of a type unknown to Breakpad, in which case the raw data will still be
+ // returned but no byte-swapping will have been performed. Check the
+ // record's signature in the first four bytes to differentiate between
+ // the various types. Current toolchains generate modules which carry
+ // MDCVInfoPDB70 by default. Returns a pointer to the CodeView record on
+ // success, and NULL on failure. On success, the optional |size| argument
+ // is set to the size of the CodeView record.
+ const uint8_t* GetCVRecord(uint32_t* size);
+
+ // The miscellaneous debug record, which is obsolete. Current toolchains
+ // do not generate this type of debugging information (dbg), and this
+ // field is not expected to be present. Returns a pointer to the debugging
+ // record on success, and NULL on failure. On success, the optional |size|
+ // argument is set to the size of the debugging record.
+ const MDImageDebugMisc* GetMiscRecord(uint32_t* size);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ // These objects are managed by MinidumpModuleList.
+ friend class MinidumpModuleList;
+
+ explicit MinidumpModule(Minidump* minidump);
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpModuleList. No size checking is done, because
+ // MinidumpModuleList handles that directly.
+ bool Read();
+
+ // Reads indirectly-referenced data, including the module name, CodeView
+ // record, and miscellaneous debugging record. This is necessary to allow
+ // MinidumpModuleList to fully construct MinidumpModule objects without
+ // requiring seeks to read a contiguous set of MinidumpModule objects.
+ // All auxiliary data should be available when Read is called, in order to
+ // allow the CodeModule getters to be const methods.
+ bool ReadAuxiliaryData();
+
+ // The largest number of bytes that will be read from a minidump for a
+ // CodeView record or miscellaneous debugging record, respectively. The
+ // default for each is 1024.
+ static uint32_t max_cv_bytes_;
+ static uint32_t max_misc_bytes_;
+
+ // True after a successful Read. This is different from valid_, which is
+ // not set true until ReadAuxiliaryData also completes successfully.
+ // module_valid_ is only used by ReadAuxiliaryData and the functions it
+ // calls to determine whether the object is ready for auxiliary data to
+ // be read.
+ bool module_valid_;
+
+ // True if debug info was read from the module. Certain modules
+ // may contain debug records in formats we don't support,
+ // so we can just set this to false to ignore them.
+ bool has_debug_info_;
+
+ MDRawModule module_;
+
+ // Cached module name.
+ const string* name_;
+
+ // Cached CodeView record - this is MDCVInfoPDB20 or (likely)
+ // MDCVInfoPDB70, or possibly something else entirely. Stored as a uint8_t
+ // because the structure contains a variable-sized string and its exact
+ // size cannot be known until it is processed.
+ vector<uint8_t>* cv_record_;
+
+ // If cv_record_ is present, cv_record_signature_ contains a copy of the
+ // CodeView record's first four bytes, for ease of determinining the
+ // type of structure that cv_record_ contains.
+ uint32_t cv_record_signature_;
+
+ // Cached MDImageDebugMisc (usually not present), stored as uint8_t
+ // because the structure contains a variable-sized string and its exact
+ // size cannot be known until it is processed.
+ vector<uint8_t>* misc_record_;
+};
+
+
+// MinidumpModuleList contains all of the loaded code modules for a process
+// in the form of MinidumpModules. It maintains a map of these modules
+// so that it may easily provide a code module corresponding to a specific
+// address.
+class MinidumpModuleList : public MinidumpStream,
+ public CodeModules {
+ public:
+ virtual ~MinidumpModuleList();
+
+ static void set_max_modules(uint32_t max_modules) {
+ max_modules_ = max_modules;
+ }
+ static uint32_t max_modules() { return max_modules_; }
+
+ // CodeModules implementation.
+ virtual unsigned int module_count() const {
+ return valid_ ? module_count_ : 0;
+ }
+ virtual const MinidumpModule* GetModuleForAddress(uint64_t address) const;
+ virtual const MinidumpModule* GetMainModule() const;
+ virtual const MinidumpModule* GetModuleAtSequence(
+ unsigned int sequence) const;
+ virtual const MinidumpModule* GetModuleAtIndex(unsigned int index) const;
+ virtual const CodeModules* Copy() const;
+
+ // Returns a vector of all modules which address ranges needed to be shrunk
+ // down due to address range conflicts with other modules.
+ virtual vector<linked_ptr<const CodeModule> > GetShrunkRangeModules() const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpModuleList(Minidump* minidump);
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpModule> MinidumpModules;
+
+ static const uint32_t kStreamType = MD_MODULE_LIST_STREAM;
+
+ bool Read(uint32_t expected_size);
+
+ bool StoreRange(const MinidumpModule& module,
+ uint64_t base_address,
+ uint32_t module_index,
+ uint32_t module_count,
+ bool is_android);
+
+ // The largest number of modules that will be read from a minidump. The
+ // default is 1024.
+ static uint32_t max_modules_;
+
+ // Access to modules using addresses as the key.
+ RangeMap<uint64_t, unsigned int> *range_map_;
+
+ MinidumpModules *modules_;
+ uint32_t module_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpModuleList);
+};
+
+
+// MinidumpMemoryList corresponds to a minidump's MEMORY_LIST_STREAM stream,
+// which references the snapshots of all of the memory regions contained
+// within the minidump. For a normal minidump, this includes stack memory
+// (also referenced by each MinidumpThread, in fact, the MDMemoryDescriptors
+// here and in MDRawThread both point to exactly the same data in a
+// minidump file, conserving space), as well as a 256-byte snapshot of memory
+// surrounding the instruction pointer in the case of an exception. Other
+// types of minidumps may contain significantly more memory regions. Full-
+// memory minidumps contain all of a process' mapped memory.
+class MinidumpMemoryList : public MinidumpStream {
+ public:
+ virtual ~MinidumpMemoryList();
+
+ static void set_max_regions(uint32_t max_regions) {
+ max_regions_ = max_regions;
+ }
+ static uint32_t max_regions() { return max_regions_; }
+
+ unsigned int region_count() const { return valid_ ? region_count_ : 0; }
+
+ // Sequential access to memory regions.
+ MinidumpMemoryRegion* GetMemoryRegionAtIndex(unsigned int index);
+
+ // Random access to memory regions. Returns the region encompassing
+ // the address identified by address.
+ virtual MinidumpMemoryRegion* GetMemoryRegionForAddress(uint64_t address);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+ friend class MockMinidumpMemoryList;
+
+ typedef vector<MDMemoryDescriptor> MemoryDescriptors;
+ typedef vector<MinidumpMemoryRegion> MemoryRegions;
+
+ static const uint32_t kStreamType = MD_MEMORY_LIST_STREAM;
+
+ explicit MinidumpMemoryList(Minidump* minidump);
+
+ bool Read(uint32_t expected_size) override;
+
+ // The largest number of memory regions that will be read from a minidump.
+ // The default is 256.
+ static uint32_t max_regions_;
+
+ // Access to memory regions using addresses as the key.
+ RangeMap<uint64_t, unsigned int> *range_map_;
+
+ // The list of descriptors. This is maintained separately from the list
+ // of regions, because MemoryRegion doesn't own its MemoryDescriptor, it
+ // maintains a pointer to it. descriptors_ provides the storage for this
+ // purpose.
+ MemoryDescriptors *descriptors_;
+
+ // The list of regions.
+ MemoryRegions *regions_;
+ uint32_t region_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryList);
+};
+
+
+// MinidumpException wraps MDRawExceptionStream, which contains information
+// about the exception that caused the minidump to be generated, if the
+// minidump was generated in an exception handler called as a result of an
+// exception. It also provides access to a MinidumpContext object, which
+// contains the CPU context for the exception thread at the time the exception
+// occurred.
+class MinidumpException : public MinidumpStream {
+ public:
+ virtual ~MinidumpException();
+
+ const MDRawExceptionStream* exception() const {
+ return valid_ ? &exception_ : NULL;
+ }
+
+ // The thread ID is used to determine if a thread is the exception thread,
+ // so a special getter is provided to retrieve this data from the
+ // MDRawExceptionStream structure. Returns false if the thread ID cannot
+ // be determined.
+ bool GetThreadID(uint32_t *thread_id) const;
+
+ MinidumpContext* GetContext();
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MD_EXCEPTION_STREAM;
+
+ explicit MinidumpException(Minidump* minidump);
+
+ bool Read(uint32_t expected_size) override;
+
+ MDRawExceptionStream exception_;
+ MinidumpContext* context_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpException);
+};
+
+// MinidumpAssertion wraps MDRawAssertionInfo, which contains information
+// about an assertion that caused the minidump to be generated.
+class MinidumpAssertion : public MinidumpStream {
+ public:
+ virtual ~MinidumpAssertion();
+
+ const MDRawAssertionInfo* assertion() const {
+ return valid_ ? &assertion_ : NULL;
+ }
+
+ string expression() const {
+ return valid_ ? expression_ : "";
+ }
+
+ string function() const {
+ return valid_ ? function_ : "";
+ }
+
+ string file() const {
+ return valid_ ? file_ : "";
+ }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MD_ASSERTION_INFO_STREAM;
+
+ explicit MinidumpAssertion(Minidump* minidump);
+
+ bool Read(uint32_t expected_size) override;
+
+ MDRawAssertionInfo assertion_;
+ string expression_;
+ string function_;
+ string file_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpAssertion);
+};
+
+
+// MinidumpSystemInfo wraps MDRawSystemInfo and provides information about
+// the system on which the minidump was generated. See also MinidumpMiscInfo.
+class MinidumpSystemInfo : public MinidumpStream {
+ public:
+ virtual ~MinidumpSystemInfo();
+
+ const MDRawSystemInfo* system_info() const {
+ return valid_ ? &system_info_ : NULL;
+ }
+
+ // GetOS and GetCPU return textual representations of the operating system
+ // and CPU that produced the minidump. Unlike most other Minidump* methods,
+ // they return string objects, not weak pointers. Defined values for
+ // GetOS() are "mac", "windows", and "linux". Defined values for GetCPU
+ // are "x86" and "ppc". These methods return an empty string when their
+ // values are unknown.
+ string GetOS();
+ string GetCPU();
+
+ // I don't know what CSD stands for, but this field is documented as
+ // returning a textual representation of the OS service pack. On other
+ // platforms, this provides additional information about an OS version
+ // level beyond major.minor.micro. Returns NULL if unknown.
+ const string* GetCSDVersion();
+
+ // If a CPU vendor string can be determined, returns a pointer to it,
+ // otherwise, returns NULL. CPU vendor strings can be determined from
+ // x86 CPUs with CPUID 0.
+ const string* GetCPUVendor();
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpSystemInfo(Minidump* minidump);
+ MDRawSystemInfo system_info_;
+
+ // Textual representation of the OS service pack, for minidumps produced
+ // by MiniDumpWriteDump on Windows.
+ const string* csd_version_;
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MD_SYSTEM_INFO_STREAM;
+
+ bool Read(uint32_t expected_size) override;
+
+ // A string identifying the CPU vendor, if known.
+ const string* cpu_vendor_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpSystemInfo);
+};
+
+
+// MinidumpUnloadedModule wraps MDRawUnloadedModule
+class MinidumpUnloadedModule : public MinidumpObject,
+ public CodeModule {
+ public:
+ ~MinidumpUnloadedModule() override;
+
+ const MDRawUnloadedModule* module() const {
+ return valid_ ? &unloaded_module_ : NULL;
+ }
+
+ // CodeModule implementation
+ uint64_t base_address() const override {
+ return valid_ ? unloaded_module_.base_of_image : 0;
+ }
+ uint64_t size() const override {
+ return valid_ ? unloaded_module_.size_of_image : 0;
+ }
+ string code_file() const override;
+ string code_identifier() const override;
+ string debug_file() const override;
+ string debug_identifier() const override;
+ string version() const override;
+ CodeModule* Copy() const override;
+ bool is_unloaded() const override { return true; }
+ uint64_t shrink_down_delta() const override;
+ void SetShrinkDownDelta(uint64_t shrink_down_delta) override;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpUnloadedModule(Minidump* minidump);
+
+ private:
+ // These objects are managed by MinidumpUnloadedModuleList
+ friend class MinidumpUnloadedModuleList;
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpUnloadedModuleList.
+ bool Read(uint32_t expected_size);
+
+ // Reads the module name. This is done separately from Read to
+ // allow contiguous reading of code modules by MinidumpUnloadedModuleList.
+ bool ReadAuxiliaryData();
+
+ // True after a successful Read. This is different from valid_, which
+ // is not set true until ReadAuxiliaryData also completes successfully.
+ // module_valid_ is only used by ReadAuxiliaryData and the functions it
+ // calls to determine whether the object is ready for auxiliary data to
+ // be read.
+ bool module_valid_;
+
+ MDRawUnloadedModule unloaded_module_;
+
+ // Cached module name
+ const string* name_;
+};
+
+
+// MinidumpUnloadedModuleList contains all the unloaded code modules for a
+// process in the form of MinidumpUnloadedModules. It maintains a map of
+// these modules so that it may easily provide a code module corresponding
+// to a specific address. If multiple modules in the list have identical
+// ranges, only the first module encountered is recorded in the range map.
+class MinidumpUnloadedModuleList : public MinidumpStream,
+ public CodeModules {
+ public:
+ ~MinidumpUnloadedModuleList() override;
+
+ static void set_max_modules(uint32_t max_modules) {
+ max_modules_ = max_modules;
+ }
+ static uint32_t max_modules() { return max_modules_; }
+
+ // CodeModules implementation.
+ unsigned int module_count() const override {
+ return valid_ ? module_count_ : 0;
+ }
+ const MinidumpUnloadedModule*
+ GetModuleForAddress(uint64_t address) const override;
+ const MinidumpUnloadedModule* GetMainModule() const override;
+ const MinidumpUnloadedModule*
+ GetModuleAtSequence(unsigned int sequence) const override;
+ const MinidumpUnloadedModule*
+ GetModuleAtIndex(unsigned int index) const override;
+ const CodeModules* Copy() const override;
+ vector<linked_ptr<const CodeModule>> GetShrunkRangeModules() const override;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpUnloadedModuleList(Minidump* minidump_);
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpUnloadedModule> MinidumpUnloadedModules;
+
+ static const uint32_t kStreamType = MD_UNLOADED_MODULE_LIST_STREAM;
+
+ bool Read(uint32_t expected_size_) override;
+
+ // The largest number of modules that will be read from a minidump. The
+ // default is 1024.
+ static uint32_t max_modules_;
+
+ // Access to module indices using addresses as the key.
+ RangeMap<uint64_t, unsigned int> *range_map_;
+
+ MinidumpUnloadedModules *unloaded_modules_;
+ uint32_t module_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpUnloadedModuleList);
+};
+
+
+// MinidumpMiscInfo wraps MDRawMiscInfo and provides information about
+// the process that generated the minidump, and optionally additional system
+// information. See also MinidumpSystemInfo.
+class MinidumpMiscInfo : public MinidumpStream {
+ public:
+ const MDRawMiscInfo* misc_info() const {
+ return valid_ ? &misc_info_ : NULL;
+ }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+ friend class TestMinidumpMiscInfo;
+
+ static const uint32_t kStreamType = MD_MISC_INFO_STREAM;
+
+ explicit MinidumpMiscInfo(Minidump* minidump_);
+
+ bool Read(uint32_t expected_size_) override;
+
+ MDRawMiscInfo misc_info_;
+
+ // Populated by Read. Contains the converted strings from the corresponding
+ // UTF-16 fields in misc_info_
+ string standard_name_;
+ string daylight_name_;
+ string build_string_;
+ string dbg_bld_str_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpMiscInfo);
+};
+
+
+// MinidumpBreakpadInfo wraps MDRawBreakpadInfo, which is an optional stream in
+// a minidump that provides additional information about the process state
+// at the time the minidump was generated.
+class MinidumpBreakpadInfo : public MinidumpStream {
+ public:
+ const MDRawBreakpadInfo* breakpad_info() const {
+ return valid_ ? &breakpad_info_ : NULL;
+ }
+
+ // These thread IDs are used to determine if threads deserve special
+ // treatment, so special getters are provided to retrieve this data from
+ // the MDRawBreakpadInfo structure. The getters return false if the thread
+ // IDs cannot be determined.
+ bool GetDumpThreadID(uint32_t *thread_id) const;
+ bool GetRequestingThreadID(uint32_t *thread_id) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MD_BREAKPAD_INFO_STREAM;
+
+ explicit MinidumpBreakpadInfo(Minidump* minidump_);
+
+ bool Read(uint32_t expected_size_) override;
+
+ MDRawBreakpadInfo breakpad_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpBreakpadInfo);
+};
+
+// MinidumpMemoryInfo wraps MDRawMemoryInfo, which provides information
+// about mapped memory regions in a process, including their ranges
+// and protection.
+class MinidumpMemoryInfo : public MinidumpObject {
+ public:
+ const MDRawMemoryInfo* info() const { return valid_ ? &memory_info_ : NULL; }
+
+ // The address of the base of the memory region.
+ uint64_t GetBase() const { return valid_ ? memory_info_.base_address : 0; }
+
+ // The size, in bytes, of the memory region.
+ uint64_t GetSize() const { return valid_ ? memory_info_.region_size : 0; }
+
+ // Return true if the memory protection allows execution.
+ bool IsExecutable() const;
+
+ // Return true if the memory protection allows writing.
+ bool IsWritable() const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ // These objects are managed by MinidumpMemoryInfoList.
+ friend class MinidumpMemoryInfoList;
+
+ explicit MinidumpMemoryInfo(Minidump* minidump_);
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpMemoryInfoList. No size checking is done, because
+ // MinidumpMemoryInfoList handles that directly.
+ bool Read();
+
+ MDRawMemoryInfo memory_info_;
+};
+
+// MinidumpMemoryInfoList contains a list of information about
+// mapped memory regions for a process in the form of MDRawMemoryInfo.
+// It maintains a map of these structures so that it may easily provide
+// info corresponding to a specific address.
+class MinidumpMemoryInfoList : public MinidumpStream {
+ public:
+ virtual ~MinidumpMemoryInfoList();
+
+ unsigned int info_count() const { return valid_ ? info_count_ : 0; }
+
+ const MinidumpMemoryInfo* GetMemoryInfoForAddress(uint64_t address) const;
+ const MinidumpMemoryInfo* GetMemoryInfoAtIndex(unsigned int index) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpMemoryInfo> MinidumpMemoryInfos;
+
+ static const uint32_t kStreamType = MD_MEMORY_INFO_LIST_STREAM;
+
+ explicit MinidumpMemoryInfoList(Minidump* minidump_);
+
+ bool Read(uint32_t expected_size) override;
+
+ // Access to memory info using addresses as the key.
+ RangeMap<uint64_t, unsigned int> *range_map_;
+
+ MinidumpMemoryInfos* infos_;
+ uint32_t info_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryInfoList);
+};
+
+// MinidumpLinuxMaps wraps information about a single mapped memory region
+// from /proc/self/maps.
+class MinidumpLinuxMaps : public MinidumpObject {
+ public:
+ // The memory address of the base of the mapped region.
+ uint64_t GetBase() const { return valid_ ? region_.start : 0; }
+ // The size of the mapped region.
+ uint64_t GetSize() const { return valid_ ? region_.end - region_.start : 0; }
+
+ // The permissions of the mapped region.
+ bool IsReadable() const {
+ return valid_ ? region_.permissions & MappedMemoryRegion::READ : false;
+ }
+ bool IsWriteable() const {
+ return valid_ ? region_.permissions & MappedMemoryRegion::WRITE : false;
+ }
+ bool IsExecutable() const {
+ return valid_ ? region_.permissions & MappedMemoryRegion::EXECUTE : false;
+ }
+ bool IsPrivate() const {
+ return valid_ ? region_.permissions & MappedMemoryRegion::PRIVATE : false;
+ }
+
+ // The offset of the mapped region.
+ uint64_t GetOffset() const { return valid_ ? region_.offset : 0; }
+
+ // The major device number.
+ uint8_t GetMajorDevice() const { return valid_ ? region_.major_device : 0; }
+ // The minor device number.
+ uint8_t GetMinorDevice() const { return valid_ ? region_.minor_device : 0; }
+
+ // The inode of the mapped region.
+ uint64_t GetInode() const { return valid_ ? region_.inode : 0; }
+
+ // The pathname of the mapped region.
+ const string GetPathname() const { return valid_ ? region_.path : ""; }
+
+ // Print the contents of this mapping.
+ void Print() const;
+
+ private:
+ // These objects are managed by MinidumpLinuxMapsList.
+ friend class MinidumpLinuxMapsList;
+
+ // This caller owns the pointer.
+ explicit MinidumpLinuxMaps(Minidump *minidump);
+
+ // The memory region struct that this class wraps.
+ MappedMemoryRegion region_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMaps);
+};
+
+// MinidumpLinuxMapsList corresponds to the Linux-exclusive MD_LINUX_MAPS
+// stream, which contains the contents of /prod/self/maps, which contains
+// the mapped memory regions and their access permissions.
+class MinidumpLinuxMapsList : public MinidumpStream {
+ public:
+ virtual ~MinidumpLinuxMapsList();
+
+ // Get number of mappings.
+ unsigned int get_maps_count() const { return valid_ ? maps_count_ : 0; }
+
+ // Get mapping at the given memory address. The caller owns the pointer.
+ const MinidumpLinuxMaps *GetLinuxMapsForAddress(uint64_t address) const;
+ // Get mapping at the given index. The caller owns the pointer.
+ const MinidumpLinuxMaps *GetLinuxMapsAtIndex(unsigned int index) const;
+
+ // Print the contents of /proc/self/maps to stdout.
+ void Print() const;
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpLinuxMaps *> MinidumpLinuxMappings;
+
+ static const uint32_t kStreamType = MD_LINUX_MAPS;
+
+ // The caller owns the pointer.
+ explicit MinidumpLinuxMapsList(Minidump *minidump);
+
+ // Read and load the contents of the process mapping data.
+ // The stream should have data in the form of /proc/self/maps.
+ // This method returns whether the stream was read successfully.
+ bool Read(uint32_t expected_size) override;
+
+ // The list of individual mappings.
+ MinidumpLinuxMappings *maps_;
+ // The number of mappings.
+ uint32_t maps_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMapsList);
+};
+
+// MinidumpCrashpadInfo wraps MDRawCrashpadInfo, which is an optional stream in
+// a minidump that provides additional information about the process state
+// at the time the minidump was generated.
+class MinidumpCrashpadInfo : public MinidumpStream {
+ public:
+ const MDRawCrashpadInfo* crashpad_info() const {
+ return valid_ ? &crashpad_info_ : NULL;
+ }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MD_CRASHPAD_INFO_STREAM;
+
+ explicit MinidumpCrashpadInfo(Minidump* minidump_);
+
+ bool Read(uint32_t expected_size);
+
+ MDRawCrashpadInfo crashpad_info_;
+ std::vector<uint32_t> module_crashpad_info_links_;
+ std::vector<MDRawModuleCrashpadInfo> module_crashpad_info_;
+ std::vector<std::vector<std::string>> module_crashpad_info_list_annotations_;
+ std::vector<std::map<std::string, std::string>>
+ module_crashpad_info_simple_annotations_;
+ std::map<std::string, std::string> simple_annotations_;
+};
+
+// MinidumpMacCrashInfo wraps MDRawMacCrashInfo. It's an optional stream
+// in a minidump that records information from the __DATA,__crash_info
+// section of every module in the crashing process that contains one, and
+// which isn't empty of useful information. Only present on macOS.
+
+// Friendly wrapper for the information in MDRawMacCrashInfoRecord.
+typedef struct crash_info_record {
+ string module_path;
+ unsigned long version;
+ string message;
+ string signature_string;
+ string backtrace;
+ string message2;
+ unsigned long long thread;
+ unsigned int dialog_mode;
+ long long abort_cause; // Only valid when 'version' > 4
+ crash_info_record()
+ : version(0), thread(0), dialog_mode(0), abort_cause(0)
+ {}
+} crash_info_record_t;
+
+class MinidumpMacCrashInfo : public MinidumpStream {
+ public:
+ // A human-readable representation of the data from the __DATA,__crash_info
+ // sections in all of the crashing process's modules that have one, if
+ // it's not empty of useful data. Suitable for use by "minidump_stackwalk".
+ string description() const { return description_; }
+ // A "machine-readable" copy of the same information, suitable for use by
+ // "minidump_stalkwalk -m".
+ vector<crash_info_record_t> const records() {
+ return records_;
+ }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const uint32_t kStreamType = MOZ_MACOS_CRASH_INFO_STREAM;
+
+ explicit MinidumpMacCrashInfo(Minidump* minidump_);
+
+ bool ReadCrashInfoRecord(MDLocationDescriptor location,
+ uint32_t record_start_size);
+ bool Read(uint32_t expected_size);
+
+ string description_;
+ vector<crash_info_record_t> records_;
+};
+
+// MinidumpThreadName wraps MDRawThreadName
+class MinidumpThreadName : public MinidumpObject {
+ public:
+ ~MinidumpThreadName() override;
+
+ const MDRawThreadName* thread_name() const {
+ if (valid_) {
+ return &thread_name_;
+ }
+
+ return NULL;
+ }
+
+ uint32_t thread_id() const {
+ if (valid_) {
+ return thread_name_.thread_id;
+ }
+
+ return 0;
+ }
+
+ string name() const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpThreadName(Minidump* minidump);
+
+ private:
+ // These objects are managed by MinidumpThreadNameList
+ friend class MinidumpThreadNamesList;
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpThreadNameList.
+ bool Read(uint32_t expected_size);
+
+ // Reads the thread name. This is done separately from Read to
+ // allow contiguous reading of thread names by MinidumpThreadNameList.
+ bool ReadAuxiliaryData();
+
+ bool valid_;
+ MDRawThreadName thread_name_;
+ const string* name_;
+};
+
+
+// MinidumpThreadNamesList contains all the names for threads in a process
+// in the form of MinidumpThreadNames.
+class MinidumpThreadNamesList : public MinidumpStream {
+ public:
+ ~MinidumpThreadNamesList() override;
+
+ unsigned int name_count() const {
+ return valid_ ? name_count_ : 0;
+ }
+
+ const string GetNameForThreadId(uint32_t thread_id) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ protected:
+ explicit MinidumpThreadNamesList(Minidump* minidump_);
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpThreadName> MinidumpThreadNames;
+
+ static const uint32_t kStreamType = MD_THREAD_NAMES_STREAM;
+
+ bool Read(uint32_t expected_size_) override;
+
+ MinidumpThreadNames* thread_names_;
+ uint32_t name_count_;
+ bool valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinidumpThreadNamesList);
+};
+
+// Minidump is the user's interface to a minidump file. It wraps MDRawHeader
+// and provides access to the minidump's top-level stream directory.
+class Minidump {
+ public:
+ // path is the pathname of a file containing the minidump.
+ explicit Minidump(const string& path,
+ bool hexdump=false,
+ unsigned int hexdump_width=16);
+ // input is an istream wrapping minidump data. Minidump holds a
+ // weak pointer to input, and the caller must ensure that the stream
+ // is valid as long as the Minidump object is.
+ explicit Minidump(std::istream& input);
+
+ virtual ~Minidump();
+
+ // path may be empty if the minidump was not opened from a file
+ virtual string path() const {
+ return path_;
+ }
+ static void set_max_streams(uint32_t max_streams) {
+ max_streams_ = max_streams;
+ }
+ static uint32_t max_streams() { return max_streams_; }
+
+ static void set_max_string_length(uint32_t max_string_length) {
+ max_string_length_ = max_string_length;
+ }
+ static uint32_t max_string_length() { return max_string_length_; }
+
+ virtual const MDRawHeader* header() const { return valid_ ? &header_ : NULL; }
+
+ // Reads the CPU information from the system info stream and generates the
+ // appropriate CPU flags. The returned context_cpu_flags are the same as
+ // if the CPU type bits were set in the context_flags of a context record.
+ // On success, context_cpu_flags will have the flags that identify the CPU.
+ // If a system info stream is missing, context_cpu_flags will be 0.
+ // Returns true if the current position in the stream was not changed.
+ // Returns false when the current location in the stream was changed and the
+ // attempt to restore the original position failed.
+ bool GetContextCPUFlagsFromSystemInfo(uint32_t* context_cpu_flags);
+
+ // Reads the minidump file's header and top-level stream directory.
+ // The minidump is expected to be positioned at the beginning of the
+ // header. Read() sets up the stream list and map, and validates the
+ // Minidump object.
+ virtual bool Read();
+
+ // The next set of methods are stubs that call GetStream. They exist to
+ // force code generation of the templatized API within the module, and
+ // to avoid exposing an ugly API (GetStream needs to accept a garbage
+ // parameter).
+ virtual MinidumpThreadList* GetThreadList();
+ virtual MinidumpModuleList* GetModuleList();
+ virtual MinidumpMemoryList* GetMemoryList();
+ virtual MinidumpException* GetException();
+ virtual MinidumpAssertion* GetAssertion();
+ virtual MinidumpSystemInfo* GetSystemInfo();
+ virtual MinidumpUnloadedModuleList* GetUnloadedModuleList();
+ virtual MinidumpMiscInfo* GetMiscInfo();
+ virtual MinidumpBreakpadInfo* GetBreakpadInfo();
+ virtual MinidumpMemoryInfoList* GetMemoryInfoList();
+ MinidumpCrashpadInfo* GetCrashpadInfo();
+ MinidumpMacCrashInfo* GetMacCrashInfo();
+ MinidumpThreadNamesList* GetThreadNamesList();
+
+ // The next method also calls GetStream, but is exclusive for Linux dumps.
+ virtual MinidumpLinuxMapsList *GetLinuxMapsList();
+
+ // The next set of methods are provided for users who wish to access
+ // data in minidump files directly, while leveraging the rest of
+ // this class and related classes to handle the basic minidump
+ // structure and known stream types.
+
+ unsigned int GetDirectoryEntryCount() const {
+ return valid_ ? header_.stream_count : 0;
+ }
+ const MDRawDirectory* GetDirectoryEntryAtIndex(unsigned int index) const;
+
+ // The next 2 methods are lower-level I/O routines. They use fd_.
+
+ // Reads count bytes from the minidump at the current position into
+ // the storage area pointed to by bytes. bytes must be of sufficient
+ // size. After the read, the file position is advanced by count.
+ bool ReadBytes(void* bytes, size_t count);
+
+ // Sets the position of the minidump file to offset.
+ bool SeekSet(off_t offset);
+
+ // Returns the current position of the minidump file.
+ off_t Tell();
+
+ // Medium-level I/O routines.
+
+ // ReadString returns a string which is owned by the caller! offset
+ // specifies the offset that a length-encoded string is stored at in the
+ // minidump file.
+ string* ReadString(off_t offset);
+
+ bool ReadUTF8String(off_t offset, string* string_utf8);
+
+ bool ReadStringList(off_t offset, std::vector<std::string>* string_list);
+
+ bool ReadSimpleStringDictionary(
+ off_t offset,
+ std::map<std::string, std::string>* simple_string_dictionary);
+
+ // SeekToStreamType positions the file at the beginning of a stream
+ // identified by stream_type, and informs the caller of the stream's
+ // length by setting *stream_length. Because stream_map maps each stream
+ // type to only one stream in the file, this might mislead the user into
+ // thinking that the stream that this seeks to is the only stream with
+ // type stream_type. That can't happen for streams that these classes
+ // deal with directly, because they're only supposed to be present in the
+ // file singly, and that's verified when stream_map_ is built. Users who
+ // are looking for other stream types should be aware of this
+ // possibility, and consider using GetDirectoryEntryAtIndex (possibly
+ // with GetDirectoryEntryCount) if expecting multiple streams of the same
+ // type in a single minidump file.
+ bool SeekToStreamType(uint32_t stream_type, uint32_t* stream_length);
+
+ bool swap() const { return valid_ ? swap_ : false; }
+
+ bool is_big_endian() const { return valid_ ? is_big_endian_ : false; }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ // Is the OS Android.
+ bool IsAndroid();
+
+ // Determines the platform where the minidump was produced. |platform| is
+ // valid iff this method returns true.
+ bool GetPlatform(MDOSPlatform* platform);
+
+ // Get current hexdump display settings.
+ unsigned int HexdumpMode() const { return hexdump_ ? hexdump_width_ : 0; }
+
+ private:
+ // MinidumpStreamInfo is used in the MinidumpStreamMap. It lets
+ // the Minidump object locate interesting streams quickly, and
+ // provides a convenient place to stash MinidumpStream objects.
+ struct MinidumpStreamInfo {
+ MinidumpStreamInfo() : stream_index(0), stream(NULL) {}
+ ~MinidumpStreamInfo() { delete stream; }
+
+ // Index into the MinidumpDirectoryEntries vector
+ unsigned int stream_index;
+
+ // Pointer to the stream if cached, or NULL if not yet populated
+ MinidumpStream* stream;
+ };
+
+ typedef vector<MDRawDirectory> MinidumpDirectoryEntries;
+ typedef map<uint32_t, MinidumpStreamInfo> MinidumpStreamMap;
+
+ template<typename T> T* GetStream(T** stream);
+
+ // Opens the minidump file, or if already open, seeks to the beginning.
+ bool Open();
+
+ // The largest number of top-level streams that will be read from a minidump.
+ // Note that streams are only read (and only consume memory) as needed,
+ // when directed by the caller. The default is 128.
+ static uint32_t max_streams_;
+
+ // The maximum length of a UTF-16 string that will be read from a minidump
+ // in 16-bit words. The default is 1024. UTF-16 strings are converted
+ // to UTF-8 when stored in memory, and each UTF-16 word will be represented
+ // by as many as 3 bytes in UTF-8.
+ static unsigned int max_string_length_;
+
+ MDRawHeader header_;
+
+ // The list of streams.
+ MinidumpDirectoryEntries* directory_;
+
+ // Access to streams using the stream type as the key.
+ MinidumpStreamMap* stream_map_;
+
+ // The pathname of the minidump file to process, set in the constructor.
+ // This may be empty if the minidump was opened directly from a stream.
+ const string path_;
+
+ // The stream for all file I/O. Used by ReadBytes and SeekSet.
+ // Set based on the path in Open, or directly in the constructor.
+ std::istream* stream_;
+
+ // swap_ is true if the minidump file should be byte-swapped. If the
+ // minidump was produced by a CPU that is other-endian than the CPU
+ // processing the minidump, this will be true. If the two CPUs are
+ // same-endian, this will be false.
+ bool swap_;
+
+ // true if the minidump was produced by a big-endian cpu.
+ bool is_big_endian_;
+
+ // Validity of the Minidump structure, false immediately after
+ // construction or after a failed Read(); true following a successful
+ // Read().
+ bool valid_;
+
+ // Knobs for controlling display of memory printing.
+ bool hexdump_;
+ unsigned int hexdump_width_;
+
+ DISALLOW_COPY_AND_ASSIGN(Minidump);
+};
+
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump_processor.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump_processor.h
new file mode 100644
index 0000000000..387115ef71
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/minidump_processor.h
@@ -0,0 +1,147 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
+
+#include <assert.h>
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/process_result.h"
+
+namespace google_breakpad {
+
+class Minidump;
+class ProcessState;
+class StackFrameSymbolizer;
+class SourceLineResolverInterface;
+class SymbolSupplier;
+struct SystemInfo;
+
+class MinidumpProcessor {
+ public:
+ // Initializes this MinidumpProcessor. supplier should be an
+ // implementation of the SymbolSupplier abstract base class.
+ MinidumpProcessor(SymbolSupplier* supplier,
+ SourceLineResolverInterface* resolver);
+
+ // Initializes the MinidumpProcessor with the option of
+ // enabling the exploitability framework to analyze dumps
+ // for probable security relevance.
+ MinidumpProcessor(SymbolSupplier* supplier,
+ SourceLineResolverInterface* resolver,
+ bool enable_exploitability);
+
+ // Initializes the MinidumpProcessor with source line resolver helper, and
+ // the option of enabling the exploitability framework to analyze dumps
+ // for probable security relevance.
+ // Does not take ownership of resolver_helper, which must NOT be NULL.
+ MinidumpProcessor(StackFrameSymbolizer* stack_frame_symbolizer,
+ bool enable_exploitability);
+
+ ~MinidumpProcessor();
+
+ // Processes the minidump file and fills process_state with the result.
+ ProcessResult Process(const string &minidump_file,
+ ProcessState* process_state);
+
+ // Processes the minidump structure and fills process_state with the
+ // result.
+ ProcessResult Process(Minidump* minidump,
+ ProcessState* process_state);
+ // Populates the cpu_* fields of the |info| parameter with textual
+ // representations of the CPU type that the minidump in |dump| was
+ // produced on. Returns false if this information is not available in
+ // the minidump.
+ static bool GetCPUInfo(Minidump* dump, SystemInfo* info);
+
+ // Populates the os_* fields of the |info| parameter with textual
+ // representations of the operating system that the minidump in |dump|
+ // was produced on. Returns false if this information is not available in
+ // the minidump.
+ static bool GetOSInfo(Minidump* dump, SystemInfo* info);
+
+ // Populates the |process_create_time| parameter with the create time of the
+ // crashed process. Returns false if this information is not available in
+ // the minidump |dump|.
+ static bool GetProcessCreateTime(Minidump* dump,
+ uint32_t* process_create_time);
+
+ // Returns a textual representation of the reason that a crash occurred,
+ // if the minidump in dump was produced as a result of a crash. Returns
+ // an empty string if this information cannot be determined. If address
+ // is non-NULL, it will be set to contain the address that caused the
+ // exception, if this information is available. This will be a code
+ // address when the crash was caused by problems such as illegal
+ // instructions or divisions by zero, or a data address when the crash
+ // was caused by a memory access violation.
+ static string GetCrashReason(Minidump* dump, uint64_t* address);
+
+ // This function returns true if the passed-in error code is
+ // something unrecoverable(i.e. retry should not happen). For
+ // instance, if the minidump is corrupt, then it makes no sense to
+ // retry as we won't be able to glean additional information.
+ // However, as an example of the other case, the symbol supplier can
+ // return an error code indicating it was 'interrupted', which can
+ // happen of the symbols are fetched from a remote store, and a
+ // retry might be successful later on.
+ // You should not call this method with PROCESS_OK! Test for
+ // that separately before calling this.
+ static bool IsErrorUnrecoverable(ProcessResult p) {
+ assert(p != PROCESS_OK);
+ return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED);
+ }
+
+ // Returns a textual representation of an assertion included
+ // in the minidump. Returns an empty string if this information
+ // does not exist or cannot be determined.
+ static string GetAssertion(Minidump* dump);
+
+ void set_enable_objdump(bool enabled) { enable_objdump_ = enabled; }
+
+ private:
+ StackFrameSymbolizer* frame_symbolizer_;
+ // Indicate whether resolver_helper_ is owned by this instance.
+ bool own_frame_symbolizer_;
+
+ // This flag enables the exploitability scanner which attempts to
+ // guess how likely it is that the crash represents an exploitable
+ // memory corruption issue.
+ bool enable_exploitability_;
+
+ // This flag permits the exploitability scanner to shell out to objdump
+ // for purposes of disassembly.
+ bool enable_objdump_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/proc_maps_linux.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/proc_maps_linux.h
new file mode 100644
index 0000000000..3045daa5f6
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/proc_maps_linux.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_DEBUG_PROC_MAPS_LINUX_H_
+#define BASE_DEBUG_PROC_MAPS_LINUX_H_
+
+#include <string>
+#include <vector>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+// Describes a region of mapped memory and the path of the file mapped.
+struct MappedMemoryRegion {
+ enum Permission {
+ READ = 1 << 0,
+ WRITE = 1 << 1,
+ EXECUTE = 1 << 2,
+ PRIVATE = 1 << 3, // If set, region is private, otherwise it is shared.
+ };
+
+ // The address range [start,end) of mapped memory.
+ uint64_t start;
+ uint64_t end;
+
+ // Byte offset into |path| of the range mapped into memory.
+ uint64_t offset;
+
+ // Bitmask of read/write/execute/private/shared permissions.
+ uint8_t permissions;
+
+ // Major and minor devices.
+ uint8_t major_device;
+ uint8_t minor_device;
+
+ // Value of the inode.
+ uint64_t inode;
+
+ // Name of the file mapped into memory.
+ //
+ // NOTE: path names aren't guaranteed to point at valid files. For example,
+ // "[heap]" and "[stack]" are used to represent the location of the process'
+ // heap and stack, respectively.
+ string path;
+
+ // The line from /proc/<pid>/maps that this struct represents.
+ string line;
+};
+
+// Parses /proc/<pid>/maps input data and stores in |regions|. Returns true
+// and updates |regions| if and only if all of |input| was successfully parsed.
+bool ParseProcMaps(const string& input,
+ std::vector<MappedMemoryRegion>* regions);
+
+} // namespace google_breakpad
+
+#endif // BASE_DEBUG_PROC_MAPS_LINUX_H_
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_result.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_result.h
new file mode 100644
index 0000000000..15c7213e9b
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_result.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2014, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_PROCESS_RESULT_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_PROCESS_RESULT_H__
+
+namespace google_breakpad {
+
+// Return type for MinidumpProcessor or MicrodumpProcessor's Process()
+enum ProcessResult {
+ PROCESS_OK, // The dump was processed
+ // successfully.
+
+ PROCESS_ERROR_MINIDUMP_NOT_FOUND, // The minidump file was not
+ // found.
+
+ PROCESS_ERROR_NO_MINIDUMP_HEADER, // The minidump file had no
+ // header.
+
+ PROCESS_ERROR_NO_THREAD_LIST, // The minidump file has no
+ // thread list.
+
+ PROCESS_ERROR_GETTING_THREAD, // There was an error getting one
+ // thread's data from th dump.
+
+ PROCESS_ERROR_GETTING_THREAD_ID, // There was an error getting a
+ // thread id from the thread's
+ // data.
+
+ PROCESS_ERROR_DUPLICATE_REQUESTING_THREADS, // There was more than one
+ // requesting thread.
+
+ PROCESS_SYMBOL_SUPPLIER_INTERRUPTED // The dump processing was
+ // interrupted by the
+ // SymbolSupplier(not fatal).
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_PROCESS_RESULT_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_state.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_state.h
new file mode 100644
index 0000000000..37b208ecbe
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/process_state.h
@@ -0,0 +1,220 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// process_state.h: A snapshot of a process, in a fully-digested state.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
+
+#include <string>
+#include <vector>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/code_modules.h"
+#include "google_breakpad/processor/exception_record.h"
+#include "google_breakpad/processor/minidump.h"
+#include "google_breakpad/processor/system_info.h"
+#include "processor/linked_ptr.h"
+
+namespace google_breakpad {
+
+using std::vector;
+
+class CallStack;
+class CodeModules;
+
+enum ExploitabilityRating {
+ EXPLOITABILITY_HIGH, // The crash likely represents
+ // a exploitable memory corruption
+ // vulnerability.
+
+ EXPLOITABILITY_MEDIUM, // The crash appears to corrupt
+ // memory in a way which may be
+ // exploitable in some situations.
+
+ EXPLOITABLITY_MEDIUM = EXPLOITABILITY_MEDIUM, // an old misspelling
+
+ EXPLOITABILITY_LOW, // The crash either does not corrupt
+ // memory directly or control over
+ // the affected data is limited. The
+ // issue may still be exploitable
+ // on certain platforms or situations.
+
+ EXPLOITABILITY_INTERESTING, // The crash does not appear to be
+ // directly exploitable. However it
+ // represents a condition which should
+ // be further analyzed.
+
+ EXPLOITABILITY_NONE, // The crash does not appear to represent
+ // an exploitable condition.
+
+ EXPLOITABILITY_NOT_ANALYZED, // The crash was not analyzed for
+ // exploitability because the engine
+ // was disabled.
+
+ EXPLOITABILITY_ERR_NOENGINE, // The supplied minidump's platform does
+ // not have a exploitability engine
+ // associated with it.
+
+ EXPLOITABILITY_ERR_PROCESSING // An error occured within the
+ // exploitability engine and no rating
+ // was calculated.
+};
+
+class ProcessState {
+ public:
+ ProcessState() : modules_(NULL), unloaded_modules_(NULL) { Clear(); }
+ ~ProcessState();
+
+ // Resets the ProcessState to its default values
+ void Clear();
+
+ // Accessors. See the data declarations below.
+ uint32_t time_date_stamp() const { return time_date_stamp_; }
+ uint32_t process_create_time() const { return process_create_time_; }
+ bool crashed() const { return crashed_; }
+ string crash_reason() const { return crash_reason_; }
+ uint64_t crash_address() const { return crash_address_; }
+ string assertion() const { return assertion_; }
+ int requesting_thread() const { return requesting_thread_; }
+ const ExceptionRecord* exception_record() const { return &exception_record_; }
+ const vector<CallStack*>* threads() const { return &threads_; }
+ const vector<MemoryRegion*>* thread_memory_regions() const {
+ return &thread_memory_regions_;
+ }
+ const SystemInfo* system_info() const { return &system_info_; }
+ string mac_crash_info() const { return mac_crash_info_; }
+ size_t mac_crash_info_records_count() const {
+ return mac_crash_info_records_.size();
+ }
+ const crash_info_record_t* mac_crash_info_records() const {
+ return reinterpret_cast<const crash_info_record_t*>(
+ &mac_crash_info_records_[0]);
+ }
+ const CodeModules* modules() const { return modules_; }
+ const CodeModules* unloaded_modules() const { return unloaded_modules_; }
+ const vector<linked_ptr<const CodeModule> >* shrunk_range_modules() const {
+ return &shrunk_range_modules_;
+ }
+ const vector<const CodeModule*>* modules_without_symbols() const {
+ return &modules_without_symbols_;
+ }
+ const vector<const CodeModule*>* modules_with_corrupt_symbols() const {
+ return &modules_with_corrupt_symbols_;
+ }
+ ExploitabilityRating exploitability() const { return exploitability_; }
+
+ private:
+ // MinidumpProcessor and MicrodumpProcessor are responsible for building
+ // ProcessState objects.
+ friend class MinidumpProcessor;
+ friend class MicrodumpProcessor;
+
+ // The time-date stamp of the minidump (time_t format)
+ uint32_t time_date_stamp_;
+
+ // The time-date stamp when the process was created (time_t format)
+ uint32_t process_create_time_;
+
+ // True if the process crashed, false if the dump was produced outside
+ // of an exception handler.
+ bool crashed_;
+
+ // If the process crashed, the type of crash. OS- and possibly CPU-
+ // specific. For example, "EXCEPTION_ACCESS_VIOLATION" (Windows),
+ // "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS" (Mac OS X), "SIGSEGV"
+ // (other Unix).
+ string crash_reason_;
+
+ // If the process crashed, and if crash_reason implicates memory,
+ // the memory address that caused the crash. For data access errors,
+ // this will be the data address that caused the fault. For code errors,
+ // this will be the address of the instruction that caused the fault.
+ uint64_t crash_address_;
+
+ // If there was an assertion that was hit, a textual representation
+ // of that assertion, possibly including the file and line at which
+ // it occurred.
+ string assertion_;
+
+ // The index of the thread that requested a dump be written in the
+ // threads vector. If a dump was produced as a result of a crash, this
+ // will point to the thread that crashed. If the dump was produced as
+ // by user code without crashing, and the dump contains extended Breakpad
+ // information, this will point to the thread that requested the dump.
+ // If the dump was not produced as a result of an exception and no
+ // extended Breakpad information is present, this field will be set to -1,
+ // indicating that the dump thread is not available.
+ int requesting_thread_;
+
+ // Exception record details: code, flags, address, parameters.
+ ExceptionRecord exception_record_;
+
+ // Stacks for each thread (except possibly the exception handler
+ // thread) at the time of the crash.
+ vector<CallStack*> threads_;
+ vector<MemoryRegion*> thread_memory_regions_;
+
+ // OS and CPU information.
+ SystemInfo system_info_;
+
+ // Information from __DATA,__crash_info sections. Only present on macOS.
+ string mac_crash_info_;
+ vector<crash_info_record_t> mac_crash_info_records_;
+
+ // The modules that were loaded into the process represented by the
+ // ProcessState.
+ const CodeModules *modules_;
+
+ // The modules that have been unloaded from the process represented by the
+ // ProcessState.
+ const CodeModules *unloaded_modules_;
+
+ // The modules which virtual address ranges were shrunk down due to
+ // virtual address conflicts.
+ vector<linked_ptr<const CodeModule> > shrunk_range_modules_;
+
+ // The modules that didn't have symbols when the report was processed.
+ vector<const CodeModule*> modules_without_symbols_;
+
+ // The modules that had corrupt symbols when the report was processed.
+ vector<const CodeModule*> modules_with_corrupt_symbols_;
+
+ // The exploitability rating as determined by the exploitability
+ // engine. When the exploitability engine is not enabled this
+ // defaults to EXPLOITABILITY_NOT_ANALYZED.
+ ExploitabilityRating exploitability_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_base.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_base.h
new file mode 100644
index 0000000000..c720b0c325
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_base.h
@@ -0,0 +1,128 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// source_line_resolver_base.h: SourceLineResolverBase, an (incomplete)
+// implementation of SourceLineResolverInterface. It serves as a common base
+// class for concrete implementations: FastSourceLineResolver and
+// BasicSourceLineResolver. It is designed for refactoring that removes
+// code redundancy in the two concrete source line resolver classes.
+//
+// See "google_breakpad/processor/source_line_resolver_interface.h" for more
+// documentation.
+
+// Author: Siyang Xie (lambxsy@google.com)
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_BASE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_BASE_H__
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "google_breakpad/processor/source_line_resolver_interface.h"
+
+namespace google_breakpad {
+
+using std::map;
+using std::set;
+
+// Forward declaration.
+// ModuleFactory is a simple factory interface for creating a Module instance
+// at run-time.
+class ModuleFactory;
+
+class SourceLineResolverBase : public SourceLineResolverInterface {
+ public:
+ // Read the symbol_data from a file with given file_name.
+ // The part of code was originally in BasicSourceLineResolver::Module's
+ // LoadMap() method.
+ // Place dynamically allocated heap buffer in symbol_data. Caller has the
+ // ownership of the buffer, and should call delete [] to free the buffer.
+ static bool ReadSymbolFile(const string &file_name,
+ char **symbol_data,
+ size_t *symbol_data_size);
+
+ protected:
+ // Users are not allowed create SourceLineResolverBase instance directly.
+ SourceLineResolverBase(ModuleFactory *module_factory);
+ virtual ~SourceLineResolverBase();
+
+ // Virtual methods inherited from SourceLineResolverInterface.
+ virtual bool LoadModule(const CodeModule *module, const string &map_file);
+ virtual bool LoadModuleUsingMapBuffer(const CodeModule *module,
+ const string &map_buffer);
+ virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module,
+ char *memory_buffer,
+ size_t memory_buffer_size);
+ virtual bool ShouldDeleteMemoryBufferAfterLoadModule();
+ virtual void UnloadModule(const CodeModule *module);
+ virtual bool HasModule(const CodeModule *module);
+ virtual bool IsModuleCorrupt(const CodeModule *module);
+ virtual void FillSourceLineInfo(StackFrame *frame);
+ virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame);
+ virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame);
+
+ // Nested structs and classes.
+ struct Line;
+ struct Function;
+ struct PublicSymbol;
+ struct CompareString {
+ bool operator()(const string &s1, const string &s2) const;
+ };
+ // Module is an interface for an in-memory symbol file.
+ class Module;
+ class AutoFileCloser;
+
+ // All of the modules that are loaded.
+ typedef map<string, Module*, CompareString> ModuleMap;
+ ModuleMap *modules_;
+
+ // The loaded modules that were detecting to be corrupt during load.
+ typedef set<string, CompareString> ModuleSet;
+ ModuleSet *corrupt_modules_;
+
+ // All of heap-allocated buffers that are owned locally by resolver.
+ typedef std::map<string, char*, CompareString> MemoryMap;
+ MemoryMap *memory_buffers_;
+
+ // Creates a concrete module at run-time.
+ ModuleFactory *module_factory_;
+
+ private:
+ // ModuleFactory needs to have access to protected type Module.
+ friend class ModuleFactory;
+
+ // Disallow unwanted copy ctor and assignment operator
+ SourceLineResolverBase(const SourceLineResolverBase&);
+ void operator=(const SourceLineResolverBase&);
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_BASE_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_interface.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_interface.h
new file mode 100644
index 0000000000..a694bf2ea1
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/source_line_resolver_interface.h
@@ -0,0 +1,117 @@
+// -*- mode: C++ -*-
+
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Abstract interface to return function/file/line info for a memory address.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/code_module.h"
+
+namespace google_breakpad {
+
+struct StackFrame;
+struct WindowsFrameInfo;
+class CFIFrameInfo;
+
+class SourceLineResolverInterface {
+ public:
+ typedef uint64_t MemAddr;
+
+ virtual ~SourceLineResolverInterface() {}
+
+ // Adds a module to this resolver, returning true on success.
+ //
+ // module should have at least the code_file, debug_file,
+ // and debug_identifier members populated.
+ //
+ // map_file should contain line/address mappings for this module.
+ virtual bool LoadModule(const CodeModule *module,
+ const string &map_file) = 0;
+ // Same as above, but takes the contents of a pre-read map buffer
+ virtual bool LoadModuleUsingMapBuffer(const CodeModule *module,
+ const string &map_buffer) = 0;
+
+ // Add an interface to load symbol using C-String data instead of string.
+ // This is useful in the optimization design for avoiding unnecessary copying
+ // of symbol data, in order to improve memory efficiency.
+ // LoadModuleUsingMemoryBuffer() does NOT take ownership of memory_buffer.
+ // LoadModuleUsingMemoryBuffer() null terminates the passed in buffer, if
+ // the last character is not a null terminator.
+ virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module,
+ char *memory_buffer,
+ size_t memory_buffer_size) = 0;
+
+ // Return true if the memory buffer should be deleted immediately after
+ // LoadModuleUsingMemoryBuffer(). Return false if the memory buffer has to be
+ // alive during the lifetime of the corresponding Module.
+ virtual bool ShouldDeleteMemoryBufferAfterLoadModule() = 0;
+
+ // Request that the specified module be unloaded from this resolver.
+ // A resolver may choose to ignore such a request.
+ virtual void UnloadModule(const CodeModule *module) = 0;
+
+ // Returns true if the module has been loaded.
+ virtual bool HasModule(const CodeModule *module) = 0;
+
+ // Returns true if the module has been loaded and it is corrupt.
+ virtual bool IsModuleCorrupt(const CodeModule *module) = 0;
+
+ // Fills in the function_base, function_name, source_file_name,
+ // and source_line fields of the StackFrame. The instruction and
+ // module_name fields must already be filled in.
+ virtual void FillSourceLineInfo(StackFrame *frame) = 0;
+
+ // If Windows stack walking information is available covering
+ // FRAME's instruction address, return a WindowsFrameInfo structure
+ // describing it. If the information is not available, returns NULL.
+ // A NULL return value does not indicate an error. The caller takes
+ // ownership of any returned WindowsFrameInfo object.
+ virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) = 0;
+
+ // If CFI stack walking information is available covering ADDRESS,
+ // return a CFIFrameInfo structure describing it. If the information
+ // is not available, return NULL. The caller takes ownership of any
+ // returned CFIFrameInfo object.
+ virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) = 0;
+
+ protected:
+ // SourceLineResolverInterface cannot be instantiated except by subclasses
+ SourceLineResolverInterface() {}
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame.h
new file mode 100644
index 0000000000..1491d78825
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame.h
@@ -0,0 +1,144 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
+
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+class CodeModule;
+
+struct StackFrame {
+ // Indicates how well the instruction pointer derived during
+ // stack walking is trusted. Since the stack walker can resort to
+ // stack scanning, it can wind up with dubious frames.
+ // In rough order of "trust metric".
+ enum FrameTrust {
+ FRAME_TRUST_NONE, // Unknown
+ FRAME_TRUST_SCAN, // Scanned the stack, found this
+ FRAME_TRUST_CFI_SCAN, // Found while scanning stack using call frame info
+ FRAME_TRUST_FP, // Derived from frame pointer
+ FRAME_TRUST_CFI, // Derived from call frame info
+ FRAME_TRUST_PREWALKED, // Explicitly provided by some external stack walker.
+ FRAME_TRUST_CONTEXT // Given as instruction pointer in a context
+ };
+
+ StackFrame()
+ : instruction(),
+ module(NULL),
+ function_name(),
+ function_base(),
+ source_file_name(),
+ source_line(),
+ source_line_base(),
+ trust(FRAME_TRUST_NONE) {}
+ virtual ~StackFrame() {}
+
+ // Return a string describing how this stack frame was found
+ // by the stackwalker.
+ string trust_description() const {
+ switch (trust) {
+ case StackFrame::FRAME_TRUST_CONTEXT:
+ return "given as instruction pointer in context";
+ case StackFrame::FRAME_TRUST_PREWALKED:
+ return "recovered by external stack walker";
+ case StackFrame::FRAME_TRUST_CFI:
+ return "call frame info";
+ case StackFrame::FRAME_TRUST_CFI_SCAN:
+ return "call frame info with scanning";
+ case StackFrame::FRAME_TRUST_FP:
+ return "previous frame's frame pointer";
+ case StackFrame::FRAME_TRUST_SCAN:
+ return "stack scanning";
+ default:
+ return "unknown";
+ }
+ }
+
+ // Return the actual return address, as saved on the stack or in a
+ // register. See the comments for 'instruction', below, for details.
+ virtual uint64_t ReturnAddress() const { return instruction; }
+
+ // The program counter location as an absolute virtual address.
+ //
+ // - For the innermost called frame in a stack, this will be an exact
+ // program counter or instruction pointer value.
+ //
+ // - For all other frames, this address is within the instruction that
+ // caused execution to branch to this frame's callee (although it may
+ // not point to the exact beginning of that instruction). This ensures
+ // that, when we look up the source code location for this frame, we
+ // get the source location of the call, not of the point at which
+ // control will resume when the call returns, which may be on the next
+ // line. (If the compiler knows the callee never returns, it may even
+ // place the call instruction at the very end of the caller's machine
+ // code, such that the "return address" (which will never be used)
+ // immediately after the call instruction is in an entirely different
+ // function, perhaps even from a different source file.)
+ //
+ // On some architectures, the return address as saved on the stack or in
+ // a register is fine for looking up the point of the call. On others, it
+ // requires adjustment. ReturnAddress returns the address as saved by the
+ // machine.
+ uint64_t instruction;
+
+ // The module in which the instruction resides.
+ const CodeModule *module;
+
+ // The function name, may be omitted if debug symbols are not available.
+ string function_name;
+
+ // The start address of the function, may be omitted if debug symbols
+ // are not available.
+ uint64_t function_base;
+
+ // The source file name, may be omitted if debug symbols are not available.
+ string source_file_name;
+
+ // The (1-based) source line number, may be omitted if debug symbols are
+ // not available.
+ int source_line;
+
+ // The start address of the source line, may be omitted if debug symbols
+ // are not available.
+ uint64_t source_line_base;
+
+ // Amount of trust the stack walker has in the instruction pointer
+ // of this frame.
+ FrameTrust trust;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_cpu.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_cpu.h
new file mode 100644
index 0000000000..dc5d8ae673
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_cpu.h
@@ -0,0 +1,405 @@
+// -*- mode: c++ -*-
+
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// stack_frame_cpu.h: CPU-specific StackFrame extensions.
+//
+// These types extend the StackFrame structure to carry CPU-specific register
+// state. They are defined in this header instead of stack_frame.h to
+// avoid the need to include minidump_format.h when only the generic
+// StackFrame type is needed.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
+
+#include "google_breakpad/common/minidump_format.h"
+#include "google_breakpad/processor/stack_frame.h"
+
+namespace google_breakpad {
+
+struct WindowsFrameInfo;
+class CFIFrameInfo;
+
+struct StackFrameX86 : public StackFrame {
+ // ContextValidity has one entry for each relevant hardware pointer
+ // register (%eip and %esp) and one entry for each general-purpose
+ // register. It's worthwhile having validity flags for caller-saves
+ // registers: they are valid in the youngest frame, and such a frame
+ // might save a callee-saves register in a caller-saves register, but
+ // SimpleCFIWalker won't touch registers unless they're marked as valid.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_EIP = 1 << 0,
+ CONTEXT_VALID_ESP = 1 << 1,
+ CONTEXT_VALID_EBP = 1 << 2,
+ CONTEXT_VALID_EAX = 1 << 3,
+ CONTEXT_VALID_EBX = 1 << 4,
+ CONTEXT_VALID_ECX = 1 << 5,
+ CONTEXT_VALID_EDX = 1 << 6,
+ CONTEXT_VALID_ESI = 1 << 7,
+ CONTEXT_VALID_EDI = 1 << 8,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFrameX86()
+ : context(),
+ context_validity(CONTEXT_VALID_NONE),
+ windows_frame_info(NULL),
+ cfi_frame_info(NULL) {}
+ ~StackFrameX86();
+
+ // Overriden to return the return address as saved on the stack.
+ virtual uint64_t ReturnAddress() const;
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextX86 context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+
+ // Any stack walking information we found describing this.instruction.
+ // These may be NULL if there is no such information for that address.
+ WindowsFrameInfo *windows_frame_info;
+ CFIFrameInfo *cfi_frame_info;
+};
+
+struct StackFramePPC : public StackFrame {
+ // ContextValidity should eventually contain entries for the validity of
+ // other nonvolatile (callee-save) registers as in
+ // StackFrameX86::ContextValidity, but the ppc stackwalker doesn't currently
+ // locate registers other than the ones listed here.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_SRR0 = 1 << 0,
+ CONTEXT_VALID_GPR1 = 1 << 1,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFramePPC() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextPPC context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+};
+
+struct StackFramePPC64 : public StackFrame {
+ // ContextValidity should eventually contain entries for the validity of
+ // other nonvolatile (callee-save) registers as in
+ // StackFrameX86::ContextValidity, but the ppc stackwalker doesn't currently
+ // locate registers other than the ones listed here.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_SRR0 = 1 << 0,
+ CONTEXT_VALID_GPR1 = 1 << 1,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFramePPC64() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextPPC64 context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+};
+
+struct StackFrameAMD64 : public StackFrame {
+ // ContextValidity has one entry for each register that we might be able
+ // to recover.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_RAX = 1 << 0,
+ CONTEXT_VALID_RDX = 1 << 1,
+ CONTEXT_VALID_RCX = 1 << 2,
+ CONTEXT_VALID_RBX = 1 << 3,
+ CONTEXT_VALID_RSI = 1 << 4,
+ CONTEXT_VALID_RDI = 1 << 5,
+ CONTEXT_VALID_RBP = 1 << 6,
+ CONTEXT_VALID_RSP = 1 << 7,
+ CONTEXT_VALID_R8 = 1 << 8,
+ CONTEXT_VALID_R9 = 1 << 9,
+ CONTEXT_VALID_R10 = 1 << 10,
+ CONTEXT_VALID_R11 = 1 << 11,
+ CONTEXT_VALID_R12 = 1 << 12,
+ CONTEXT_VALID_R13 = 1 << 13,
+ CONTEXT_VALID_R14 = 1 << 14,
+ CONTEXT_VALID_R15 = 1 << 15,
+ CONTEXT_VALID_RIP = 1 << 16,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFrameAMD64() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Overriden to return the return address as saved on the stack.
+ virtual uint64_t ReturnAddress() const;
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, which registers are present depends on what
+ // debugging information we had available. Refer to context_validity.
+ MDRawContextAMD64 context;
+
+ // For each register in context whose value has been recovered, we set
+ // the corresponding CONTEXT_VALID_ bit in context_validity.
+ //
+ // context_validity's type should actually be ContextValidity, but
+ // we use int instead because the bitwise inclusive or operator
+ // yields an int when applied to enum values, and C++ doesn't
+ // silently convert from ints to enums.
+ int context_validity;
+};
+
+struct StackFrameSPARC : public StackFrame {
+ // to be confirmed
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_PC = 1 << 0,
+ CONTEXT_VALID_SP = 1 << 1,
+ CONTEXT_VALID_FP = 1 << 2,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFrameSPARC() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextSPARC context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+};
+
+struct StackFrameARM : public StackFrame {
+ // A flag for each register we might know.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_R0 = 1 << 0,
+ CONTEXT_VALID_R1 = 1 << 1,
+ CONTEXT_VALID_R2 = 1 << 2,
+ CONTEXT_VALID_R3 = 1 << 3,
+ CONTEXT_VALID_R4 = 1 << 4,
+ CONTEXT_VALID_R5 = 1 << 5,
+ CONTEXT_VALID_R6 = 1 << 6,
+ CONTEXT_VALID_R7 = 1 << 7,
+ CONTEXT_VALID_R8 = 1 << 8,
+ CONTEXT_VALID_R9 = 1 << 9,
+ CONTEXT_VALID_R10 = 1 << 10,
+ CONTEXT_VALID_R11 = 1 << 11,
+ CONTEXT_VALID_R12 = 1 << 12,
+ CONTEXT_VALID_R13 = 1 << 13,
+ CONTEXT_VALID_R14 = 1 << 14,
+ CONTEXT_VALID_R15 = 1 << 15,
+ CONTEXT_VALID_ALL = ~CONTEXT_VALID_NONE,
+
+ // Aliases for registers with dedicated or conventional roles.
+ CONTEXT_VALID_FP = CONTEXT_VALID_R11,
+ CONTEXT_VALID_SP = CONTEXT_VALID_R13,
+ CONTEXT_VALID_LR = CONTEXT_VALID_R14,
+ CONTEXT_VALID_PC = CONTEXT_VALID_R15
+ };
+
+ StackFrameARM() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Return the ContextValidity flag for register rN.
+ static ContextValidity RegisterValidFlag(int n) {
+ return ContextValidity(1 << n);
+ }
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextARM context;
+
+ // For each register in context whose value has been recovered, we set
+ // the corresponding CONTEXT_VALID_ bit in context_validity.
+ //
+ // context_validity's type should actually be ContextValidity, but
+ // we use int instead because the bitwise inclusive or operator
+ // yields an int when applied to enum values, and C++ doesn't
+ // silently convert from ints to enums.
+ int context_validity;
+};
+
+struct StackFrameARM64 : public StackFrame {
+ // A flag for each register we might know. Note that we can't use an enum
+ // here as there are 33 values to represent.
+ static const uint64_t CONTEXT_VALID_NONE = 0;
+ static const uint64_t CONTEXT_VALID_X0 = 1ULL << 0;
+ static const uint64_t CONTEXT_VALID_X1 = 1ULL << 1;
+ static const uint64_t CONTEXT_VALID_X2 = 1ULL << 2;
+ static const uint64_t CONTEXT_VALID_X3 = 1ULL << 3;
+ static const uint64_t CONTEXT_VALID_X4 = 1ULL << 4;
+ static const uint64_t CONTEXT_VALID_X5 = 1ULL << 5;
+ static const uint64_t CONTEXT_VALID_X6 = 1ULL << 6;
+ static const uint64_t CONTEXT_VALID_X7 = 1ULL << 7;
+ static const uint64_t CONTEXT_VALID_X8 = 1ULL << 8;
+ static const uint64_t CONTEXT_VALID_X9 = 1ULL << 9;
+ static const uint64_t CONTEXT_VALID_X10 = 1ULL << 10;
+ static const uint64_t CONTEXT_VALID_X11 = 1ULL << 11;
+ static const uint64_t CONTEXT_VALID_X12 = 1ULL << 12;
+ static const uint64_t CONTEXT_VALID_X13 = 1ULL << 13;
+ static const uint64_t CONTEXT_VALID_X14 = 1ULL << 14;
+ static const uint64_t CONTEXT_VALID_X15 = 1ULL << 15;
+ static const uint64_t CONTEXT_VALID_X16 = 1ULL << 16;
+ static const uint64_t CONTEXT_VALID_X17 = 1ULL << 17;
+ static const uint64_t CONTEXT_VALID_X18 = 1ULL << 18;
+ static const uint64_t CONTEXT_VALID_X19 = 1ULL << 19;
+ static const uint64_t CONTEXT_VALID_X20 = 1ULL << 20;
+ static const uint64_t CONTEXT_VALID_X21 = 1ULL << 21;
+ static const uint64_t CONTEXT_VALID_X22 = 1ULL << 22;
+ static const uint64_t CONTEXT_VALID_X23 = 1ULL << 23;
+ static const uint64_t CONTEXT_VALID_X24 = 1ULL << 24;
+ static const uint64_t CONTEXT_VALID_X25 = 1ULL << 25;
+ static const uint64_t CONTEXT_VALID_X26 = 1ULL << 26;
+ static const uint64_t CONTEXT_VALID_X27 = 1ULL << 27;
+ static const uint64_t CONTEXT_VALID_X28 = 1ULL << 28;
+ static const uint64_t CONTEXT_VALID_X29 = 1ULL << 29;
+ static const uint64_t CONTEXT_VALID_X30 = 1ULL << 30;
+ static const uint64_t CONTEXT_VALID_X31 = 1ULL << 31;
+ static const uint64_t CONTEXT_VALID_X32 = 1ULL << 32;
+ static const uint64_t CONTEXT_VALID_ALL = ~CONTEXT_VALID_NONE;
+
+ // Aliases for registers with dedicated or conventional roles.
+ static const uint64_t CONTEXT_VALID_FP = CONTEXT_VALID_X29;
+ static const uint64_t CONTEXT_VALID_LR = CONTEXT_VALID_X30;
+ static const uint64_t CONTEXT_VALID_SP = CONTEXT_VALID_X31;
+ static const uint64_t CONTEXT_VALID_PC = CONTEXT_VALID_X32;
+
+ StackFrameARM64() : context(),
+ context_validity(CONTEXT_VALID_NONE) {}
+
+ // Return the validity flag for register xN.
+ static uint64_t RegisterValidFlag(int n) {
+ return 1ULL << n;
+ }
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextARM64 context;
+
+ // For each register in context whose value has been recovered, we set
+ // the corresponding CONTEXT_VALID_ bit in context_validity.
+ uint64_t context_validity;
+};
+
+struct StackFrameMIPS : public StackFrame {
+ // MIPS callee save registers for o32 ABI (32bit registers) are:
+ // 1. $s0-$s7,
+ // 2. $sp, $fp
+ // 3. $f20-$f31
+ //
+ // The register structure is available at
+ // http://en.wikipedia.org/wiki/MIPS_architecture#Compiler_register_usage
+
+#define INDEX_MIPS_REG_S0 MD_CONTEXT_MIPS_REG_S0 // 16
+#define INDEX_MIPS_REG_S7 MD_CONTEXT_MIPS_REG_S7 // 23
+#define INDEX_MIPS_REG_GP MD_CONTEXT_MIPS_REG_GP // 28
+#define INDEX_MIPS_REG_RA MD_CONTEXT_MIPS_REG_RA // 31
+#define INDEX_MIPS_REG_PC 34
+#define SHIFT_MIPS_REG_S0 0
+#define SHIFT_MIPS_REG_GP 8
+#define SHIFT_MIPS_REG_PC 12
+
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_S0 = 1 << 0, // $16
+ CONTEXT_VALID_S1 = 1 << 1, // $17
+ CONTEXT_VALID_S2 = 1 << 2, // $18
+ CONTEXT_VALID_S3 = 1 << 3, // $19
+ CONTEXT_VALID_S4 = 1 << 4, // $20
+ CONTEXT_VALID_S5 = 1 << 5, // $21
+ CONTEXT_VALID_S6 = 1 << 6, // $22
+ CONTEXT_VALID_S7 = 1 << 7, // $23
+ // GP is not calee-save for o32 abi.
+ CONTEXT_VALID_GP = 1 << 8, // $28
+ CONTEXT_VALID_SP = 1 << 9, // $29
+ CONTEXT_VALID_FP = 1 << 10, // $30
+ CONTEXT_VALID_RA = 1 << 11, // $31
+ CONTEXT_VALID_PC = 1 << 12, // $34
+ CONTEXT_VALID_ALL = ~CONTEXT_VALID_NONE
+ };
+
+ // Return the ContextValidity flag for register rN.
+ static ContextValidity RegisterValidFlag(int n) {
+ if (n >= INDEX_MIPS_REG_S0 && n <= INDEX_MIPS_REG_S7)
+ return ContextValidity(1 << (n - INDEX_MIPS_REG_S0 + SHIFT_MIPS_REG_S0));
+ else if (n >= INDEX_MIPS_REG_GP && n <= INDEX_MIPS_REG_RA)
+ return ContextValidity(1 << (n - INDEX_MIPS_REG_GP + SHIFT_MIPS_REG_GP));
+ else if (n == INDEX_MIPS_REG_PC)
+ return ContextValidity(1 << SHIFT_MIPS_REG_PC);
+
+ return CONTEXT_VALID_NONE;
+ }
+
+ StackFrameMIPS() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, which registers are present depends on what
+ // debugging information were available. Refer to 'context_validity' below.
+ MDRawContextMIPS context;
+
+ // For each register in context whose value has been recovered,
+ // the corresponding CONTEXT_VALID_ bit in 'context_validity' is set.
+ //
+ // context_validity's type should actually be ContextValidity, but
+ // type int is used instead because the bitwise inclusive or operator
+ // yields an int when applied to enum values, and C++ doesn't
+ // silently convert from ints to enums.
+ int context_validity;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_symbolizer.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_symbolizer.h
new file mode 100644
index 0000000000..0bbaae0a36
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stack_frame_symbolizer.h
@@ -0,0 +1,110 @@
+// -*- mode: C++ -*-
+
+// Copyright (c) 2012 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Helper class that encapsulates the logic of how symbol supplier interacts
+// with source line resolver to fill stack frame information.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_SYMBOLIZER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_SYMBOLIZER_H__
+
+#include <set>
+#include <string>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/code_module.h"
+
+namespace google_breakpad {
+class CFIFrameInfo;
+class CodeModules;
+class SymbolSupplier;
+class SourceLineResolverInterface;
+struct StackFrame;
+struct SystemInfo;
+struct WindowsFrameInfo;
+
+class StackFrameSymbolizer {
+ public:
+ enum SymbolizerResult {
+ // Symbol data was found and successfully loaded in resolver.
+ // This does NOT guarantee source line info is found within symbol file.
+ kNoError,
+ // This indicates non-critical error, such as, no code module found for
+ // frame's instruction, no symbol file, or resolver failed to load symbol.
+ kError,
+ // This indicates error for which stack walk should be interrupted
+ // and retried in future.
+ kInterrupt,
+ // Symbol data was found and loaded in resolver however some corruptions
+ // were detected.
+ kWarningCorruptSymbols,
+ };
+
+ StackFrameSymbolizer(SymbolSupplier* supplier,
+ SourceLineResolverInterface* resolver);
+
+ virtual ~StackFrameSymbolizer() { }
+
+ // Encapsulate the step of resolving source line info for a stack frame.
+ // "frame" must not be NULL.
+ virtual SymbolizerResult FillSourceLineInfo(
+ const CodeModules* modules,
+ const CodeModules* unloaded_modules,
+ const SystemInfo* system_info,
+ StackFrame* stack_frame);
+
+ virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame);
+
+ virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame);
+
+ // Reset internal (locally owned) data as if the helper is re-instantiated.
+ // A typical case is to call Reset() after processing an individual report
+ // before start to process next one, in order to reset internal information
+ // about missing symbols found so far.
+ virtual void Reset() { no_symbol_modules_.clear(); }
+
+ // Returns true if there is valid implementation for stack symbolization.
+ virtual bool HasImplementation() { return resolver_ && supplier_; }
+
+ SourceLineResolverInterface* resolver() { return resolver_; }
+ SymbolSupplier* supplier() { return supplier_; }
+
+ protected:
+ SymbolSupplier* supplier_;
+ SourceLineResolverInterface* resolver_;
+ // A list of modules known to have symbols missing. This helps avoid
+ // repeated lookups for the missing symbols within one minidump.
+ std::set<string> no_symbol_modules_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_SYMBOLIZER_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stackwalker.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stackwalker.h
new file mode 100644
index 0000000000..0c458d500e
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/stackwalker.h
@@ -0,0 +1,257 @@
+// Copyright (c) 2010 Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// stackwalker.h: Generic stackwalker.
+//
+// The Stackwalker class is an abstract base class providing common generic
+// methods that apply to stacks from all systems. Specific implementations
+// will extend this class by providing GetContextFrame and GetCallerFrame
+// methods to fill in system-specific data in a StackFrame structure.
+// Stackwalker assembles these StackFrame strucutres into a CallStack.
+//
+// Author: Mark Mentovai
+
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "common/using_std_string.h"
+#include "google_breakpad/common/breakpad_types.h"
+#include "google_breakpad/processor/code_modules.h"
+#include "google_breakpad/processor/memory_region.h"
+#include "google_breakpad/processor/stack_frame_symbolizer.h"
+
+namespace google_breakpad {
+
+class CallStack;
+class DumpContext;
+class StackFrameSymbolizer;
+
+using std::set;
+using std::vector;
+
+class Stackwalker {
+ public:
+ virtual ~Stackwalker() {}
+
+ // Populates the given CallStack by calling GetContextFrame and
+ // GetCallerFrame. The frames are further processed to fill all available
+ // data. Returns true if the stackwalk completed, or false if it was
+ // interrupted by SymbolSupplier::GetSymbolFile().
+ // Upon return, |modules_without_symbols| will be populated with pointers to
+ // the code modules (CodeModule*) that DON'T have symbols.
+ // |modules_with_corrupt_symbols| will be populated with pointers to the
+ // modules which have corrupt symbols. |modules_without_symbols| and
+ // |modules_with_corrupt_symbols| DO NOT take ownership of the code modules.
+ // The lifetime of these code modules is the same as the lifetime of the
+ // CodeModules passed to the StackWalker constructor (which currently
+ // happens to be the lifetime of the Breakpad's ProcessingState object).
+ // There is a check for duplicate modules so no duplicates are expected.
+ bool Walk(CallStack* stack,
+ vector<const CodeModule*>* modules_without_symbols,
+ vector<const CodeModule*>* modules_with_corrupt_symbols);
+
+ // Returns a new concrete subclass suitable for the CPU that a stack was
+ // generated on, according to the CPU type indicated by the context
+ // argument. If no suitable concrete subclass exists, returns NULL.
+ static Stackwalker* StackwalkerForCPU(
+ const SystemInfo* system_info,
+ DumpContext* context,
+ MemoryRegion* memory,
+ const CodeModules* modules,
+ const CodeModules* unloaded_modules,
+ StackFrameSymbolizer* resolver_helper);
+
+
+ static void set_max_frames(uint32_t max_frames) {
+ max_frames_ = max_frames;
+ max_frames_set_ = true;
+ }
+ static uint32_t max_frames() { return max_frames_; }
+
+ static void set_max_frames_scanned(uint32_t max_frames_scanned) {
+ max_frames_scanned_ = max_frames_scanned;
+ }
+
+ protected:
+ // system_info identifies the operating system, NULL or empty if unknown.
+ // memory identifies a MemoryRegion that provides the stack memory
+ // for the stack to walk. modules, if non-NULL, is a CodeModules
+ // object that is used to look up which code module each stack frame is
+ // associated with. frame_symbolizer is a StackFrameSymbolizer object that
+ // encapsulates the logic of how source line resolver interacts with symbol
+ // supplier to symbolize stack frame and look up caller frame information
+ // (see stack_frame_symbolizer.h).
+ // frame_symbolizer MUST NOT be NULL (asserted).
+ Stackwalker(const SystemInfo* system_info,
+ MemoryRegion* memory,
+ const CodeModules* modules,
+ StackFrameSymbolizer* frame_symbolizer);
+
+ // This can be used to filter out potential return addresses when
+ // the stack walker resorts to stack scanning.
+ // Returns true if any of:
+ // * This address is within a loaded module, but we don't have symbols
+ // for that module.
+ // * This address is within a loaded module for which we have symbols,
+ // and falls inside a function in that module.
+ // Returns false otherwise.
+ bool InstructionAddressSeemsValid(uint64_t address) const;
+
+ // Checks whether we should stop the stack trace.
+ // (either we reached the end-of-stack or we detected a
+ // broken callstack invariant)
+ bool TerminateWalk(uint64_t caller_ip,
+ uint64_t caller_sp,
+ uint64_t callee_sp,
+ bool first_unwind) const;
+
+ // The default number of words to search through on the stack
+ // for a return address.
+ static const int kRASearchWords;
+
+ template<typename InstructionType>
+ bool ScanForReturnAddress(InstructionType location_start,
+ InstructionType* location_found,
+ InstructionType* ip_found,
+ bool is_context_frame) {
+ // When searching for the caller of the context frame,
+ // allow the scanner to look farther down the stack.
+ const int search_words = is_context_frame ?
+ kRASearchWords * 4 :
+ kRASearchWords;
+
+ return ScanForReturnAddress(location_start, location_found, ip_found,
+ search_words);
+ }
+
+ // Scan the stack starting at location_start, looking for an address
+ // that looks like a valid instruction pointer. Addresses must
+ // 1) be contained in the current stack memory
+ // 2) pass the checks in InstructionAddressSeemsValid
+ //
+ // Returns true if a valid-looking instruction pointer was found.
+ // When returning true, sets location_found to the address at which
+ // the value was found, and ip_found to the value contained at that
+ // location in memory.
+ template<typename InstructionType>
+ bool ScanForReturnAddress(InstructionType location_start,
+ InstructionType* location_found,
+ InstructionType* ip_found,
+ int searchwords) {
+ for (InstructionType location = location_start;
+ location <= location_start + searchwords * sizeof(InstructionType);
+ location += sizeof(InstructionType)) {
+ InstructionType ip;
+ if (!memory_->GetMemoryAtAddress(location, &ip))
+ break;
+
+ if (modules_ && modules_->GetModuleForAddress(ip) &&
+ InstructionAddressSeemsValid(ip)) {
+ *ip_found = ip;
+ *location_found = location;
+ return true;
+ }
+ }
+ // nothing found
+ return false;
+ }
+
+ // Information about the system that produced the minidump. Subclasses
+ // and the SymbolSupplier may find this information useful.
+ const SystemInfo* system_info_;
+
+ // The stack memory to walk. Subclasses will require this region to
+ // get information from the stack.
+ MemoryRegion* memory_;
+
+ // A list of modules, for populating each StackFrame's module information.
+ // This field is optional and may be NULL.
+ const CodeModules* modules_;
+
+ // A list of unloaded modules, for populating frames which aren't matched
+ // to any loaded modules.
+ // This field is optional and may be NULL.
+ const CodeModules* unloaded_modules_;
+
+ protected:
+ // The StackFrameSymbolizer implementation.
+ StackFrameSymbolizer* frame_symbolizer_;
+
+ private:
+ // Obtains the context frame, the innermost called procedure in a stack
+ // trace. Returns NULL on failure. GetContextFrame allocates a new
+ // StackFrame (or StackFrame subclass), ownership of which is taken by
+ // the caller.
+ virtual StackFrame* GetContextFrame() = 0;
+
+ // Obtains a caller frame. Each call to GetCallerFrame should return the
+ // frame that called the last frame returned by GetContextFrame or
+ // GetCallerFrame. To aid this purpose, stack contains the CallStack
+ // made of frames that have already been walked. GetCallerFrame should
+ // return NULL on failure or when there are no more caller frames (when
+ // the end of the stack has been reached). GetCallerFrame allocates a new
+ // StackFrame (or StackFrame subclass), ownership of which is taken by
+ // the caller. |stack_scan_allowed| controls whether stack scanning is
+ // an allowable frame-recovery method, since it is desirable to be able to
+ // disable stack scanning in performance-critical use cases.
+ //
+ // CONSIDER: a way to differentiate between:
+ // - full stack traces
+ // - explicitly truncated traces (max_frames_)
+ // - stopping after max scanned frames
+ // - failed stack walk (breaking one of the stack walk invariants)
+ //
+ virtual StackFrame* GetCallerFrame(const CallStack* stack,
+ bool stack_scan_allowed) = 0;
+
+ // The maximum number of frames Stackwalker will walk through.
+ // This defaults to 1024 to prevent infinite loops.
+ static uint32_t max_frames_;
+
+ // Keep track of whether max_frames_ has been set by the user, since
+ // it affects whether or not an error message is printed in the case
+ // where an unwind got stopped by the limit.
+ static bool max_frames_set_;
+
+ // The maximum number of stack-scanned and otherwise untrustworthy
+ // frames allowed. Stack-scanning can be expensive, so the option to
+ // disable or limit it is helpful in cases where unwind performance is
+ // important. This defaults to 1024, the same as max_frames_.
+ static uint32_t max_frames_scanned_;
+};
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/symbol_supplier.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/symbol_supplier.h
new file mode 100644
index 0000000000..a042081f3b
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/symbol_supplier.h
@@ -0,0 +1,99 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The caller may implement the SymbolSupplier abstract base class
+// to provide symbols for a given module.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
+
+#include <string>
+#include "common/using_std_string.h"
+
+namespace google_breakpad {
+
+class CodeModule;
+struct SystemInfo;
+
+class SymbolSupplier {
+ public:
+ // Result type for GetSymbolFile
+ enum SymbolResult {
+ // no symbols were found, but continue processing
+ NOT_FOUND,
+
+ // symbols were found, and the path has been placed in symbol_file
+ FOUND,
+
+ // stops processing the minidump immediately
+ INTERRUPT
+ };
+
+ virtual ~SymbolSupplier() {}
+
+ // Retrieves the symbol file for the given CodeModule, placing the
+ // path in symbol_file if successful. system_info contains strings
+ // identifying the operating system and CPU; SymbolSupplier may use
+ // to help locate the symbol file. system_info may be NULL or its
+ // fields may be empty if these values are unknown. symbol_file
+ // must be a pointer to a valid string
+ virtual SymbolResult GetSymbolFile(const CodeModule *module,
+ const SystemInfo *system_info,
+ string *symbol_file) = 0;
+ // Same as above, except also places symbol data into symbol_data.
+ // If symbol_data is NULL, the data is not returned.
+ // TODO(nealsid) Once we have symbol data caching behavior implemented
+ // investigate making all symbol suppliers implement all methods,
+ // and make this pure virtual
+ virtual SymbolResult GetSymbolFile(const CodeModule *module,
+ const SystemInfo *system_info,
+ string *symbol_file,
+ string *symbol_data) = 0;
+
+ // Same as above, except allocates data buffer on heap and then places the
+ // symbol data into the buffer as C-string.
+ // SymbolSupplier is responsible for deleting the data buffer. After the call
+ // to GetCStringSymbolData(), the caller should call FreeSymbolData(const
+ // Module *module) once the data buffer is no longer needed.
+ // If symbol_data is not NULL, symbol supplier won't return FOUND unless it
+ // returns a valid buffer in symbol_data, e.g., returns INTERRUPT on memory
+ // allocation failure.
+ virtual SymbolResult GetCStringSymbolData(const CodeModule *module,
+ const SystemInfo *system_info,
+ string *symbol_file,
+ char **symbol_data,
+ size_t *symbol_data_size) = 0;
+
+ // Frees the data buffer allocated for the module in GetCStringSymbolData.
+ virtual void FreeSymbolData(const CodeModule *module) = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
diff --git a/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/system_info.h b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/system_info.h
new file mode 100644
index 0000000000..8d2f60be48
--- /dev/null
+++ b/toolkit/crashreporter/google-breakpad/src/google_breakpad/processor/system_info.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// system_info.h: Information about the system that was running a program
+// when a crash report was produced.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__
+
+#include <string>
+
+#include "common/using_std_string.h"
+
+namespace google_breakpad {
+
+struct SystemInfo {
+ public:
+ SystemInfo() : os(), os_short(), os_version(), cpu(), cpu_info(),
+ cpu_count(0), gl_version(), gl_vendor(), gl_renderer() {}
+
+ // Resets the SystemInfo object to its default values.
+ void Clear() {
+ os.clear();
+ os_short.clear();
+ os_version.clear();
+ cpu.clear();
+ cpu_info.clear();
+ cpu_count = 0;
+ gl_version.clear();
+ gl_vendor.clear();
+ gl_renderer.clear();
+ }
+
+ // A string identifying the operating system, such as "Windows NT",
+ // "Mac OS X", or "Linux". If the information is present in the dump but
+ // its value is unknown, this field will contain a numeric value. If
+ // the information is not present in the dump, this field will be empty.
+ string os;
+
+ // A short form of the os string, using lowercase letters and no spaces,
+ // suitable for use in a filesystem. Possible values include "windows",
+ // "mac", "linux" and "nacl". Empty if the information is not present
+ // in the dump or if the OS given by the dump is unknown. The values
+ // stored in this field should match those used by
+ // MinidumpSystemInfo::GetOS.
+ string os_short;
+
+ // A string identifying the version of the operating system, such as
+ // "5.1.2600 Service Pack 2" or "10.4.8 8L2127". If the dump does not
+ // contain this information, this field will be empty.
+ string os_version;
+
+ // A string identifying the basic CPU family, such as "x86" or "ppc".
+ // If this information is present in the dump but its value is unknown,
+ // this field will contain a numeric value. If the information is not
+ // present in the dump, this field will be empty. The values stored in
+ // this field should match those used by MinidumpSystemInfo::GetCPU.
+ string cpu;
+
+ // A string further identifying the specific CPU, such as
+ // "GenuineIntel level 6 model 13 stepping 8". If the information is not
+ // present in the dump, or additional identifying information is not
+ // defined for the CPU family, this field will be empty.
+ string cpu_info;
+
+ // The number of processors in the system. Will be greater than one for
+ // multi-core systems.
+ int cpu_count;
+
+ // The GPU information. Currently only populated in microdumps.
+ string gl_version;
+ string gl_vendor;
+ string gl_renderer;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__