32DEFINE_FLAG(
bool, trace_service,
false,
"Trace VM service requests.");
34 trace_service_pause_events,
36 "Trace VM service isolate pause events.");
38 trace_service_verbose,
40 "Provide extra service tracing information.");
43#define VM_SERVICE_ISOLATE_EXIT_MESSAGE_ID 0
44#define VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID 1
45#define VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID 2
47#define VM_SERVICE_WEB_SERVER_CONTROL_MESSAGE_ID 3
48#define VM_SERVICE_SERVER_INFO_MESSAGE_ID 4
50#define VM_SERVICE_METHOD_CALL_FROM_NATIVE 5
81 message.value.as_array.length = 4;
91 const Bool& silenceOutput) {
97 list.
SetAt(3, silenceOutput);
123 const Bool& silenceOutput) {
136 if (address ==
nullptr) {
170 intptr_t request_json_length,
181 message.value.as_typed_data.length = request_json_length;
182 message.value.as_typed_data.values = request_json;
201 bool success =
false;
204 if (!success &&
error !=
nullptr) {
208 if (
error !=
nullptr) {
211 "Service isolate failed to start up: %s.",
232 if (FLAG_trace_service) {
235 isolate->
name(), main_port);
255 if (FLAG_trace_service) {
258 isolate->
name(), main_port);
270 if (FLAG_trace_service) {
272 ": sending service exit message.\n");
282 message.value.as_array.length = 1;
299 ASSERT(isolate->is_service_isolate());
309 if (!
I->is_service_isolate()) {
349#if defined(SUPPORT_TIMELINE)
350 TimelineBeginEndScope tbes(Timeline::GetVMStream(),
351 "ServiceIsolateStartup");
353 char*
error =
nullptr;
357 ASSERT(create_group_callback !=
nullptr);
363 isolate =
reinterpret_cast<Isolate*
>(
365 nullptr,
nullptr, &api_flags,
nullptr, &
error));
366 if (isolate ==
nullptr) {
367 if (FLAG_trace_service) {
369 ": Isolate creation error: %s\n",
374 nullptr,
"Invoking the 'create_group' failed with: '%s'",
402 reinterpret_cast<uword>(isolate));
407 if (FLAG_trace_service) {
417 auto I =
T->isolate();
418 ASSERT(
I->is_service_isolate());
423 error =
T->sticky_error();
424 if (!
error.IsNull() && !
error.IsUnwindError()) {
426 error.ToErrorCString());
428 error =
I->sticky_error();
429 if (!
error.IsNull() && !
error.IsUnwindError()) {
431 error.ToErrorCString());
435 if (FLAG_trace_service) {
448 if (root_library.
IsNull()) {
449 if (FLAG_trace_service) {
451 ": Embedder did not install a script.");
463 if (FLAG_trace_service) {
465 ": Embedder did not provide a main function.");
474 if (FLAG_trace_service) {
477 ": Calling main resulted in an error: %s",
478 error.ToErrorCString());
480 if (
result.IsUnwindError()) {
501 Utils::StrDup(
"The 'create_group' callback was not provided"));
508void ServiceIsolate::KillServiceIsolate() {
557 KillServiceIsolate();
573 const Library& vmservice_library =
583 if (
result.IsUnwindError() ||
result.IsUnhandledException()) {
587 if (
result.IsReceivePort()) {
598 auto zone = thread->zone();
600 ASSERT(thread->isolate()->is_service_isolate());
603 const String& library_url = Symbols::DartVMService();
611 const Function& register_function_ =
621 for (intptr_t
i = 0;
i < isolate_ports.
length(); ++
i) {
627 args.SetAt(0, port_int);
628 args.SetAt(1, send_port);
631 if (FLAG_trace_service) {
633 name.ToCString(), port_id);
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
void SetAt(intptr_t index, const Object &value) const
static const Bool & Get(bool value)
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
static ThreadPool * thread_pool()
static DART_NORETURN void PropagateError(const Error &error)
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
MutatorThreadPool * thread_pool()
static Isolate * Current()
static void KillIfExists(Isolate *isolate, LibMsgId msg_id)
MessageHandler * message_handler() const
bool is_vm_isolate() const
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
IsolateGroup * group() const
static Dart_IsolateGroupCreateCallback CreateGroupCallback()
void set_is_service_registered(bool value)
Dart_Port main_port() const
const char * name() const
FunctionPtr LookupFunctionAllowPrivate(const String &name) const
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
bool Run(ThreadPool *pool, StartCallback start_callback, EndCallback end_callback, CallbackData data)
Monitor::WaitResult Wait(int64_t millis=Monitor::kNoTimeout)
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
static bool PostMessage(std::unique_ptr< Message > message, bool before_events=false)
static void ShutdownIsolate(uword parameter)
static SendPortPtr New(Dart_Port id, Heap::Space space=Heap::kNew)
static void FinishedExiting()
static void ControlWebServer(const SendPort &sp, bool enable, const Bool &silenceOutput)
static void SetServiceIsolate(Isolate *isolate)
static void RequestServerInfo(const SendPort &sp)
static bool SendIsolateStartupMessage()
static void VisitObjectPointers(ObjectPointerVisitor *visitor)
static Monitor * monitor_
static const char * kName
static bool SendServiceControlMessage(Thread *thread, Dart_Port port_id, intptr_t code, const char *name)
static void FinishedInitializing()
static bool SendIsolateShutdownMessage()
static char * server_address_
static Dart_IsolateGroupCreateCallback create_group_callback()
static bool IsServiceIsolateDescendant(Isolate *isolate)
static void RegisterRunningIsolates(const GrowableArray< Dart_Port > &isolate_ports, const GrowableArray< const String * > &isolate_names)
static Dart_IsolateGroupCreateCallback create_group_callback_
static void WaitForServiceIsolateStartup()
static bool SendServiceRpc(uint8_t *request_json, intptr_t request_json_length, Dart_Port reply_port, char **error)
static void SetServerAddress(const char *address)
static void InitializingFailed(char *error)
static void SetServicePort(Dart_Port port)
static Isolate * isolate_
static void MaybeMakeServiceIsolate(Isolate *isolate)
static void SendServiceExitMessage()
static void BootVmServiceLibrary()
static char * startup_failure_reason_
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
bool Run(Args &&... args)
static Thread * Current()
Isolate * isolate() const
static char * StrDup(const char *s)
Dart_Isolate(* Dart_IsolateGroupCreateCallback)(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error)
struct _Dart_Isolate * Dart_Isolate
#define DART_VM_SERVICE_ISOLATE_NAME
@ Dart_CObject_kTypedData
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
DART_EXPORT Dart_Port Dart_GetMainPortId()
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
static ArrayPtr MakeServerControlMessage(const SendPort &sp, intptr_t code, bool enable, const Bool &silenceOutput)
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
std::unique_ptr< Message > WriteMessage(bool same_group, const Object &obj, Dart_Port dest_port, Message::Priority priority)
std::unique_ptr< Message > WriteApiMessage(Zone *zone, Dart_CObject *obj, Dart_Port dest_port, Message::Priority priority)
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject *message)
const char *const function_name
DART_EXPORT void Dart_ShutdownIsolate()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
struct _Dart_CObject::@86::@87 as_send_port
union _Dart_CObject::@86 value
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values
#define VM_SERVICE_WEB_SERVER_CONTROL_MESSAGE_ID
#define VM_SERVICE_ISOLATE_EXIT_MESSAGE_ID
#define VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID
#define VM_SERVICE_METHOD_CALL_FROM_NATIVE
#define VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID
#define VM_SERVICE_SERVER_INFO_MESSAGE_ID
#define ARRAY_SIZE(array)