| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "base/debug_util.h" | 6 #include "base/debug_util.h" |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <execinfo.h> | 9 #include <execinfo.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 // Our pid is 0 without a debugger, assume this for any pid starting with 0. | 102 // Our pid is 0 without a debugger, assume this for any pid starting with 0. |
| 103 pid_index += tracer.size(); | 103 pid_index += tracer.size(); |
| 104 return pid_index < status.size() && status[pid_index] != '0'; | 104 return pid_index < status.size() && status[pid_index] != '0'; |
| 105 } | 105 } |
| 106 | 106 |
| 107 #endif // OS_LINUX | 107 #endif // OS_LINUX |
| 108 | 108 |
| 109 // static | 109 // static |
| 110 void DebugUtil::BreakDebugger() { | 110 void DebugUtil::BreakDebugger() { |
| 111 #if !defined(ARCH_CPU_ARM_FAMILY) | 111 #if defined(ARCH_CPU_ARM_FAMILY) |
| 112 asm ("int3"); | 112 asm("bkpt 0"); |
| 113 #else |
| 114 asm("int3"); |
| 113 #endif | 115 #endif |
| 114 } | 116 } |
| 115 | 117 |
| 116 StackTrace::StackTrace() { | 118 StackTrace::StackTrace() { |
| 117 const int kMaxCallers = 256; | 119 const int kMaxCallers = 256; |
| 118 | 120 |
| 119 void* callers[kMaxCallers]; | 121 void* callers[kMaxCallers]; |
| 120 int count = backtrace(callers, kMaxCallers); | 122 int count = backtrace(callers, kMaxCallers); |
| 121 | 123 |
| 122 // Though the backtrace API man page does not list any possible negative | 124 // Though the backtrace API man page does not list any possible negative |
| (...skipping 24 matching lines...) Expand all Loading... |
| 147 for (size_t i = 0; i < trace_.size(); ++i) { | 149 for (size_t i = 0; i < trace_.size(); ++i) { |
| 148 (*os) << "\t" << trace_[i] << "\n"; | 150 (*os) << "\t" << trace_[i] << "\n"; |
| 149 } | 151 } |
| 150 } else { | 152 } else { |
| 151 (*os) << "Backtrace:\n"; | 153 (*os) << "Backtrace:\n"; |
| 152 for (size_t i = 0; i < trace_.size(); ++i) { | 154 for (size_t i = 0; i < trace_.size(); ++i) { |
| 153 (*os) << "\t" << trace_symbols.get()[i] << "\n"; | 155 (*os) << "\t" << trace_symbols.get()[i] << "\n"; |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 } | 158 } |
| OLD | NEW |