summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmail Pazarbasi <ismail.pazarbasi@gmail.com>2015-05-12 20:47:21 +0000
committerIsmail Pazarbasi <ismail.pazarbasi@gmail.com>2015-05-12 20:47:21 +0000
commitb981dc84799f315bf82f3a2d95ff12bcd98389ed (patch)
tree6b21e53597a0005e65e3f203864a1300b2b84e1c
parent5708cca7abd2a6b5b74304aa80dd70b633569f8d (diff)
downloadbcm5719-llvm-b981dc84799f315bf82f3a2d95ff12bcd98389ed.tar.gz
bcm5719-llvm-b981dc84799f315bf82f3a2d95ff12bcd98389ed.zip
Sanitizers: Implement `GetRSS` on Mac OS X
Reviewers: kcc, glider, dvyukov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9636 llvm-svn: 237173
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index 4c5b40935ef..04051e9fef7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -30,8 +30,11 @@
#include "sanitizer_procmaps.h"
#include <crt_externs.h> // for _NSGetEnviron
+#include <errno.h>
#include <fcntl.h>
+#include <libkern/OSAtomic.h>
#include <mach-o/dyld.h>
+#include <mach/mach.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
@@ -42,8 +45,6 @@
#include <sys/sysctl.h>
#include <sys/types.h>
#include <unistd.h>
-#include <libkern/OSAtomic.h>
-#include <errno.h>
namespace __sanitizer {
@@ -333,7 +334,15 @@ MacosVersion GetMacosVersion() {
}
uptr GetRSS() {
- return 0;
+ struct task_basic_info info;
+ unsigned count = TASK_BASIC_INFO_COUNT;
+ kern_return_t result =
+ task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &count);
+ if (UNLIKELY(result != KERN_SUCCESS)) {
+ Report("Cannot get task info. Error: %d\n", result);
+ Die();
+ }
+ return info.resident_size;
}
void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; }
OpenPOWER on IntegriCloud