| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // add the directory of the executable to symbol search path. | 70 // add the directory of the executable to symbol search path. |
| 71 // All following errors are non-fatal. | 71 // All following errors are non-fatal. |
| 72 const size_t kSymbolsArraySize = 1024; | 72 const size_t kSymbolsArraySize = 1024; |
| 73 scoped_ptr<wchar_t[]> symbols_path(new wchar_t[kSymbolsArraySize]); | 73 scoped_ptr<wchar_t[]> symbols_path(new wchar_t[kSymbolsArraySize]); |
| 74 | 74 |
| 75 // Note: The below function takes buffer size as number of characters, | 75 // Note: The below function takes buffer size as number of characters, |
| 76 // not number of bytes! | 76 // not number of bytes! |
| 77 if (!SymGetSearchPathW(GetCurrentProcess(), | 77 if (!SymGetSearchPathW(GetCurrentProcess(), |
| 78 symbols_path.get(), | 78 symbols_path.get(), |
| 79 kSymbolsArraySize)) { | 79 kSymbolsArraySize)) { |
| 80 g_init_error = GetLastError(); |
| 80 DLOG(WARNING) << "SymGetSearchPath failed: " << g_init_error; | 81 DLOG(WARNING) << "SymGetSearchPath failed: " << g_init_error; |
| 81 g_init_error = GetLastError(); | |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 std::wstring new_path(std::wstring(symbols_path.get()) + | 85 std::wstring new_path(std::wstring(symbols_path.get()) + |
| 86 L";" + GetExePath().DirName().value()); | 86 L";" + GetExePath().DirName().value()); |
| 87 if (!SymSetSearchPathW(GetCurrentProcess(), new_path.c_str())) { | 87 if (!SymSetSearchPathW(GetCurrentProcess(), new_path.c_str())) { |
| 88 g_init_error = GetLastError(); | 88 g_init_error = GetLastError(); |
| 89 DLOG(WARNING) << "SymSetSearchPath failed." << g_init_error; | 89 DLOG(WARNING) << "SymSetSearchPath failed." << g_init_error; |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 (*os) << "\t" << trace_[i] << "\n"; | 276 (*os) << "\t" << trace_[i] << "\n"; |
| 277 } | 277 } |
| 278 } else { | 278 } else { |
| 279 (*os) << "Backtrace:\n"; | 279 (*os) << "Backtrace:\n"; |
| 280 context->OutputTraceToStream(trace_, count_, os); | 280 context->OutputTraceToStream(trace_, count_, os); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace debug | 284 } // namespace debug |
| 285 } // namespace base | 285 } // namespace base |
| OLD | NEW |