~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/breakpad/common/windows/pdb_source_line_writer.h

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-31 09:49:54 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071231094954-ix1amvcsj9pk61ya
Tags: 1:1.4.1.57486.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #180254), remaining changes:
  - debian/rules;
    - Added dh_icons
  - Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) 2006, Google Inc.
2
 
// All rights reserved.
3
 
//
4
 
// Redistribution and use in source and binary forms, with or without
5
 
// modification, are permitted provided that the following conditions are
6
 
// met:
7
 
//
8
 
//     * Redistributions of source code must retain the above copyright
9
 
// notice, this list of conditions and the following disclaimer.
10
 
//     * Redistributions in binary form must reproduce the above
11
 
// copyright notice, this list of conditions and the following disclaimer
12
 
// in the documentation and/or other materials provided with the
13
 
// distribution.
14
 
//     * Neither the name of Google Inc. nor the names of its
15
 
// contributors may be used to endorse or promote products derived from
16
 
// this software without specific prior written permission.
17
 
//
18
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 
 
30
 
// PDBSourceLineWriter uses a pdb file produced by Visual C++ to output
31
 
// a line/address map for use with BasicSourceLineResolver.
32
 
 
33
 
#ifndef _PDB_SOURCE_LINE_WRITER_H__
34
 
#define _PDB_SOURCE_LINE_WRITER_H__
35
 
 
36
 
#include <atlcomcli.h>
37
 
 
38
 
#include <string>
39
 
 
40
 
struct IDiaEnumLineNumbers;
41
 
struct IDiaSession;
42
 
struct IDiaSymbol;
43
 
 
44
 
namespace google_breakpad {
45
 
 
46
 
using std::wstring;
47
 
 
48
 
// A structure that carries information that identifies a pdb file.
49
 
struct PDBModuleInfo {
50
 
 public:
51
 
  // The basename of the pdb file from which information was loaded.
52
 
  wstring debug_file;
53
 
 
54
 
  // The pdb's identifier.  For recent pdb files, the identifier consists
55
 
  // of the pdb's guid, in uppercase hexadecimal form without any dashes
56
 
  // or separators, followed immediately by the pdb's age, also in
57
 
  // uppercase hexadecimal form.  For older pdb files which have no guid,
58
 
  // the identifier is the pdb's 32-bit signature value, in zero-padded
59
 
  // hexadecimal form, followed immediately by the pdb's age, in lowercase
60
 
  // hexadecimal form.
61
 
  wstring debug_identifier;
62
 
 
63
 
  // A string identifying the cpu that the pdb is associated with.
64
 
  // Currently, this may be "x86" or "unknown".
65
 
  wstring cpu;
66
 
};
67
 
 
68
 
class PDBSourceLineWriter {
69
 
 public:
70
 
  enum FileFormat {
71
 
    PDB_FILE,  // a .pdb file containing debug symbols
72
 
    EXE_FILE,  // a .exe or .dll file
73
 
    ANY_FILE   // try PDB_FILE and then EXE_FILE
74
 
  };
75
 
 
76
 
  explicit PDBSourceLineWriter();
77
 
  ~PDBSourceLineWriter();
78
 
 
79
 
  // Opens the given file.  For executable files, the corresponding pdb
80
 
  // file must be available; Open will be if it is not.
81
 
  // If there is already a pdb file open, it is automatically closed.
82
 
  // Returns true on success.
83
 
  bool Open(const wstring &file, FileFormat format);
84
 
 
85
 
  // Locates the pdb file for the given executable (exe or dll) file,
86
 
  // and opens it.  If there is already a pdb file open, it is automatically
87
 
  // closed.  Returns true on success.
88
 
  bool OpenExecutable(const wstring &exe_file);
89
 
 
90
 
  // Writes a map file from the current pdb file to the given file stream.
91
 
  // Returns true on success.
92
 
  bool WriteMap(FILE *map_file);
93
 
 
94
 
  // Closes the current pdb file and its associated resources.
95
 
  void Close();
96
 
 
97
 
  // Retrieves information about the module's debugging file.  Returns
98
 
  // true on success and false on failure.
99
 
  bool GetModuleInfo(PDBModuleInfo *info);
100
 
 
101
 
  // Sets uses_guid to true if the opened file uses a new-style CodeView
102
 
  // record with a 128-bit GUID, or false if the opened file uses an old-style
103
 
  // CodeView record.  When no GUID is available, a 32-bit signature should be
104
 
  // used to identify the module instead.  If the information cannot be
105
 
  // determined, this method returns false.
106
 
  bool UsesGUID(bool *uses_guid);
107
 
 
108
 
 private:
109
 
  // Outputs the line/address pairs for each line in the enumerator.
110
 
  // Returns true on success.
111
 
  bool PrintLines(IDiaEnumLineNumbers *lines);
112
 
 
113
 
  // Outputs a function address and name, followed by its source line list.
114
 
  // Returns true on success.
115
 
  bool PrintFunction(IDiaSymbol *function);
116
 
 
117
 
  // Outputs all functions as described above.  Returns true on success.
118
 
  bool PrintFunctions();
119
 
 
120
 
  // Outputs all of the source files in the session's pdb file.
121
 
  // Returns true on success.
122
 
  bool PrintSourceFiles();
123
 
 
124
 
  // Outputs all of the frame information necessary to construct stack
125
 
  // backtraces in the absence of frame pointers.  Returns true on success.
126
 
  bool PrintFrameData();
127
 
 
128
 
  // Outputs a single public symbol address and name, if the symbol corresponds
129
 
  // to a code address.  Returns true on success.  If symbol is does not
130
 
  // correspond to code, returns true without outputting anything.
131
 
  bool PrintCodePublicSymbol(IDiaSymbol *symbol);
132
 
 
133
 
  // Outputs a line identifying the PDB file that is being dumped, along with
134
 
  // its uuid and age.
135
 
  bool PrintPDBInfo();
136
 
 
137
 
  // Returns the function name for a symbol.  If possible, the name is
138
 
  // undecorated.  If the symbol's decorated form indicates the size of
139
 
  // parameters on the stack, this information is returned in stack_param_size.
140
 
  // Returns true on success.  If the symbol doesn't encode parameter size
141
 
  // information, stack_param_size is set to -1.
142
 
  static bool GetSymbolFunctionName(IDiaSymbol *function, BSTR *name,
143
 
                                    int *stack_param_size);
144
 
 
145
 
  // Returns the number of bytes of stack space used for a function's
146
 
  // parameters.  function must have the tag SymTagFunction.  In the event of
147
 
  // a failure, returns 0, which is also a valid number of bytes.
148
 
  static int GetFunctionStackParamSize(IDiaSymbol *function);
149
 
 
150
 
  // The session for the currently-open pdb file.
151
 
  CComPtr<IDiaSession> session_;
152
 
 
153
 
  // The current output file for this WriteMap invocation.
154
 
  FILE *output_;
155
 
 
156
 
  // Disallow copy ctor and operator=
157
 
  PDBSourceLineWriter(const PDBSourceLineWriter&);
158
 
  void operator=(const PDBSourceLineWriter&);
159
 
};
160
 
 
161
 
}  // namespace google_breakpad
162
 
 
163
 
#endif  // _PDB_SOURCE_LINE_WRITER_H__