1 //===-- sanitizer_symbolizer_mac.cc ---------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file is shared between AddressSanitizer and ThreadSanitizer 11 // run-time libraries. 12 // Mac-specific implementation of symbolizer parts. 13 //===----------------------------------------------------------------------===// 14 15 #include "sanitizer_platform.h" 16 #if SANITIZER_MAC 17 #include "sanitizer_common.h" 18 #include "sanitizer_internal_defs.h" 19 #include "sanitizer_placement_new.h" 20 #include "sanitizer_procmaps.h" 21 #include "sanitizer_symbolizer.h" 22 23 namespace __sanitizer { 24 25 uptr GetListOfModules(LoadedModule *modules, uptr max_modules, 26 string_predicate_t filter) { 27 MemoryMappingLayout memory_mapping(false); 28 memory_mapping.Reset(); 29 uptr cur_beg, cur_end, cur_offset; 30 InternalScopedBuffer<char> module_name(kMaxPathLength); 31 uptr n_modules = 0; 32 for (uptr i = 0; 33 n_modules < max_modules && 34 memory_mapping.Next(&cur_beg, &cur_end, &cur_offset, 35 module_name.data(), module_name.size(), 0); 36 i++) { 37 const char *cur_name = module_name.data(); 38 if (cur_name[0] == '\0') 39 continue; 40 if (filter && !filter(cur_name)) 41 continue; 42 LoadedModule *cur_module = 0; 43 if (n_modules > 0 && 44 0 == internal_strcmp(cur_name, modules[n_modules - 1].full_name())) { 45 cur_module = &modules[n_modules - 1]; 46 } else { 47 void *mem = &modules[n_modules]; 48 cur_module = new(mem) LoadedModule(cur_name, cur_beg); 49 n_modules++; 50 } 51 cur_module->addAddressRange(cur_beg, cur_end); 52 } 53 return n_modules; 54 } 55 56 void SymbolizerPrepareForSandboxing() { 57 // Do nothing on Mac. 58 } 59 60 } // namespace __sanitizer 61 62 #endif // SANITIZER_MAC 63