| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 base::StringPiece::size_type pid_index = status.find(tracer); | 98 base::StringPiece::size_type pid_index = status.find(tracer); |
| 99 if (pid_index == base::StringPiece::npos) | 99 if (pid_index == base::StringPiece::npos) |
| 100 return false; | 100 return false; |
| 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 #elif defined(OS_FREEBSD) |
| 108 |
| 109 // TODO(benl): can we determine this under FreeBSD? |
| 110 |
| 111 bool DebugUtil::BeingDebugged() { |
| 112 return false; |
| 113 } |
| 114 |
| 107 #endif // OS_LINUX | 115 #endif // OS_LINUX |
| 108 | 116 |
| 109 // static | 117 // static |
| 110 void DebugUtil::BreakDebugger() { | 118 void DebugUtil::BreakDebugger() { |
| 111 #if defined(ARCH_CPU_ARM_FAMILY) | 119 #if defined(ARCH_CPU_ARM_FAMILY) |
| 112 asm("bkpt 0"); | 120 asm("bkpt 0"); |
| 113 #else | 121 #else |
| 114 asm("int3"); | 122 asm("int3"); |
| 115 #endif | 123 #endif |
| 116 } | 124 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 137 for (int i = 0; i < count_; ++i) { | 145 for (int i = 0; i < count_; ++i) { |
| 138 (*os) << "\t" << trace_[i] << "\n"; | 146 (*os) << "\t" << trace_[i] << "\n"; |
| 139 } | 147 } |
| 140 } else { | 148 } else { |
| 141 (*os) << "Backtrace:\n"; | 149 (*os) << "Backtrace:\n"; |
| 142 for (int i = 0; i < count_; ++i) { | 150 for (int i = 0; i < count_; ++i) { |
| 143 (*os) << "\t" << trace_symbols.get()[i] << "\n"; | 151 (*os) << "\t" << trace_symbols.get()[i] << "\n"; |
| 144 } | 152 } |
| 145 } | 153 } |
| 146 } | 154 } |
| OLD | NEW |