2012-08-14 21:00:32 +08:00
|
|
|
//===-- sanitizer_symbolizer_mac.cc ---------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is shared between AddressSanitizer and ThreadSanitizer
|
|
|
|
// run-time libraries.
|
|
|
|
// Mac-specific implementation of symbolizer parts.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-03-19 22:33:38 +08:00
|
|
|
|
|
|
|
#include "sanitizer_platform.h"
|
2013-03-19 22:54:17 +08:00
|
|
|
#if SANITIZER_MAC
|
2013-06-11 16:13:36 +08:00
|
|
|
#include "sanitizer_common.h"
|
2012-08-14 21:00:32 +08:00
|
|
|
#include "sanitizer_internal_defs.h"
|
2013-06-11 16:13:36 +08:00
|
|
|
#include "sanitizer_placement_new.h"
|
|
|
|
#include "sanitizer_procmaps.h"
|
2012-08-14 21:00:32 +08:00
|
|
|
#include "sanitizer_symbolizer.h"
|
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
2013-05-14 22:04:06 +08:00
|
|
|
uptr GetListOfModules(LoadedModule *modules, uptr max_modules,
|
|
|
|
string_predicate_t filter) {
|
2013-06-11 16:13:36 +08:00
|
|
|
MemoryMappingLayout memory_mapping(false);
|
|
|
|
memory_mapping.Reset();
|
|
|
|
uptr cur_beg, cur_end, cur_offset;
|
|
|
|
InternalScopedBuffer<char> module_name(kMaxPathLength);
|
|
|
|
uptr n_modules = 0;
|
|
|
|
for (uptr i = 0;
|
|
|
|
n_modules < max_modules &&
|
|
|
|
memory_mapping.Next(&cur_beg, &cur_end, &cur_offset,
|
|
|
|
module_name.data(), module_name.size(), 0);
|
|
|
|
i++) {
|
|
|
|
const char *cur_name = module_name.data();
|
|
|
|
if (cur_name[0] == '\0')
|
|
|
|
continue;
|
|
|
|
if (filter && !filter(cur_name))
|
|
|
|
continue;
|
|
|
|
LoadedModule *cur_module = 0;
|
|
|
|
if (n_modules > 0 &&
|
|
|
|
0 == internal_strcmp(cur_name, modules[n_modules - 1].full_name())) {
|
|
|
|
cur_module = &modules[n_modules - 1];
|
|
|
|
} else {
|
|
|
|
void *mem = &modules[n_modules];
|
|
|
|
cur_module = new(mem) LoadedModule(cur_name, cur_beg);
|
|
|
|
n_modules++;
|
|
|
|
}
|
|
|
|
cur_module->addAddressRange(cur_beg, cur_end);
|
|
|
|
}
|
|
|
|
return n_modules;
|
2012-08-14 21:00:32 +08:00
|
|
|
}
|
|
|
|
|
2013-05-23 19:53:36 +08:00
|
|
|
void SymbolizerPrepareForSandboxing() {
|
|
|
|
// Do nothing on Mac.
|
|
|
|
}
|
|
|
|
|
2012-08-14 21:00:32 +08:00
|
|
|
} // namespace __sanitizer
|
|
|
|
|
2013-04-03 15:24:35 +08:00
|
|
|
#endif // SANITIZER_MAC
|