Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::ProfilerNativeStackWalker Class Reference
Inheritance diagram for dart::ProfilerNativeStackWalker:
dart::ProfilerStackWalker dart::ValueObject

Public Member Functions

 ProfilerNativeStackWalker (ProfilerCounters *counters, Dart_Port port_id, Sample *sample, SampleBuffer *sample_buffer, uword stack_lower, uword stack_upper, uword pc, uword fp, uword sp, intptr_t skip_count=0)
 
void walk ()
 
- Public Member Functions inherited from dart::ProfilerStackWalker
 ProfilerStackWalker (Dart_Port port_id, Sample *head_sample, SampleBuffer *sample_buffer, intptr_t skip_count=0)
 
bool Append (uword pc, uword fp)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Additional Inherited Members

- Protected Attributes inherited from dart::ProfilerStackWalker
Dart_Port port_id_
 
Samplesample_
 
SampleBuffersample_buffer_
 
intptr_t skip_count_
 
intptr_t frames_skipped_
 
intptr_t frame_index_
 
intptr_t total_frames_
 

Detailed Description

Definition at line 217 of file profiler.cc.

Constructor & Destructor Documentation

◆ ProfilerNativeStackWalker()

dart::ProfilerNativeStackWalker::ProfilerNativeStackWalker ( ProfilerCounters counters,
Dart_Port  port_id,
Sample sample,
SampleBuffer sample_buffer,
uword  stack_lower,
uword  stack_upper,
uword  pc,
uword  fp,
uword  sp,
intptr_t  skip_count = 0 
)
inline

Definition at line 219 of file profiler.cc.

229 : ProfilerStackWalker(port_id, sample, sample_buffer, skip_count),
230 counters_(counters),
231 stack_upper_(stack_upper),
232 original_pc_(pc),
233 original_fp_(fp),
234 original_sp_(sp),
235 lower_bound_(stack_lower) {}
ProfilerStackWalker(Dart_Port port_id, Sample *head_sample, SampleBuffer *sample_buffer, intptr_t skip_count=0)
Definition profiler.cc:126
const uint32_t fp

Member Function Documentation

◆ walk()

void dart::ProfilerNativeStackWalker::walk ( )
inline

Definition at line 237 of file profiler.cc.

237 {
238 const uword kMaxStep = VirtualMemory::PageSize();
239
240 Append(original_pc_, original_fp_);
241
242 uword* pc = reinterpret_cast<uword*>(original_pc_);
243 uword* fp = reinterpret_cast<uword*>(original_fp_);
244 uword* previous_fp = fp;
245
246 uword gap = original_fp_ - original_sp_;
247 if (gap >= kMaxStep) {
248 // Gap between frame pointer and stack pointer is
249 // too large.
250 counters_->incomplete_sample_fp_step.fetch_add(1);
251 return;
252 }
253
254 if (!ValidFramePointer(fp)) {
255 counters_->incomplete_sample_fp_bounds.fetch_add(1);
256 return;
257 }
258
259 while (true) {
260 pc = CallerPC(fp);
261 previous_fp = fp;
262 fp = CallerFP(fp);
263
264 if (fp == nullptr) {
265 return;
266 }
267
268 if (fp <= previous_fp) {
269 // Frame pointer did not move to a higher address.
270 counters_->incomplete_sample_fp_step.fetch_add(1);
271 return;
272 }
273
274 gap = fp - previous_fp;
275 if (gap >= kMaxStep) {
276 // Frame pointer step is too large.
277 counters_->incomplete_sample_fp_step.fetch_add(1);
278 return;
279 }
280
281 if (!ValidFramePointer(fp)) {
282 // Frame pointer is outside of isolate stack boundary.
283 counters_->incomplete_sample_fp_bounds.fetch_add(1);
284 return;
285 }
286
287 const uword pc_value = reinterpret_cast<uword>(pc);
288 if ((pc_value + 1) < pc_value) {
289 // It is not uncommon to encounter an invalid pc as we
290 // traverse a stack frame. Most of these we can tolerate. If
291 // the pc is so large that adding one to it will cause an
292 // overflow it is invalid and it will cause headaches later
293 // while we are building the profile. Discard it.
294 counters_->incomplete_sample_bad_pc.fetch_add(1);
295 return;
296 }
297
298 // Move the lower bound up.
299 lower_bound_ = reinterpret_cast<uword>(fp);
300
301 if (!Append(pc_value, reinterpret_cast<uword>(fp))) {
302 return;
303 }
304 }
305 }
bool Append(uword pc, uword fp)
Definition profiler.cc:145
static intptr_t PageSize()
uintptr_t uword
Definition globals.h:501

The documentation for this class was generated from the following file: