summaryrefslogtreecommitdiffstats
path: root/base/debug_util.h
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 23:53:53 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 23:53:53 +0000
commit0fe31f2ba217cceb277b670e2812667c3aee8e80 (patch)
tree3d2adea86b5d61d297318ea60c3faf1b1636c996 /base/debug_util.h
parent2f66ed584522a2383f0f7193b264b3da7928eb82 (diff)
downloadchromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.zip
chromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.tar.gz
chromium_src-0fe31f2ba217cceb277b670e2812667c3aee8e80.tar.bz2
Print stack trace on exception in unit tests on Windows.
Also remove std::vector<> from StackTrace to reduce heap usage during potential unstable execution. TEST=none BUG=http://crbug.com/20996 Review URL: http://codereview.chromium.org/201050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug_util.h')
-rw-r--r--base/debug_util.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/base/debug_util.h b/base/debug_util.h
index de4a208..8ccb020 100644
--- a/base/debug_util.h
+++ b/base/debug_util.h
@@ -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);
};