[Sanitizer] Remove now unused symbolization functionality from MemoryMappingLayout

llvm-svn: 198014
This commit is contained in:
Alexey Samsonov 2013-12-25 12:11:06 +00:00
parent 371e363833
commit 782ad0eb71
6 changed files with 15 additions and 102 deletions

View File

@ -16,7 +16,6 @@ set(SANITIZER_SOURCES
sanitizer_printf.cc
sanitizer_procmaps_linux.cc
sanitizer_procmaps_mac.cc
sanitizer_procmaps_posix.cc
sanitizer_stackdepot.cc
sanitizer_stacktrace.cc
sanitizer_suppressions.cc

View File

@ -20,20 +20,6 @@
namespace __sanitizer {
#if SANITIZER_WINDOWS
class MemoryMappingLayout {
public:
explicit MemoryMappingLayout(bool cache_enabled) {
(void)cache_enabled;
}
bool GetObjectNameAndOffset(uptr addr, uptr *offset,
char filename[], uptr filename_size,
uptr *protection) {
UNIMPLEMENTED();
}
};
#else // SANITIZER_WINDOWS
#if SANITIZER_LINUX
struct ProcSelfMapsBuff {
char *data;
@ -49,11 +35,6 @@ class MemoryMappingLayout {
bool Next(uptr *start, uptr *end, uptr *offset,
char filename[], uptr filename_size, uptr *protection);
void Reset();
// Gets the object file name and the offset in that object for a given
// address 'addr'. Returns true on success.
bool GetObjectNameAndOffset(uptr addr, uptr *offset,
char filename[], uptr filename_size,
uptr *protection);
// In some cases, e.g. when running under a sandbox on Linux, ASan is unable
// to obtain the memory mappings. It should fall back to pre-cached data
// instead of aborting.
@ -71,12 +52,6 @@ class MemoryMappingLayout {
private:
void LoadFromCache();
// Default implementation of GetObjectNameAndOffset.
// Quite slow, because it iterates through the whole process map for each
// lookup.
bool IterateForObjectNameAndOffset(uptr addr, uptr *offset,
char filename[], uptr filename_size,
uptr *protection);
// FIXME: Hide implementation details for different platforms in
// platform-specific files.
@ -111,8 +86,6 @@ void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size);
// Returns code range for the specified module.
bool GetCodeRangeForFile(const char *module, uptr *start, uptr *end);
#endif // SANITIZER_WINDOWS
} // namespace __sanitizer
#endif // SANITIZER_PROCMAPS_H

View File

@ -191,24 +191,15 @@ bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
return true;
}
// Gets the object name and the offset by walking MemoryMappingLayout.
bool MemoryMappingLayout::GetObjectNameAndOffset(uptr addr, uptr *offset,
char filename[],
uptr filename_size,
uptr *protection) {
return IterateForObjectNameAndOffset(addr, offset, filename, filename_size,
protection);
}
uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules,
uptr max_modules,
string_predicate_t filter) {
Reset();
uptr cur_beg, cur_end;
uptr cur_beg, cur_end, cur_offset;
InternalScopedBuffer<char> module_name(kMaxPathLength);
uptr n_modules = 0;
for (uptr i = 0; n_modules < max_modules &&
Next(&cur_beg, &cur_end, 0, module_name.data(),
Next(&cur_beg, &cur_end, &cur_offset, module_name.data(),
module_name.size(), 0);
i++) {
const char *cur_name = module_name.data();
@ -217,7 +208,19 @@ uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules,
if (filter && !filter(cur_name))
continue;
void *mem = &modules[n_modules];
LoadedModule *cur_module = new(mem) LoadedModule(cur_name, cur_beg);
// Don't subtract 'cur_beg' from the first entry:
// * If a binary is compiled w/o -pie, then the first entry in
// process maps is likely the binary itself (all dynamic libs
// are mapped higher in address space). For such a binary,
// instruction offset in binary coincides with the actual
// instruction address in virtual memory (as code section
// is mapped to a fixed memory range).
// * If a binary is compiled with -pie, all the modules are
// mapped high at address space (in particular, higher than
// shadow memory of the tool), so the module can't be the
// first entry.
uptr base_address = (i ? cur_beg : 0) - cur_offset;
LoadedModule *cur_module = new(mem) LoadedModule(cur_name, base_address);
cur_module->addAddressRange(cur_beg, cur_end);
n_modules++;
}

View File

@ -153,14 +153,6 @@ bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
return false;
}
bool MemoryMappingLayout::GetObjectNameAndOffset(uptr addr, uptr *offset,
char filename[],
uptr filename_size,
uptr *protection) {
return IterateForObjectNameAndOffset(addr, offset, filename, filename_size,
protection);
}
uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules,
uptr max_modules,
string_predicate_t filter) {

View File

@ -1,52 +0,0 @@
//===-- sanitizer_procmaps_posix.cc ---------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Information about the process mappings.
//===----------------------------------------------------------------------===//
#include "sanitizer_platform.h"
#if SANITIZER_POSIX
#include "sanitizer_common.h"
#include "sanitizer_procmaps.h"
namespace __sanitizer {
bool MemoryMappingLayout::IterateForObjectNameAndOffset(uptr addr, uptr *offset,
char filename[],
uptr filename_size,
uptr *protection) {
Reset();
uptr start, end, file_offset;
for (int i = 0; Next(&start, &end, &file_offset, filename, filename_size,
protection);
i++) {
if (addr >= start && addr < end) {
// Don't subtract 'start' for the first entry:
// * If a binary is compiled w/o -pie, then the first entry in
// process maps is likely the binary itself (all dynamic libs
// are mapped higher in address space). For such a binary,
// instruction offset in binary coincides with the actual
// instruction address in virtual memory (as code section
// is mapped to a fixed memory range).
// * If a binary is compiled with -pie, all the modules are
// mapped high at address space (in particular, higher than
// shadow memory of the tool), so the module can't be the
// first entry.
*offset = (addr - (i ? start : 0)) + file_offset;
return true;
}
}
if (filename_size)
filename[0] = '\0';
return false;
}
} // namespace __sanitizer
#endif // SANITIZER_POSIX

View File

@ -33,7 +33,6 @@ if [ "`uname -a | grep Linux`" != "" ]; then
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_posix_libcdep.cc
../../sanitizer_common/sanitizer_procmaps_linux.cc
../../sanitizer_common/sanitizer_procmaps_posix.cc
../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_linux_libcdep.cc
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@ -48,7 +47,6 @@ elif [ "`uname -a | grep Darwin`" != "" ]; then
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_posix_libcdep.cc
../../sanitizer_common/sanitizer_procmaps_mac.cc
../../sanitizer_common/sanitizer_procmaps_posix.cc
"
elif [ "`uname -a | grep MINGW`" != "" ]; then
SUFFIX="windows_amd64"