OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_MAC_MACH_O_IMAGE_ANNOTATIONS_READER_H_ | |
16 #define CRASHPAD_UTIL_MAC_MACH_O_IMAGE_ANNOTATIONS_READER_H_ | |
17 | |
18 #include <map> | |
19 #include <string> | |
20 #include <vector> | |
21 | |
22 #include "base/basictypes.h" | |
23 | |
24 namespace crashpad { | |
25 | |
26 class MachOImageReader; | |
27 class ProcessReader; | |
28 | |
29 //! \brief A reader for annotations stored in a Mach-O image mapped into another | |
30 //! process. | |
31 //! | |
32 //! These annotations are stored for the benefit of crash reporters, and provide | |
33 //! information though to be potentially useful for crash analysis. This class | |
34 //! can decode annotations stored in these formats: | |
35 //! - CrashpadInfo. This format is used by Crashpad clients. The “simple | |
36 //! annotations” are recovered from any module with a compatible data | |
37 //! section, and are included in the annotations returned by SimpleMap(). | |
38 //! - `CrashReporterClient.h`’s `crashreporter_annotations_t`. This format is | |
39 //! used by Apple code. The `message` and `message2` fields can be recovered | |
40 //! from any module with a compatible data section, and are included in the | |
41 //! annotations returned by Vector(). | |
42 //! - `dyld`’s `error_string`. This format is used exclusively by dyld, | |
43 //! typically for fatal errors. This string can be recovered from any | |
44 //! `MH_DYLINKER`-type module with this symbol, and is included in the | |
45 //! annotations returned by Vector(). | |
46 class MachOImageAnnotationsReader { | |
47 public: | |
48 //! \brief Constructs an object. | |
49 //! | |
50 //! \param[in] process_reader The reader for the remote process. | |
51 //! \param[in] image_reader The MachOImageReader for the Mach-O image file | |
52 //! contained within the remote process. | |
53 //! \param[in] name The module’s name, a string to be used in logged messages. | |
54 //! This string is for diagnostic purposes only, and may be empty. | |
55 MachOImageAnnotationsReader(ProcessReader* process_reader, | |
56 const MachOImageReader* image_reader, | |
57 const std::string& name); | |
58 | |
59 ~MachOImageAnnotationsReader() {} | |
60 | |
61 //! \brief Returns the module’s annotations that are organized as a vector of | |
62 //! strings. | |
63 std::vector<std::string> Vector() const; | |
Robert Sesek
2014/10/15 20:25:20
What if there are errors during the reading proces
| |
64 | |
65 //! \brief Returns the module’s annotations that are organized as key-value | |
66 //! pairs, where all keys and values are strings. | |
67 std::map<std::string, std::string> SimpleMap() const; | |
Robert Sesek
2014/10/15 20:25:20
Why SimpleMap() instead of just Map() to match Vec
| |
68 | |
69 private: | |
70 // Reades crashreporter_annotations_t::message and | |
71 // crashreporter_annotations_t::message2 on behalf of Vector(). | |
72 void ReadCrashReporterClientAnnotations( | |
73 std::vector<std::string>* vector_annotations) const; | |
74 | |
75 // Reads dyld_error_string on behalf of Vector(). | |
76 void ReadDyldErrorStringAnnotation( | |
77 std::vector<std::string>* vector_annotations) const; | |
78 | |
79 // Reads CrashpadInfo::simple_annotations_ on behalf of SimpleMap(). | |
80 void ReadCrashpadSimpleAnnotations( | |
81 std::map<std::string, std::string>* simple_map_annotations) const; | |
82 | |
83 std::string name_; | |
84 ProcessReader* process_reader_; // weak | |
85 const MachOImageReader* image_reader_; // weak | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(MachOImageAnnotationsReader); | |
88 }; | |
89 | |
90 } // namespace crashpad | |
91 | |
92 #endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_ANNOTATIONS_READER_H_ | |
OLD | NEW |