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

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

Issue 979823003: Major rework of vm service events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service.h ('k') | runtime/vm/service/service.idl » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
11 #include "vm/coverage.h" 11 #include "vm/coverage.h"
12 #include "vm/cpu.h" 12 #include "vm/cpu.h"
13 #include "vm/dart_api_impl.h" 13 #include "vm/dart_api_impl.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/debugger.h" 15 #include "vm/debugger.h"
16 #include "vm/isolate.h" 16 #include "vm/isolate.h"
17 #include "vm/lockers.h" 17 #include "vm/lockers.h"
18 #include "vm/message.h" 18 #include "vm/message.h"
19 #include "vm/message_handler.h" 19 #include "vm/message_handler.h"
20 #include "vm/native_entry.h" 20 #include "vm/native_entry.h"
21 #include "vm/native_arguments.h" 21 #include "vm/native_arguments.h"
22 #include "vm/object.h" 22 #include "vm/object.h"
23 #include "vm/object_graph.h" 23 #include "vm/object_graph.h"
24 #include "vm/object_id_ring.h" 24 #include "vm/object_id_ring.h"
25 #include "vm/object_store.h" 25 #include "vm/object_store.h"
26 #include "vm/parser.h" 26 #include "vm/parser.h"
27 #include "vm/port.h" 27 #include "vm/port.h"
28 #include "vm/profiler_service.h" 28 #include "vm/profiler_service.h"
29 #include "vm/reusable_handles.h" 29 #include "vm/reusable_handles.h"
30 #include "vm/service_event.h"
30 #include "vm/service_isolate.h" 31 #include "vm/service_isolate.h"
31 #include "vm/stack_frame.h" 32 #include "vm/stack_frame.h"
32 #include "vm/symbols.h" 33 #include "vm/symbols.h"
33 #include "vm/unicode.h" 34 #include "vm/unicode.h"
34 #include "vm/version.h" 35 #include "vm/version.h"
35 36
36 namespace dart { 37 namespace dart {
37 38
38 DECLARE_FLAG(bool, trace_service); 39 DECLARE_FLAG(bool, trace_service);
39 DECLARE_FLAG(bool, trace_service_pause_events); 40 DECLARE_FLAG(bool, trace_service_pause_events);
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 ASSERT(isolate != NULL); 495 ASSERT(isolate != NULL);
495 InvokeMethod(isolate, msg); 496 InvokeMethod(isolate, msg);
496 } 497 }
497 498
498 499
499 bool Service::EventMaskHas(uint32_t mask) { 500 bool Service::EventMaskHas(uint32_t mask) {
500 return (event_mask_ & mask) != 0; 501 return (event_mask_ & mask) != 0;
501 } 502 }
502 503
503 504
505 bool Service::NeedsEvents() {
506 return ServiceIsolate::IsRunning();
507 }
508
509
504 bool Service::NeedsDebuggerEvents() { 510 bool Service::NeedsDebuggerEvents() {
505 return ServiceIsolate::IsRunning() && EventMaskHas(kEventFamilyDebugMask); 511 return NeedsEvents() && EventMaskHas(kEventFamilyDebugMask);
506 } 512 }
507 513
508 514
509 bool Service::NeedsGCEvents() { 515 bool Service::NeedsGCEvents() {
510 return ServiceIsolate::IsRunning() && EventMaskHas(kEventFamilyGCMask); 516 return NeedsEvents() && EventMaskHas(kEventFamilyGCMask);
511 } 517 }
512 518
513 519
514 void Service::SetEventMask(uint32_t mask) { 520 void Service::SetEventMask(uint32_t mask) {
515 event_mask_ = mask; 521 event_mask_ = mask;
516 } 522 }
517 523
518 524
519 void Service::SendEvent(intptr_t eventId, const Object& eventMessage) { 525 void Service::SendEvent(intptr_t eventId, const Object& eventMessage) {
520 if (!ServiceIsolate::IsRunning()) { 526 if (!ServiceIsolate::IsRunning()) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 582
577 583
578 void Service::HandleGCEvent(GCEvent* event) { 584 void Service::HandleGCEvent(GCEvent* event) {
579 JSONStream js; 585 JSONStream js;
580 event->PrintJSON(&js); 586 event->PrintJSON(&js);
581 const String& message = String::Handle(String::New(js.ToCString())); 587 const String& message = String::Handle(String::New(js.ToCString()));
582 SendEvent(kEventFamilyGC, message); 588 SendEvent(kEventFamilyGC, message);
583 } 589 }
584 590
585 591
586 void Service::HandleDebuggerEvent(DebuggerEvent* event) { 592 void Service::HandleEvent(ServiceEvent* event) {
587 JSONStream js; 593 JSONStream js;
588 event->PrintJSON(&js); 594 event->PrintJSON(&js);
589 const String& message = String::Handle(String::New(js.ToCString())); 595 const String& message = String::Handle(String::New(js.ToCString()));
590 SendEvent(kEventFamilyDebug, message); 596 SendEvent(kEventFamilyDebug, message);
591 } 597 }
592 598
593 599
594 class EmbedderServiceHandler { 600 class EmbedderServiceHandler {
595 public: 601 public:
596 explicit EmbedderServiceHandler(const char* name) : name_(NULL), 602 explicit EmbedderServiceHandler(const char* name) : name_(NULL),
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 2015
2010 2016
2011 static bool Resume(Isolate* isolate, JSONStream* js) { 2017 static bool Resume(Isolate* isolate, JSONStream* js) {
2012 const char* step_param = js->LookupParam("step"); 2018 const char* step_param = js->LookupParam("step");
2013 if (isolate->message_handler()->paused_on_start()) { 2019 if (isolate->message_handler()->paused_on_start()) {
2014 isolate->message_handler()->set_pause_on_start(false); 2020 isolate->message_handler()->set_pause_on_start(false);
2015 JSONObject jsobj(js); 2021 JSONObject jsobj(js);
2016 jsobj.AddProperty("type", "Success"); 2022 jsobj.AddProperty("type", "Success");
2017 jsobj.AddProperty("id", ""); 2023 jsobj.AddProperty("id", "");
2018 { 2024 {
2019 DebuggerEvent resumeEvent(isolate, DebuggerEvent::kIsolateResumed); 2025 ServiceEvent event(isolate, ServiceEvent::kResume);
2020 Service::HandleDebuggerEvent(&resumeEvent); 2026 Service::HandleEvent(&event);
2021 } 2027 }
2022 return true; 2028 return true;
2023 } 2029 }
2024 if (isolate->message_handler()->paused_on_exit()) { 2030 if (isolate->message_handler()->paused_on_exit()) {
2025 isolate->message_handler()->set_pause_on_exit(false); 2031 isolate->message_handler()->set_pause_on_exit(false);
2026 JSONObject jsobj(js); 2032 JSONObject jsobj(js);
2027 jsobj.AddProperty("type", "Success"); 2033 jsobj.AddProperty("type", "Success");
2028 jsobj.AddProperty("id", ""); 2034 jsobj.AddProperty("id", "");
2029 // We don't send a resume event because we will be exiting. 2035 // We don't send a resume event because we will be exiting.
2030 return true; 2036 return true;
(...skipping 16 matching lines...) Expand all
2047 jsobj.AddProperty("type", "Success"); 2053 jsobj.AddProperty("type", "Success");
2048 jsobj.AddProperty("id", ""); 2054 jsobj.AddProperty("id", "");
2049 return true; 2055 return true;
2050 } 2056 }
2051 2057
2052 PrintError(js, "VM was not paused"); 2058 PrintError(js, "VM was not paused");
2053 return true; 2059 return true;
2054 } 2060 }
2055 2061
2056 2062
2057 static const MethodParameter* get_breakpoints_params[] = {
2058 ISOLATE_PARAMETER,
2059 NULL,
2060 };
2061
2062
2063 static bool GetBreakpoints(Isolate* isolate, JSONStream* js) {
2064 JSONObject jsobj(js);
2065 jsobj.AddProperty("type", "BreakpointList");
2066 JSONArray jsarr(&jsobj, "breakpoints");
2067 isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr);
2068 return true;
2069 }
2070
2071
2072 static const MethodParameter* pause_params[] = { 2063 static const MethodParameter* pause_params[] = {
2073 ISOLATE_PARAMETER, 2064 ISOLATE_PARAMETER,
2074 NULL, 2065 NULL,
2075 }; 2066 };
2076 2067
2077 2068
2078 static bool Pause(Isolate* isolate, JSONStream* js) { 2069 static bool Pause(Isolate* isolate, JSONStream* js) {
2079 // TODO(turnidge): Don't double-interrupt the isolate here. 2070 // TODO(turnidge): Don't double-interrupt the isolate here.
2080 isolate->ScheduleInterrupts(Isolate::kApiInterrupt); 2071 isolate->ScheduleInterrupts(Isolate::kApiInterrupt);
2081 JSONObject jsobj(js); 2072 JSONObject jsobj(js);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 { "addBreakpoint", AddBreakpoint, 2501 { "addBreakpoint", AddBreakpoint,
2511 add_breakpoint_params }, 2502 add_breakpoint_params },
2512 { "addBreakpointAtEntry", AddBreakpointAtEntry, 2503 { "addBreakpointAtEntry", AddBreakpointAtEntry,
2513 add_breakpoint_at_entry_params }, 2504 add_breakpoint_at_entry_params },
2514 { "clearCpuProfile", ClearCpuProfile, 2505 { "clearCpuProfile", ClearCpuProfile,
2515 clear_cpu_profile_params }, 2506 clear_cpu_profile_params },
2516 { "eval", Eval, 2507 { "eval", Eval,
2517 eval_params }, 2508 eval_params },
2518 { "getAllocationProfile", GetAllocationProfile, 2509 { "getAllocationProfile", GetAllocationProfile,
2519 get_allocation_profile_params }, 2510 get_allocation_profile_params },
2520 { "getBreakpoints", GetBreakpoints,
2521 get_breakpoints_params },
2522 { "getCallSiteData", GetCallSiteData, 2511 { "getCallSiteData", GetCallSiteData,
2523 get_call_site_data_params }, 2512 get_call_site_data_params },
2524 { "getClassList", GetClassList, 2513 { "getClassList", GetClassList,
2525 get_class_list_params }, 2514 get_class_list_params },
2526 { "getCoverage", GetCoverage, 2515 { "getCoverage", GetCoverage,
2527 get_coverage_params }, 2516 get_coverage_params },
2528 { "getCpuProfile", GetCpuProfile, 2517 { "getCpuProfile", GetCpuProfile,
2529 get_cpu_profile_params }, 2518 get_cpu_profile_params },
2530 { "getFlagList", GetFlagList , 2519 { "getFlagList", GetFlagList ,
2531 get_flag_list_params }, 2520 get_flag_list_params },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 ServiceMethodDescriptor& method = service_methods_[i]; 2570 ServiceMethodDescriptor& method = service_methods_[i];
2582 if (strcmp(method_name, method.name) == 0) { 2571 if (strcmp(method_name, method.name) == 0) {
2583 return &method; 2572 return &method;
2584 } 2573 }
2585 } 2574 }
2586 return NULL; 2575 return NULL;
2587 } 2576 }
2588 2577
2589 2578
2590 } // namespace dart 2579 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.h ('k') | runtime/vm/service/service.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698