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

Side by Side Diff: base/debug/stack_trace.h

Issue 2632643004: Remove WTFReportAssertionFailure and WTFReportBacktrace. (Closed)
Patch Set: Add Truncate() helper Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/debug/stack_trace.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_DEBUG_STACK_TRACE_H_ 5 #ifndef BASE_DEBUG_STACK_TRACE_H_
6 #define BASE_DEBUG_STACK_TRACE_H_ 6 #define BASE_DEBUG_STACK_TRACE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #if defined(OS_WIN) 61 #if defined(OS_WIN)
62 // Creates a stacktrace for an exception. 62 // Creates a stacktrace for an exception.
63 // Note: this function will throw an import not found (StackWalk64) exception 63 // Note: this function will throw an import not found (StackWalk64) exception
64 // on system without dbghelp 5.1. 64 // on system without dbghelp 5.1.
65 StackTrace(_EXCEPTION_POINTERS* exception_pointers); 65 StackTrace(_EXCEPTION_POINTERS* exception_pointers);
66 StackTrace(const _CONTEXT* context); 66 StackTrace(const _CONTEXT* context);
67 #endif 67 #endif
68 68
69 // Copying and assignment are allowed with the default functions. 69 // Copying and assignment are allowed with the default functions.
70 70
71 ~StackTrace(); 71 // Returns a copy of this StackTrace, but with at most |max_entries|.
72 StackTrace Truncate(size_t max_entries) const;
esprehn 2017/01/26 22:55:45 This does mean we waste time inside backtrace() fi
Wez 2017/01/27 01:29:58 Fair point; let's optimize that if it proves to be
72 73
73 // Gets an array of instruction pointer values. |*count| will be set to the 74 // Gets an array of instruction pointer values. |*count| will be set to the
74 // number of elements in the returned array. 75 // number of elements in the returned array.
75 const void* const* Addresses(size_t* count) const; 76 const void* const* Addresses(size_t* count) const;
76 77
77 // Prints the stack trace to stderr. 78 // Prints the stack trace to stderr.
78 void Print() const; 79 void Print() const;
79 80
80 #if !defined(__UCLIBC__) 81 #if !defined(__UCLIBC__)
81 // Resolves backtrace to symbols and write to stream. 82 // Resolves backtrace to symbols and write to stream.
82 void OutputToStream(std::ostream* os) const; 83 void OutputToStream(std::ostream* os) const;
83 #endif 84 #endif
84 85
85 // Resolves backtrace to symbols and returns as string. 86 // Resolves backtrace to symbols and returns as string.
86 std::string ToString() const; 87 std::string ToString() const;
87 88
88 private: 89 private:
89 #if defined(OS_WIN) 90 #if defined(OS_WIN)
90 void InitTrace(const _CONTEXT* context_record); 91 void InitTrace(const _CONTEXT* context_record);
91 #endif 92 #endif
92 93
93 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, 94 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx,
94 // the sum of FramesToSkip and FramesToCapture must be less than 63, 95 // the sum of FramesToSkip and FramesToCapture must be less than 63,
95 // so set it to 62. Even if on POSIX it could be a larger value, it usually 96 // so set it to 62. Even if on POSIX it could be a larger value, it usually
96 // doesn't give much more information. 97 // doesn't give much more information.
97 static const int kMaxTraces = 62; 98 static const int kMaxTraces = 62;
98 99
100 protected:
99 void* trace_[kMaxTraces]; 101 void* trace_[kMaxTraces];
100 102
101 // The number of valid frames in |trace_|. 103 // The number of valid frames in |trace_|.
102 size_t count_; 104 size_t count_;
103 }; 105 };
104 106
105 #if HAVE_TRACE_STACK_FRAME_POINTERS 107 #if HAVE_TRACE_STACK_FRAME_POINTERS
106 // Traces the stack by using frame pointers. This function is faster but less 108 // Traces the stack by using frame pointers. This function is faster but less
107 // reliable than StackTrace. It should work for debug and profiling builds, 109 // reliable than StackTrace. It should work for debug and profiling builds,
108 // but not for release builds (although there are some exceptions). 110 // but not for release builds (although there are some exceptions).
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 int base, 184 int base,
183 size_t padding); 185 size_t padding);
184 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 186 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
185 187
186 } // namespace internal 188 } // namespace internal
187 189
188 } // namespace debug 190 } // namespace debug
189 } // namespace base 191 } // namespace base
190 192
191 #endif // BASE_DEBUG_STACK_TRACE_H_ 193 #endif // BASE_DEBUG_STACK_TRACE_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/stack_trace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698