OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/debugger.h" | 5 #include "vm/debugger.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "vm/stub_code.h" | 21 #include "vm/stub_code.h" |
22 #include "vm/symbols.h" | 22 #include "vm/symbols.h" |
23 #include "vm/visitor.h" | 23 #include "vm/visitor.h" |
24 | 24 |
25 | 25 |
26 namespace dart { | 26 namespace dart { |
27 | 27 |
28 DEFINE_FLAG(bool, verbose_debug, false, "Verbose debugger messages"); | 28 DEFINE_FLAG(bool, verbose_debug, false, "Verbose debugger messages"); |
29 | 29 |
30 | 30 |
31 static void DefaultBreakpointHandler(SourceBreakpoint* bpt, | 31 static void DefaultBreakpointHandler(Dart_Port isolate_id, |
32 SourceBreakpoint* bpt, | |
32 DebuggerStackTrace* stack) { | 33 DebuggerStackTrace* stack) { |
33 String& var_name = String::Handle(); | 34 String& var_name = String::Handle(); |
34 Instance& value = Instance::Handle(); | 35 Instance& value = Instance::Handle(); |
35 for (intptr_t i = 0; i < stack->Length(); i++) { | 36 for (intptr_t i = 0; i < stack->Length(); i++) { |
36 ActivationFrame* frame = stack->ActivationFrameAt(i); | 37 ActivationFrame* frame = stack->ActivationFrameAt(i); |
37 OS::Print(" %"Pd". %s\n", | 38 OS::Print(" %"Pd". %s\n", |
38 i + 1, frame->ToCString()); | 39 i + 1, frame->ToCString()); |
39 intptr_t num_locals = frame->NumLocalVariables(); | 40 intptr_t num_locals = frame->NumLocalVariables(); |
40 for (intptr_t i = 0; i < num_locals; i++) { | 41 for (intptr_t i = 0; i < num_locals; i++) { |
41 intptr_t token_pos, end_pos; | 42 intptr_t token_pos, end_pos; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 | 162 |
162 | 163 |
163 void Debugger::SignalIsolateEvent(EventType type) { | 164 void Debugger::SignalIsolateEvent(EventType type) { |
164 if (event_handler_ != NULL) { | 165 if (event_handler_ != NULL) { |
165 Debugger* debugger = Isolate::Current()->debugger(); | 166 Debugger* debugger = Isolate::Current()->debugger(); |
166 ASSERT(debugger != NULL); | 167 ASSERT(debugger != NULL); |
167 DebuggerEvent event; | 168 DebuggerEvent event; |
168 event.type = type; | 169 event.type = type; |
169 event.isolate_id = debugger->GetIsolateId(); | 170 event.isolate_id = debugger->GetIsolateId(); |
170 ASSERT(event.isolate_id != ILLEGAL_ISOLATE_ID); | 171 ASSERT(event.isolate_id != ILLEGAL_ISOLATE_ID); |
171 (*event_handler_)(&event); | 172 if (type == kIsolateInterrupted) { |
173 DebuggerStackTrace* stack_trace = debugger->CollectStackTrace(); | |
174 ASSERT(stack_trace->Length() > 0); | |
175 ASSERT(debugger->stack_trace_ == NULL); | |
176 ASSERT(debugger->obj_cache_ == NULL); | |
177 debugger->obj_cache_ = new RemoteObjectCache(64); | |
178 debugger->stack_trace_ = stack_trace; | |
179 (*event_handler_)(&event); | |
180 debugger->stack_trace_ = NULL; | |
181 debugger->obj_cache_ = NULL; // Remote object cache is zone allocated. | |
182 // TODO(asiva): Need some work here to be able to single step after | |
183 // an interrupt. | |
184 } else { | |
185 (*event_handler_)(&event); | |
186 } | |
172 } | 187 } |
173 } | 188 } |
174 | 189 |
175 | 190 |
176 const char* Debugger::QualifiedFunctionName(const Function& func) { | 191 const char* Debugger::QualifiedFunctionName(const Function& func) { |
177 const String& func_name = String::Handle(func.name()); | 192 const String& func_name = String::Handle(func.name()); |
178 Class& func_class = Class::Handle(func.Owner()); | 193 Class& func_class = Class::Handle(func.Owner()); |
179 String& class_name = String::Handle(func_class.Name()); | 194 String& class_name = String::Handle(func_class.Name()); |
180 | 195 |
181 const char* kFormat = "%s%s%s"; | 196 const char* kFormat = "%s%s%s"; |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 // callback even if it is on the same line as the previous breakpoint. | 1345 // callback even if it is on the same line as the previous breakpoint. |
1331 last_bpt_line_ = -1; | 1346 last_bpt_line_ = -1; |
1332 } | 1347 } |
1333 | 1348 |
1334 bool notify_frontend = | 1349 bool notify_frontend = |
1335 (last_bpt_line_ < 0) || (last_bpt_line_ != bpt->LineNumber()); | 1350 (last_bpt_line_ < 0) || (last_bpt_line_ != bpt->LineNumber()); |
1336 | 1351 |
1337 if (notify_frontend) { | 1352 if (notify_frontend) { |
1338 resume_action_ = kContinue; | 1353 resume_action_ = kContinue; |
1339 if (bp_handler_ != NULL) { | 1354 if (bp_handler_ != NULL) { |
1355 Isolate* isolate = Isolate::Current(); | |
hausner
2012/10/05 18:06:34
Why do you need to get the debugger object through
siva
2012/10/05 22:35:06
Good point, this is not a static function so just
| |
1356 ASSERT(isolate != NULL); | |
1357 ASSERT(isolate->debugger() != NULL); | |
1340 SourceBreakpoint* src_bpt = bpt->src_bpt(); | 1358 SourceBreakpoint* src_bpt = bpt->src_bpt(); |
1341 ASSERT(stack_trace_ == NULL); | 1359 ASSERT(stack_trace_ == NULL); |
1342 ASSERT(obj_cache_ == NULL); | 1360 ASSERT(obj_cache_ == NULL); |
1343 obj_cache_ = new RemoteObjectCache(64); | 1361 obj_cache_ = new RemoteObjectCache(64); |
1344 stack_trace_ = stack_trace; | 1362 stack_trace_ = stack_trace; |
1345 (*bp_handler_)(src_bpt, stack_trace); | 1363 (*bp_handler_)(isolate->debugger()->GetIsolateId(), src_bpt, stack_trace); |
1346 stack_trace_ = NULL; | 1364 stack_trace_ = NULL; |
1347 obj_cache_ = NULL; // Remote object cache is zone allocated. | 1365 obj_cache_ = NULL; // Remote object cache is zone allocated. |
1348 last_bpt_line_ = bpt->LineNumber(); | 1366 last_bpt_line_ = bpt->LineNumber(); |
1349 } | 1367 } |
1350 } | 1368 } |
1351 | 1369 |
1352 Function& currently_instrumented_func = Function::Handle(); | 1370 Function& currently_instrumented_func = Function::Handle(); |
1353 if (bpt->IsInternal()) { | 1371 if (bpt->IsInternal()) { |
1354 currently_instrumented_func = bpt->function(); | 1372 currently_instrumented_func = bpt->function(); |
1355 } | 1373 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1601 } | 1619 } |
1602 | 1620 |
1603 | 1621 |
1604 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1622 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
1605 ASSERT(bpt->next() == NULL); | 1623 ASSERT(bpt->next() == NULL); |
1606 bpt->set_next(code_breakpoints_); | 1624 bpt->set_next(code_breakpoints_); |
1607 code_breakpoints_ = bpt; | 1625 code_breakpoints_ = bpt; |
1608 } | 1626 } |
1609 | 1627 |
1610 } // namespace dart | 1628 } // namespace dart |
OLD | NEW |