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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 8826007: First bits of external debugger API (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
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 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
12 #include "vm/dart_api_state.h" 12 #include "vm/dart_api_state.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/debugger.h"
15 #include "vm/debuginfo.h" 14 #include "vm/debuginfo.h"
16 #include "vm/exceptions.h" 15 #include "vm/exceptions.h"
17 #include "vm/growable_array.h" 16 #include "vm/growable_array.h"
18 #include "vm/longjump.h" 17 #include "vm/longjump.h"
19 #include "vm/native_entry.h" 18 #include "vm/native_entry.h"
20 #include "vm/object.h" 19 #include "vm/object.h"
21 #include "vm/object_store.h" 20 #include "vm/object_store.h"
22 #include "vm/port.h" 21 #include "vm/port.h"
23 #include "vm/resolver.h" 22 #include "vm/resolver.h"
24 #include "vm/snapshot.h" 23 #include "vm/snapshot.h"
(...skipping 21 matching lines...) Expand all
46 return dart_handle; \ 45 return dart_handle; \
47 } else { \ 46 } else { \
48 return Api::Error("%s expects argument '%s' to be of type %s.", \ 47 return Api::Error("%s expects argument '%s' to be of type %s.", \
49 CURRENT_FUNC, #dart_handle, #Type); \ 48 CURRENT_FUNC, #dart_handle, #Type); \
50 } \ 49 } \
51 } while (0) 50 } while (0)
52 51
53 52
54 // Return error if isolate is in an inconsistent state. 53 // Return error if isolate is in an inconsistent state.
55 // Return NULL when no error condition exists. 54 // Return NULL when no error condition exists.
56 static const char* CheckIsolateState( 55 const char* CheckIsolateState(Isolate* isolate, bool generating_snapshot) {
57 Isolate* isolate,
58 bool generating_snapshot = ClassFinalizer::kNotGeneratingSnapshot) {
59 bool result = (generating_snapshot) ? 56 bool result = (generating_snapshot) ?
60 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() : 57 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() :
61 ClassFinalizer::FinalizePendingClasses(); 58 ClassFinalizer::FinalizePendingClasses();
62 if (!result) { 59 if (!result) {
63 // Make a copy of the error message as the original message string 60 // Make a copy of the error message as the original message string
64 // may get deallocated when we return back from the Dart API call. 61 // may get deallocated when we return back from the Dart API call.
65 const String& err = 62 const String& err =
66 String::Handle(isolate->object_store()->sticky_error()); 63 String::Handle(isolate->object_store()->sticky_error());
67 const char* errmsg = err.ToCString(); 64 const char* errmsg = err.ToCString();
68 intptr_t errlen = strlen(errmsg) + 1; 65 intptr_t errlen = strlen(errmsg) + 1;
69 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); 66 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen));
70 OS::SNPrint(msg, errlen, "%s", errmsg); 67 OS::SNPrint(msg, errlen, "%s", errmsg);
71 return msg; 68 return msg;
72 } 69 }
73 return NULL; 70 return NULL;
74 } 71 }
75 72
76 73
77 static void SetupErrorResult(Dart_Handle* handle) { 74 void SetupErrorResult(Dart_Handle* handle) {
78 // Make a copy of the error message as the original message string 75 // Make a copy of the error message as the original message string
79 // may get deallocated when we return back from the Dart API call. 76 // may get deallocated when we return back from the Dart API call.
80 const String& error = String::Handle( 77 const String& error = String::Handle(
81 Isolate::Current()->object_store()->sticky_error()); 78 Isolate::Current()->object_store()->sticky_error());
82 const Object& obj = Object::Handle(ApiError::New(error)); 79 const Object& obj = Object::Handle(ApiError::New(error));
83 *handle = Api::NewLocalHandle(obj); 80 *handle = Api::NewLocalHandle(obj);
84 } 81 }
85 82
86 83
87 // NOTE: Need to pass 'result' as a parameter here in order to avoid 84 // NOTE: Need to pass 'result' as a parameter here in order to avoid
88 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' 85 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
89 // which shows up because of the use of setjmp. 86 // which shows up because of the use of setjmp.
90 static void InvokeStatic(Isolate* isolate, 87 static void InvokeStatic(Isolate* isolate,
91 const Function& function, 88 const Function& function,
92 GrowableArray<const Object*>& args, 89 GrowableArray<const Object*>& args,
93 Dart_Handle* result) { 90 Dart_Handle* result) {
94 ASSERT(isolate != NULL); 91 ASSERT(isolate != NULL);
95 LongJump* base = isolate->long_jump_base(); 92 LongJump* base = isolate->long_jump_base();
96 LongJump jump; 93 LongJump jump;
97 isolate->set_long_jump_base(&jump); 94 isolate->set_long_jump_base(&jump);
98 if (setjmp(*jump.Set()) == 0) { 95 if (setjmp(*jump.Set()) == 0) {
99 isolate->debugger()->Initialize(isolate);
100 const Array& kNoArgumentNames = Array::Handle(); 96 const Array& kNoArgumentNames = Array::Handle();
101 const Instance& retval = Instance::Handle( 97 const Instance& retval = Instance::Handle(
102 DartEntry::InvokeStatic(function, args, kNoArgumentNames)); 98 DartEntry::InvokeStatic(function, args, kNoArgumentNames));
103 if (retval.IsUnhandledException()) { 99 if (retval.IsUnhandledException()) {
104 *result = Api::ErrorFromException(retval); 100 *result = Api::ErrorFromException(retval);
105 } else { 101 } else {
106 *result = Api::NewLocalHandle(retval); 102 *result = Api::NewLocalHandle(retval);
107 } 103 }
108 } else { 104 } else {
109 SetupErrorResult(result); 105 SetupErrorResult(result);
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 } 2403 }
2408 delete debug_region; 2404 delete debug_region;
2409 } else { 2405 } else {
2410 *buffer = NULL; 2406 *buffer = NULL;
2411 *buffer_size = 0; 2407 *buffer_size = 0;
2412 } 2408 }
2413 } 2409 }
2414 2410
2415 2411
2416 } // namespace dart 2412 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698