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

Unified Diff: base/debug/stack_trace.h

Issue 1879073002: Add function to trace stack using frame pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 8 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/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace.h
diff --git a/base/debug/stack_trace.h b/base/debug/stack_trace.h
index 07e119a16b4a255dc443acf28c37d0c5cefa25c2..49d123227938c15733cfc1676061117c6069533c 100644
--- a/base/debug/stack_trace.h
+++ b/base/debug/stack_trace.h
@@ -22,6 +22,12 @@ struct _EXCEPTION_POINTERS;
struct _CONTEXT;
#endif
+#if defined(OS_POSIX) && (defined(__i386__) || defined(__x86_64__))
Nico 2016/04/15 20:00:00 do we still have any 32-bit posix platforms we nee
+#define HAVE_TRACE_STACK_FRAME_POINTERS 1
+#else
+#define HAVE_TRACE_STACK_FRAME_POINTERS 0
+#endif
+
namespace base {
namespace debug {
@@ -76,6 +82,8 @@ class BASE_EXPORT StackTrace {
// Resolves backtrace to symbols and returns as string.
std::string ToString() const;
+ static StackTrace FromFramePointers(size_t max_depth);
+
private:
#if defined(OS_WIN)
void InitTrace(const _CONTEXT* context_record);
@@ -93,6 +101,20 @@ class BASE_EXPORT StackTrace {
size_t count_;
};
+#if HAVE_TRACE_STACK_FRAME_POINTERS
+// Traces the stack by using frame pointers. This function is faster but less
+// reliable than StackTrace. It should work for debug and profiling builds,
+// but not for release builds (although there are some exceptions).
+//
+// Writes at most |max_depth| frames (instruction pointers) into |out_trace|
+// after skipping |skip_initial| frames. Note that the function itself is not
+// added to the trace so |skip_initial| should be 0 in most cases.
+// Returns number of frames written.
+BASE_EXPORT size_t TraceStackFramePointers(const void** out_trace,
Primiano Tucci (use gerrit) 2016/04/18 20:18:07 it's a bit conflicting that you have two APIs publ
Dmitry Skiba 2016/04/20 16:32:56 Actually, the top one is a mistake. Thanks for not
+ size_t max_depth,
+ size_t skip_initial);
+#endif // HAVE_TRACE_STACK_FRAME_POINTERS
+
namespace internal {
#if defined(OS_POSIX) && !defined(OS_ANDROID)
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698