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

Unified Diff: base/debug_util.h

Issue 18303: Add StackTrace debugging utility class. (Closed)
Patch Set: Addressing comments Created 11 years, 11 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_posix.cc » ('j') | base/debug_util_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug_util.h
diff --git a/base/debug_util.h b/base/debug_util.h
index 45729485884bd52206c4dbd8d3599ddd0952a55a..b7b51805ec877abb4bc74dc8ecfc064bfd6f5d67 100644
--- a/base/debug_util.h
+++ b/base/debug_util.h
@@ -9,6 +9,29 @@
#ifndef BASE_DEBUG_UTIL_H_
#define BASE_DEBUG_UTIL_H_
+#include "base/basictypes.h"
+
+#include <vector>
+
+// 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
+ StackTrace();
+ // Get 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
+ void PrintBacktrace();
+
+ private:
+ std::vector<void*> trace_;
+
+ DISALLOW_EVIL_CONSTRUCTORS(StackTrace);
+};
+
class DebugUtil {
public:
// Starts the registered system-wide JIT debugger to attach it to specified
@@ -27,4 +50,3 @@ class DebugUtil {
};
#endif // BASE_DEBUG_UTIL_H_
-
« no previous file with comments | « no previous file | base/debug_util_posix.cc » ('j') | base/debug_util_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698