Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: snapshot/module_snapshot.h

Issue 597673004: Add the Snapshot interface (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Make everything else const too Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « snapshot/memory_snapshot.h ('k') | snapshot/process_snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_SNAPSHOT_MODULE_SNAPSHOT_H_
16 #define CRASHPAD_SNAPSHOT_MODULE_SNAPSHOT_H_
17
18 #include <stdint.h>
19 #include <sys/types.h>
20
21 #include <map>
22 #include <string>
23 #include <vector>
24
25 #include "util/misc/uuid.h"
26
27 namespace crashpad {
28
29 //! \brief An abstract interface to a snapshot representing a code module
30 //! (binary image) loaded into a snapshot process.
31 class ModuleSnapshot {
32 public:
33 //! \brief A module’s type.
34 enum ModuleType {
35 //! \brief The module’s type is unknown.
36 kModuleTypeUnknown = 0,
37
38 //! \brief The module is a main executable.
39 kModuleTypeExecutable,
40
41 //! \brief The module is a shared library.
42 //!
43 //! \sa kModuleTypeLoadableModule
44 kModuleTypeSharedLibrary,
45
46 //! \brief The module is a loadable module.
47 //!
48 //! On some platforms, loadable modules are distinguished from shared
49 //! libraries. On these platforms, a shared library is a module that another
50 //! module links against directly, and a loadable module is not. Loadable
51 //! modules tend to be binary plug-ins.
52 kModuleTypeLoadableModule,
53
54 //! \brief The module is a dynamic loader.
55 //!
56 //! This is the module responsible for loading other modules. This is
57 //! normally `dyld` for Mac OS X and `ld.so` for Linux and other systems
58 //! using ELF.
59 kModuleTypeDynamicLoader,
60 };
61
62 //! \brief Returns the module’s pathname.
63 virtual std::string Name() const = 0;
64
65 //! \brief Returns the base address that the module is loaded at in the
66 //! snapshot process.
67 virtual uint64_t Address() const = 0;
68
69 //! \brief Returns the size that the module occupies in the snapshot process’
70 //! address space, starting at its base address.
71 //!
72 //! For Mac OS X snapshots, this method only reports the size of the `__TEXT`
73 //! segment, because segments may not be loaded contiguously.
74 virtual uint64_t Size() const = 0;
75
76 //! \brief Returns the module’s timestamp, if known.
77 //!
78 //! The timestamp is typically the modification time of the file that provided
79 //! the module in `time_t` format, seconds since the POSIX epoch. If the
80 //! module’s timestamp is unknown, this method returns `0`.
81 virtual time_t Timestamp() const = 0;
82
83 //! \brief Returns the module’s file version in the \a version_* parameters.
84 //!
85 //! If no file version can be determined, the \a version_* parameters are set
86 //! to `0`.
87 //!
88 //! For Mac OS X snapshots, this is taken from the module’s `LC_ID_DYLIB` load
89 //! command for shared libraries, and is `0` for other module types.
90 virtual void FileVersion(uint16_t* version_0,
91 uint16_t* version_1,
92 uint16_t* version_2,
93 uint16_t* version_3) const = 0;
94
95 //! \brief Returns the module’s source version in the \a version_* parameters.
96 //!
97 //! If no source version can be determined, the \a version_* parameters are
98 //! set to `0`.
99 //!
100 //! For Mac OS X snapshots, this is taken from the module’s
101 //! `LC_SOURCE_VERSION` load command.
102 virtual void SourceVersion(uint16_t* version_0,
103 uint16_t* version_1,
104 uint16_t* version_2,
105 uint16_t* version_3) const = 0;
106
107 //! \brief Returns the module’s type.
108 virtual ModuleType GetModuleType() const = 0;
109
110 //! \brief Returns the module’s UUID in the \a uuid parameter.
111 //!
112 //! A snapshot module’s UUID is taken directly from the module itself. If the
113 //! module does not have a UUID, the \a uuid parameter will be zeroed out.
114 virtual void UUID(crashpad::UUID* uuid) const = 0;
115
116 //! \brief Returns diagnostic messages recorded in the module.
117 //!
118 //! This method retrieves diagnostic messages recorded in a module. These
119 //! messages are intended for diagnostic use, including crash analysis. A
120 //! module may contain multiple diagnostic messages.
121 //!
122 //! For Mac OS X snapshots, the diagnostic messages are found by interpreting
123 //! the module’s `__DATA, __crash_info` section as
124 //! `crashreporter_annotations_t`. System libraries using the crash reporter
125 //! client interface may reference diagnostic messages in this structure.
126 //! Additional diagnostic messages may be found in other locations, which may
127 //! be module-specific. The dynamic linker (`dyld`) can provide a diagnostic
128 //! message at its `_error_string` symbol.
129 virtual std::vector<std::string> DiagnosticMessages() const = 0;
130
131 //! \brief Returns simple annotations recorded in the module.
132 //!
133 //! This method retrieves simple annotations recorded in a module. These
134 //! annotations are intended for diagnostic use, including crash analysis.
135 //! Simple annotations are structured as a sequence of key-value pairs. These
136 //! are referred to in Chrome as “crash keys.”
137 //!
138 //! For Mac OS X snapshots, simple annotations are found by interpreting
139 //! the `__DATA, __crashpad_info` section as `CrashpadInfo`. Clients can use
140 //! the Crashpad client interface to store annotations in this structure.
141 virtual std::map<std::string, std::string> SimpleAnnotations() const = 0;
142
143 protected:
144 ~ModuleSnapshot() {}
145 };
146
147 } // namespace crashpad
148
149 #endif // CRASHPAD_SNAPSHOT_MODULE_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « snapshot/memory_snapshot.h ('k') | snapshot/process_snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698