Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::DebuggerStackTrace Class Reference

#include <debugger.h>

Inheritance diagram for dart::DebuggerStackTrace:
dart::ZoneAllocated

Public Member Functions

 DebuggerStackTrace (int capacity)
 
intptr_t Length () const
 
ActivationFrameFrameAt (int i) const
 
ActivationFrameGetHandlerFrame (const Instance &exc_obj) const
 
bool has_async_catch_error () const
 
void set_has_async_catch_error (bool has_async_catch_error)
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static DebuggerStackTraceCollect ()
 
static DebuggerStackTraceCollectAsyncAwaiters ()
 
static DebuggerStackTraceFrom (const class StackTrace &ex_trace)
 

Friends

class Debugger
 

Detailed Description

Definition at line 460 of file debugger.h.

Constructor & Destructor Documentation

◆ DebuggerStackTrace()

dart::DebuggerStackTrace::DebuggerStackTrace ( int  capacity)
inlineexplicit

Definition at line 462 of file debugger.h.

463 : thread_(Thread::Current()), zone_(thread_->zone()), trace_(capacity) {}
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362

Member Function Documentation

◆ Collect()

DebuggerStackTrace * dart::DebuggerStackTrace::Collect ( )
static

Definition at line 1671 of file debugger.cc.

1671 {
1672 Thread* thread = Thread::Current();
1673 Zone* zone = thread->zone();
1674
1675 Code& code = Code::Handle(zone);
1676 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
1677
1678 StackFrameIterator iterator(ValidationPolicy::kDontValidateFrames, thread,
1680 for (StackFrame* frame = iterator.NextFrame(); frame != nullptr;
1681 frame = iterator.NextFrame()) {
1682 ASSERT(frame->IsValid());
1683 if (FLAG_trace_debugger_stacktrace) {
1684 OS::PrintErr("CollectStackTrace: visiting frame:\n\t%s\n",
1685 frame->ToCString());
1686 }
1687 if (frame->IsDartFrame()) {
1688 code = frame->LookupDartCode();
1689 stack_trace->AppendCodeFrames(frame, code);
1690 }
1691 }
1692 return stack_trace;
1693}
DebuggerStackTrace(int capacity)
Definition: debugger.h:462
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static Object & Handle()
Definition: object.h:407
#define ASSERT(E)
double frame
Definition: examples.cpp:31

◆ CollectAsyncAwaiters()

DebuggerStackTrace * dart::DebuggerStackTrace::CollectAsyncAwaiters ( )
static

Definition at line 1732 of file debugger.cc.

1732 {
1733 Thread* thread = Thread::Current();
1734 Zone* zone = thread->zone();
1735
1736 Function& function = Function::Handle(zone);
1737
1738 constexpr intptr_t kDefaultStackAllocation = 8;
1739 auto stack_trace = new DebuggerStackTrace(kDefaultStackAllocation);
1740
1741 bool has_async = false;
1742 bool has_async_catch_error = false;
1744 thread, /*skip_frames=*/0,
1745 [&](const StackTraceUtils::Frame& frame) {
1746 if (frame.frame != nullptr) { // Synchronous portion of the stack.
1747 stack_trace->AppendCodeFrames(frame.frame, frame.code);
1748 } else {
1749 has_async = true;
1750
1751 if (frame.code.ptr() == StubCode::AsynchronousGapMarker().ptr()) {
1752 stack_trace->AddAsyncSuspension();
1753 return;
1754 }
1755
1756 // Skip invisible function frames.
1757 function ^= frame.code.function();
1758 if (!function.is_visible()) {
1759 return;
1760 }
1761
1762 const uword absolute_pc = frame.code.PayloadStart() + frame.pc_offset;
1763 stack_trace->AddAsyncAwaiterFrame(absolute_pc, frame.code,
1764 frame.closure);
1765 }
1766 },
1768
1769 // If the entire stack is sync, return no (async) trace.
1770 if (!has_async) {
1771 return nullptr;
1772 }
1773
1774 stack_trace->set_has_async_catch_error(has_async_catch_error);
1775
1776 return stack_trace;
1777}
bool has_async_catch_error() const
Definition: debugger.h:479
static void CollectFrames(Thread *thread, int skip_frames, const std::function< void(const Frame &)> &handle_frame, bool *has_async_catch_error=nullptr)
Definition: stack_trace.cc:745
if(end==-1)
Dart_NativeFunction function
Definition: fuchsia.cc:51
static constexpr intptr_t kDefaultStackAllocation
Definition: stacktrace.cc:19
uintptr_t uword
Definition: globals.h:501

◆ FrameAt()

ActivationFrame * dart::DebuggerStackTrace::FrameAt ( int  i) const
inline

Definition at line 467 of file debugger.h.

467{ return trace_[i]; }

◆ From()

DebuggerStackTrace * dart::DebuggerStackTrace::From ( const class StackTrace ex_trace)
static

Definition at line 1808 of file debugger.cc.

1808 {
1809 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
1810 Function& function = Function::Handle();
1811 Object& code_object = Object::Handle();
1812 Code& code = Code::Handle();
1813
1814 const uword fp = 0;
1815 const uword sp = 0;
1816 const Array& deopt_frame = Array::Handle();
1817 const intptr_t deopt_frame_offset = -1;
1818
1819 for (intptr_t i = 0; i < ex_trace.Length(); i++) {
1820 code_object = ex_trace.CodeAtFrame(i);
1821 // Pre-allocated StackTraces may include empty slots, either (a) to indicate
1822 // where frames were omitted in the case a stack has more frames than the
1823 // pre-allocated trace (such as a stack overflow) or (b) because a stack has
1824 // fewer frames that the pre-allocated trace (such as memory exhaustion with
1825 // a shallow stack).
1826 if (!code_object.IsNull()) {
1827 code ^= code_object.ptr();
1828 ASSERT(code.IsFunctionCode());
1829 function = code.function();
1830 if (function.is_visible()) {
1831 ASSERT(function.ptr() == code.function());
1832 uword pc = code.PayloadStart() + ex_trace.PcOffsetAtFrame(i);
1833 if (code.is_optimized() && ex_trace.expand_inlined()) {
1834 // Traverse inlined frames.
1835 for (InlinedFunctionsIterator it(code, pc); !it.Done();
1836 it.Advance()) {
1837 function = it.function();
1838 code = it.code();
1839 ASSERT(function.ptr() == code.function());
1840 uword pc = it.pc();
1841 ASSERT(pc != 0);
1842 ASSERT(code.PayloadStart() <= pc);
1843 ASSERT(pc < (code.PayloadStart() + code.Size()));
1844
1845 ActivationFrame* activation = new ActivationFrame(
1846 pc, fp, sp, code, deopt_frame, deopt_frame_offset);
1847 stack_trace->AddActivation(activation);
1848 }
1849 } else {
1850 ActivationFrame* activation = new ActivationFrame(
1851 pc, fp, sp, code, deopt_frame, deopt_frame_offset);
1852 stack_trace->AddActivation(activation);
1853 }
1854 }
1855 }
1856 }
1857 return stack_trace;
1858}
const uint32_t fp

◆ GetHandlerFrame()

ActivationFrame * dart::DebuggerStackTrace::GetHandlerFrame ( const Instance exc_obj) const

Definition at line 733 of file debugger.cc.

734 {
735 if (FLAG_trace_debugger_stacktrace) {
736 OS::PrintErr("GetHandlerFrame(%s)\n", exc_obj.ToCString());
737 }
738
739 for (intptr_t frame_index = 0; frame_index < Length(); frame_index++) {
740 ActivationFrame* frame = FrameAt(frame_index);
741 const bool can_handle = frame->HandlesException(exc_obj);
742 if (FLAG_trace_debugger_stacktrace) {
743 OS::PrintErr(" #%04" Pd " (%s) %s", frame_index,
744 can_handle ? "+" : "-", frame->ToCString());
745 }
746 if (can_handle) {
747 return frame;
748 }
749 }
750 return nullptr;
751}
intptr_t Length() const
Definition: debugger.h:465
ActivationFrame * FrameAt(int i) const
Definition: debugger.h:467
#define Pd
Definition: globals.h:408

◆ has_async_catch_error()

bool dart::DebuggerStackTrace::has_async_catch_error ( ) const
inline

Definition at line 479 of file debugger.h.

479{ return has_async_catch_error_; }

◆ Length()

intptr_t dart::DebuggerStackTrace::Length ( ) const
inline

Definition at line 465 of file debugger.h.

465{ return trace_.length(); }

◆ set_has_async_catch_error()

void dart::DebuggerStackTrace::set_has_async_catch_error ( bool  has_async_catch_error)
inline

Definition at line 480 of file debugger.h.

480 {
481 has_async_catch_error_ = has_async_catch_error;
482 }

Friends And Related Function Documentation

◆ Debugger

friend class Debugger
friend

Definition at line 498 of file debugger.h.


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