Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // -*- mode: c++ -*- | 1 // -*- mode: c++ -*- |
| 2 | 2 |
| 3 // Copyright (c) 2011, Google Inc. | 3 // Copyright (c) 2011, Google Inc. |
| 4 // All rights reserved. | 4 // All rights reserved. |
| 5 // | 5 // |
| 6 // Redistribution and use in source and binary forms, with or without | 6 // Redistribution and use in source and binary forms, with or without |
| 7 // modification, are permitted provided that the following conditions are | 7 // modification, are permitted provided that the following conditions are |
| 8 // met: | 8 // met: |
| 9 // | 9 // |
| 10 // * Redistributions of source code must retain the above copyright | 10 // * Redistributions of source code must retain the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | 31 |
| 32 // Author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> | 32 // Author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> |
| 33 | 33 |
| 34 // dump_syms.h: Declaration of google_breakpad::DumpSymbols, a class for | 34 // dump_syms.h: Declaration of google_breakpad::DumpSymbols, a class for |
| 35 // reading debugging information from Mach-O files and writing it out as a | 35 // reading debugging information from Mach-O files and writing it out as a |
| 36 // Breakpad symbol file. | 36 // Breakpad symbol file. |
| 37 | 37 |
| 38 #include <Foundation/Foundation.h> | |
| 39 #include <mach-o/loader.h> | 38 #include <mach-o/loader.h> |
| 40 #include <stdio.h> | 39 #include <stdio.h> |
| 41 #include <stdlib.h> | 40 #include <stdlib.h> |
| 42 | 41 |
| 43 #include <ostream> | 42 #include <ostream> |
| 44 #include <string> | 43 #include <string> |
| 45 #include <vector> | 44 #include <vector> |
| 46 | 45 |
| 47 #include "common/byte_cursor.h" | 46 #include "common/byte_cursor.h" |
| 48 #include "common/mac/macho_reader.h" | 47 #include "common/mac/macho_reader.h" |
| 49 #include "common/mac/super_fat_arch.h" | 48 #include "common/mac/super_fat_arch.h" |
| 50 #include "common/module.h" | 49 #include "common/module.h" |
| 51 #include "common/symbol_data.h" | 50 #include "common/symbol_data.h" |
| 52 | 51 |
| 53 namespace google_breakpad { | 52 namespace google_breakpad { |
| 54 | 53 |
| 55 class DumpSymbols { | 54 class DumpSymbols { |
| 56 public: | 55 public: |
| 57 DumpSymbols(SymbolData symbol_data, bool handle_inter_cu_refs) | 56 DumpSymbols(SymbolData symbol_data, bool handle_inter_cu_refs) |
| 58 : symbol_data_(symbol_data), | 57 : symbol_data_(symbol_data), |
| 59 handle_inter_cu_refs_(handle_inter_cu_refs), | 58 handle_inter_cu_refs_(handle_inter_cu_refs), |
| 60 input_pathname_(), | 59 input_pathname_(), |
| 61 object_filename_(), | 60 object_filename_(), |
| 62 contents_(), | 61 contents_(), |
| 63 object_files_(), | 62 object_files_(), |
| 64 selected_object_file_(), | 63 selected_object_file_(), |
| 65 selected_object_name_() { } | 64 selected_object_name_() { } |
| 66 ~DumpSymbols() { | 65 ~DumpSymbols() { |
| 67 [input_pathname_ release]; | |
| 68 [object_filename_ release]; | |
| 69 [contents_ release]; | |
| 70 } | 66 } |
| 71 | 67 |
| 72 // Prepare to read debugging information from |filename|. |filename| may be | 68 // Prepare to read debugging information from |filename|. |filename| may be |
| 73 // the name of a universal binary, a Mach-O file, or a dSYM bundle | 69 // the name of a universal binary, a Mach-O file, or a dSYM bundle |
| 74 // containing either of the above. On success, return true; if there is a | 70 // containing either of the above. On success, return true; if there is a |
| 75 // problem reading |filename|, report it and return false. | 71 // problem reading |filename|, report it and return false. |
| 76 // | 72 bool Read(const std::string &filename); |
| 77 // (This class uses NSString for filenames and related values, | |
| 78 // because the Mac Foundation framework seems to support | |
| 79 // filename-related operations more fully on NSString values.) | |
| 80 bool Read(NSString *filename); | |
| 81 | 73 |
| 82 // If this dumper's file includes an object file for |cpu_type| and | 74 // If this dumper's file includes an object file for |cpu_type| and |
| 83 // |cpu_subtype|, then select that object file for dumping, and return | 75 // |cpu_subtype|, then select that object file for dumping, and return |
| 84 // true. Otherwise, return false, and leave this dumper's selected | 76 // true. Otherwise, return false, and leave this dumper's selected |
| 85 // architecture unchanged. | 77 // architecture unchanged. |
| 86 // | 78 // |
| 87 // By default, if this dumper's file contains only one object file, then | 79 // By default, if this dumper's file contains only one object file, then |
| 88 // the dumper will dump those symbols; and if it contains more than one | 80 // the dumper will dump those symbols; and if it contains more than one |
| 89 // object file, then the dumper will dump the object file whose | 81 // object file, then the dumper will dump the object file whose |
| 90 // architecture matches that of this dumper program. | 82 // architecture matches that of this dumper program. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 bool eh_frame) const; | 148 bool eh_frame) const; |
| 157 | 149 |
| 158 // The selection of what type of symbol data to read/write. | 150 // The selection of what type of symbol data to read/write. |
| 159 const SymbolData symbol_data_; | 151 const SymbolData symbol_data_; |
| 160 | 152 |
| 161 // Whether to handle references between compilation units. | 153 // Whether to handle references between compilation units. |
| 162 const bool handle_inter_cu_refs_; | 154 const bool handle_inter_cu_refs_; |
| 163 | 155 |
| 164 // The name of the file or bundle whose symbols this will dump. | 156 // The name of the file or bundle whose symbols this will dump. |
| 165 // This is the path given to Read, for use in error messages. | 157 // This is the path given to Read, for use in error messages. |
| 166 NSString *input_pathname_; | 158 std::string input_pathname_; |
| 167 | 159 |
| 168 // The name of the file this DumpSymbols will actually read debugging | 160 // The name of the file this DumpSymbols will actually read debugging |
| 169 // information from. Normally, this is the same as input_pathname_, but if | 161 // information from. Normally, this is the same as input_pathname_, but if |
| 170 // filename refers to a dSYM bundle, then this is the resource file | 162 // filename refers to a dSYM bundle, then this is the resource file |
| 171 // within that bundle. | 163 // within that bundle. |
| 172 NSString *object_filename_; | 164 std::string object_filename_; |
| 173 | 165 |
| 174 // The complete contents of object_filename_, mapped into memory. | 166 // The complete contents of object_filename_, mapped into memory. |
| 175 NSData *contents_; | 167 vector<uint8_t> contents_; |
|
Mark Mentovai
2015/09/11 15:49:50
vector<> always initializes each element when it g
Ted Mielczarek
2015/09/15 12:58:36
Done.
| |
| 176 | 168 |
| 177 // A vector of SuperFatArch structures describing the object files | 169 // A vector of SuperFatArch structures describing the object files |
| 178 // object_filename_ contains. If object_filename_ refers to a fat binary, | 170 // object_filename_ contains. If object_filename_ refers to a fat binary, |
| 179 // this may have more than one element; if it refers to a Mach-O file, this | 171 // this may have more than one element; if it refers to a Mach-O file, this |
| 180 // has exactly one element. | 172 // has exactly one element. |
| 181 vector<SuperFatArch> object_files_; | 173 vector<SuperFatArch> object_files_; |
| 182 | 174 |
| 183 // The object file in object_files_ selected to dump, or NULL if | 175 // The object file in object_files_ selected to dump, or NULL if |
| 184 // SetArchitecture hasn't been called yet. | 176 // SetArchitecture hasn't been called yet. |
| 185 const SuperFatArch *selected_object_file_; | 177 const SuperFatArch *selected_object_file_; |
| 186 | 178 |
| 187 // A string that identifies the selected object file, for use in error | 179 // A string that identifies the selected object file, for use in error |
| 188 // messages. This is usually object_filename_, but if that refers to a | 180 // messages. This is usually object_filename_, but if that refers to a |
| 189 // fat binary, it includes an indication of the particular architecture | 181 // fat binary, it includes an indication of the particular architecture |
| 190 // within that binary. | 182 // within that binary. |
| 191 string selected_object_name_; | 183 string selected_object_name_; |
| 192 }; | 184 }; |
| 193 | 185 |
| 194 } // namespace google_breakpad | 186 } // namespace google_breakpad |
| OLD | NEW |