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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc

Issue 2555353002: Update Crashpad to 32981a3ee9d7c2769fb27afa038fe2e194cfa329 (Closed)
Patch Set: fix readme Created 4 years 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
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_misc_info_writer.h" 15 #include "minidump/minidump_misc_info_writer.h"
16 16
17 #include <limits> 17 #include <limits>
18 18
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/numerics/safe_conversions.h" 20 #include "base/numerics/safe_conversions.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "minidump/minidump_writer_util.h" 24 #include "minidump/minidump_writer_util.h"
25 #include "package.h" 25 #include "package.h"
26 #include "snapshot/process_snapshot.h" 26 #include "snapshot/process_snapshot.h"
27 #include "snapshot/system_snapshot.h" 27 #include "snapshot/system_snapshot.h"
28 #include "util/file/file_writer.h" 28 #include "util/file/file_writer.h"
29 #include "util/misc/arraysize_unsafe.h"
29 #include "util/numeric/in_range_cast.h" 30 #include "util/numeric/in_range_cast.h"
30 #include "util/numeric/safe_assignment.h" 31 #include "util/numeric/safe_assignment.h"
31 32
32 #if defined(OS_MACOSX) 33 #if defined(OS_MACOSX)
33 #include <AvailabilityMacros.h> 34 #include <AvailabilityMacros.h>
34 #elif defined(OS_ANDROID) 35 #elif defined(OS_ANDROID)
35 #include <android/api-level.h> 36 #include <android/api-level.h>
36 #endif 37 #endif
37 38
38 namespace crashpad { 39 namespace crashpad {
(...skipping 22 matching lines...) Expand all
61 "%s; %s", os_version_full.c_str(), machine_description.c_str()); 62 "%s; %s", os_version_full.c_str(), machine_description.c_str());
62 } 63 }
63 return os_version_full; 64 return os_version_full;
64 } 65 }
65 return machine_description; 66 return machine_description;
66 } 67 }
67 68
68 #if defined(OS_MACOSX) 69 #if defined(OS_MACOSX)
69 // Converts the value of the MAC_OS_VERSION_MIN_REQUIRED or 70 // Converts the value of the MAC_OS_VERSION_MIN_REQUIRED or
70 // MAC_OS_X_VERSION_MAX_ALLOWED macro from <AvailabilityMacros.h> to a number 71 // MAC_OS_X_VERSION_MAX_ALLOWED macro from <AvailabilityMacros.h> to a number
71 // identifying the minor Mac OS X version that it represents. For example, with 72 // identifying the minor macOS version that it represents. For example, with an
72 // an argument of MAC_OS_X_VERSION_10_6, this function will return 6. 73 // argument of MAC_OS_X_VERSION_10_6, this function will return 6.
73 int AvailabilityVersionToMacOSXMinorVersion(int availability) { 74 int AvailabilityVersionToMacOSXMinorVersion(int availability) {
74 // Through MAC_OS_X_VERSION_10_9, the minor version is the tens digit. 75 // Through MAC_OS_X_VERSION_10_9, the minor version is the tens digit.
75 if (availability >= 1000 && availability <= 1099) { 76 if (availability >= 1000 && availability <= 1099) {
76 return (availability / 10) % 10; 77 return (availability / 10) % 10;
77 } 78 }
78 79
79 // After MAC_OS_X_VERSION_10_9, the older format was insufficient to represent 80 // After MAC_OS_X_VERSION_10_9, the older format was insufficient to represent
80 // versions. Since then, the minor version is the thousands and hundreds 81 // versions. Since then, the minor version is the thousands and hundreds
81 // digits. 82 // digits.
82 if (availability >= 100000 && availability <= 109999) { 83 if (availability >= 100000 && availability <= 109999) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 const std::string& daylight_name, 289 const std::string& daylight_name,
289 const SYSTEMTIME& daylight_date, 290 const SYSTEMTIME& daylight_date,
290 int32_t daylight_bias) { 291 int32_t daylight_bias) {
291 DCHECK_EQ(state(), kStateMutable); 292 DCHECK_EQ(state(), kStateMutable);
292 293
293 misc_info_.TimeZoneId = time_zone_id; 294 misc_info_.TimeZoneId = time_zone_id;
294 misc_info_.TimeZone.Bias = bias; 295 misc_info_.TimeZone.Bias = bias;
295 296
296 internal::MinidumpWriterUtil::AssignUTF8ToUTF16( 297 internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
297 misc_info_.TimeZone.StandardName, 298 misc_info_.TimeZone.StandardName,
298 arraysize(misc_info_.TimeZone.StandardName), 299 ARRAYSIZE_UNSAFE(misc_info_.TimeZone.StandardName),
299 standard_name); 300 standard_name);
300 301
301 misc_info_.TimeZone.StandardDate = standard_date; 302 misc_info_.TimeZone.StandardDate = standard_date;
302 misc_info_.TimeZone.StandardBias = standard_bias; 303 misc_info_.TimeZone.StandardBias = standard_bias;
303 304
304 internal::MinidumpWriterUtil::AssignUTF8ToUTF16( 305 internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
305 misc_info_.TimeZone.DaylightName, 306 misc_info_.TimeZone.DaylightName,
306 arraysize(misc_info_.TimeZone.DaylightName), 307 ARRAYSIZE_UNSAFE(misc_info_.TimeZone.DaylightName),
307 daylight_name); 308 daylight_name);
308 309
309 misc_info_.TimeZone.DaylightDate = daylight_date; 310 misc_info_.TimeZone.DaylightDate = daylight_date;
310 misc_info_.TimeZone.DaylightBias = daylight_bias; 311 misc_info_.TimeZone.DaylightBias = daylight_bias;
311 312
312 misc_info_.Flags1 |= MINIDUMP_MISC3_TIMEZONE; 313 misc_info_.Flags1 |= MINIDUMP_MISC3_TIMEZONE;
313 } 314 }
314 315
315 void MinidumpMiscInfoWriter::SetBuildString( 316 void MinidumpMiscInfoWriter::SetBuildString(
316 const std::string& build_string, 317 const std::string& build_string,
317 const std::string& debug_build_string) { 318 const std::string& debug_build_string) {
318 DCHECK_EQ(state(), kStateMutable); 319 DCHECK_EQ(state(), kStateMutable);
319 320
320 misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING; 321 misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
321 322
322 internal::MinidumpWriterUtil::AssignUTF8ToUTF16( 323 internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
323 misc_info_.BuildString, arraysize(misc_info_.BuildString), build_string); 324 misc_info_.BuildString,
325 ARRAYSIZE_UNSAFE(misc_info_.BuildString),
326 build_string);
324 internal::MinidumpWriterUtil::AssignUTF8ToUTF16( 327 internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
325 misc_info_.DbgBldStr, 328 misc_info_.DbgBldStr,
326 arraysize(misc_info_.DbgBldStr), 329 ARRAYSIZE_UNSAFE(misc_info_.DbgBldStr),
327 debug_build_string); 330 debug_build_string);
328 } 331 }
329 332
330 bool MinidumpMiscInfoWriter::Freeze() { 333 bool MinidumpMiscInfoWriter::Freeze() {
331 DCHECK_EQ(state(), kStateMutable); 334 DCHECK_EQ(state(), kStateMutable);
332 335
333 if (!MinidumpStreamWriter::Freeze()) { 336 if (!MinidumpStreamWriter::Freeze()) {
334 return false; 337 return false;
335 } 338 }
336 339
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC3_PROTECTED_PROCESS)) { 373 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC3_PROTECTED_PROCESS)) {
371 return sizeof(MINIDUMP_MISC_INFO_3); 374 return sizeof(MINIDUMP_MISC_INFO_3);
372 } 375 }
373 if (misc_info_.Flags1 & MINIDUMP_MISC1_PROCESSOR_POWER_INFO) { 376 if (misc_info_.Flags1 & MINIDUMP_MISC1_PROCESSOR_POWER_INFO) {
374 return sizeof(MINIDUMP_MISC_INFO_2); 377 return sizeof(MINIDUMP_MISC_INFO_2);
375 } 378 }
376 return sizeof(MINIDUMP_MISC_INFO); 379 return sizeof(MINIDUMP_MISC_INFO);
377 } 380 }
378 381
379 } // namespace crashpad 382 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698