38
38
// because we do not require a C++ ABI library to be linked to a program
39
39
// using sanitizers; if it's not present, we'll just use the mangled name.
40
40
namespace __cxxabiv1 {
41
- extern " C" SANITIZER_WEAK_ATTRIBUTE char *__cxa_demangle (const char *mangled,
42
- char *buffer,
43
- size_t *length,
44
- int *status);
41
+ extern " C" SANITIZER_WEAK_ATTRIBUTE
42
+ char *__cxa_demangle (const char *mangled, char *buffer,
43
+ size_t *length, int *status);
45
44
}
46
45
47
46
namespace __sanitizer {
@@ -54,7 +53,8 @@ const char *DemangleCXXABI(const char *name) {
54
53
// it does not allocate). For now, we just call it anyway, and we leak
55
54
// the returned value.
56
55
if (&__cxxabiv1::__cxa_demangle)
57
- if (const char *demangled_name = __cxxabiv1::__cxa_demangle (name, 0 , 0 , 0 ))
56
+ if (const char *demangled_name =
57
+ __cxxabiv1::__cxa_demangle (name, 0 , 0 , 0 ))
58
58
return demangled_name;
59
59
60
60
return nullptr ;
@@ -85,8 +85,7 @@ const char *DemangleSwift(const char *name) {
85
85
}
86
86
87
87
const char *DemangleSwiftAndCXX (const char *name) {
88
- if (!name)
89
- return nullptr ;
88
+ if (!name) return nullptr ;
90
89
if (const char *swift_demangled_name = DemangleSwift (name))
91
90
return swift_demangled_name;
92
91
return DemangleCXXABI (name);
@@ -115,8 +114,7 @@ static bool CreateTwoHighNumberedPipes(int *infd_, int *outfd_) {
115
114
} else {
116
115
outfd = sock_pair[i];
117
116
for (int j = 0 ; j < i; j++) {
118
- if (sock_pair[j] == infd)
119
- continue ;
117
+ if (sock_pair[j] == infd) continue ;
120
118
internal_close (sock_pair[j][0 ]);
121
119
internal_close (sock_pair[j][1 ]);
122
120
}
@@ -157,7 +155,7 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
157
155
}
158
156
159
157
if (use_posix_spawn_) {
160
- # if SANITIZER_APPLE
158
+ #if SANITIZER_APPLE
161
159
fd_t fd = internal_spawn (argv, const_cast <const char **>(GetEnvP ()), &pid);
162
160
if (fd == kInvalidFd ) {
163
161
Report (" WARNING: failed to spawn external symbolizer (errno: %d)\n " ,
@@ -167,16 +165,14 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
167
165
168
166
input_fd_ = fd;
169
167
output_fd_ = fd;
170
- # else // SANITIZER_APPLE
168
+ #else // SANITIZER_APPLE
171
169
UNIMPLEMENTED ();
172
- # endif // SANITIZER_APPLE
170
+ #endif // SANITIZER_APPLE
173
171
} else {
174
172
fd_t infd[2 ] = {}, outfd[2 ] = {};
175
173
if (!CreateTwoHighNumberedPipes (infd, outfd)) {
176
- Report (
177
- " WARNING: Can't create a socket pair to start "
178
- " external symbolizer (errno: %d)\n " ,
179
- errno);
174
+ Report (" WARNING: Can't create a socket pair to start "
175
+ " external symbolizer (errno: %d)\n " , errno);
180
176
return false ;
181
177
}
182
178
@@ -264,11 +260,10 @@ bool Addr2LineProcess::ReachedEndOfOutput(const char *buffer,
264
260
// 1. First one, corresponding to given offset to be symbolized
265
261
// (may be equal to output_terminator_, if offset is not valid).
266
262
// 2. Second one for output_terminator_, itself to mark the end of output.
267
- if (length <= kTerminatorLen )
268
- return false ;
263
+ if (length <= kTerminatorLen ) return false ;
269
264
// Addr2Line output should end up with output_terminator_.
270
- return !internal_memcmp (buffer + length - kTerminatorLen , output_terminator_,
271
- kTerminatorLen );
265
+ return !internal_memcmp (buffer + length - kTerminatorLen ,
266
+ output_terminator_, kTerminatorLen );
272
267
}
273
268
274
269
class Addr2LinePool final : public SymbolizerTool {
@@ -288,7 +283,9 @@ class Addr2LinePool final : public SymbolizerTool {
288
283
return false ;
289
284
}
290
285
291
- bool SymbolizeData (uptr addr, DataInfo *info) override { return false ; }
286
+ bool SymbolizeData (uptr addr, DataInfo *info) override {
287
+ return false ;
288
+ }
292
289
293
290
private:
294
291
const char *SendCommand (const char *module_name, uptr module_offset) {
@@ -302,21 +299,22 @@ class Addr2LinePool final : public SymbolizerTool {
302
299
}
303
300
if (!addr2line) {
304
301
addr2line =
305
- new (*allocator_) Addr2LineProcess (addr2line_path_, module_name);
302
+ new (*allocator_) Addr2LineProcess (addr2line_path_, module_name);
306
303
addr2line_pool_.push_back (addr2line);
307
304
}
308
305
CHECK_EQ (0 , internal_strcmp (module_name, addr2line->module_name ()));
309
306
char buffer[kBufferSize ];
310
- internal_snprintf (buffer, kBufferSize , " 0x%zx\n 0x%zx\n " , module_offset,
311
- dummy_address_);
307
+ internal_snprintf (buffer, kBufferSize , " 0x%zx\n 0x%zx\n " ,
308
+ module_offset, dummy_address_);
312
309
return addr2line->SendCommand (buffer);
313
310
}
314
311
315
312
static const uptr kBufferSize = 64 ;
316
313
const char *addr2line_path_;
317
314
LowLevelAllocator *allocator_;
318
- InternalMmapVector<Addr2LineProcess *> addr2line_pool_;
319
- static const uptr dummy_address_ = FIRST_32_SECOND_64(UINT32_MAX, UINT64_MAX);
315
+ InternalMmapVector<Addr2LineProcess*> addr2line_pool_;
316
+ static const uptr dummy_address_ =
317
+ FIRST_32_SECOND_64 (UINT32_MAX, UINT64_MAX);
320
318
};
321
319
322
320
# if SANITIZER_SUPPORTS_WEAK_HOOKS
@@ -354,9 +352,8 @@ class InternalSymbolizer final : public SymbolizerTool {
354
352
}
355
353
356
354
bool SymbolizePC (uptr addr, SymbolizedStack *stack) override {
357
- bool result = __sanitizer_symbolize_code (stack->info .module ,
358
- stack->info .module_offset , buffer_,
359
- sizeof (buffer_));
355
+ bool result = __sanitizer_symbolize_code (
356
+ stack->info .module , stack->info .module_offset , buffer_, sizeof (buffer_));
360
357
if (result)
361
358
ParseSymbolizePCOutput (buffer_, stack);
362
359
return result;
@@ -426,43 +423,41 @@ static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
426
423
} else if (!internal_strncmp (binary_name, kLLVMSymbolizerPrefix ,
427
424
internal_strlen (kLLVMSymbolizerPrefix ))) {
428
425
VReport (2 , " Using llvm-symbolizer at user-specified path: %s\n " , path);
429
- return new (*allocator) LLVMSymbolizer (path, allocator);
426
+ return new (*allocator) LLVMSymbolizer (path, allocator);
430
427
} else if (!internal_strcmp (binary_name, " atos" )) {
431
- # if SANITIZER_APPLE
428
+ #if SANITIZER_APPLE
432
429
VReport (2 , " Using atos at user-specified path: %s\n " , path);
433
- return new (*allocator) AtosSymbolizer (path, allocator);
434
- # else // SANITIZER_APPLE
430
+ return new (*allocator) AtosSymbolizer (path, allocator);
431
+ #else // SANITIZER_APPLE
435
432
Report (" ERROR: Using `atos` is only supported on Darwin.\n " );
436
433
Die ();
437
- # endif // SANITIZER_APPLE
434
+ #endif // SANITIZER_APPLE
438
435
} else if (!internal_strcmp (binary_name, " addr2line" )) {
439
436
VReport (2 , " Using addr2line at user-specified path: %s\n " , path);
440
- return new (*allocator) Addr2LinePool (path, allocator);
437
+ return new (*allocator) Addr2LinePool (path, allocator);
441
438
} else if (path) {
442
- Report (
443
- " ERROR: External symbolizer path is set to '%s' which isn't "
444
- " a known symbolizer. Please set the path to the llvm-symbolizer "
445
- " binary or other known tool.\n " ,
446
- path);
439
+ Report (" ERROR: External symbolizer path is set to '%s' which isn't "
440
+ " a known symbolizer. Please set the path to the llvm-symbolizer "
441
+ " binary or other known tool.\n " , path);
447
442
Die ();
448
443
}
449
444
450
445
// Otherwise symbolizer program is unknown, let's search $PATH
451
446
CHECK (path == nullptr );
452
- # if SANITIZER_APPLE
447
+ #if SANITIZER_APPLE
453
448
if (const char *found_path = FindPathToBinary (" atos" )) {
454
449
VReport (2 , " Using atos found at: %s\n " , found_path);
455
- return new (*allocator) AtosSymbolizer (found_path, allocator);
450
+ return new (*allocator) AtosSymbolizer (found_path, allocator);
456
451
}
457
- # endif // SANITIZER_APPLE
452
+ #endif // SANITIZER_APPLE
458
453
if (const char *found_path = FindPathToBinary (" llvm-symbolizer" )) {
459
454
VReport (2 , " Using llvm-symbolizer found at: %s\n " , found_path);
460
- return new (*allocator) LLVMSymbolizer (found_path, allocator);
455
+ return new (*allocator) LLVMSymbolizer (found_path, allocator);
461
456
}
462
457
if (common_flags ()->allow_addr2line ) {
463
458
if (const char *found_path = FindPathToBinary (" addr2line" )) {
464
459
VReport (2 , " Using addr2line found at: %s\n " , found_path);
465
- return new (*allocator) Addr2LinePool (found_path, allocator);
460
+ return new (*allocator) Addr2LinePool (found_path, allocator);
466
461
}
467
462
}
468
463
return nullptr ;
@@ -497,17 +492,17 @@ static void ChooseSymbolizerTools(IntrusiveList<SymbolizerTool> *list,
497
492
list->push_back (tool);
498
493
}
499
494
500
- # if SANITIZER_APPLE
495
+ #if SANITIZER_APPLE
501
496
VReport (2 , " Using dladdr symbolizer.\n " );
502
- list->push_back (new (*allocator) DlAddrSymbolizer ());
503
- # endif // SANITIZER_APPLE
497
+ list->push_back (new (*allocator) DlAddrSymbolizer ());
498
+ #endif // SANITIZER_APPLE
504
499
}
505
500
506
501
Symbolizer *Symbolizer::PlatformInit () {
507
502
IntrusiveList<SymbolizerTool> list;
508
503
list.clear ();
509
504
ChooseSymbolizerTools (&list, &symbolizer_allocator_);
510
- return new (symbolizer_allocator_) Symbolizer (list);
505
+ return new (symbolizer_allocator_) Symbolizer (list);
511
506
}
512
507
513
508
void Symbolizer::LateInitialize () {
0 commit comments