diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-05 18:25:20 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-05 18:25:20 +0000 |
commit | dbd9bfc0b4df5132997d1c4216ba4bbd860fed85 (patch) | |
tree | e4e6ec0a6e0468447d6b0337bd981c55c376099e /base | |
parent | f505c31ba55975411a009f74a59b001a5a46bb56 (diff) | |
download | chromium_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')
-rw-r--r-- | base/debug_util.h | 4 | ||||
-rw-r--r-- | base/debug_util_posix.cc | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/base/debug_util.h b/base/debug_util.h index b7b5180..b61cb1e 100644 --- a/base/debug_util.h +++ b/base/debug_util.h @@ -43,6 +43,10 @@ class DebugUtil { static bool WaitForDebugger(int wait_seconds, bool silent); // Are we running under a debugger? + // On OS X, the underlying mechanism doesn't work when the sandbox is enabled. + // To get around this, this function caches it's value. + // WARNING: Because of this, on OS X, a call MUST be made to this function + // BEFORE the sandbox is enabled. static bool BeingDebugged(); // Break into the debugger, assumes a debugger is present. 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) |