Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: runtime/include/dart_debugger_api.h

Issue 1185983005: Introduce dart_tools_api.h (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/include/dart_tools_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(johnmccutchan): Remove this file.
6
5 #ifndef INCLUDE_DART_DEBUGGER_API_H_ 7 #ifndef INCLUDE_DART_DEBUGGER_API_H_
6 #define INCLUDE_DART_DEBUGGER_API_H_ 8 #define INCLUDE_DART_DEBUGGER_API_H_
7 9
8 #include "include/dart_api.h" 10 #include "include/dart_tools_api.h"
9
10 typedef struct _Dart_Breakpoint* Dart_Breakpoint;
11
12 typedef struct _Dart_StackTrace* Dart_StackTrace;
13
14 typedef struct _Dart_ActivationFrame* Dart_ActivationFrame;
15
16 /**
17 * An id used to uniquely represent an Isolate in the debugger wire protocol
18 * messages.
19 */
20 typedef Dart_Port Dart_IsolateId;
21
22 /**
23 * ILLEGAL_ISOLATE_ID is a number guaranteed never to be associated with a
24 * valid isolate.
25 */
26 #define ILLEGAL_ISOLATE_ID ILLEGAL_PORT
27
28
29 /**
30 * Null value for breakpoint id. Guaranteed never to be associated
31 * with a valid breakpoint.
32 */
33 #define ILLEGAL_BREAKPOINT_ID 0
34
35
36 typedef void Dart_ExceptionThrownHandler(Dart_IsolateId isolate_id,
37 Dart_Handle exception_object,
38 Dart_StackTrace stack_trace);
39
40 typedef enum {
41 kCreated = 0,
42 kInterrupted,
43 kShutdown,
44 } Dart_IsolateEvent;
45
46
47 /**
48 * Represents a location in Dart code.
49 */
50 typedef struct {
51 Dart_Handle script_url; // Url (string) of the script.
52 int32_t library_id; // Library in which the script is loaded.
53 int32_t token_pos; // Code address.
54 } Dart_CodeLocation;
55
56
57 typedef void Dart_IsolateEventHandler(Dart_IsolateId isolate_id,
58 Dart_IsolateEvent kind);
59
60 typedef void Dart_PausedEventHandler(Dart_IsolateId isolate_id,
61 intptr_t bp_id,
62 const Dart_CodeLocation& location);
63
64 typedef void Dart_BreakpointResolvedHandler(Dart_IsolateId isolate_id,
65 intptr_t bp_id,
66 const Dart_CodeLocation& location);
67
68
69 /**
70 * Caches a given \object and returns an object id. The object id is only
71 * valid while the VM is paused. The cache is invalidated when the VM
72 * resumes.
73 *
74 * Requires there to be a current isolate.
75 *
76 * Returns an id >= 0 on success, or -1 if there is an error.
77 */
78 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in);
79
80
81 /**
82 * Returns a cached object given the \obj_id.
83 *
84 * Requires there to be a current isolate.
85 */
86 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id);
87
88
89 /**
90 * Returns a list of ids (integers) of all the libraries loaded in the
91 * current isolate.
92 *
93 * Requires there to be a current isolate.
94 *
95 * \return A handle to a list of library ids.
96 */
97 DART_EXPORT Dart_Handle Dart_GetLibraryIds();
98
99
100 /**
101 * Returns true if the debugger can step into code of the given library.
102 *
103 * Requires there to be a current isolate.
104 *
105 * \return A handle to the True object if no error occurs.
106 */
107 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id,
108 bool* is_debuggable);
109
110
111 /**
112 * Requets that debugging be enabled for the given library.
113 *
114 * Requires there to be a current isolate.
115 *
116 * \return A handle to the True object if no error occurs.
117 */
118 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id,
119 bool is_debuggable);
120
121
122 /**
123 * Returns a list of urls (strings) of all the scripts loaded in the
124 * given library.
125 *
126 * Requires there to be a current isolate.
127 *
128 * \return A handle to a list of string handles.
129 */
130 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url);
131
132
133 /**
134 * Returns a string containing the source code of the given script
135 * in the given library.
136 *
137 * Requires there to be a current isolate.
138 *
139 * \return A handle to string containing the source text if no error
140 * occurs.
141 */
142 DART_EXPORT Dart_Handle Dart_ScriptGetSource(
143 intptr_t library_id,
144 Dart_Handle script_url_in);
145
146
147 /**
148 * Returns an array containing line number and token offset info
149 * for the given script.
150 *
151 * Returns an array of numbers. Null values indicate the beginning of
152 * a new line. The first number after null is the line number.
153 * The line number is followed by pairs of numbers, with the first value
154 * being the "token offset" and the second value being the column number
155 * of the token.
156 * The "token offset" is a value that is used to indicate a location
157 * in code, similarly to a "PC" address.
158 * Source lines with no tokens are omitted.
159 *
160 * Requires there to be a current isolate.
161 *
162 * \return A handle to an array or an error object.
163 */
164 DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(
165 intptr_t library_id,
166 Dart_Handle script_url_in);
167
168
169 /**
170 * Returns a string containing a generated source code of the given script
171 * in the given library. This is essentially used to pretty print dart code
172 * generated from any tool (e.g: dart2dart).
173 *
174 * Requires there to be a current isolate.
175 *
176 * \return A handle to string containing the source text if no error
177 * occurs.
178 */
179 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in,
180 Dart_Handle script_url_in);
181
182
183 /**
184 * Sets a breakpoint at line \line_number in \script_url, or the closest
185 * following line (within the same function) where a breakpoint can be set.
186 *
187 * Requires there to be a current isolate.
188 *
189 * \return A handle containing the breakpoint id, which is an integer
190 * value, or an error object if a breakpoint could not be set.
191 */
192 DART_EXPORT Dart_Handle Dart_SetBreakpoint(
193 Dart_Handle script_url,
194 intptr_t line_number);
195
196 /**
197 * Deletes the breakpoint with the given id \pb_id.
198 *
199 * Requires there to be a current isolate.
200 *
201 * \return A handle to the True object if no error occurs.
202 */
203 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id);
204
205
206 /**
207 * Get the script URL of the breakpoint with the given id \pb_id.
208 *
209 * Requires there to be a current isolate.
210 *
211 * \return A handle to the URL (string) of the script, or an error
212 * object.
213 */
214 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id);
215
216
217 /**
218 * Get the line number of the breakpoint with the given id \pb_id.
219 *
220 * Requires there to be a current isolate.
221 *
222 * \return A handle to the line number (integer) of the script,
223 * or an error object.
224 */
225 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id);
226
227
228 /**
229 * Sets a one-time breakpoint at the entry of the given function.
230 * If class_name is the empty string, looks for a library function
231 * with the given name.
232 *
233 * Requires there to be a current isolate.
234 *
235 * \return A handle containing the breakpoint id, which is an integer
236 * value, or an error object if a breakpoint could not be set.
237 */
238 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
239 Dart_Handle library,
240 Dart_Handle class_name,
241 Dart_Handle function_name);
242
243
244 /**
245 * Sets a breakpoint at the entry of the given function. If class_name
246 * is the empty string, looks for a library function with the given
247 * name.
248 *
249 * Requires there to be a current isolate.
250 *
251 * \return A handle to the True object if no error occurs.
252 */
253 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry(
254 Dart_Handle library,
255 Dart_Handle class_name,
256 Dart_Handle function_name);
257
258
259 /**
260 * Can be called from the breakpoint handler. Sets the debugger to
261 * single step mode.
262 *
263 * Requires there to be a current isolate.
264 */
265 DART_EXPORT Dart_Handle Dart_SetStepOver();
266
267
268 /**
269 * Can be called from the breakpoint handler. Causes the debugger to
270 * break after at the beginning of the next function call.
271 *
272 * Requires there to be a current isolate.
273 */
274 DART_EXPORT Dart_Handle Dart_SetStepInto();
275
276
277 /**
278 * Can be called from the breakpoint handler. Causes the debugger to
279 * break after returning from the current Dart function.
280 *
281 * Requires there to be a current isolate.
282 */
283 DART_EXPORT Dart_Handle Dart_SetStepOut();
284
285
286 /**
287 * Installs a handler callback function that gets called by the VM
288 * when a breakpoint location has been reached or when stepping.
289 *
290 * Requires there to be a current isolate.
291 */
292 DART_EXPORT void Dart_SetPausedEventHandler(
293 Dart_PausedEventHandler handler);
294
295
296 /**
297 * Installs a callback function that gets called by the VM when
298 * a breakpoint has been resolved to an actual url and line number.
299 *
300 * Requires there to be a current isolate.
301 */
302 DART_EXPORT void Dart_SetBreakpointResolvedHandler(
303 Dart_BreakpointResolvedHandler handler);
304
305 /**
306 * Installs a callback function that gets called by the VM when
307 * an exception has been thrown.
308 *
309 * Requires there to be a current isolate.
310 */
311 DART_EXPORT void Dart_SetExceptionThrownHandler(
312 Dart_ExceptionThrownHandler handler);
313
314 /**
315 * Installs a callback function that gets called by the VM when
316 * an isolate event happens, e.g:
317 * - creation of a new isolate
318 * - shutdown of an isolate
319 * - interruption of an isolate
320 */
321 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler);
322
323 // On which exceptions to pause.
324 typedef enum {
325 kNoPauseOnExceptions = 1,
326 kPauseOnUnhandledExceptions,
327 kPauseOnAllExceptions,
328 } Dart_ExceptionPauseInfo;
329
330 /**
331 * Define on which exceptions the debugger pauses.
332 *
333 * Requires there to be a current isolate.
334 */
335 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo(
336 Dart_ExceptionPauseInfo pause_info);
337
338
339 /**
340 * Returns on which exceptions the debugger pauses.
341 *
342 * Requires there to be a current isolate.
343 */
344 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo();
345
346 /**
347 * Returns in \trace the current stack trace, or NULL if the
348 * VM is not paused.
349 *
350 * Requires there to be a current isolate.
351 *
352 * \return A valid handle if no error occurs during the operation.
353 */
354 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace);
355
356
357 /**
358 * Returns in \trace the stack trace associated with the error given in \handle.
359 *
360 * Requires there to be a current isolate.
361 *
362 * \return A valid handle if no error occurs during the operation.
363 */
364 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle error,
365 Dart_StackTrace* trace);
366
367
368 /**
369 * Returns in \length the number of activation frames in the given
370 * stack trace.
371 *
372 * Requires there to be a current isolate.
373 *
374 * \return A handle to the True object if no error occurs.
375 */
376 DART_EXPORT Dart_Handle Dart_StackTraceLength(
377 Dart_StackTrace trace,
378 intptr_t* length);
379
380
381 /**
382 * Returns in \frame the activation frame with index \frame_index.
383 * The activation frame at the top of stack has index 0.
384 *
385 * Requires there to be a current isolate.
386 *
387 * \return A handle to the True object if no error occurs.
388 */
389 DART_EXPORT Dart_Handle Dart_GetActivationFrame(
390 Dart_StackTrace trace,
391 int frame_index,
392 Dart_ActivationFrame* frame);
393
394
395 /**
396 * Returns information about the given activation frame.
397 * \function_name receives a string handle with the qualified
398 * function name.
399 * \script_url receives a string handle with the url of the
400 * source script that contains the frame's function.
401 * \line_number receives the line number in the script.
402 * \col_number receives the column number in the script, or -1 if column
403 * information is not available
404 *
405 * Any or all of the out parameters above may be NULL.
406 *
407 * Requires there to be a current isolate.
408 *
409 * \return A valid handle if no error occurs during the operation.
410 */
411 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo(
412 Dart_ActivationFrame activation_frame,
413 Dart_Handle* function_name,
414 Dart_Handle* script_url,
415 intptr_t* line_number,
416 intptr_t* column_number);
417
418
419 /**
420 * Returns code location of the given activation frame.
421 *
422 * \function_name receives a string handle with the qualified
423 * function name.
424 * \function receives a handle to the function.
425 * \location.script_url receives a string handle with the url of
426 * the source script that contains the frame's function.
427 * Receives a null handle if there is no textual location
428 * that corresponds to the frame, e.g. for implicitly
429 * generated constructors.
430 * \location.library_id receives the id of the library in which the
431 * function in this frame is defined.
432 * \location.token_pos receives the token position in the script.
433 *
434 * Any of the out parameters above may be NULL.
435 *
436 * Requires there to be a current isolate.
437 *
438 * \return A handle to the True object if no error occurs.
439 * A handle to the False object if there is no text
440 * position for the frame.
441 */
442 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation(
443 Dart_ActivationFrame activation_frame,
444 Dart_Handle* function_name,
445 Dart_Handle* function,
446 Dart_CodeLocation* location);
447
448 /**
449 * Returns frame pointer of the given activation frame.
450 *
451 * \frame_pointer receives the frame pointer for the frame.
452 *
453 * Requires there to be a current isolate.
454 *
455 * \return A handle to the True object if no error occurs.
456 */
457 DART_EXPORT Dart_Handle Dart_ActivationFrameGetFramePointer(
458 Dart_ActivationFrame activation_frame,
459 uintptr_t* frame_pointer);
460
461 /**
462 * Returns an array containing all the local variable names and values of
463 * the given \activation_frame.
464 *
465 * Requires there to be a current isolate.
466 *
467 * \return A handle to an array containing variable names and
468 * corresponding values. The array is empty if the activation frame has
469 * no variables. If non-empty, variable names are at array offsets 2*n,
470 * values at offset 2*n+1.
471 */
472 DART_EXPORT Dart_Handle Dart_GetLocalVariables(
473 Dart_ActivationFrame activation_frame);
474
475
476 /**
477 * Returns origin class of a function.
478 *
479 * Requires there to be a current isolate.
480 *
481 * \return Returns the class id (a handle to an integer) of the class in
482 * which \function is defined. Returns a null handle if \function is defined
483 * at the top level. Returns an error object otherwise.
484 */
485 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function);
486
487
488 /**
489 * Returns an array containing all the global variable names and values of
490 * the library with given \library_id.
491 *
492 * Requires there to be a current isolate.
493 *
494 * \return A handle to an array containing variable names and
495 * corresponding values. Variable names are at array offsets 2*n,
496 * values at offset 2*n+1.
497 */
498 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id);
499
500
501 /**
502 * Execute the expression given in string \expr in the context
503 * of stack frame \activation_frame.
504 */
505 DART_EXPORT Dart_Handle Dart_ActivationFrameEvaluate(
506 Dart_ActivationFrame activation_frame,
507 Dart_Handle expr_in);
508
509
510 /**
511 * Execute the expression given in string \expr in the context
512 * of \target.
513 *
514 * Requires there to be a current isolate.
515 *
516 * The expression is evaluated in the context of \target.
517 * If \target is a Dart object, the expression is evaluated as if
518 * it were an instance method of the class of the object.
519 * If \target is a Class, the expression is evaluated as if it
520 * were a static method of that class.
521 * If \target is a Library, the expression is evaluated as if it
522 * were a top-level function in that library.
523 *
524 * \return A handle to the computed value, or an error object if
525 * the compilation of the expression fails, or if the evaluation throws
526 * an error.
527 */
528 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target,
529 Dart_Handle expr);
530
531
532 /**
533 * Returns the class of the given \object.
534 *
535 * Requires there to be a current isolate.
536 *
537 * \return A handle to the class object.
538 */
539 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object);
540
541
542 /**
543 * Returns in \class_id the class id of the given \object. The id is valid
544 * for the lifetime of the isolate.
545 *
546 * Requires there to be a current isolate.
547 *
548 * \return True if no error occurs.
549 */
550 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object,
551 intptr_t* class_id);
552
553
554 /**
555 * Returns the supertype of the given instantiated type \cls.
556 *
557 * Requires there to be a current isolate.
558 *
559 * \return A handle to the type object.
560 */
561 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type);
562
563
564 /**
565 * Returns handle to class with class id \class_id.
566 *
567 * Requires there to be a current isolate.
568 *
569 * \return A handle to the class if no error occurs.
570 */
571 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id);
572
573
574 /**
575 * Returns info about the given class \cls_id.
576 *
577 * \param class_name receives handle to class name (string) if non-null.
578 * \param library receives handle to library in which the class
579 * is defined, if non-null.
580 * \param super_class_id receives the class id to the super class of
581 * \cls_id if non-null.
582 * \param static_fields If non-null, receives an array containing field
583 * names and values of static fields of the class. Names are
584 * at array offsets 2*n, values at offset 2*n+1.
585 *
586 * Requires there to be a current isolate.
587 *
588 * \return A handle to the value true if no error occurs.
589 */
590 DART_EXPORT Dart_Handle Dart_GetClassInfo(intptr_t class_id,
591 Dart_Handle* class_name,
592 intptr_t* library_id,
593 intptr_t* super_class_id,
594 Dart_Handle* static_fields);
595
596
597 /** Returns info about the given closure \closure.
598 *
599 * \param name receives handle to closure name (string).
600 * Receives a null handle if the closure is anonymous.
601 * \param signature receives handle to closure signature (string).
602 * \param location.script_url receives a string handle with the url of
603 * the source script that contains the closure.
604 * Receives a null handle if there is no textual location
605 * that corresponds to the fucntion.
606 * \param location.library_id receives the id of the library in which the
607 * function in this frame is defined.
608 * \param location.token_pos receives the token position in the script.
609 *
610 * \return A handle to the value true if no error occurs.
611 */
612 DART_EXPORT Dart_Handle Dart_GetClosureInfo(Dart_Handle closure,
613 Dart_Handle* name,
614 Dart_Handle* signature,
615 Dart_CodeLocation* location);
616
617
618 /**
619 * Returns an array containing all instance field names and values of
620 * the given \object.
621 *
622 * Requires there to be a current isolate.
623 *
624 * \return A handle to an array containing field names and
625 * corresponding field values. The array is empty if the object has
626 * no fields. If non-empty, field names are at array offsets 2*n,
627 * values at offset 2*n+1. Field values may also be a handle to an
628 * error object if an error was encountered evaluating the field.
629 */
630 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object);
631
632
633 /**
634 * Returns an array containing all static field names and values of
635 * the given type \target.
636 *
637 * Requires there to be a current isolate.
638 *
639 * \return A handle to an array containing field names and
640 * corresponding field values. The array is empty if the class has
641 * no static fields. If non-empty, field names are at array offsets 2*n,
642 * values at offset 2*n+1. Field values may also be a handle to an
643 * error object if an error was encountered evaluating the field.
644 */
645 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target);
646
647
648 /**
649 * Returns a handle to the library \library_id.
650 *
651 * Requires there to be a current isolate.
652 *
653 * \return A library handle if the id is valid.
654 */
655 DART_EXPORT Dart_Handle Dart_GetLibraryFromId(intptr_t library_id);
656
657
658 /**
659 * Returns in \library_id the library id of the given \library.
660 *
661 * \return A valid handle if no error occurs during the operation.
662 */
663 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library,
664 intptr_t* library_id);
665
666
667 /**
668 * Returns an array containing all variable names and values of
669 * the given library \library_id.
670 *
671 * Requires there to be a current isolate.
672 *
673 * \return A handle to an array containing variable names and
674 * corresponding values. The array is empty if the library has
675 * no variables. If non-empty, variable names are at array offsets 2*n,
676 * values at offset 2*n+1. Variable values may also be a handle to an
677 * error object if an error was encountered evaluating the value.
678 */
679 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id);
680
681
682 /**
683 * Returns an array containing all imported libraries of
684 * the given library \library_id.
685 *
686 * Requires there to be a current isolate.
687 *
688 * \return A handle to an array containing prefix names and
689 * library ids. The array is empty if the library has
690 * no imports. If non-empty, import prefixes are at array offsets 2*n,
691 * corresponding library ids at offset 2*n+1. Prefixes may be null
692 * which indicates the respective library has been imported without
693 * a prefix.
694 */
695 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id);
696
697
698 /**
699 * Returns the url of the library \library_id.
700 *
701 * Requires there to be a current isolate.
702 *
703 * \return A string handle containing the URL of the library.
704 */
705 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id);
706
707
708 /**
709 * Returns the isolate object corresponding to the isolate id.
710 *
711 * \return The Dart_Isolate object corresponding to the isolate id.
712 * If the specified id is invalid NULL is returned.
713 */
714 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id);
715
716
717 /**
718 * Returns the isolate id for an isolate.
719 *
720 * \return The Dart_IsolateId value corresponding to the isolate.
721 */
722 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate isolate);
723 11
724 #endif // INCLUDE_DART_DEBUGGER_API_H_ 12 #endif // INCLUDE_DART_DEBUGGER_API_H_
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/include/dart_tools_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698