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 <windows.h> | 7 #include <windows.h> |
8 #include <dbghelp.h> | 8 #include <dbghelp.h> |
9 | 9 |
10 #include <iostream> | 10 #include <iostream> |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void StackTrace::Print() const { | 256 void StackTrace::Print() const { |
257 OutputToStream(&std::cerr); | 257 OutputToStream(&std::cerr); |
258 } | 258 } |
259 | 259 |
260 void StackTrace::OutputToStream(std::ostream* os) const { | 260 void StackTrace::OutputToStream(std::ostream* os) const { |
261 SymbolContext* context = SymbolContext::GetInstance(); | 261 SymbolContext* context = SymbolContext::GetInstance(); |
262 DWORD error = context->init_error(); | 262 DWORD error = context->init_error(); |
263 if (error != ERROR_SUCCESS) { | 263 if (error != ERROR_SUCCESS) { |
264 (*os) << "Error initializing symbols (" << error | 264 (*os) << "Error initializing symbols (" << error |
265 << "). Dumping unresolved backtrace:\n"; | 265 << "). Dumping unresolved backtrace:\n"; |
266 for (int i = 0; (i < count_) && os->good(); ++i) { | 266 for (size_t i = 0; (i < count_) && os->good(); ++i) { |
267 (*os) << "\t" << trace_[i] << "\n"; | 267 (*os) << "\t" << trace_[i] << "\n"; |
268 } | 268 } |
269 } else { | 269 } else { |
270 (*os) << "Backtrace:\n"; | 270 (*os) << "Backtrace:\n"; |
271 context->OutputTraceToStream(trace_, count_, os); | 271 context->OutputTraceToStream(trace_, count_, os); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 } // namespace debug | 275 } // namespace debug |
276 } // namespace base | 276 } // namespace base |
OLD | NEW |