| 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/stack_trace.h" | 5 #include "base/debug/stack_trace.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <execinfo.h> | 8 #include <execinfo.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 handler->HandleOutput("<unknown>"); | 144 handler->HandleOutput("<unknown>"); |
| 145 | 145 |
| 146 handler->HandleOutput("\n"); | 146 handler->HandleOutput("\n"); |
| 147 } | 147 } |
| 148 #else | 148 #else |
| 149 bool printed = false; | 149 bool printed = false; |
| 150 | 150 |
| 151 // Below part is async-signal unsafe (uses malloc), so execute it only | 151 // Below part is async-signal unsafe (uses malloc), so execute it only |
| 152 // when we are not executing the signal handler. | 152 // when we are not executing the signal handler. |
| 153 if (in_signal_handler == 0) { | 153 if (in_signal_handler == 0) { |
| 154 scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace, size)); | 154 scoped_ptr<char*, FreeDeleter> |
| 155 trace_symbols(backtrace_symbols(trace, size)); |
| 155 if (trace_symbols.get()) { | 156 if (trace_symbols.get()) { |
| 156 for (int i = 0; i < size; ++i) { | 157 for (int i = 0; i < size; ++i) { |
| 157 std::string trace_symbol = trace_symbols.get()[i]; | 158 std::string trace_symbol = trace_symbols.get()[i]; |
| 158 DemangleSymbols(&trace_symbol); | 159 DemangleSymbols(&trace_symbol); |
| 159 handler->HandleOutput(trace_symbol.c_str()); | 160 handler->HandleOutput(trace_symbol.c_str()); |
| 160 handler->HandleOutput("\n"); | 161 handler->HandleOutput("\n"); |
| 161 } | 162 } |
| 162 | 163 |
| 163 printed = true; | 164 printed = true; |
| 164 } | 165 } |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 *ptr = *start; | 548 *ptr = *start; |
| 548 *start++ = ch; | 549 *start++ = ch; |
| 549 } | 550 } |
| 550 return buf; | 551 return buf; |
| 551 } | 552 } |
| 552 | 553 |
| 553 } // namespace internal | 554 } // namespace internal |
| 554 | 555 |
| 555 } // namespace debug | 556 } // namespace debug |
| 556 } // namespace base | 557 } // namespace base |
| OLD | NEW |