toolkit/crashreporter/google-breakpad/src/processor/simple_symbol_supplier.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/crashreporter/google-breakpad/src/processor/simple_symbol_supplier.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     1.4 +// Copyright (c) 2006, Google Inc.
     1.5 +// All rights reserved.
     1.6 +//
     1.7 +// Redistribution and use in source and binary forms, with or without
     1.8 +// modification, are permitted provided that the following conditions are
     1.9 +// met:
    1.10 +//
    1.11 +//     * Redistributions of source code must retain the above copyright
    1.12 +// notice, this list of conditions and the following disclaimer.
    1.13 +//     * Redistributions in binary form must reproduce the above
    1.14 +// copyright notice, this list of conditions and the following disclaimer
    1.15 +// in the documentation and/or other materials provided with the
    1.16 +// distribution.
    1.17 +//     * Neither the name of Google Inc. nor the names of its
    1.18 +// contributors may be used to endorse or promote products derived from
    1.19 +// this software without specific prior written permission.
    1.20 +//
    1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.32 +
    1.33 +// simple_symbol_supplier.h: A simple SymbolSupplier implementation
    1.34 +//
    1.35 +// SimpleSymbolSupplier is a straightforward implementation of SymbolSupplier
    1.36 +// that stores symbol files in a filesystem tree.  A SimpleSymbolSupplier is
    1.37 +// created with one or more base directories, which are the root paths for all
    1.38 +// symbol files.  Each symbol file contained therein has a directory entry in
    1.39 +// the base directory with a name identical to the corresponding debugging 
    1.40 +// file (pdb).  Within each of these directories, there are subdirectories
    1.41 +// named for the debugging file's identifier.  For recent pdb files, this is
    1.42 +// a concatenation of the pdb's uuid and age, presented in hexadecimal form,
    1.43 +// without any dashes or separators.  The uuid is in uppercase hexadecimal
    1.44 +// and the age is in lowercase hexadecimal.  Within that subdirectory,
    1.45 +// SimpleSymbolSupplier expects to find the symbol file, which is named
    1.46 +// identically to the debug file, but with a .sym extension.  If the original
    1.47 +// debug file had a name ending in .pdb, the .pdb extension will be replaced
    1.48 +// with .sym.  This sample hierarchy is rooted at the "symbols" base
    1.49 +// directory:
    1.50 +//
    1.51 +// symbols
    1.52 +// symbols/test_app.pdb
    1.53 +// symbols/test_app.pdb/63FE4780728D49379B9D7BB6460CB42A1
    1.54 +// symbols/test_app.pdb/63FE4780728D49379B9D7BB6460CB42A1/test_app.sym
    1.55 +// symbols/kernel32.pdb
    1.56 +// symbols/kernel32.pdb/BCE8785C57B44245A669896B6A19B9542
    1.57 +// symbols/kernel32.pdb/BCE8785C57B44245A669896B6A19B9542/kernel32.sym
    1.58 +//
    1.59 +// In this case, the uuid of test_app.pdb is
    1.60 +// 63fe4780-728d-4937-9b9d-7bb6460cb42a and its age is 1.
    1.61 +//
    1.62 +// This scheme was chosen to be roughly analogous to the way that
    1.63 +// symbol files may be accessed from Microsoft Symbol Server.  A hierarchy
    1.64 +// used for Microsoft Symbol Server storage is usable as a hierarchy for
    1.65 +// SimpleSymbolServer, provided that the pdb files are transformed to dumped
    1.66 +// format using a tool such as dump_syms, and given a .sym extension.
    1.67 +//
    1.68 +// SimpleSymbolSupplier will iterate over all root paths searching for
    1.69 +// a symbol file existing in that path.
    1.70 +//
    1.71 +// SimpleSymbolSupplier supports any debugging file which can be identified
    1.72 +// by a CodeModule object's debug_file and debug_identifier accessors.  The
    1.73 +// expected ultimate source of these CodeModule objects are MinidumpModule
    1.74 +// objects; it is this class that is responsible for assigning appropriate
    1.75 +// values for debug_file and debug_identifier.
    1.76 +//
    1.77 +// Author: Mark Mentovai
    1.78 +
    1.79 +#ifndef PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__
    1.80 +#define PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__
    1.81 +
    1.82 +#include <map>
    1.83 +#include <string>
    1.84 +#include <vector>
    1.85 +
    1.86 +#include "common/using_std_string.h"
    1.87 +#include "google_breakpad/processor/symbol_supplier.h"
    1.88 +
    1.89 +namespace google_breakpad {
    1.90 +
    1.91 +using std::map;
    1.92 +using std::vector;
    1.93 +
    1.94 +class CodeModule;
    1.95 +
    1.96 +class SimpleSymbolSupplier : public SymbolSupplier {
    1.97 + public:
    1.98 +  // Creates a new SimpleSymbolSupplier, using path as the root path where
    1.99 +  // symbols are stored.
   1.100 +  explicit SimpleSymbolSupplier(const string &path) : paths_(1, path) {}
   1.101 +
   1.102 +  // Creates a new SimpleSymbolSupplier, using paths as a list of root
   1.103 +  // paths where symbols may be stored.
   1.104 +  explicit SimpleSymbolSupplier(const vector<string> &paths) : paths_(paths) {}
   1.105 +
   1.106 +  virtual ~SimpleSymbolSupplier() {}
   1.107 +
   1.108 +  // Returns the path to the symbol file for the given module.  See the
   1.109 +  // description above.
   1.110 +  virtual SymbolResult GetSymbolFile(const CodeModule *module,
   1.111 +                                     const SystemInfo *system_info,
   1.112 +                                     string *symbol_file);
   1.113 +
   1.114 +  virtual SymbolResult GetSymbolFile(const CodeModule *module,
   1.115 +                                     const SystemInfo *system_info,
   1.116 +                                     string *symbol_file,
   1.117 +                                     string *symbol_data);
   1.118 +
   1.119 +  // Allocates data buffer on heap and writes symbol data into buffer.
   1.120 +  // Symbol supplier ALWAYS takes ownership of the data buffer.
   1.121 +  virtual SymbolResult GetCStringSymbolData(const CodeModule *module,
   1.122 +                                            const SystemInfo *system_info,
   1.123 +                                            string *symbol_file,
   1.124 +                                            char **symbol_data);
   1.125 +
   1.126 +  // Free the data buffer allocated in the above GetCStringSymbolData();
   1.127 +  virtual void FreeSymbolData(const CodeModule *module);
   1.128 +
   1.129 + protected:
   1.130 +  SymbolResult GetSymbolFileAtPathFromRoot(const CodeModule *module,
   1.131 +                                           const SystemInfo *system_info,
   1.132 +                                           const string &root_path,
   1.133 +                                           string *symbol_file);
   1.134 +
   1.135 + private:
   1.136 +  map<string, char *> memory_buffers_;
   1.137 +  vector<string> paths_;
   1.138 +};
   1.139 +
   1.140 +}  // namespace google_breakpad
   1.141 +
   1.142 +#endif  // PROCESSOR_SIMPLE_SYMBOL_SUPPLIER_H__

mercurial