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

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

Issue 2757123002: Cleaner fall-back stack capture for --enable-heap-profiling=native. (Closed)
Patch Set: Fix comments Created 3 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 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // but not for release builds (although there are some exceptions). 108 // but not for release builds (although there are some exceptions).
109 // 109 //
110 // Writes at most |max_depth| frames (instruction pointers) into |out_trace| 110 // Writes at most |max_depth| frames (instruction pointers) into |out_trace|
111 // after skipping |skip_initial| frames. Note that the function itself is not 111 // after skipping |skip_initial| frames. Note that the function itself is not
112 // added to the trace so |skip_initial| should be 0 in most cases. 112 // added to the trace so |skip_initial| should be 0 in most cases.
113 // Returns number of frames written. 113 // Returns number of frames written.
114 BASE_EXPORT size_t TraceStackFramePointers(const void** out_trace, 114 BASE_EXPORT size_t TraceStackFramePointers(const void** out_trace,
115 size_t max_depth, 115 size_t max_depth,
116 size_t skip_initial); 116 size_t skip_initial);
117 117
118 #if !defined(OS_WIN)
119 // Links stack frame |fp| to |parent_fp|, so that during stack unwinding 118 // Links stack frame |fp| to |parent_fp|, so that during stack unwinding
120 // TraceStackFramePointers() visits |parent_fp| after visiting |fp|. 119 // TraceStackFramePointers() visits |parent_fp| after visiting |fp|.
121 // Both frame pointers must come from __builtin_frame_address(). 120 // Both frame pointers must come from __builtin_frame_address().
122 // Destructor restores original linkage of |fp| to avoid corrupting caller's 121 // Destructor restores original linkage of |fp| to avoid corrupting caller's
123 // frame register on return. 122 // frame register on return.
124 // 123 //
125 // This class can be used to repair broken stack frame chain in cases 124 // This class can be used to repair broken stack frame chain in cases
126 // when execution flow goes into code built without frame pointers: 125 // when execution flow goes into code built without frame pointers:
127 // 126 //
128 // void DoWork() { 127 // void DoWork() {
(...skipping 29 matching lines...) Expand all
158 ScopedStackFrameLinker(void* fp, void* parent_fp); 157 ScopedStackFrameLinker(void* fp, void* parent_fp);
159 ~ScopedStackFrameLinker(); 158 ~ScopedStackFrameLinker();
160 159
161 private: 160 private:
162 void* fp_; 161 void* fp_;
163 void* parent_fp_; 162 void* parent_fp_;
164 void* original_parent_fp_; 163 void* original_parent_fp_;
165 164
166 DISALLOW_COPY_AND_ASSIGN(ScopedStackFrameLinker); 165 DISALLOW_COPY_AND_ASSIGN(ScopedStackFrameLinker);
167 }; 166 };
168 #endif // !defined(OS_WIN)
169 167
170 #endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) 168 #endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
171 169
172 namespace internal { 170 namespace internal {
173 171
174 #if defined(OS_POSIX) && !defined(OS_ANDROID) 172 #if defined(OS_POSIX) && !defined(OS_ANDROID)
175 // POSIX doesn't define any async-signal safe function for converting 173 // POSIX doesn't define any async-signal safe function for converting
176 // an integer to ASCII. We'll have to define our own version. 174 // an integer to ASCII. We'll have to define our own version.
177 // itoa_r() converts a (signed) integer to ASCII. It returns "buf", if the 175 // itoa_r() converts a (signed) integer to ASCII. It returns "buf", if the
178 // conversion was successful or NULL otherwise. It never writes more than "sz" 176 // conversion was successful or NULL otherwise. It never writes more than "sz"
179 // bytes. Output will be truncated as needed, and a NUL character is always 177 // bytes. Output will be truncated as needed, and a NUL character is always
180 // appended. 178 // appended.
181 BASE_EXPORT char *itoa_r(intptr_t i, 179 BASE_EXPORT char *itoa_r(intptr_t i,
182 char *buf, 180 char *buf,
183 size_t sz, 181 size_t sz,
184 int base, 182 int base,
185 size_t padding); 183 size_t padding);
186 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 184 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
187 185
188 } // namespace internal 186 } // namespace internal
189 187
190 } // namespace debug 188 } // namespace debug
191 } // namespace base 189 } // namespace base
192 190
193 #endif // BASE_DEBUG_STACK_TRACE_H_ 191 #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