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