diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-06-07 06:15:12 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-06-07 06:15:12 +0000 |
commit | 6895adc39c4e09371154c8037366ad4464163ed0 (patch) | |
tree | 7f9a3e828980b8b3daf20b689450432525f26ebe /lib/asan/asan_linux.cc | |
parent | cffe2f5c30c27234260d004b54152916ff0c45c6 (diff) | |
download | compiler-rt-6895adc39c4e09371154c8037366ad4464163ed0.tar.gz compiler-rt-6895adc39c4e09371154c8037366ad4464163ed0.tar.bz2 compiler-rt-6895adc39c4e09371154c8037366ad4464163ed0.tar.xz |
[Sanitizer] __asan::AsanProcMaps -> __sanitizer::ProcessMaps.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_linux.cc')
-rw-r--r-- | lib/asan/asan_linux.cc | 65 |
1 files changed, 2 insertions, 63 deletions
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc index b59a0a51..947c17f7 100644 --- a/lib/asan/asan_linux.cc +++ b/lib/asan/asan_linux.cc @@ -19,6 +19,7 @@ #include "asan_procmaps.h" #include "asan_thread.h" #include "sanitizer_common/sanitizer_libc.h" +#include "sanitizer_common/sanitizer_procmaps.h" #include <sys/time.h> #include <sys/resource.h> @@ -116,68 +117,6 @@ const char* AsanGetEnv(const char* name) { return 0; // Not found. } -AsanProcMaps::AsanProcMaps() { - proc_self_maps_buff_len_ = - ReadFileToBuffer("/proc/self/maps", &proc_self_maps_buff_, - &proc_self_maps_buff_mmaped_size_, 1 << 26); - CHECK(proc_self_maps_buff_len_ > 0); - // internal_write(2, proc_self_maps_buff_, proc_self_maps_buff_len_); - Reset(); -} - -AsanProcMaps::~AsanProcMaps() { - UnmapOrDie(proc_self_maps_buff_, proc_self_maps_buff_mmaped_size_); -} - -void AsanProcMaps::Reset() { - current_ = proc_self_maps_buff_; -} - -bool AsanProcMaps::Next(uptr *start, uptr *end, - uptr *offset, char filename[], - uptr filename_size) { - char *last = proc_self_maps_buff_ + proc_self_maps_buff_len_; - if (current_ >= last) return false; - int consumed = 0; - char flags[10]; - int major, minor; - uptr inode; - uptr dummy; - if (!start) start = &dummy; - if (!end) end = &dummy; - if (!offset) offset = &dummy; - char *next_line = (char*)internal_memchr(current_, '\n', last - current_); - if (next_line == 0) - next_line = last; - if (internal_sscanf(current_, - "%lx-%lx %4s %lx %x:%x %ld %n", - start, end, flags, offset, &major, &minor, - &inode, &consumed) != 7) - return false; - current_ += consumed; - // Skip spaces. - while (current_ < next_line && *current_ == ' ') - current_++; - // Fill in the filename. - uptr i = 0; - while (current_ < next_line) { - if (filename && i < filename_size - 1) - filename[i++] = *current_; - current_++; - } - if (filename && i < filename_size) - filename[i] = 0; - current_ = next_line + 1; - return true; -} - -// Gets the object name and the offset by walking AsanProcMaps. -bool AsanProcMaps::GetObjectNameAndOffset(uptr addr, uptr *offset, - char filename[], - uptr filename_size) { - return IterateForObjectNameAndOffset(addr, offset, filename, filename_size); -} - void AsanThread::SetThreadStackTopAndBottom() { if (tid() == 0) { // This is the main thread. Libpthread may not be initialized yet. @@ -185,7 +124,7 @@ void AsanThread::SetThreadStackTopAndBottom() { CHECK(getrlimit(RLIMIT_STACK, &rl) == 0); // Find the mapping that contains a stack variable. - AsanProcMaps proc_maps; + ProcessMaps proc_maps; uptr start, end, offset; uptr prev_end = 0; while (proc_maps.Next(&start, &end, &offset, 0, 0)) { |