Skip to content

Commit

Permalink
When debugger is attached, use int3 to break debugger for Android x86.
Browse files Browse the repository at this point in the history
Patch follows up https://codereview.chromium.org/13891005/.

BUG=

Review URL: https://chromiumcodereview.appspot.com/14267012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195751 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
shouqun.liu@intel.com committed Apr 23, 2013
1 parent 74d9698 commit 480a2a3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions base/debug/debugger_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,26 @@ bool BeingDebugged() {
#define DEBUG_BREAK() abort()
#elif defined(OS_ANDROID)
// Though Android has a "helpful" process called debuggerd to catch native
// signals on the general assumption that they are fatal errors. The bkpt
// instruction appears to cause SIGBUS which is trapped by debuggerd, and
// we've had great difficulty continuing in a debugger once we stop from
// SIG triggered by native code.
//
// Use GDB to set |go| to 1 to resume execution.
// signals on the general assumption that they are fatal errors. If no debugger
// is attached, we call abort since Breakpad needs SIGABRT to create a dump.
// When debugger is attached, for ARM platform the bkpt instruction appears
// to cause SIGBUS which is trapped by debuggerd, and we've had great
// difficulty continuing in a debugger once we stop from SIG triggered by native
// code, use GDB to set |go| to 1 to resume execution; for X86 platform, use
// "int3" to setup breakpiont and raise SIGTRAP.
namespace {
void DebugBreak() {
if (!BeingDebugged()) {
abort();
} else {
#if defined(ARCH_CPU_X86_FAMILY)
asm("int3");
#else
volatile int go = 0;
while (!go) {
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
}
#endif
}
}
} // namespace
Expand Down

0 comments on commit 480a2a3

Please sign in to comment.