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

Side by Side Diff: snapshot/system_snapshot.h

Issue 597673004: Add the Snapshot interface (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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
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_SYSTEM_SNAPSHOT_H_
16 #define CRASHPAD_SNAPSHOT_SYSTEM_SNAPSHOT_H_
17
18 #include <stdint.h>
19 #include <sys/types.h>
20
21 #include <string>
22
23 namespace crashpad {
24
25 //! \brief An abstract interface to a snapshot representing the state of a
26 //! system, comprising an operating system, CPU architecture, and various
27 //! other characteristics.
28 class SystemSnapshot {
29 public:
30 //! \brief A system’s CPU architecture.
31 enum CPUArchitecture {
Robert Sesek 2014/09/25 15:44:08 This seems redundant with the CPUContext::ContextF
32 //! \brief The snapshot system’s CPU architecture is unknown.
33 kCPUArchitectureUnknown = 0,
34
35 //! \brief 32-bit x86 (not 64-bit-capable).
36 kCPUArchitectureX86,
37
38 //! \brief x86_64.
39 kCPUArchitectureX86_64,
40 };
41
42 //! \brief A system’s operating system family.
43 enum OperatingSystem {
44 //! \brief The snapshot system’s operating system is unknown.
45 kOperatingSystemUnknown = 0,
46
47 //! \brief Mac OS X.
48 kOperatingSystemMacOSX,
49 };
50
51 //! \brief A system’s daylight saving time status.
52 //!
53 //! The daylight saving time status is taken partially from the system’s
54 //! locale configuration. This determines whether daylight saving time is
55 //! ever observed on the system. If it is, the snapshot’s time
56 //! (ProcessSnapshot::SnapshotTime()) is used to determine whether the system
57 //! was observing daylight saving time at the time of the snapshot.
58 enum DaylightSavingTimeStatus {
59 //! \brief Daylight saving time is never observed on the snapshot system.
60 kDoesNotObserveDaylightSavingTime = 0,
61
62 //! \brief Daylight saving time is observed on the snapshot system when in
63 //! effect, but standard time was in effect at the time of the snapshot.
64 kObservingStandardTime,
65
66 //! \brief Daylight saving time is observed on the snapshot system when in
67 //! effect, and daylight saving time was in effect at the time of the
68 //! snapshot.
69 kObservingDaylightSavingTime,
70 };
71
72 //! \brief Returns the snapshot system’s CPU architecture.
73 virtual CPUArchitecture GetCPUArchitecture() = 0;
74
75 //! \brief Returns the snapshot system’s CPU revision.
76 //!
77 //! For x86-family CPUs (including x86_64 and 32-bit x86), this is the CPU
78 //! family ID value from `cpuid 1` `eax`, adjusted to take the extended family
79 //! ID into account.
80 //!
81 //! \return A CPU architecture-specific value identifying the CPU revision.
82 virtual uint32_t CPURevision() = 0;
83
84 //! \brief Returns the total number of CPUs present in the snapshot system.
85 virtual uint8_t CPUCount() = 0;
86
87 //! \brief Returns the vendor of the snapshot system’s CPUs.
88 //!
89 //! For x86-family CPUs (including x86_64 and 32-bit x86), this is the CPU
90 //! vendor identification string as encoded in `cpuid 0` `ebx`, `edx`, and
91 //! `ecx`.
92 //!
93 //! \return A string identifying the vendor of the snapshot system’s CPUs.
94 virtual std::string CPUVendor() = 0;
95
96 //! \brief Returns frequency information about the snapshot system’s CPUs in
97 //! \current_hz and \a max_hz.
98 //!
99 //! \param[out] current_hz The snapshot system’s CPU clock frequency in Hz at
100 //! the time of the snapshot.
101 //! \param[out] max_hz The snapshot system’s maximum possible CPU clock
102 //! frequency.
103 virtual void CPUFrequency(uint64_t* current_hz, uint64_t* max_hz) = 0;
104
105 //! \brief Returns an x86-family snapshot system’s CPU signature.
106 //!
107 //! This is the family, model, and stepping ID values as encoded in `cpuid 1`
108 //! `eax`.
109 //!
110 //! This method must only be called when GetCPUArchitecture() indicates an
111 //! x86-family CPU architecture (#kCPUArchitectureX86 or
112 //! #kCPUArchitectureX86_64).
113 //!
114 //! \return An x86 family-specific value identifying the CPU signature.
115 virtual uint32_t CPUX86Signature() = 0;
116
117 //! \brief Returns an x86-family snapshot system’s CPU features.
118 //!
119 //! This is the feature information as encoded in `cpuid 1` `edx` and `ecx`.
120 //! `edx` is placed in the low half of the return value, and `ecx` is placed
121 //! in the high half.
122 //!
123 //! This method must only be called when GetCPUArchitecture() indicates an
124 //! x86-family CPU architecture (#kCPUArchitectureX86 or
125 //! #kCPUArchitectureX86_64).
126 //!
127 //! \return An x86 family-specific value identifying CPU features.
128 //!
129 //! \sa CPUX86ExtendedFeatures()
130 //! \sa CPUX86Leaf7Features()
131 virtual uint64_t CPUX86Features() = 0;
132
133 //! \brief Returns an x86-family snapshot system’s extended CPU features.
134 //!
135 //! This is the extended feature information as encoded in `cpuid 0x80000001`
136 //! `edx` and `ecx`. `edx` is placed in the low half of the return value, and
137 //! `ecx` is placed in the high half.
138 //!
139 //! This method must only be called when GetCPUArchitecture() indicates an
140 //! x86-family CPU architecture (#kCPUArchitectureX86 or
141 //! #kCPUArchitectureX86_64).
142 //!
143 //! \return An x86 family-specific value identifying extended CPU features.
144 //!
145 //! \sa CPUX86Features()
146 //! \sa CPUX86Leaf7Features()
147 virtual uint64_t CPUX86ExtendedFeatures() = 0;
148
149 //! \brief Returns an x86-family snapshot system’s “leaf 7” CPU features.
150 //!
151 //! This is the “leaf 7” feature information as encoded in `cpuid 7` `ebx`. If
152 //! `cpuid 7` is not supported by the snapshot CPU, this returns `0`.
153 //!
154 //! This method must only be called when GetCPUArchitecture() indicates an
155 //! x86-family CPU architecture (#kCPUArchitectureX86 or
156 //! #kCPUArchitectureX86_64).
157 //!
158 //! \return An x86 family-specific value identifying “leaf 7” CPU features.
159 //!
160 //! \sa CPUX86Features()
161 //! \sa CPUX86ExtendedFeatures()
162 virtual uint32_t CPUX86Leaf7Features() = 0;
163
164 //! \brief Returns an x86-family snapshot system’s CPU’s support for the SSE
165 //! DAZ (“denormals are zeros”) mode.
166 //!
167 //! This determines whether the CPU supports DAZ mode at all, not whether this
168 //! mode is enabled for any particular thread. DAZ mode support is detected by
169 //! examining the DAZ bit in the `mxcsr_mask` field of the floating-point
170 //! context saved by `fxsave`.
171 //!
172 //! This method must only be called when GetCPUArchitecture() indicates an
173 //! x86-family CPU architecture (#kCPUArchitectureX86 or
174 //! #kCPUArchitectureX86_64).
175 //!
176 //! \return `true` if the snapshot system’s CPUs support the SSE DAZ mode,
177 //! `false` if they do not.
178 virtual bool CPUX86SupportsDAZ() = 0;
179
180 //! \brief Returns the snapshot system’s operating system family.
181 virtual OperatingSystem GetOperatingSystem() = 0;
182
183 //! \brief Returns whether the snapshot system runs a server variant of its
184 //! operating system.
185 virtual bool OSServer() = 0;
186
187 //! \brief Returns the snapshot system’s operating system version information
188 //! in \a major, \a minor, \a bugfix, and \a build.
189 //!
190 //! \param[out] major The snapshot system’s operating system’s first (major)
191 //! version number component. This would be `10` for Mac OS X 10.9.5, and
192 //! `6` for Windows 7 (NT 6.1) SP1 version 6.1.7601.
193 //! \param[out] minor The snapshot system’s operating system’s second (minor)
194 //! version number component. This would be `9` for Mac OS X 10.9.5, and
195 //! `1` for Windows 7 (NT 6.1) SP1 version 6.1.7601.
196 //! \param[out] bugfix The snapshot system’s operating system’s third (bugfix)
197 //! version number component. This would be `5` for Mac OS X 10.9.5, and
198 //! `7601` for Windows 7 (NT 6.1) SP1 version 6.1.7601.
199 //! \param[out] build A string further identifying an operating system
200 //! version. For Mac OS X 10.9.5, this would be `"13F34"`. For Windows,
201 //! this would be `"Service Pack 1"` if that service pack was installed.
202 //! For Linux and other Unix-like systems, this would be the kernel
203 //! version from `uname -srvm`, possibly with additional information
204 //! appended. On Android, the `ro.build.fingerprint` system property would
205 //! be appended.
206 virtual void OSVersion(int* major,
207 int* minor,
208 int* bugfix,
209 std::string* build) = 0;
210
211 //! \brief Returns the snapshot system’s full operating system version
212 //! information in string format.
213 //!
214 //! For Mac OS X, the string contains values from the operating system and
215 //! kernel. A Mac OS X 10.9.5 snapshot system would be identified as `"Mac OS
216 //! X 10.9.5 (13F34); Darwin 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17
217 //! 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64"`.
218 virtual std::string OSVersionFull() = 0;
219
220 //! \brief Returns a description of the snapshot system’s hardware in string
221 //! format.
222 //!
223 //! For Mac OS X, the string contains the Mac model and board ID. A mid-2014
224 //! 15" MacBook Pro would be identified as `"MacBookPro11,3
225 //! (Mac-2BD1B31983FE1663)"`.
226 virtual std::string MachineDescription() = 0;
227
228 //! \brief Returns the status of the NX (no-execute, or XD, execute-disable)
229 //! feature on the snapshot system.
230 //!
231 //! This refers to a feature that allows mapped readable pages to be marked
232 //! as non-executable.
233 //!
234 //! \return `true` if the snapshot system supports NX and it is enabled.
235 virtual bool NXEnabled() = 0;
236
237 //! \brief Returns time zone information from the snapshot system, based on
238 //! its locale configuration and real-time clock.
239 //!
240 //! \param[out] dst_status Whether the location observes daylight saving time,
241 //! and if so, whether it or standard time is currently being observed.
242 //! \param[out] standard_offset_seconds The number of seconds that the
243 //! location’s time zone is east (ahead) of UTC during standard time.
244 //! \param[out] daylight_offset_seconds The number of seconds that the
245 //! location’s time zone is east (ahead) of UTC during daylight saving.
246 //! time.
247 //! \param[out] standard_name The name of the time zone while standard time is
248 //! being observed.
249 //! \param[out] daylight_name The name of the time zone while daylight saving
250 //! time is being observed.
251 virtual void TimeZone(DaylightSavingTimeStatus* observes_daylight,
252 int* standard_offset_seconds,
253 int* daylight_offset_seconds,
254 std::string* standard_name,
255 std::string* daylight_name) = 0;
256
257 protected:
258 ~SystemSnapshot() {}
259 };
260
261 } // namespace crashpad
262
263 #endif // CRASHPAD_SNAPSHOT_SYSTEM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698