3838// because we do not require a C++ ABI library to be linked to a program
3939// using sanitizers; if it's not present, we'll just use the mangled name.
4040namespace __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);
4445}
4546
4647namespace __sanitizer {
@@ -53,8 +54,7 @@ const char *DemangleCXXABI(const char *name) {
5354 // it does not allocate). For now, we just call it anyway, and we leak
5455 // the returned value.
5556 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 ))
5858 return demangled_name;
5959
6060 return nullptr ;
@@ -85,7 +85,8 @@ const char *DemangleSwift(const char *name) {
8585}
8686
8787const char *DemangleSwiftAndCXX (const char *name) {
88- if (!name) return nullptr ;
88+ if (!name)
89+ return nullptr ;
8990 if (const char *swift_demangled_name = DemangleSwift (name))
9091 return swift_demangled_name;
9192 return DemangleCXXABI (name);
@@ -114,7 +115,8 @@ static bool CreateTwoHighNumberedPipes(int *infd_, int *outfd_) {
114115 } else {
115116 outfd = sock_pair[i];
116117 for (int j = 0 ; j < i; j++) {
117- if (sock_pair[j] == infd) continue ;
118+ if (sock_pair[j] == infd)
119+ continue ;
118120 internal_close (sock_pair[j][0 ]);
119121 internal_close (sock_pair[j][1 ]);
120122 }
@@ -155,7 +157,7 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
155157 }
156158
157159 if (use_posix_spawn_) {
158- #if SANITIZER_APPLE
160+ # if SANITIZER_APPLE
159161 fd_t fd = internal_spawn (argv, const_cast <const char **>(GetEnvP ()), &pid);
160162 if (fd == kInvalidFd ) {
161163 Report (" WARNING: failed to spawn external symbolizer (errno: %d)\n " ,
@@ -165,14 +167,16 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
165167
166168 input_fd_ = fd;
167169 output_fd_ = fd;
168- #else // SANITIZER_APPLE
170+ # else // SANITIZER_APPLE
169171 UNIMPLEMENTED ();
170- #endif // SANITIZER_APPLE
172+ # endif // SANITIZER_APPLE
171173 } else {
172174 fd_t infd[2 ] = {}, outfd[2 ] = {};
173175 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);
176180 return false ;
177181 }
178182
@@ -260,10 +264,11 @@ bool Addr2LineProcess::ReachedEndOfOutput(const char *buffer,
260264 // 1. First one, corresponding to given offset to be symbolized
261265 // (may be equal to output_terminator_, if offset is not valid).
262266 // 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 ;
264269 // 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 );
267272}
268273
269274class Addr2LinePool final : public SymbolizerTool {
@@ -283,9 +288,7 @@ class Addr2LinePool final : public SymbolizerTool {
283288 return false ;
284289 }
285290
286- bool SymbolizeData (uptr addr, DataInfo *info) override {
287- return false ;
288- }
291+ bool SymbolizeData (uptr addr, DataInfo *info) override { return false ; }
289292
290293 private:
291294 const char *SendCommand (const char *module_name, uptr module_offset) {
@@ -299,22 +302,21 @@ class Addr2LinePool final : public SymbolizerTool {
299302 }
300303 if (!addr2line) {
301304 addr2line =
302- new (*allocator_) Addr2LineProcess (addr2line_path_, module_name);
305+ new (*allocator_) Addr2LineProcess (addr2line_path_, module_name);
303306 addr2line_pool_.push_back (addr2line);
304307 }
305308 CHECK_EQ (0 , internal_strcmp (module_name, addr2line->module_name ()));
306309 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_);
309312 return addr2line->SendCommand (buffer);
310313 }
311314
312315 static const uptr kBufferSize = 64 ;
313316 const char *addr2line_path_;
314317 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);
318320};
319321
320322# if SANITIZER_SUPPORTS_WEAK_HOOKS
@@ -352,8 +354,9 @@ class InternalSymbolizer final : public SymbolizerTool {
352354 }
353355
354356 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_));
357360 if (result)
358361 ParseSymbolizePCOutput (buffer_, stack);
359362 return result;
@@ -423,41 +426,43 @@ static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
423426 } else if (!internal_strncmp (binary_name, kLLVMSymbolizerPrefix ,
424427 internal_strlen (kLLVMSymbolizerPrefix ))) {
425428 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);
427430 } else if (!internal_strcmp (binary_name, " atos" )) {
428- #if SANITIZER_APPLE
431+ # if SANITIZER_APPLE
429432 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
432435 Report (" ERROR: Using `atos` is only supported on Darwin.\n " );
433436 Die ();
434- #endif // SANITIZER_APPLE
437+ # endif // SANITIZER_APPLE
435438 } else if (!internal_strcmp (binary_name, " addr2line" )) {
436439 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);
438441 } 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);
442447 Die ();
443448 }
444449
445450 // Otherwise symbolizer program is unknown, let's search $PATH
446451 CHECK (path == nullptr );
447- #if SANITIZER_APPLE
452+ # if SANITIZER_APPLE
448453 if (const char *found_path = FindPathToBinary (" atos" )) {
449454 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);
451456 }
452- #endif // SANITIZER_APPLE
457+ # endif // SANITIZER_APPLE
453458 if (const char *found_path = FindPathToBinary (" llvm-symbolizer" )) {
454459 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);
456461 }
457462 if (common_flags ()->allow_addr2line ) {
458463 if (const char *found_path = FindPathToBinary (" addr2line" )) {
459464 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);
461466 }
462467 }
463468 return nullptr ;
@@ -492,17 +497,17 @@ static void ChooseSymbolizerTools(IntrusiveList<SymbolizerTool> *list,
492497 list->push_back (tool);
493498 }
494499
495- #if SANITIZER_APPLE
500+ # if SANITIZER_APPLE
496501 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
499504}
500505
501506Symbolizer *Symbolizer::PlatformInit () {
502507 IntrusiveList<SymbolizerTool> list;
503508 list.clear ();
504509 ChooseSymbolizerTools (&list, &symbolizer_allocator_);
505- return new (symbolizer_allocator_) Symbolizer (list);
510+ return new (symbolizer_allocator_) Symbolizer (list);
506511}
507512
508513void Symbolizer::LateInitialize () {
0 commit comments