summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2016-02-22 18:52:51 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2016-02-22 18:52:51 +0000
commit8e3cbde27d471ed207275cc3106f59c8d3cfa284 (patch)
treebc9fc762cf00c73097c943c18f38ff2ae4dd4d8d /compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
parent8c03c542002258ccf0197908904d5cb9767f2394 (diff)
downloadbcm5719-llvm-8e3cbde27d471ed207275cc3106f59c8d3cfa284.tar.gz
bcm5719-llvm-8e3cbde27d471ed207275cc3106f59c8d3cfa284.zip
[Sanitizer] Introduce ListOfModules object and use it to replace GetListOfModules().
Summary: This removes the hard limit on the number of loaded modules (used to be 16K), and makes it easier to use LoadedModules w/o causing a memory leak: ListOfModules owns the modules, and makes sure to properly clean them in destructor. Remove filtering functionality that is only needed in one place (LSan). Reviewers: aizatsky Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D17470 llvm-svn: 261554
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
index d43432cae90..fac3fbdad07 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
@@ -116,22 +116,17 @@ void MemoryMappingLayout::LoadFromCache() {
}
}
-uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules,
- uptr max_modules,
- string_predicate_t filter) {
+void MemoryMappingLayout::DumpListOfModules(
+ InternalMmapVector<LoadedModule> *modules) {
Reset();
uptr cur_beg, cur_end, cur_offset, prot;
InternalScopedString module_name(kMaxPathLength);
- uptr n_modules = 0;
- for (uptr i = 0; n_modules < max_modules &&
- Next(&cur_beg, &cur_end, &cur_offset, module_name.data(),
- module_name.size(), &prot);
+ for (uptr i = 0; Next(&cur_beg, &cur_end, &cur_offset, module_name.data(),
+ module_name.size(), &prot);
i++) {
const char *cur_name = module_name.data();
if (cur_name[0] == '\0')
continue;
- if (filter && !filter(cur_name))
- continue;
// 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
@@ -144,12 +139,11 @@ uptr MemoryMappingLayout::DumpListOfModules(LoadedModule *modules,
// 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 = &modules[n_modules];
- cur_module->set(cur_name, base_address);
- cur_module->addAddressRange(cur_beg, cur_end, prot & kProtectionExecute);
- n_modules++;
+ LoadedModule cur_module;
+ cur_module.set(cur_name, base_address);
+ cur_module.addAddressRange(cur_beg, cur_end, prot & kProtectionExecute);
+ modules->push_back(cur_module);
}
- return n_modules;
}
void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) {
OpenPOWER on IntegriCloud