Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1325)

Unified Diff: base/debug/stack_trace_win.cc

Issue 13863008: GTTF: Make debug symbol "resolution" work even after binaries are moved. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace_win.cc
===================================================================
--- base/debug/stack_trace_win.cc (revision 193166)
+++ base/debug/stack_trace_win.cc (working copy)
@@ -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 @@
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,7 +140,42 @@
// 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.";
cpu_(ooo_6.6-7.5) 2013/04/10 23:19:26 I would seem to me that we should avoid calling dl
Paweł Hajdan Jr. 2013/04/10 23:50:19 There was a DLOG here already and I think it's use
+ 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;
+ }
}
DWORD init_error_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698