source_line_resolver_interface.h revision 83e085b7a331c96237cf8e814f97b3ef4c36a70f
1// -*- mode: C++ -*-
2
3// Copyright (c) 2010 Google Inc.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10//     * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12//     * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16//     * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32// Abstract interface to return function/file/line info for a memory address.
33
34#ifndef GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
35#define GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
36
37#include <string>
38#include "google_breakpad/common/breakpad_types.h"
39
40namespace google_breakpad {
41
42using std::string;
43
44struct StackFrame;
45struct WindowsFrameInfo;
46
47class SourceLineResolverInterface {
48 public:
49  typedef u_int64_t MemAddr;
50
51  virtual ~SourceLineResolverInterface() {}
52
53  // Adds a module to this resolver, returning true on success.
54  //
55  // module_name may be an arbitrary string.  Typically, it will be the
56  // filename of the module, optionally with version identifiers.
57  //
58  // map_file should contain line/address mappings for this module.
59  virtual bool LoadModule(const string &module_name,
60                          const string &map_file) = 0;
61  // Same as above, but takes the contents of a pre-read map buffer
62  virtual bool LoadModuleUsingMapBuffer(const string &module_name,
63                                        const string &map_buffer) = 0;
64
65  // Returns true if a module with the given name has been loaded.
66  virtual bool HasModule(const string &module_name) const = 0;
67
68  // Fills in the function_base, function_name, source_file_name,
69  // and source_line fields of the StackFrame.  The instruction and
70  // module_name fields must already be filled in.
71  virtual void FillSourceLineInfo(StackFrame *frame) const = 0;
72
73  // If Windows stack walking information is available covering
74  // FRAME's instruction address, return a WindowsFrameInfo structure
75  // describing it. If the information is not available, returns NULL.
76  // A NULL return value does not indicate an error. The caller takes
77  // ownership of any returned WindowsFrameInfo object.
78  virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame)
79    const = 0;
80
81 protected:
82  // SourceLineResolverInterface cannot be instantiated except by subclasses
83  SourceLineResolverInterface() {}
84};
85
86}  // namespace google_breakpad
87
88#endif  // GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
89