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

Side by Side Diff: base/debug_util_win.cc

Issue 118162: Reduce header dependencies in base/ (Closed)
Patch Set: Created 11 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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_util.h" 5 #include "base/debug_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbghelp.h> 8 #include <dbghelp.h>
9 9
10 #include <iostream>
11
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
11 #include "base/lock.h" 13 #include "base/lock.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/singleton.h" 15 #include "base/singleton.h"
14 16
15 namespace { 17 namespace {
16 18
17 // Minimalist key reader. 19 // Minimalist key reader.
18 // Note: Does not use the CRT. 20 // Note: Does not use the CRT.
19 bool RegReadString(HKEY root, const wchar_t* subkey, 21 bool RegReadString(HKEY root, const wchar_t* subkey,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 LOG(ERROR) << "Calling GetInitError() before Init() was called. " 125 LOG(ERROR) << "Calling GetInitError() before Init() was called. "
124 << "Returning ERROR_INVALID_DATA."; 126 << "Returning ERROR_INVALID_DATA.";
125 return ERROR_INVALID_DATA; 127 return ERROR_INVALID_DATA;
126 } 128 }
127 129
128 return init_error_; 130 return init_error_;
129 } 131 }
130 132
131 // Returns the process this was initialized for. This should only be 133 // Returns the process this was initialized for. This should only be
132 // called if Init() has been called. We LOG(ERROR) in this situation. 134 // called if Init() has been called. We LOG(ERROR) in this situation.
133 // LOG(FATAL) is not used because this code is might be triggered 135 // LOG(FATAL) is not used because this code is might be triggered
134 // by a LOG(FATAL) itself. 136 // by a LOG(FATAL) itself.
135 HANDLE process() { 137 HANDLE process() {
136 if (!initialized_) { 138 if (!initialized_) {
137 LOG(ERROR) << "Calling process() before Init() was called. " 139 LOG(ERROR) << "Calling process() before Init() was called. "
138 << "Returning NULL."; 140 << "Returning NULL.";
139 return NULL; 141 return NULL;
140 } 142 }
141 143
142 return process_; 144 return process_;
143 } 145 }
144 146
145 // For the given trace, attempts to resolve the symbols, and output a trace 147 // For the given trace, attempts to resolve the symbols, and output a trace
146 // to the ostream os. The format for each line of the backtrace is: 148 // to the ostream os. The format for each line of the backtrace is:
147 // 149 //
148 // <tab>SymbolName[0xAddress+Offset] (FileName:LineNo) 150 // <tab>SymbolName[0xAddress+Offset] (FileName:LineNo)
149 // 151 //
150 // This function should only be called if Init() has been called. We do not 152 // This function should only be called if Init() has been called. We do not
151 // LOG(FATAL) here because this code is called might be triggered by a 153 // LOG(FATAL) here because this code is called might be triggered by a
152 // LOG(FATAL) itself. 154 // LOG(FATAL) itself.
153 void OutputTraceToStream(const std::vector<void*>& trace, std::ostream* os) { 155 void OutputTraceToStream(const std::vector<void*>& trace, std::ostream* os) {
154 AutoLock lock(lock_); 156 AutoLock lock(lock_);
155 157
156 for (size_t i = 0; (i < trace.size()) && os->good(); ++i) { 158 for (size_t i = 0; (i < trace.size()) && os->good(); ++i) {
157 const int kMaxNameLength = 256; 159 const int kMaxNameLength = 256;
158 DWORD_PTR frame = reinterpret_cast<DWORD_PTR>(trace[i]); 160 DWORD_PTR frame = reinterpret_cast<DWORD_PTR>(trace[i]);
159 161
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 (*os) << "Error initializing symbols (" << error 282 (*os) << "Error initializing symbols (" << error
281 << "). Dumping unresolved backtrace:\n"; 283 << "). Dumping unresolved backtrace:\n";
282 for (size_t i = 0; (i < trace_.size()) && os->good(); ++i) { 284 for (size_t i = 0; (i < trace_.size()) && os->good(); ++i) {
283 (*os) << "\t" << trace_[i] << "\n"; 285 (*os) << "\t" << trace_[i] << "\n";
284 } 286 }
285 } else { 287 } else {
286 (*os) << "Backtrace:\n"; 288 (*os) << "Backtrace:\n";
287 context->OutputTraceToStream(trace_, os); 289 context->OutputTraceToStream(trace_, os);
288 } 290 }
289 } 291 }
OLDNEW
« no previous file with comments | « base/debug_util.h ('k') | base/field_trial.h » ('j') | base/system_monitor.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698