diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 15:59:59 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 15:59:59 +0000 |
commit | 8ad54828f10e7add4a477a9bdb4e8429db15c924 (patch) | |
tree | 6d3e3932beed698b804ac4d850c1b4fa01ed5e7d /base | |
parent | 0e1f7d2b8c9201d59235c82d6e07027f4a905e64 (diff) | |
download | chromium_src-8ad54828f10e7add4a477a9bdb4e8429db15c924.zip chromium_src-8ad54828f10e7add4a477a9bdb4e8429db15c924.tar.gz chromium_src-8ad54828f10e7add4a477a9bdb4e8429db15c924.tar.bz2 |
GTTF: Make debug symbol "resolution" work even after binaries are moved.
This happens e.g. between the builder and tester bots.
This is a resubmit of https://codereview.chromium.org/12557003 ,
but with the new logic disabled on Windows XP because of mysterious
hangs.
BUG=168411
Review URL: https://codereview.chromium.org/13863008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/debug/stack_trace_win.cc | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/base/debug/stack_trace_win.cc b/base/debug/stack_trace_win.cc index da75b0b..f1d3590 100644 --- a/base/debug/stack_trace_win.cc +++ b/base/debug/stack_trace_win.cc @@ -12,8 +12,11 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/singleton.h" +#include "base/path_service.h" #include "base/process_util.h" +#include "base/string_util.h" #include "base/synchronization/lock.h" +#include "base/win/windows_version.h" namespace base { namespace debug { @@ -129,9 +132,7 @@ class SymbolContext { SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES); - if (SymInitialize(GetCurrentProcess(), NULL, TRUE)) { - init_error_ = ERROR_SUCCESS; - } else { + if (!SymInitialize(GetCurrentProcess(), NULL, TRUE)) { init_error_ = GetLastError(); // TODO(awong): Handle error: SymInitialize can fail with // ERROR_INVALID_PARAMETER. @@ -139,6 +140,41 @@ class SymbolContext { // process (prevents future tests from running or kills the browser // process). DLOG(ERROR) << "SymInitialize failed: " << init_error_; + return; + } + + init_error_ = ERROR_SUCCESS; + + // Work around a mysterious hang on Windows XP. + if (base::win::GetVersion() < base::win::VERSION_VISTA) + return; + + // When transferring the binaries e.g. between bots, path put + // into the executable will get off. To still retrieve symbols correctly, + // add the directory of the executable to symbol search path. + // All following errors are non-fatal. + wchar_t symbols_path[1024]; + + // Note: The below function takes buffer size as number of characters, + // not number of bytes! + if (!SymGetSearchPathW(GetCurrentProcess(), + symbols_path, + arraysize(symbols_path))) { + DLOG(WARNING) << "SymGetSearchPath failed: "; + return; + } + + FilePath module_path; + if (!PathService::Get(FILE_EXE, &module_path)) { + DLOG(WARNING) << "PathService::Get(FILE_EXE) failed."; + return; + } + + std::wstring new_path(std::wstring(symbols_path) + + L";" + module_path.DirName().value()); + if (!SymSetSearchPathW(GetCurrentProcess(), new_path.c_str())) { + DLOG(WARNING) << "SymSetSearchPath failed."; + return; } } |