| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  167                      exception_pointers->ContextRecord, |  167                      exception_pointers->ContextRecord, | 
|  168                      NULL, |  168                      NULL, | 
|  169                      &SymFunctionTableAccess64, |  169                      &SymFunctionTableAccess64, | 
|  170                      &SymGetModuleBase64, |  170                      &SymGetModuleBase64, | 
|  171                      NULL) && |  171                      NULL) && | 
|  172          count_ < arraysize(trace_)) { |  172          count_ < arraysize(trace_)) { | 
|  173     trace_[count_++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset); |  173     trace_[count_++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset); | 
|  174   } |  174   } | 
|  175 } |  175 } | 
|  176  |  176  | 
|  177 void StackTrace::PrintBacktrace() { |  177 void StackTrace::PrintBacktrace() const { | 
|  178   OutputToStream(&std::cerr); |  178   OutputToStream(&std::cerr); | 
|  179 } |  179 } | 
|  180  |  180  | 
|  181 void StackTrace::OutputToStream(std::ostream* os) { |  181 void StackTrace::OutputToStream(std::ostream* os) const { | 
|  182   SymbolContext* context = SymbolContext::GetInstance(); |  182   SymbolContext* context = SymbolContext::GetInstance(); | 
|  183   DWORD error = context->init_error(); |  183   DWORD error = context->init_error(); | 
|  184   if (error != ERROR_SUCCESS) { |  184   if (error != ERROR_SUCCESS) { | 
|  185     (*os) << "Error initializing symbols (" << error |  185     (*os) << "Error initializing symbols (" << error | 
|  186           << ").  Dumping unresolved backtrace:\n"; |  186           << ").  Dumping unresolved backtrace:\n"; | 
|  187     for (int i = 0; (i < count_) && os->good(); ++i) { |  187     for (int i = 0; (i < count_) && os->good(); ++i) { | 
|  188       (*os) << "\t" << trace_[i] << "\n"; |  188       (*os) << "\t" << trace_[i] << "\n"; | 
|  189     } |  189     } | 
|  190   } else { |  190   } else { | 
|  191     (*os) << "Backtrace:\n"; |  191     (*os) << "Backtrace:\n"; | 
|  192     context->OutputTraceToStream(trace_, count_, os); |  192     context->OutputTraceToStream(trace_, count_, os); | 
|  193   } |  193   } | 
|  194 } |  194 } | 
|  195  |  195  | 
|  196 }  // namespace debug |  196 }  // namespace debug | 
|  197 }  // namespace base |  197 }  // namespace base | 
| OLD | NEW |