| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 17 matching lines...) Expand all Loading... |
| 28 #include <sys/sysctl.h> | 28 #include <sys/sysctl.h> |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #if defined(OS_FREEBSD) | 31 #if defined(OS_FREEBSD) |
| 32 #include <sys/user.h> | 32 #include <sys/user.h> |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #include <ostream> | 35 #include <ostream> |
| 36 | 36 |
| 37 #include "base/basictypes.h" | 37 #include "base/basictypes.h" |
| 38 #include "base/debug/alias.h" |
| 38 #include "base/logging.h" | 39 #include "base/logging.h" |
| 39 #include "base/memory/scoped_ptr.h" | 40 #include "base/memory/scoped_ptr.h" |
| 40 #include "base/posix/eintr_wrapper.h" | 41 #include "base/posix/eintr_wrapper.h" |
| 41 #include "base/strings/string_piece.h" | 42 #include "base/strings/string_piece.h" |
| 42 | 43 |
| 43 #if defined(USE_SYMBOLIZE) | 44 #if defined(USE_SYMBOLIZE) |
| 44 #include "base/third_party/symbolize/symbolize.h" | 45 #include "base/third_party/symbolize/symbolize.h" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 #elif defined(DEBUG_BREAK_ASM) | 231 #elif defined(DEBUG_BREAK_ASM) |
| 231 #define DEBUG_BREAK() DEBUG_BREAK_ASM() | 232 #define DEBUG_BREAK() DEBUG_BREAK_ASM() |
| 232 #else | 233 #else |
| 233 #error "Don't know how to debug break on this architecture/OS" | 234 #error "Don't know how to debug break on this architecture/OS" |
| 234 #endif | 235 #endif |
| 235 | 236 |
| 236 void BreakDebugger() { | 237 void BreakDebugger() { |
| 237 // NOTE: This code MUST be async-signal safe (it's used by in-process | 238 // NOTE: This code MUST be async-signal safe (it's used by in-process |
| 238 // stack dumping signal handler). NO malloc or stdio is allowed here. | 239 // stack dumping signal handler). NO malloc or stdio is allowed here. |
| 239 | 240 |
| 241 // Linker's ICF feature may merge this function with other functions with the |
| 242 // same definition (e.g. any function whose sole job is to call abort()) and |
| 243 // it may confuse the crash report processing system. http://crbug.com/508489 |
| 244 static int static_variable_to_make_this_function_unique = 0; |
| 245 base::debug::Alias(&static_variable_to_make_this_function_unique); |
| 246 |
| 240 DEBUG_BREAK(); | 247 DEBUG_BREAK(); |
| 241 #if defined(OS_ANDROID) && !defined(OFFICIAL_BUILD) | 248 #if defined(OS_ANDROID) && !defined(OFFICIAL_BUILD) |
| 242 // For Android development we always build release (debug builds are | 249 // For Android development we always build release (debug builds are |
| 243 // unmanageably large), so the unofficial build is used for debugging. It is | 250 // unmanageably large), so the unofficial build is used for debugging. It is |
| 244 // helpful to be able to insert BreakDebugger() statements in the source, | 251 // helpful to be able to insert BreakDebugger() statements in the source, |
| 245 // attach the debugger, inspect the state of the program and then resume it by | 252 // attach the debugger, inspect the state of the program and then resume it by |
| 246 // setting the 'go' variable above. | 253 // setting the 'go' variable above. |
| 247 #elif defined(NDEBUG) | 254 #elif defined(NDEBUG) |
| 248 // Terminate the program after signaling the debug break. | 255 // Terminate the program after signaling the debug break. |
| 249 _exit(1); | 256 _exit(1); |
| 250 #endif | 257 #endif |
| 251 } | 258 } |
| 252 | 259 |
| 253 } // namespace debug | 260 } // namespace debug |
| 254 } // namespace base | 261 } // namespace base |
| OLD | NEW |