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

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

Issue 2523053002: Implement rewind: drop one or more frames from the debugger. (Closed)
Patch Set: code review Created 4 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
« no previous file with comments | « runtime/vm/runtime_entry_list.h ('k') | runtime/vm/simulator_dbc.cc » ('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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 2970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 int64_t time_origin_micros = 2981 int64_t time_origin_micros =
2982 Int64Parameter::Parse(js->LookupParam("timeOriginMicros")); 2982 Int64Parameter::Parse(js->LookupParam("timeOriginMicros"));
2983 int64_t time_extent_micros = 2983 int64_t time_extent_micros =
2984 Int64Parameter::Parse(js->LookupParam("timeExtentMicros")); 2984 Int64Parameter::Parse(js->LookupParam("timeExtentMicros"));
2985 TimelineEventFilter filter(time_origin_micros, time_extent_micros); 2985 TimelineEventFilter filter(time_origin_micros, time_extent_micros);
2986 timeline_recorder->PrintJSON(js, &filter); 2986 timeline_recorder->PrintJSON(js, &filter);
2987 return true; 2987 return true;
2988 } 2988 }
2989 2989
2990 2990
2991 static const char* const step_enum_names[] = {
2992 "None", "Into", "Over", "Out", "Rewind", "OverAsyncSuspension", NULL,
2993 };
2994
2995
2996 static const Debugger::ResumeAction step_enum_values[] = {
2997 Debugger::kContinue, Debugger::kStepInto,
2998 Debugger::kStepOver, Debugger::kStepOut,
2999 Debugger::kStepRewind, Debugger::kStepOverAsyncSuspension,
3000 Debugger::kContinue, // Default value
3001 };
3002
3003
2991 static const MethodParameter* resume_params[] = { 3004 static const MethodParameter* resume_params[] = {
2992 RUNNABLE_ISOLATE_PARAMETER, NULL, 3005 RUNNABLE_ISOLATE_PARAMETER,
3006 new EnumParameter("step", false, step_enum_names),
3007 new UIntParameter("frameIndex", false), NULL,
2993 }; 3008 };
2994 3009
2995 3010
2996 static bool Resume(Thread* thread, JSONStream* js) { 3011 static bool Resume(Thread* thread, JSONStream* js) {
2997 const char* step_param = js->LookupParam("step"); 3012 const char* step_param = js->LookupParam("step");
3013 Debugger::ResumeAction step = Debugger::kContinue;
3014 if (step_param != NULL) {
3015 step = EnumMapper(step_param, step_enum_names, step_enum_values);
3016 }
3017 #if defined(TARGET_ARCH_DBC)
3018 if (step == Debugger::kStepRewind) {
3019 js->PrintError(kCannotResume,
3020 "Rewind not yet implemented on this architecture");
3021 return true;
3022 }
3023 #endif
3024 intptr_t frame_index = 1;
3025 const char* frame_index_param = js->LookupParam("frameIndex");
3026 if (frame_index_param != NULL) {
3027 if (step != Debugger::kStepRewind) {
3028 // Only rewind supports the frameIndex parameter.
3029 js->PrintError(
3030 kInvalidParams,
3031 "%s: the 'frameIndex' parameter can only be used when rewinding",
3032 js->method());
3033 return true;
3034 }
3035 frame_index = UIntParameter::Parse(js->LookupParam("frameIndex"));
3036 }
2998 Isolate* isolate = thread->isolate(); 3037 Isolate* isolate = thread->isolate();
2999 if (isolate->message_handler()->is_paused_on_start()) { 3038 if (isolate->message_handler()->is_paused_on_start()) {
3000 // If the user is issuing a 'Over' or an 'Out' step, that is the 3039 // If the user is issuing a 'Over' or an 'Out' step, that is the
3001 // same as a regular resume request. 3040 // same as a regular resume request.
3002 if ((step_param != NULL) && (strcmp(step_param, "Into") == 0)) { 3041 if (step == Debugger::kStepInto) {
3003 isolate->debugger()->EnterSingleStepMode(); 3042 isolate->debugger()->EnterSingleStepMode();
3004 } 3043 }
3005 isolate->message_handler()->set_should_pause_on_start(false); 3044 isolate->message_handler()->set_should_pause_on_start(false);
3006 isolate->SetResumeRequest(); 3045 isolate->SetResumeRequest();
3007 if (Service::debug_stream.enabled()) { 3046 if (Service::debug_stream.enabled()) {
3008 ServiceEvent event(isolate, ServiceEvent::kResume); 3047 ServiceEvent event(isolate, ServiceEvent::kResume);
3009 Service::HandleEvent(&event); 3048 Service::HandleEvent(&event);
3010 } 3049 }
3011 PrintSuccess(js); 3050 PrintSuccess(js);
3012 return true; 3051 return true;
3013 } 3052 }
3014 if (isolate->message_handler()->should_pause_on_start()) { 3053 if (isolate->message_handler()->should_pause_on_start()) {
3015 isolate->message_handler()->set_should_pause_on_start(false); 3054 isolate->message_handler()->set_should_pause_on_start(false);
3016 isolate->SetResumeRequest(); 3055 isolate->SetResumeRequest();
3017 if (Service::debug_stream.enabled()) { 3056 if (Service::debug_stream.enabled()) {
3018 ServiceEvent event(isolate, ServiceEvent::kResume); 3057 ServiceEvent event(isolate, ServiceEvent::kResume);
3019 Service::HandleEvent(&event); 3058 Service::HandleEvent(&event);
3020 } 3059 }
3021 PrintSuccess(js); 3060 PrintSuccess(js);
3022 return true; 3061 return true;
3023 } 3062 }
3024 if (isolate->message_handler()->is_paused_on_exit()) { 3063 if (isolate->message_handler()->is_paused_on_exit()) {
3025 isolate->message_handler()->set_should_pause_on_exit(false); 3064 isolate->message_handler()->set_should_pause_on_exit(false);
3026 isolate->SetResumeRequest(); 3065 isolate->SetResumeRequest();
3027 // We don't send a resume event because we will be exiting. 3066 // We don't send a resume event because we will be exiting.
3028 PrintSuccess(js); 3067 PrintSuccess(js);
3029 return true; 3068 return true;
3030 } 3069 }
3031 if (isolate->debugger()->PauseEvent() != NULL) { 3070 if (isolate->debugger()->PauseEvent() == NULL) {
3032 if (step_param != NULL) { 3071 js->PrintError(kIsolateMustBePaused, NULL);
3033 if (strcmp(step_param, "Into") == 0) {
3034 isolate->debugger()->SetSingleStep();
3035 } else if (strcmp(step_param, "Over") == 0) {
3036 isolate->debugger()->SetStepOver();
3037 } else if (strcmp(step_param, "Out") == 0) {
3038 isolate->debugger()->SetStepOut();
3039 } else if (strcmp(step_param, "OverAsyncSuspension") == 0) {
3040 if (!isolate->debugger()->SetupStepOverAsyncSuspension()) {
3041 js->PrintError(kInvalidParams,
3042 "Isolate must be paused at an async suspension point");
3043 return true;
3044 }
3045 } else {
3046 PrintInvalidParamError(js, "step");
3047 return true;
3048 }
3049 }
3050 isolate->SetResumeRequest();
3051 PrintSuccess(js);
3052 return true; 3072 return true;
3053 } 3073 }
3054 3074
3055 js->PrintError(kIsolateMustBePaused, NULL); 3075 const char* error = NULL;
3076 if (!isolate->debugger()->SetResumeAction(step, frame_index, &error)) {
3077 js->PrintError(kCannotResume, error);
3078 return true;
3079 }
3080 isolate->SetResumeRequest();
3081 PrintSuccess(js);
3056 return true; 3082 return true;
3057 } 3083 }
3058 3084
3059 3085
3060 static const MethodParameter* pause_params[] = { 3086 static const MethodParameter* pause_params[] = {
3061 RUNNABLE_ISOLATE_PARAMETER, NULL, 3087 RUNNABLE_ISOLATE_PARAMETER, NULL,
3062 }; 3088 };
3063 3089
3064 3090
3065 static bool Pause(Thread* thread, JSONStream* js) { 3091 static bool Pause(Thread* thread, JSONStream* js) {
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
4081 if (strcmp(method_name, method.name) == 0) { 4107 if (strcmp(method_name, method.name) == 0) {
4082 return &method; 4108 return &method;
4083 } 4109 }
4084 } 4110 }
4085 return NULL; 4111 return NULL;
4086 } 4112 }
4087 4113
4088 #endif // !PRODUCT 4114 #endif // !PRODUCT
4089 4115
4090 } // namespace dart 4116 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/runtime_entry_list.h ('k') | runtime/vm/simulator_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698