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

#include <debugger.h>

Public Member Functions

 BreakpointLocation (Debugger *debugger, const GrowableHandlePtrArray< const Script > &scripts, TokenPosition token_pos, TokenPosition end_token_pos, intptr_t requested_line_number, intptr_t requested_column_number)
 
 BreakpointLocation (Debugger *debugger, const String &url, intptr_t requested_line_number, intptr_t requested_column_number)
 
 ~BreakpointLocation ()
 
TokenPosition token_pos () const
 
intptr_t line_number ()
 
TokenPosition end_token_pos () const
 
ScriptPtr script () const
 
StringPtr url () const
 
intptr_t requested_line_number () const
 
intptr_t requested_column_number () const
 
void GetCodeLocation (Script *script, TokenPosition *token_pos) const
 
BreakpointAddRepeated (Debugger *dbg)
 
BreakpointAddSingleShot (Debugger *dbg)
 
BreakpointAddBreakpoint (Debugger *dbg, const Closure &closure, bool single_shot)
 
bool AnyEnabled () const
 
bool IsResolved () const
 
bool IsLatent () const
 
bool EnsureIsResolved (const Function &target_function, TokenPosition exact_token_pos)
 
Debuggerdebugger ()
 

Friends

class Debugger
 
class GroupDebugger
 

Detailed Description

Definition at line 111 of file debugger.h.

Constructor & Destructor Documentation

◆ BreakpointLocation() [1/2]

dart::BreakpointLocation::BreakpointLocation ( Debugger debugger,
const GrowableHandlePtrArray< const Script > &  scripts,
TokenPosition  token_pos,
TokenPosition  end_token_pos,
intptr_t  requested_line_number,
intptr_t  requested_column_number 
)

Definition at line 60 of file debugger.cc.

67 : debugger_(debugger),
68 scripts_(MallocGrowableArray<ScriptPtr>(scripts.length())),
69 url_(scripts.At(0).url()),
70 line_number_lock_(new SafepointRwLock()),
71 line_number_(-1), // lazily computed
72 token_pos_(token_pos),
73 end_token_pos_(end_token_pos),
74 next_(nullptr),
75 conditions_(nullptr),
76 requested_line_number_(requested_line_number),
77 requested_column_number_(requested_column_number),
78 code_token_pos_(TokenPosition::kNoSource) {
79 ASSERT(scripts.length() > 0);
81 for (intptr_t i = 0; i < scripts.length(); ++i) {
82 scripts_.Add(scripts.At(i).ptr());
83 }
84}
void Add(const T &value)
TokenPosition token_pos() const
Definition: debugger.h:128
TokenPosition end_token_pos() const
Definition: debugger.h:130
Debugger * debugger()
Definition: debugger.h:158
intptr_t requested_column_number() const
Definition: debugger.h:141
intptr_t requested_line_number() const
Definition: debugger.h:140
#define ASSERT(E)

◆ BreakpointLocation() [2/2]

dart::BreakpointLocation::BreakpointLocation ( Debugger debugger,
const String url,
intptr_t  requested_line_number,
intptr_t  requested_column_number 
)

Definition at line 87 of file debugger.cc.

91 : debugger_(debugger),
92 scripts_(MallocGrowableArray<ScriptPtr>(0)),
93 url_(url.ptr()),
94 line_number_lock_(new SafepointRwLock()),
95 line_number_(-1), // lazily computed
96 token_pos_(TokenPosition::kNoSource),
97 end_token_pos_(TokenPosition::kNoSource),
98 next_(nullptr),
99 conditions_(nullptr),
100 requested_line_number_(requested_line_number),
101 requested_column_number_(requested_column_number),
102 code_token_pos_(TokenPosition::kNoSource) {
103 ASSERT(requested_line_number_ >= 0);
104}
StringPtr url() const
Definition: debugger.h:138

◆ ~BreakpointLocation()

dart::BreakpointLocation::~BreakpointLocation ( )

Definition at line 106 of file debugger.cc.

106 {
107 Breakpoint* bpt = breakpoints();
108 while (bpt != nullptr) {
109 Breakpoint* temp = bpt;
110 bpt = bpt->next();
111 delete temp;
112 }
113}

Member Function Documentation

◆ AddBreakpoint()

Breakpoint * dart::BreakpointLocation::AddBreakpoint ( Debugger dbg,
const Closure closure,
bool  single_shot 
)

Definition at line 348 of file debugger.cc.

350 {
351 Breakpoint* bpt = breakpoints();
352 while (bpt != nullptr) {
353 if ((bpt->closure() == closure.ptr()) &&
354 (bpt->is_single_shot() == single_shot)) {
355 break;
356 }
357 bpt = bpt->next();
358 }
359 if (bpt == nullptr) {
360 bpt = new Breakpoint(dbg->nextId(), this, single_shot, closure);
361 AddBreakpoint(bpt, dbg);
362 }
363 return bpt;
364}
Breakpoint * AddBreakpoint(Debugger *dbg, const Closure &closure, bool single_shot)
Definition: debugger.cc:348
std::function< void()> closure
Definition: closure.h:14

◆ AddRepeated()

Breakpoint * dart::BreakpointLocation::AddRepeated ( Debugger dbg)

Definition at line 340 of file debugger.cc.

340 {
341 return AddBreakpoint(dbg, Closure::Handle(), /*single_shot=*/false);
342}
static Object & Handle()
Definition: object.h:407

◆ AddSingleShot()

Breakpoint * dart::BreakpointLocation::AddSingleShot ( Debugger dbg)

Definition at line 344 of file debugger.cc.

344 {
345 return AddBreakpoint(dbg, Closure::Handle(), /*single_shot=*/true);
346}

