summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-04-09 17:25:57 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-04-09 17:25:57 +0000
commitdd7c60c2d2f20907b30320890687a5eacaaace8f (patch)
tree78cab8e6cf5e0880596be1151ea54ad3d084e227 /compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
parent698fdfab7524088a3c390d783c94ae3f7d3290a9 (diff)
downloadbcm5719-llvm-dd7c60c2d2f20907b30320890687a5eacaaace8f.tar.gz
bcm5719-llvm-dd7c60c2d2f20907b30320890687a5eacaaace8f.zip
[sanitizer] Allow BackgroundThread to not depend on StackDepot
Summary: Still pursuing the ultimate goal of splitting the Symbolizer code from RTSanitizerCommon core, allow `BackgroundThread` to work even when not linked with `sanitizer_stackdepot.cc`. There is no reason this function should pull in the whole `StackDepot` if symbolization is not supported. Currently this has no functional change as the depot is always linked anyway. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45296 llvm-svn: 329595
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
index 9c24c30749c..48d1749b210 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc
@@ -18,7 +18,6 @@
#include "sanitizer_flags.h"
#include "sanitizer_procmaps.h"
#include "sanitizer_report_decorator.h"
-#include "sanitizer_stackdepot.h"
#include "sanitizer_stacktrace.h"
#include "sanitizer_symbolizer.h"
@@ -113,6 +112,9 @@ void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) {
}
#if SANITIZER_LINUX && !SANITIZER_GO
+// Weak definition for when sanitizer_stackdepot is not linked in.
+SANITIZER_WEAK_ATTRIBUTE StackDepotStats *StackDepotGetStats();
+
void BackgroundThread(void *arg) {
uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
@@ -130,15 +132,17 @@ void BackgroundThread(void *arg) {
Printf("%s: RSS: %zdMb\n", SanitizerToolName, current_rss_mb);
prev_reported_rss = current_rss_mb;
}
- // If stack depot has grown 10% since last time, print it too.
- StackDepotStats *stack_depot_stats = StackDepotGetStats();
- if (prev_reported_stack_depot_size * 11 / 10 <
- stack_depot_stats->allocated) {
- Printf("%s: StackDepot: %zd ids; %zdM allocated\n",
- SanitizerToolName,
- stack_depot_stats->n_uniq_ids,
- stack_depot_stats->allocated >> 20);
- prev_reported_stack_depot_size = stack_depot_stats->allocated;
+ if (&StackDepotGetStats) {
+ // If stack depot has grown 10% since last time, print it too.
+ StackDepotStats *stack_depot_stats = StackDepotGetStats();
+ if (prev_reported_stack_depot_size * 11 / 10 <
+ stack_depot_stats->allocated) {
+ Printf("%s: StackDepot: %zd ids; %zdM allocated\n",
+ SanitizerToolName,
+ stack_depot_stats->n_uniq_ids,
+ stack_depot_stats->allocated >> 20);
+ prev_reported_stack_depot_size = stack_depot_stats->allocated;
+ }
}
}
// Check RSS against the limit.
OpenPOWER on IntegriCloud