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

Unified Diff: base/debug_util.h

Issue 201050: Print stack trace on exception in unit tests on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | base/debug_util.cc » ('j') | base/debug_util_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug_util.h
===================================================================
--- base/debug_util.h (revision 25620)
+++ base/debug_util.h (working copy)
@@ -14,24 +14,40 @@
#include "base/basictypes.h"
+#if defined(OS_WIN)
+struct _EXCEPTION_POINTERS;
+#endif
+
// A stacktrace can be helpful in debugging. For example, you can include a
// stacktrace member in a object (probably around #ifndef NDEBUG) so that you
// can later see where the given object was created from.
class StackTrace {
public:
- // Create a stacktrace from the current location
+ // Creates a stacktrace from the current location
StackTrace();
- // Get an array of instruction pointer values.
+#if defined(OS_WIN)
+ // Creates a stacktrace for an exception.
+ // Note: this function will throw an import not found (StackWalk64) exception
+ // on system without dbghelp 5.1.
+ StackTrace(_EXCEPTION_POINTERS* exception_pointers);
+#endif
+ // Gets an array of instruction pointer values.
// count: (output) the number of elements in the returned array
const void *const *Addresses(size_t* count);
- // Print a backtrace to stderr
+ // Prints a backtrace to stderr
void PrintBacktrace();
- // Resolve backtrace to symbols and write to stream.
+ // Resolves backtrace to symbols and write to stream.
void OutputToStream(std::ostream* os);
private:
- std::vector<void*> trace_;
+ // From http://msdn.microsoft.com/en-us/library/bb204633.aspx,
+ // the sum of FramesToSkip and FramesToCapture must be less than 63,
+ // so set it to 62. Even if on POSIX it could be a larger value, it usually
+ // doesn't give much more information.
+ static const int MAX_TRACES = 62;
+ void* trace_[MAX_TRACES];
+ int count_;
DISALLOW_EVIL_CONSTRUCTORS(StackTrace);
};
« no previous file with comments | « no previous file | base/debug_util.cc » ('j') | base/debug_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698