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_ |
- |