toolkit/crashreporter/google-breakpad/src/common/mac/dump_syms.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // -*- mode: c++ -*-
michael@0 2
michael@0 3 // Copyright (c) 2011, Google Inc.
michael@0 4 // All rights reserved.
michael@0 5 //
michael@0 6 // Redistribution and use in source and binary forms, with or without
michael@0 7 // modification, are permitted provided that the following conditions are
michael@0 8 // met:
michael@0 9 //
michael@0 10 // * Redistributions of source code must retain the above copyright
michael@0 11 // notice, this list of conditions and the following disclaimer.
michael@0 12 // * Redistributions in binary form must reproduce the above
michael@0 13 // copyright notice, this list of conditions and the following disclaimer
michael@0 14 // in the documentation and/or other materials provided with the
michael@0 15 // distribution.
michael@0 16 // * Neither the name of Google Inc. nor the names of its
michael@0 17 // contributors may be used to endorse or promote products derived from
michael@0 18 // this software without specific prior written permission.
michael@0 19 //
michael@0 20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 31
michael@0 32 // Author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com>
michael@0 33
michael@0 34 // dump_syms.h: Declaration of google_breakpad::DumpSymbols, a class for
michael@0 35 // reading debugging information from Mach-O files and writing it out as a
michael@0 36 // Breakpad symbol file.
michael@0 37
michael@0 38 #include <Foundation/Foundation.h>
michael@0 39 #include <mach-o/loader.h>
michael@0 40 #include <stdio.h>
michael@0 41 #include <stdlib.h>
michael@0 42
michael@0 43 #include <ostream>
michael@0 44 #include <string>
michael@0 45 #include <vector>
michael@0 46
michael@0 47 #include "common/byte_cursor.h"
michael@0 48 #include "common/mac/macho_reader.h"
michael@0 49 #include "common/module.h"
michael@0 50 #include "common/symbol_data.h"
michael@0 51
michael@0 52 namespace google_breakpad {
michael@0 53
michael@0 54 class DumpSymbols {
michael@0 55 public:
michael@0 56 explicit DumpSymbols(SymbolData symbol_data)
michael@0 57 : symbol_data_(symbol_data),
michael@0 58 input_pathname_(),
michael@0 59 object_filename_(),
michael@0 60 contents_(),
michael@0 61 selected_object_file_(),
michael@0 62 selected_object_name_() { }
michael@0 63 ~DumpSymbols() {
michael@0 64 [input_pathname_ release];
michael@0 65 [object_filename_ release];
michael@0 66 [contents_ release];
michael@0 67 }
michael@0 68
michael@0 69 // Prepare to read debugging information from |filename|. |filename| may be
michael@0 70 // the name of a universal binary, a Mach-O file, or a dSYM bundle
michael@0 71 // containing either of the above. On success, return true; if there is a
michael@0 72 // problem reading |filename|, report it and return false.
michael@0 73 //
michael@0 74 // (This class uses NSString for filenames and related values,
michael@0 75 // because the Mac Foundation framework seems to support
michael@0 76 // filename-related operations more fully on NSString values.)
michael@0 77 bool Read(NSString *filename);
michael@0 78
michael@0 79 // If this dumper's file includes an object file for |cpu_type| and
michael@0 80 // |cpu_subtype|, then select that object file for dumping, and return
michael@0 81 // true. Otherwise, return false, and leave this dumper's selected
michael@0 82 // architecture unchanged.
michael@0 83 //
michael@0 84 // By default, if this dumper's file contains only one object file, then
michael@0 85 // the dumper will dump those symbols; and if it contains more than one
michael@0 86 // object file, then the dumper will dump the object file whose
michael@0 87 // architecture matches that of this dumper program.
michael@0 88 bool SetArchitecture(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype);
michael@0 89
michael@0 90 // If this dumper's file includes an object file for |arch_name|, then select
michael@0 91 // that object file for dumping, and return true. Otherwise, return false,
michael@0 92 // and leave this dumper's selected architecture unchanged.
michael@0 93 //
michael@0 94 // By default, if this dumper's file contains only one object file, then
michael@0 95 // the dumper will dump those symbols; and if it contains more than one
michael@0 96 // object file, then the dumper will dump the object file whose
michael@0 97 // architecture matches that of this dumper program.
michael@0 98 bool SetArchitecture(const std::string &arch_name);
michael@0 99
michael@0 100 // Return a pointer to an array of 'struct fat_arch' structures,
michael@0 101 // describing the object files contained in this dumper's file. Set
michael@0 102 // *|count| to the number of elements in the array. The returned array is
michael@0 103 // owned by this DumpSymbols instance.
michael@0 104 //
michael@0 105 // If there are no available architectures, this function
michael@0 106 // may return NULL.
michael@0 107 const struct fat_arch *AvailableArchitectures(size_t *count) {
michael@0 108 *count = object_files_.size();
michael@0 109 if (object_files_.size() > 0)
michael@0 110 return &object_files_[0];
michael@0 111 return NULL;
michael@0 112 }
michael@0 113
michael@0 114 // Read the selected object file's debugging information, and write it out to
michael@0 115 // |stream|. Return true on success; if an error occurs, report it and
michael@0 116 // return false.
michael@0 117 bool WriteSymbolFile(std::ostream &stream);
michael@0 118
michael@0 119 // As above, but simply return the debugging information in module
michael@0 120 // instead of writing it to a stream. The caller owns the resulting
michael@0 121 // module object and must delete it when finished.
michael@0 122 bool ReadSymbolData(Module** module);
michael@0 123
michael@0 124 private:
michael@0 125 // Used internally.
michael@0 126 class DumperLineToModule;
michael@0 127 class LoadCommandDumper;
michael@0 128
michael@0 129 // Return an identifier string for the file this DumpSymbols is dumping.
michael@0 130 std::string Identifier();
michael@0 131
michael@0 132 // Read debugging information from |dwarf_sections|, which was taken from
michael@0 133 // |macho_reader|, and add it to |module|. On success, return true;
michael@0 134 // on failure, report the problem and return false.
michael@0 135 bool ReadDwarf(google_breakpad::Module *module,
michael@0 136 const mach_o::Reader &macho_reader,
michael@0 137 const mach_o::SectionMap &dwarf_sections) const;
michael@0 138
michael@0 139 // Read DWARF CFI or .eh_frame data from |section|, belonging to
michael@0 140 // |macho_reader|, and record it in |module|. If |eh_frame| is true,
michael@0 141 // then the data is .eh_frame-format data; otherwise, it is standard DWARF
michael@0 142 // .debug_frame data. On success, return true; on failure, report
michael@0 143 // the problem and return false.
michael@0 144 bool ReadCFI(google_breakpad::Module *module,
michael@0 145 const mach_o::Reader &macho_reader,
michael@0 146 const mach_o::Section &section,
michael@0 147 bool eh_frame) const;
michael@0 148
michael@0 149 // The selection of what type of symbol data to read/write.
michael@0 150 const SymbolData symbol_data_;
michael@0 151
michael@0 152 // The name of the file or bundle whose symbols this will dump.
michael@0 153 // This is the path given to Read, for use in error messages.
michael@0 154 NSString *input_pathname_;
michael@0 155
michael@0 156 // The name of the file this DumpSymbols will actually read debugging
michael@0 157 // information from. Normally, this is the same as input_pathname_, but if
michael@0 158 // filename refers to a dSYM bundle, then this is the resource file
michael@0 159 // within that bundle.
michael@0 160 NSString *object_filename_;
michael@0 161
michael@0 162 // The complete contents of object_filename_, mapped into memory.
michael@0 163 NSData *contents_;
michael@0 164
michael@0 165 // A vector of fat_arch structures describing the object files
michael@0 166 // object_filename_ contains. If object_filename_ refers to a fat binary,
michael@0 167 // this may have more than one element; if it refers to a Mach-O file, this
michael@0 168 // has exactly one element.
michael@0 169 vector<struct fat_arch> object_files_;
michael@0 170
michael@0 171 // The object file in object_files_ selected to dump, or NULL if
michael@0 172 // SetArchitecture hasn't been called yet.
michael@0 173 const struct fat_arch *selected_object_file_;
michael@0 174
michael@0 175 // A string that identifies the selected object file, for use in error
michael@0 176 // messages. This is usually object_filename_, but if that refers to a
michael@0 177 // fat binary, it includes an indication of the particular architecture
michael@0 178 // within that binary.
michael@0 179 string selected_object_name_;
michael@0 180 };
michael@0 181
michael@0 182 } // namespace google_breakpad

mercurial