Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Evgeniy Stepanov | 24e1372 | 2013-03-19 14:33:38 +0000 | [diff] [blame] | 14 | |
| 15 | #include "sanitizer_platform.h" |
Evgeniy Stepanov | 30e110e | 2013-03-19 14:54:17 +0000 | [diff] [blame] | 16 | #if SANITIZER_MAC |
Alexey Samsonov | d64bcf4 | 2013-06-11 08:13:36 +0000 | [diff] [blame] | 17 | #include "sanitizer_common.h" |
Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 18 | #include "sanitizer_internal_defs.h" |
Alexey Samsonov | d64bcf4 | 2013-06-11 08:13:36 +0000 | [diff] [blame] | 19 | #include "sanitizer_placement_new.h" |
| 20 | #include "sanitizer_procmaps.h" |
Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 21 | #include "sanitizer_symbolizer.h" |
| 22 | |
| 23 | namespace __sanitizer { |
| 24 | |
Sergey Matveev | d1470cb | 2013-05-14 14:04:06 +0000 | [diff] [blame] | 25 | uptr GetListOfModules(LoadedModule *modules, uptr max_modules, |
| 26 | string_predicate_t filter) { |
Alexey Samsonov | d64bcf4 | 2013-06-11 08:13:36 +0000 | [diff] [blame] | 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; |
Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Alexander Potapenko | 5ce93fc | 2013-05-23 11:53:36 +0000 | [diff] [blame] | 56 | void SymbolizerPrepareForSandboxing() { |
| 57 | // Do nothing on Mac. |
| 58 | } |
| 59 | |
Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 60 | } // namespace __sanitizer |
| 61 | |
Alexey Samsonov | 46f9395 | 2013-04-03 07:24:35 +0000 | [diff] [blame] | 62 | #endif // SANITIZER_MAC |