Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Friends | List of all members
dart::StackFrameIterator Class Reference

#include <stack_frame.h>

Public Types

enum  CrossThreadPolicy { kNoCrossThreadIteration = 0 , kAllowCrossThreadIteration = 1 }
 

Public Member Functions

 StackFrameIterator (ValidationPolicy validation_policy, Thread *thread, CrossThreadPolicy cross_thread_policy)
 
 StackFrameIterator (uword last_fp, ValidationPolicy validation_policy, Thread *thread, CrossThreadPolicy cross_thread_policy)
 
 StackFrameIterator (uword fp, uword sp, uword pc, ValidationPolicy validation_policy, Thread *thread, CrossThreadPolicy cross_thread_policy)
 
 StackFrameIterator (const StackFrameIterator &orig)
 
bool HasNextFrame () const
 
StackFrameNextFrame ()
 
bool validate () const
 

Friends

class ProfilerDartStackWalker
 

Detailed Description

Definition at line 218 of file stack_frame.h.

Member Enumeration Documentation

◆ CrossThreadPolicy

Enumerator
kNoCrossThreadIteration 
kAllowCrossThreadIteration 

Definition at line 220 of file stack_frame.h.

Constructor & Destructor Documentation

◆ StackFrameIterator() [1/4]

dart::StackFrameIterator::StackFrameIterator ( ValidationPolicy  validation_policy,
Thread thread,
CrossThreadPolicy  cross_thread_policy 
)

Definition at line 484 of file stack_frame.cc.

487 : validate_(validation_policy == ValidationPolicy::kValidateFrames),
488 entry_(thread),
489 exit_(thread),
490 frames_(thread),
491 current_frame_(nullptr),
492 thread_(thread) {
493 ASSERT(cross_thread_policy == kAllowCrossThreadIteration ||
494 thread_ == Thread::Current());
495 SetupLastExitFrameData(); // Setup data for last exit frame.
496}
static Thread * Current()
Definition thread.h:361
#define ASSERT(E)

◆ StackFrameIterator() [2/4]

dart::StackFrameIterator::StackFrameIterator ( uword  last_fp,
ValidationPolicy  validation_policy,
Thread thread,
CrossThreadPolicy  cross_thread_policy 
)

Definition at line 498 of file stack_frame.cc.

502 : validate_(validation_policy == ValidationPolicy::kValidateFrames),
503 entry_(thread),
504 exit_(thread),
505 frames_(thread),
506 current_frame_(nullptr),
507 thread_(thread) {
508 ASSERT(cross_thread_policy == kAllowCrossThreadIteration ||
509 thread_ == Thread::Current());
510 frames_.fp_ = last_fp;
511 frames_.sp_ = 0;
512 frames_.pc_ = 0;
513 frames_.Unpoison();
514}

◆ StackFrameIterator() [3/4]

dart::StackFrameIterator::StackFrameIterator ( uword  fp,
uword  sp,
uword  pc,
ValidationPolicy  validation_policy,
Thread thread,
CrossThreadPolicy  cross_thread_policy 
)

Definition at line 516 of file stack_frame.cc.

522 : validate_(validation_policy == ValidationPolicy::kValidateFrames),
523 entry_(thread),
524 exit_(thread),
525 frames_(thread),
526 current_frame_(nullptr),
527 thread_(thread) {
528 ASSERT(cross_thread_policy == kAllowCrossThreadIteration ||
529 thread_ == Thread::Current());
530 frames_.fp_ = fp;
531 frames_.sp_ = sp;
532 frames_.pc_ = pc;
533 frames_.Unpoison();
534}
const uint32_t fp

◆ StackFrameIterator() [4/4]

dart::StackFrameIterator::StackFrameIterator ( const StackFrameIterator orig)
explicit

Definition at line 536 of file stack_frame.cc.

537 : validate_(orig.validate_),
538 entry_(orig.thread_),
539 exit_(orig.thread_),
540 frames_(orig.thread_),
541 current_frame_(nullptr),
542 thread_(orig.thread_) {
543 frames_.fp_ = orig.frames_.fp_;
544 frames_.sp_ = orig.frames_.sp_;
545 frames_.pc_ = orig.frames_.pc_;
546 frames_.Unpoison();
547}

Member Function Documentation

◆ HasNextFrame()

bool dart::StackFrameIterator::HasNextFrame ( ) const
inline

Definition at line 247 of file stack_frame.h.

247{ return frames_.fp_ != 0; }

◆ NextFrame()

StackFrame * dart::StackFrameIterator::NextFrame ( )

Definition at line 549 of file stack_frame.cc.

549 {
550 // When we are at the start of iteration after having created an
551 // iterator object, current_frame_ will be nullptr as we haven't seen
552 // any frames yet (unless we start iterating in the simulator from a given
553 // triplet of fp, sp, and pc). At this point, if NextFrame is called, it tries
554 // to set up the next exit frame by reading the top_exit_frame_info
555 // from the isolate. If we do not have any dart invocations yet,
556 // top_exit_frame_info will be 0 and so we would return nullptr.
557
558 // current_frame_ will also be nullptr, when we are at the end of having
559 // iterated through all the frames. If NextFrame is called at this
560 // point, we will try and set up the next exit frame, but since we are
561 // at the end of the iteration, fp_ will be 0 and we would return nullptr.
562 if (current_frame_ == nullptr) {
563 if (!HasNextFrame()) {
564 return nullptr;
565 }
566 if (frames_.pc_ == 0) {
567 // Iteration starts from an exit frame given by its fp.
568 current_frame_ = NextExitFrame();
569 } else if (*(reinterpret_cast<uword*>(
570 frames_.fp_ + (kSavedCallerFpSlotFromFp * kWordSize))) ==
571 0) {
572 // Iteration starts from an entry frame given by its fp, sp, and pc.
573 current_frame_ = NextEntryFrame();
574 } else {
575 // Iteration starts from a Dart or stub frame given by its fp, sp, and pc.
576 current_frame_ = frames_.NextFrame(validate_);
577 }
578 return current_frame_;
579 }
580 ASSERT(!validate_ || current_frame_->IsValid());
581 if (current_frame_->IsEntryFrame()) {
582 if (HasNextFrame()) { // We have another chained block.
583 current_frame_ = NextExitFrame();
584 return current_frame_;
585 }
586 current_frame_ = nullptr; // No more frames.
587 return current_frame_;
588 }
589 ASSERT(!validate_ || current_frame_->IsExitFrame() ||
590 current_frame_->IsDartFrame(validate_) ||
591 current_frame_->IsStubFrame());
592
593 // Consume dart/stub frames using StackFrameIterator::FrameSetIterator
594 // until we are out of dart/stub frames at which point we return the
595 // corresponding entry frame for that set of dart/stub frames.
596 current_frame_ =
597 (frames_.HasNext()) ? frames_.NextFrame(validate_) : NextEntryFrame();
598 return current_frame_;
599}
virtual bool IsEntryFrame() const
virtual bool IsExitFrame() const
virtual bool IsStubFrame() const
virtual bool IsDartFrame(bool validate=true) const
Definition stack_frame.h:97
virtual bool IsValid() const
static constexpr int kSavedCallerFpSlotFromFp
uintptr_t uword
Definition globals.h:501
constexpr intptr_t kWordSize
Definition globals.h:509

◆ validate()

bool dart::StackFrameIterator::validate ( ) const
inline

Definition at line 252 of file stack_frame.h.

252{ return validate_; }

Friends And Related Symbol Documentation

◆ ProfilerDartStackWalker

friend class ProfilerDartStackWalker
friend

Definition at line 309 of file stack_frame.h.


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