| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // read this much all at once. In practice this will generally be true. | 85 // read this much all at once. In practice this will generally be true. |
| 86 // This simplifies and speeds up things considerably. | 86 // This simplifies and speeds up things considerably. |
| 87 char buf[1024]; | 87 char buf[1024]; |
| 88 | 88 |
| 89 ssize_t num_read = HANDLE_EINTR(read(status_fd, buf, sizeof(buf))); | 89 ssize_t num_read = HANDLE_EINTR(read(status_fd, buf, sizeof(buf))); |
| 90 HANDLE_EINTR(close(status_fd)); | 90 HANDLE_EINTR(close(status_fd)); |
| 91 | 91 |
| 92 if (num_read <= 0) | 92 if (num_read <= 0) |
| 93 return false; | 93 return false; |
| 94 | 94 |
| 95 StringPiece status(buf, num_read); | 95 base::StringPiece status(buf, num_read); |
| 96 StringPiece tracer("TracerPid:\t"); | 96 base::StringPiece tracer("TracerPid:\t"); |
| 97 | 97 |
| 98 StringPiece::size_type pid_index = status.find(tracer); | 98 base::StringPiece::size_type pid_index = status.find(tracer); |
| 99 if (pid_index == 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 #endif // OS_LINUX | 107 #endif // OS_LINUX |
| 108 | 108 |
| 109 // static | 109 // static |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 for (int i = 0; i < count_; ++i) { | 137 for (int i = 0; i < count_; ++i) { |
| 138 (*os) << "\t" << trace_[i] << "\n"; | 138 (*os) << "\t" << trace_[i] << "\n"; |
| 139 } | 139 } |
| 140 } else { | 140 } else { |
| 141 (*os) << "Backtrace:\n"; | 141 (*os) << "Backtrace:\n"; |
| 142 for (int i = 0; i < count_; ++i) { | 142 for (int i = 0; i < count_; ++i) { |
| 143 (*os) << "\t" << trace_symbols.get()[i] << "\n"; | 143 (*os) << "\t" << trace_symbols.get()[i] << "\n"; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| OLD | NEW |