summaryrefslogtreecommitdiffstats
path: root/base/debug_util_posix.cc
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 18:25:20 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 18:25:20 +0000
commitdbd9bfc0b4df5132997d1c4216ba4bbd860fed85 (patch)
treee4e6ec0a6e0468447d6b0337bd981c55c376099e /base/debug_util_posix.cc
parentf505c31ba55975411a009f74a59b001a5a46bb56 (diff)
downloadchromium_src-dbd9bfc0b4df5132997d1c4216ba4bbd860fed85.zip
chromium_src-dbd9bfc0b4df5132997d1c4216ba4bbd860fed85.tar.gz
chromium_src-dbd9bfc0b4df5132997d1c4216ba4bbd860fed85.tar.bz2
Some fixes to ease debugging of the renderer process on OS X.
Review URL: http://codereview.chromium.org/21084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug_util_posix.cc')
-rw-r--r--base/debug_util_posix.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index 3a25017..60e2ff5 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -29,6 +29,15 @@ bool DebugUtil::SpawnDebuggerOnProcess(unsigned /* process_id */) {
// http://developer.apple.com/qa/qa2004/qa1361.html
// static
bool DebugUtil::BeingDebugged() {
+ // If the process is sandboxed then we can't use the sysctl, so cache the
+ // value.
+ static bool is_set = false;
+ static bool being_debugged = false;
+
+ if (is_set) {
+ return being_debugged;
+ }
+
// Initialize mib, which tells sysctl what info we want. In this case,
// we're looking for information about a specific process ID.
int mib[] = {
@@ -45,11 +54,16 @@ bool DebugUtil::BeingDebugged() {
int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
DCHECK(sysctl_result == 0);
- if (sysctl_result != 0)
- return false;
+ if (sysctl_result != 0) {
+ is_set = true;
+ being_debugged = false;
+ return being_debugged;
+ }
// This process is being debugged if the P_TRACED flag is set.
- return (info.kp_proc.p_flag & P_TRACED) != 0;
+ is_set = true;
+ being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0;
+ return being_debugged;
}
#elif defined(OS_LINUX)