| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/debugger.h" | 5 #include "base/debug/debugger.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 #elif defined(ARCH_CPU_ARM_FAMILY) | 191 #elif defined(ARCH_CPU_ARM_FAMILY) |
| 192 #if defined(OS_ANDROID) | 192 #if defined(OS_ANDROID) |
| 193 // Though Android has a "helpful" process called debuggerd to catch native | 193 // Though Android has a "helpful" process called debuggerd to catch native |
| 194 // signals on the general assumption that they are fatal errors, we've had great | 194 // signals on the general assumption that they are fatal errors, we've had great |
| 195 // difficulty continuing in a debugger once we stop from SIGINT triggered by | 195 // difficulty continuing in a debugger once we stop from SIGINT triggered by |
| 196 // native code. | 196 // native code. |
| 197 // | 197 // |
| 198 // Use GDB to set |go| to 1 to resume execution. | 198 // Use GDB to set |go| to 1 to resume execution. |
| 199 #define DEBUG_BREAK() do { \ | 199 #define DEBUG_BREAK() do { \ |
| 200 volatile int go = 0; \ | 200 volatile int go = 0; \ |
| 201 while (!go) { base::PlatformThread::Sleep(100); } \ | 201 while (!go) { \ |
| 202 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); \ |
| 203 } \ |
| 202 } while (0) | 204 } while (0) |
| 203 #else | 205 #else |
| 204 // ARM && !ANDROID | 206 // ARM && !ANDROID |
| 205 #define DEBUG_BREAK() asm("bkpt 0") | 207 #define DEBUG_BREAK() asm("bkpt 0") |
| 206 #endif | 208 #endif |
| 207 #else | 209 #else |
| 208 #define DEBUG_BREAK() asm("int3") | 210 #define DEBUG_BREAK() asm("int3") |
| 209 #endif | 211 #endif |
| 210 | 212 |
| 211 void BreakDebugger() { | 213 void BreakDebugger() { |
| 212 DEBUG_BREAK(); | 214 DEBUG_BREAK(); |
| 213 #if defined(NDEBUG) | 215 #if defined(NDEBUG) |
| 214 _exit(1); | 216 _exit(1); |
| 215 #endif | 217 #endif |
| 216 } | 218 } |
| 217 | 219 |
| 218 } // namespace debug | 220 } // namespace debug |
| 219 } // namespace base | 221 } // namespace base |
| OLD | NEW |