◆ AnyEnabled()

bool dart::BreakpointLocation::AnyEnabled ( ) const

Definition at line 115 of file debugger.cc.

115 {
116 Breakpoint* bpt = breakpoints();
117 while (bpt != nullptr) {
118 if (bpt->is_enabled()) {
119 return true;
120 }
121 bpt = bpt->next();
122 }
123 return false;
124}

◆ debugger()

Debugger * dart::BreakpointLocation::debugger ( )
inline

Definition at line 158 of file debugger.h.

158{ return debugger_; }

◆ end_token_pos()

TokenPosition dart::BreakpointLocation::end_token_pos ( ) const
inline

Definition at line 130 of file debugger.h.

130{ return end_token_pos_.load(); }

◆ EnsureIsResolved()

bool dart::BreakpointLocation::EnsureIsResolved ( const Function target_function,
TokenPosition  exact_token_pos 
)

Definition at line 2172 of file debugger.cc.

2173 {
2174 if (IsResolved()) {
2175 return true;
2176 }
2177
2178 // Resolve source breakpoint in the newly compiled function.
2179 TokenPosition resolved_pos =
2180 ResolveBreakpointPos(target_function, token_pos(), end_token_pos(),
2181 requested_column_number(), exact_token_pos);
2182 if (!resolved_pos.IsDebugPause()) {
2183 if (FLAG_verbose_debug) {
2184 OS::PrintErr("Failed resolving breakpoint for function '%s'\n",
2185 target_function.ToFullyQualifiedCString());
2186 }
2187 return false;
2188 }
2189 TokenPosition requested_pos = token_pos();
2190 TokenPosition requested_end_pos = end_token_pos();
2191 SetResolved(target_function, resolved_pos);
2192 Breakpoint* breakpoint = breakpoints();
2193 while (breakpoint != nullptr) {
2194 if (FLAG_verbose_debug) {
2195 OS::PrintErr("Resolved breakpoint %" Pd
2196 " to pos %s, function '%s' (requested range %s-%s, "
2197 "requested col %" Pd ")\n",
2198 breakpoint->id(), token_pos().ToCString(),
2199 target_function.ToFullyQualifiedCString(),
2200 requested_pos.ToCString(), requested_end_pos.ToCString(),
2202 }
2203 debugger()->SendBreakpointEvent(ServiceEvent::kBreakpointResolved,
2204 breakpoint);
2205 breakpoint = breakpoint->next();
2206 }
2207
2208 return true;
2209}
bool IsResolved() const
Definition: debugger.h:152
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
const char * ToCString() const
static TokenPosition ResolveBreakpointPos(const Function &func, TokenPosition requested_token_pos, TokenPosition last_token_pos, intptr_t requested_column, TokenPosition exact_token_pos)
Definition: debugger.cc:2062
#define Pd
Definition: globals.h:408

◆ GetCodeLocation()

void dart::BreakpointLocation::GetCodeLocation ( Script script,
TokenPosition token_pos 
) const

Definition at line 142 of file debugger.cc.

143 {
144 if (IsLatent()) {
145 *script = Script::null();
146 *pos = TokenPosition::kNoSource;
147 } else {
148 *script = this->script();
149 *pos = token_pos_;
150 }
151}
SkPoint pos
ScriptPtr script() const
Definition: debugger.h:132
bool IsLatent() const
Definition: debugger.h:153
static ObjectPtr null()
Definition: object.h:433

◆ IsLatent()

bool dart::BreakpointLocation::IsLatent ( ) const
inline

Definition at line 153 of file debugger.h.

153{ return !token_pos().IsReal(); }

◆ IsResolved()

bool dart::BreakpointLocation::IsResolved ( ) const
inline

Definition at line 152 of file debugger.h.

152{ return code_token_pos_.IsReal(); }

◆ line_number()

intptr_t dart::BreakpointLocation::line_number ( )

Definition at line 153 of file debugger.cc.

153 {
154 // Compute line number lazily since it causes scanning of the script.
155 {
156 SafepointReadRwLocker sl(Thread::Current(), line_number_lock());
157 if (line_number_ >= 0) {
158 return line_number_;
159 }
160 }
161 SafepointWriteRwLocker sl(Thread::Current(), line_number_lock());
162 if (line_number_ < 0) {
163 Script::Handle(script()).GetTokenLocation(token_pos(), &line_number_);
164 }
165 return line_number_;
166}
static Thread * Current()
Definition: thread.h:362

◆ requested_column_number()

intptr_t dart::BreakpointLocation::requested_column_number ( ) const
inline

Definition at line 141 of file debugger.h.

141{ return requested_column_number_; }

◆ requested_line_number()

intptr_t dart::BreakpointLocation::requested_line_number ( ) const
inline

Definition at line 140 of file debugger.h.

140{ return requested_line_number_; }

◆ script()

ScriptPtr dart::BreakpointLocation::script ( ) const
inline

Definition at line 132 of file debugger.h.

132 {
133 if (scripts_.length() == 0) {
134 return Script::null();
135 }
136 return scripts_.At(0);
137 }
const T & At(intptr_t index) const
intptr_t length() const

◆ token_pos()

TokenPosition dart::BreakpointLocation::token_pos ( ) const
inline

Definition at line 128 of file debugger.h.

128{ return token_pos_.load(); }

◆ url()

StringPtr dart::BreakpointLocation::url ( ) const
inline

Definition at line 138 of file debugger.h.

138{ return url_; }

Friends And Related Function Documentation

◆ Debugger

friend class Debugger
friend

Definition at line 193 of file debugger.h.

◆ GroupDebugger

friend class GroupDebugger
friend

Definition at line 194 of file debugger.h.


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