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

Side by Side Diff: util/mach/symbolic_constants_mach.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations 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 | « util/mach/mach_message_server.cc ('k') | util/mach/symbolic_constants_mach_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "util/mach/symbolic_constants_mach.h" 15 #include "util/mach/symbolic_constants_mach.h"
16 16
17 #include <string.h> 17 #include <string.h>
18 18
19 #include "base/basictypes.h" 19 #include "base/basictypes.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "util/mach/exception_behaviors.h" 21 #include "util/mach/exception_behaviors.h"
22 #include "util/mach/mach_extensions.h" 22 #include "util/mach/mach_extensions.h"
23 #include "util/stdlib/string_number_conversion.h" 23 #include "util/stdlib/string_number_conversion.h"
24 24
25 namespace { 25 namespace {
26 26
27 const char* kExceptionNames[] = { 27 const char* kExceptionNames[] = {
28 NULL, 28 nullptr,
29 29
30 // sed -Ene 's/^#define[[:space:]]EXC_([[:graph:]]+)[[:space:]]+[[:digit:]]{ 1,2}([[:space:]]|$).*/ "\1",/p' 30 // sed -Ene 's/^#define[[:space:]]EXC_([[:graph:]]+)[[:space:]]+[[:digit:]]{ 1,2}([[:space:]]|$).*/ "\1",/p'
31 // /usr/include/mach/exception_types.h 31 // /usr/include/mach/exception_types.h
32 "BAD_ACCESS", 32 "BAD_ACCESS",
33 "BAD_INSTRUCTION", 33 "BAD_INSTRUCTION",
34 "ARITHMETIC", 34 "ARITHMETIC",
35 "EMULATION", 35 "EMULATION",
36 "SOFTWARE", 36 "SOFTWARE",
37 "BREAKPOINT", 37 "BREAKPOINT",
38 "SYSCALL", 38 "SYSCALL",
39 "MACH_SYSCALL", 39 "MACH_SYSCALL",
40 "RPC_ALERT", 40 "RPC_ALERT",
41 "CRASH", 41 "CRASH",
42 "RESOURCE", 42 "RESOURCE",
43 "GUARD", 43 "GUARD",
44 }; 44 };
45 static_assert(arraysize(kExceptionNames) == EXC_TYPES_COUNT, 45 static_assert(arraysize(kExceptionNames) == EXC_TYPES_COUNT,
46 "kExceptionNames length"); 46 "kExceptionNames length");
47 47
48 const char kExcPrefix[] = "EXC_"; 48 const char kExcPrefix[] = "EXC_";
49 const char kExcMaskPrefix[] = "EXC_MASK_"; 49 const char kExcMaskPrefix[] = "EXC_MASK_";
50 50
51 const char* kBehaviorNames[] = { 51 const char* kBehaviorNames[] = {
52 NULL, 52 nullptr,
53 53
54 // sed -Ene 's/^# define[[:space:]]EXCEPTION_([[:graph:]]+)[[:space:]]+[[:di git:]]{1,2}([[:space:]]|$).*/ "\1",/p' 54 // sed -Ene 's/^# define[[:space:]]EXCEPTION_([[:graph:]]+)[[:space:]]+[[:di git:]]{1,2}([[:space:]]|$).*/ "\1",/p'
55 // /usr/include/mach/exception_types.h 55 // /usr/include/mach/exception_types.h
56 "DEFAULT", 56 "DEFAULT",
57 "STATE", 57 "STATE",
58 "STATE_IDENTITY", 58 "STATE_IDENTITY",
59 }; 59 };
60 60
61 const char kBehaviorPrefix[] = "EXCEPTION_"; 61 const char kBehaviorPrefix[] = "EXCEPTION_";
62 const char kMachExceptionCodesFull[] = "MACH_EXCEPTION_CODES"; 62 const char kMachExceptionCodesFull[] = "MACH_EXCEPTION_CODES";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // usr/include/mach/arm/thread_status.h 103 // usr/include/mach/arm/thread_status.h
104 // (iOS 7 SDK) 104 // (iOS 7 SDK)
105 // and then fix up by making the list sparse as appropriate. 105 // and then fix up by making the list sparse as appropriate.
106 "ARM_THREAD_STATE", 106 "ARM_THREAD_STATE",
107 "ARM_VFP_STATE", 107 "ARM_VFP_STATE",
108 "ARM_EXCEPTION_STATE", 108 "ARM_EXCEPTION_STATE",
109 "ARM_DEBUG_STATE", 109 "ARM_DEBUG_STATE",
110 "THREAD_STATE_NONE", 110 "THREAD_STATE_NONE",
111 "ARM_THREAD_STATE64", 111 "ARM_THREAD_STATE64",
112 "ARM_EXCEPTION_STATE64", 112 "ARM_EXCEPTION_STATE64",
113 NULL, 113 nullptr,
114 "ARM_THREAD_STATE32", 114 "ARM_THREAD_STATE32",
115 NULL, 115 nullptr,
116 NULL, 116 nullptr,
117 NULL, 117 nullptr,
118 NULL, 118 nullptr,
119 "ARM_DEBUG_STATE32", 119 "ARM_DEBUG_STATE32",
120 "ARM_DEBUG_STATE64", 120 "ARM_DEBUG_STATE64",
121 "ARM_NEON_STATE", 121 "ARM_NEON_STATE",
122 "ARM_NEON_STATE64", 122 "ARM_NEON_STATE64",
123 #endif 123 #endif
124 }; 124 };
125 125
126 // Certain generic flavors have high constants not contiguous with the flavors 126 // Certain generic flavors have high constants not contiguous with the flavors
127 // above. List them separately alongside their constants. 127 // above. List them separately alongside their constants.
128 const struct { 128 const struct {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 } // namespace 188 } // namespace
189 189
190 namespace crashpad { 190 namespace crashpad {
191 191
192 std::string ExceptionToString(exception_type_t exception, 192 std::string ExceptionToString(exception_type_t exception,
193 SymbolicConstantToStringOptions options) { 193 SymbolicConstantToStringOptions options) {
194 const char* exception_name = 194 const char* exception_name =
195 static_cast<size_t>(exception) < arraysize(kExceptionNames) 195 static_cast<size_t>(exception) < arraysize(kExceptionNames)
196 ? kExceptionNames[exception] 196 ? kExceptionNames[exception]
197 : NULL; 197 : nullptr;
198 if (!exception_name) { 198 if (!exception_name) {
199 if (options & kUnknownIsNumeric) { 199 if (options & kUnknownIsNumeric) {
200 return base::StringPrintf("%d", exception); 200 return base::StringPrintf("%d", exception);
201 } 201 }
202 return std::string(); 202 return std::string();
203 } 203 }
204 204
205 if (options & kUseShortName) { 205 if (options & kUseShortName) {
206 return std::string(exception_name); 206 return std::string(exception_name);
207 } 207 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return false; 356 return false;
357 } 357 }
358 358
359 std::string ExceptionBehaviorToString(exception_behavior_t behavior, 359 std::string ExceptionBehaviorToString(exception_behavior_t behavior,
360 SymbolicConstantToStringOptions options) { 360 SymbolicConstantToStringOptions options) {
361 const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior); 361 const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior);
362 362
363 const char* behavior_name = 363 const char* behavior_name =
364 static_cast<size_t>(basic_behavior) < arraysize(kBehaviorNames) 364 static_cast<size_t>(basic_behavior) < arraysize(kBehaviorNames)
365 ? kBehaviorNames[basic_behavior] 365 ? kBehaviorNames[basic_behavior]
366 : NULL; 366 : nullptr;
367 if (!behavior_name) { 367 if (!behavior_name) {
368 if (options & kUnknownIsNumeric) { 368 if (options & kUnknownIsNumeric) {
369 return base::StringPrintf("%#x", behavior); 369 return base::StringPrintf("%#x", behavior);
370 } 370 }
371 return std::string(); 371 return std::string();
372 } 372 }
373 373
374 std::string behavior_string; 374 std::string behavior_string;
375 if (options & kUseShortName) { 375 if (options & kUseShortName) {
376 behavior_string.assign(behavior_name); 376 behavior_string.assign(behavior_name);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 459
460 return false; 460 return false;
461 } 461 }
462 462
463 std::string ThreadStateFlavorToString(thread_state_flavor_t flavor, 463 std::string ThreadStateFlavorToString(thread_state_flavor_t flavor,
464 SymbolicConstantToStringOptions options) { 464 SymbolicConstantToStringOptions options) {
465 const char* flavor_name = 465 const char* flavor_name =
466 static_cast<size_t>(flavor) < arraysize(kFlavorNames) 466 static_cast<size_t>(flavor) < arraysize(kFlavorNames)
467 ? kFlavorNames[flavor] 467 ? kFlavorNames[flavor]
468 : NULL; 468 : nullptr;
469 469
470 if (!flavor_name) { 470 if (!flavor_name) {
471 for (size_t generic_flavor_index = 0; 471 for (size_t generic_flavor_index = 0;
472 generic_flavor_index < arraysize(kGenericFlavorNames); 472 generic_flavor_index < arraysize(kGenericFlavorNames);
473 ++generic_flavor_index) { 473 ++generic_flavor_index) {
474 if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) { 474 if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) {
475 flavor_name = kGenericFlavorNames[generic_flavor_index].name; 475 flavor_name = kGenericFlavorNames[generic_flavor_index].name;
476 break; 476 break;
477 } 477 }
478 } 478 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 536 }
537 537
538 if (options & kAllowNumber) { 538 if (options & kAllowNumber) {
539 return StringToNumber(string, reinterpret_cast<unsigned int*>(flavor)); 539 return StringToNumber(string, reinterpret_cast<unsigned int*>(flavor));
540 } 540 }
541 541
542 return false; 542 return false;
543 } 543 }
544 544
545 } // namespace crashpad 545 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_message_server.cc ('k') | util/mach/symbolic_constants_mach_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698