aboutsummaryrefslogtreecommitdiff
path: root/src/google_airbag/processor
diff options
context:
space:
mode:
authorbryner <bryner@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-12-11 23:22:54 +0000
committerbryner <bryner@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-12-11 23:22:54 +0000
commitfd38d48e6d5e56cb66b0fa0f7e25f840a83dac5c (patch)
tree96d3961df7843da00963e52ac0a10604d2c31148 /src/google_airbag/processor
parentRemoving CRs from #81. Hey, how'd those get in there? (diff)
downloadbreakpad-fd38d48e6d5e56cb66b0fa0f7e25f840a83dac5c.tar.xz
Add an abstract interface to SourceLineResolver, and allow any implementation
to be used with MinidumpProcessor. The basic SourceLineResolver is now a public interface (#89) git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@83 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/google_airbag/processor')
-rw-r--r--src/google_airbag/processor/basic_source_line_resolver.h84
-rw-r--r--src/google_airbag/processor/minidump_processor.h5
-rw-r--r--src/google_airbag/processor/source_line_resolver_interface.h79
-rw-r--r--src/google_airbag/processor/stackwalker.h14
4 files changed, 178 insertions, 4 deletions
diff --git a/src/google_airbag/processor/basic_source_line_resolver.h b/src/google_airbag/processor/basic_source_line_resolver.h
new file mode 100644
index 00000000..c688191a
--- /dev/null
+++ b/src/google_airbag/processor/basic_source_line_resolver.h
@@ -0,0 +1,84 @@
+// 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.
+
+// BasicSourceLineResolver implements SourceLineResolverInterface, using
+// address map files produced by a compatible writer, e.g. PDBSourceLineWriter.
+
+#ifndef GOOGLE_AIRBAG_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+#define GOOGLE_AIRBAG_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+
+#include <ext/hash_map>
+
+#include "google_airbag/processor/source_line_resolver_interface.h"
+
+namespace google_airbag {
+
+using std::string;
+using __gnu_cxx::hash_map;
+
+class BasicSourceLineResolver : public SourceLineResolverInterface {
+ public:
+ BasicSourceLineResolver();
+ virtual ~BasicSourceLineResolver();
+
+ // SourceLineResolverInterface methods, see source_line_resolver_interface.h
+ // for more details.
+
+ // Adds a module to this resolver, returning true on success.
+ // The given map_file is read into memory, and its symbols will be
+ // retained until the BasicSourceLineResolver is destroyed.
+ virtual bool LoadModule(const string &module_name, const string &map_file);
+
+ virtual bool HasModule(const string &module_name) const;
+
+ virtual StackFrameInfo* FillSourceLineInfo(StackFrame *frame) const;
+
+ private:
+ template<class T> class MemAddrMap;
+ struct Line;
+ struct Function;
+ struct PublicSymbol;
+ struct File;
+ struct HashString {
+ size_t operator()(const string &s) const;
+ };
+ class Module;
+
+ // All of the modules we've loaded
+ typedef hash_map<string, Module*, HashString> ModuleMap;
+ ModuleMap *modules_;
+
+ // Disallow unwanted copy ctor and assignment operator
+ BasicSourceLineResolver(const BasicSourceLineResolver&);
+ void operator=(const BasicSourceLineResolver&);
+};
+
+} // namespace google_airbag
+
+#endif // GOOGLE_AIRBAG_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
diff --git a/src/google_airbag/processor/minidump_processor.h b/src/google_airbag/processor/minidump_processor.h
index 604eae45..a50d8a79 100644
--- a/src/google_airbag/processor/minidump_processor.h
+++ b/src/google_airbag/processor/minidump_processor.h
@@ -38,6 +38,7 @@ using std::string;
class Minidump;
class ProcessState;
+class SourceLineResolverInterface;
class SymbolSupplier;
class MinidumpProcessor {
@@ -51,7 +52,8 @@ class MinidumpProcessor {
// Initializes this MinidumpProcessor. supplier should be an
// implementation of the SymbolSupplier abstract base class.
- explicit MinidumpProcessor(SymbolSupplier *supplier);
+ MinidumpProcessor(SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
~MinidumpProcessor();
// Processes the minidump file and fills process_state with the result.
@@ -84,6 +86,7 @@ class MinidumpProcessor {
private:
SymbolSupplier *supplier_;
+ SourceLineResolverInterface *resolver_;
};
} // namespace google_airbag
diff --git a/src/google_airbag/processor/source_line_resolver_interface.h b/src/google_airbag/processor/source_line_resolver_interface.h
new file mode 100644
index 00000000..2afd4d8f
--- /dev/null
+++ b/src/google_airbag/processor/source_line_resolver_interface.h
@@ -0,0 +1,79 @@
+// 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.
+
+// Abstract interface to return function/file/line info for a memory address.
+
+#ifndef GOOGLE_AIRBAG_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+#define GOOGLE_AIRBAG_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+
+#include <string>
+#include "google_airbag/common/airbag_types.h"
+
+namespace google_airbag {
+
+using std::string;
+
+struct StackFrame;
+struct StackFrameInfo;
+
+class SourceLineResolverInterface {
+ public:
+ typedef u_int64_t MemAddr;
+
+ virtual ~SourceLineResolverInterface() {}
+
+ // Adds a module to this resolver, returning true on success.
+ //
+ // module_name may be an arbitrary string. Typically, it will be the
+ // filename of the module, optionally with version identifiers.
+ //
+ // map_file should contain line/address mappings for this module.
+ virtual bool LoadModule(const string &module_name,
+ const string &map_file) = 0;
+
+ // Returns true if a module with the given name has been loaded.
+ virtual bool HasModule(const string &module_name) const = 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. Additional debugging
+ // information, if available, is returned. If the information is not
+ // available, returns NULL. A NULL return value does not indicate an
+ // error. The caller takes ownership of any returned StackFrameInfo
+ // object.
+ virtual StackFrameInfo* FillSourceLineInfo(StackFrame *frame) const = 0;
+
+ protected:
+ // SourceLineResolverInterface cannot be instantiated except by subclasses
+ SourceLineResolverInterface() {}
+};
+
+} // namespace google_airbag
+
+#endif // GOOGLE_AIRBAG_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
diff --git a/src/google_airbag/processor/stackwalker.h b/src/google_airbag/processor/stackwalker.h
index 70da125e..381b9e29 100644
--- a/src/google_airbag/processor/stackwalker.h
+++ b/src/google_airbag/processor/stackwalker.h
@@ -50,6 +50,7 @@ class CodeModules;
template<typename T> class linked_ptr;
class MemoryRegion;
class MinidumpContext;
+class SourceLineResolverInterface;
struct StackFrame;
struct StackFrameInfo;
class SymbolSupplier;
@@ -73,7 +74,8 @@ class Stackwalker {
static Stackwalker* StackwalkerForCPU(MinidumpContext *context,
MemoryRegion *memory,
const CodeModules *modules,
- SymbolSupplier *supplier);
+ SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
protected:
// memory identifies a MemoryRegion that provides the stack memory
@@ -81,10 +83,13 @@ class Stackwalker {
// object that is used to look up which code module each stack frame is
// associated with. supplier is an optional caller-supplied SymbolSupplier
// implementation. If supplier is NULL, source line info will not be
- // resolved.
+ // resolved. resolver is an instance of SourceLineResolverInterface
+ // (see source_line_resolver_interface.h and basic_source_line_resolver.h).
+ // If resolver is NULL, source line info will not be resolved.
Stackwalker(MemoryRegion *memory,
const CodeModules *modules,
- SymbolSupplier *supplier);
+ SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
// The stack memory to walk. Subclasses will require this region to
// get information from the stack.
@@ -115,6 +120,9 @@ class Stackwalker {
// The optional SymbolSupplier for resolving source line info.
SymbolSupplier *supplier_;
+
+ // The SourceLineResolver implementation
+ SourceLineResolverInterface *resolver_;
};