| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 const char* msg = CheckIsolateState(isolate); | 138 const char* msg = CheckIsolateState(isolate); |
| 139 if (msg != NULL) { | 139 if (msg != NULL) { |
| 140 return Api::NewError(msg); | 140 return Api::NewError(msg); |
| 141 } | 141 } |
| 142 | 142 |
| 143 Dart_Handle result = Api::True(); | 143 Dart_Handle result = Api::True(); |
| 144 *breakpoint = NULL; | 144 *breakpoint = NULL; |
| 145 Debugger* debugger = isolate->debugger(); | 145 Debugger* debugger = isolate->debugger(); |
| 146 ASSERT(debugger != NULL); | 146 ASSERT(debugger != NULL); |
| 147 Error& error = Error::Handle(); | 147 SourceBreakpoint* bpt = |
| 148 Breakpoint* bpt = debugger->SetBreakpointAtLine(script_url, line, &error); | 148 debugger->SetBreakpointAtLine(script_url, line); |
| 149 if (bpt == NULL) { | 149 if (bpt == NULL) { |
| 150 if (!error.IsNull()) { | 150 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'", |
| 151 // If SetBreakpointAtLine provided an error message, use it. | |
| 152 result = Api::NewLocalHandle(error); | |
| 153 } else { | |
| 154 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'", | |
| 155 CURRENT_FUNC, line, script_url.ToCString()); | 151 CURRENT_FUNC, line, script_url.ToCString()); |
| 156 } | |
| 157 } else { | 152 } else { |
| 158 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); | 153 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); |
| 159 } | 154 } |
| 160 return result; | 155 return result; |
| 161 } | 156 } |
| 162 | 157 |
| 163 | 158 |
| 164 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( | 159 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( |
| 165 Dart_Handle library_in, | 160 Dart_Handle library_in, |
| 166 Dart_Handle class_name_in, | 161 Dart_Handle class_name_in, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 191 return Api::NewError("%s: could not find function '%s%s%s'", | 186 return Api::NewError("%s: could not find function '%s%s%s'", |
| 192 CURRENT_FUNC, | 187 CURRENT_FUNC, |
| 193 toplevel ? "" : class_name.ToCString(), | 188 toplevel ? "" : class_name.ToCString(), |
| 194 toplevel ? "" : ".", | 189 toplevel ? "" : ".", |
| 195 function_name.ToCString()); | 190 function_name.ToCString()); |
| 196 } | 191 } |
| 197 | 192 |
| 198 Dart_Handle result = Api::True(); | 193 Dart_Handle result = Api::True(); |
| 199 *breakpoint = NULL; | 194 *breakpoint = NULL; |
| 200 | 195 |
| 201 Error& error = Error::Handle(); | 196 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); |
| 202 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, &error); | |
| 203 if (!error.IsNull()) { | |
| 204 return Api::NewLocalHandle(error); | |
| 205 } | |
| 206 if (bpt == NULL) { | 197 if (bpt == NULL) { |
| 207 const char* target_name = Debugger::QualifiedFunctionName(bp_target); | 198 const char* target_name = Debugger::QualifiedFunctionName(bp_target); |
| 208 result = Api::NewError("%s: no breakpoint location found in '%s'", | 199 result = Api::NewError("%s: no breakpoint location found in '%s'", |
| 209 CURRENT_FUNC, target_name); | 200 CURRENT_FUNC, target_name); |
| 210 } else { | 201 } else { |
| 211 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); | 202 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); |
| 212 } | 203 } |
| 213 return result; | 204 return result; |
| 214 } | 205 } |
| 215 | 206 |
| 216 | 207 |
| 217 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint( | 208 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint( |
| 218 Dart_Breakpoint breakpoint_in) { | 209 Dart_Breakpoint breakpoint_in) { |
| 219 Isolate* isolate = Isolate::Current(); | 210 Isolate* isolate = Isolate::Current(); |
| 220 DARTSCOPE(isolate); | 211 DARTSCOPE(isolate); |
| 221 | 212 |
| 222 CHECK_AND_CAST(Breakpoint, breakpoint, breakpoint_in); | 213 CHECK_AND_CAST(SourceBreakpoint, breakpoint, breakpoint_in); |
| 223 isolate->debugger()->RemoveBreakpoint(breakpoint); | 214 isolate->debugger()->RemoveBreakpoint(breakpoint); |
| 224 return Api::True(); | 215 return Api::True(); |
| 225 } | 216 } |
| 226 | 217 |
| 227 | 218 |
| 228 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 219 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
| 229 Isolate* isolate = Isolate::Current(); | 220 Isolate* isolate = Isolate::Current(); |
| 230 DARTSCOPE(isolate); | 221 DARTSCOPE(isolate); |
| 231 isolate->debugger()->SetStepOver(); | 222 isolate->debugger()->SetStepOver(); |
| 232 return Api::True(); | 223 return Api::True(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 for (int i = 0; i < num_libs; i++) { | 357 for (int i = 0; i < num_libs; i++) { |
| 367 ASSERT(!lib.IsNull()); | 358 ASSERT(!lib.IsNull()); |
| 368 lib_url = lib.url(); | 359 lib_url = lib.url(); |
| 369 library_list.SetAt(i, lib_url); | 360 library_list.SetAt(i, lib_url); |
| 370 lib = lib.next_registered(); | 361 lib = lib.next_registered(); |
| 371 } | 362 } |
| 372 return Api::NewLocalHandle(library_list); | 363 return Api::NewLocalHandle(library_list); |
| 373 } | 364 } |
| 374 | 365 |
| 375 } // namespace dart | 366 } // namespace dart |
| OLD | NEW |