blob: c44e3b3cfaf6e9bcdf053a51d79fa086757d6f2d [file] [log] [blame]
Alexey Samsonov6e893b62012-08-14 13:00:32 +00001//===-- 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 Stepanov24e13722013-03-19 14:33:38 +000014
15#include "sanitizer_platform.h"
Evgeniy Stepanov30e110e2013-03-19 14:54:17 +000016#if SANITIZER_MAC
Alexey Samsonovd64bcf42013-06-11 08:13:36 +000017#include "sanitizer_common.h"
Alexey Samsonov6e893b62012-08-14 13:00:32 +000018#include "sanitizer_internal_defs.h"
Alexey Samsonovd64bcf42013-06-11 08:13:36 +000019#include "sanitizer_placement_new.h"
20#include "sanitizer_procmaps.h"
Alexey Samsonov6e893b62012-08-14 13:00:32 +000021#include "sanitizer_symbolizer.h"
22
23namespace __sanitizer {
24
Sergey Matveevd1470cb2013-05-14 14:04:06 +000025uptr GetListOfModules(LoadedModule *modules, uptr max_modules,
26 string_predicate_t filter) {
Alexey Samsonovd64bcf42013-06-11 08:13:36 +000027 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 Samsonov6e893b62012-08-14 13:00:32 +000054}
55
Alexander Potapenko5ce93fc2013-05-23 11:53:36 +000056void SymbolizerPrepareForSandboxing() {
57 // Do nothing on Mac.
58}
59
Alexey Samsonov6e893b62012-08-14 13:00:32 +000060} // namespace __sanitizer
61
Alexey Samsonov46f93952013-04-03 07:24:35 +000062#endif // SANITIZER_MAC