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

Side by Side Diff: src/vm/session.cc

Issue 1987673002: Initial Implementation of the vm-service protocol (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Keep track of terminated state Created 4 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 | « pkg/dartino_compiler/lib/vm_context.dart ('k') | no next file » | 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) 2014, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #ifdef DARTINO_ENABLE_DEBUGGING 5 #ifdef DARTINO_ENABLE_DEBUGGING
6 6
7 #include "src/vm/session.h" 7 #include "src/vm/session.h"
8 8
9 #include "src/shared/bytecodes.h" 9 #include "src/shared/bytecodes.h"
10 #include "src/shared/connection.h" 10 #include "src/shared/connection.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 Scheduler::ProcessInterruptionEvent HandleUncaughtException( 310 Scheduler::ProcessInterruptionEvent HandleUncaughtException(
311 Process* process) { 311 Process* process) {
312 if (IsDebuggingEnabled() || ObserveTermination(process)) { 312 if (IsDebuggingEnabled() || ObserveTermination(process)) {
313 ProcessDebugInfo* debug_info = process->debug_info(); 313 ProcessDebugInfo* debug_info = process->debug_info();
314 if (debug_info->is_stepping()) { 314 if (debug_info->is_stepping()) {
315 debug_info->ClearSteppingInterrupted(); 315 debug_info->ClearSteppingInterrupted();
316 } 316 }
317 WriteBuffer buffer; 317 WriteBuffer buffer;
318 buffer.WriteInt(debug_info->process_id());
319 session()->PushTopStackFrame(process->stack());
320 buffer.WriteInt64(
321 session()->FunctionMessage(Function::cast(session()->Top())));
322 // Drop function from session stack.
323 session()->Drop(1);
324 // Pop bytecode index from session stack and send it.
325 buffer.WriteInt64(session()->PopInteger());
318 connection()->Send(Connection::kUncaughtException, buffer); 326 connection()->Send(Connection::kUncaughtException, buffer);
319 // If observing termination, remain paused to allow access to the 327 // If observing termination, remain paused to allow access to the
320 // termination state. 328 // termination state.
321 return Scheduler::kRemainPaused; 329 return Scheduler::kRemainPaused;
322 } 330 }
323 return Scheduler::kExitWithUncaughtException; 331 return Scheduler::kExitWithUncaughtException;
324 } 332 }
325 333
326 Scheduler::ProcessInterruptionEvent HandleCompileTimeError(Process* process) { 334 Scheduler::ProcessInterruptionEvent HandleCompileTimeError(Process* process) {
327 if (IsDebuggingEnabled() || ObserveTermination(process)) { 335 if (IsDebuggingEnabled() || ObserveTermination(process)) {
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 case Connection::kMapLookup: { 847 case Connection::kMapLookup: {
840 ASSERT(!IsScheduled() || IsPaused()); 848 ASSERT(!IsScheduled() || IsPaused());
841 int map_index = connection()->ReadInt(); 849 int map_index = connection()->ReadInt();
842 WriteBuffer buffer; 850 WriteBuffer buffer;
843 buffer.WriteInt64( 851 buffer.WriteInt64(
844 session()->MapLookupByObject(map_index, session()->Top())); 852 session()->MapLookupByObject(map_index, session()->Top()));
845 connection()->Send(Connection::kObjectId, buffer); 853 connection()->Send(Connection::kObjectId, buffer);
846 break; 854 break;
847 } 855 }
848 856
857 case Connection::kProcessGetProcessIds: {
858 int count = 0;
859 auto processes = program()->process_list();
860 for (auto process : *processes) {
861 USE(process);
862 ++count;
863 }
864 WriteBuffer buffer;
865 buffer.WriteInt(count);
866 for (auto process : *processes) {
867 process->EnsureDebuggerAttached();
868 buffer.WriteInt(process->debug_info()->process_id());
869 }
870 connection()->Send(Connection::kProcessGetProcessIdsResult, buffer);
871 break;
872 }
873
849 #ifdef DARTINO_ENABLE_LIVE_CODING 874 #ifdef DARTINO_ENABLE_LIVE_CODING
850 case Connection::kSetEntryPoint: { 875 case Connection::kSetEntryPoint: {
851 program()->set_entry(Function::cast(session()->Pop())); 876 program()->set_entry(Function::cast(session()->Pop()));
852 break; 877 break;
853 } 878 }
854 879
855 case Connection::kCreateSnapshot: { 880 case Connection::kCreateSnapshot: {
856 ASSERT(!IsScheduled()); 881 ASSERT(!IsScheduled());
857 bool writeToDisk = connection()->ReadBoolean(); 882 bool writeToDisk = connection()->ReadBoolean();
858 int length; 883 int length;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 stack->set_next(Smi::FromWord(0)); 1404 stack->set_next(Smi::FromWord(0));
1380 } 1405 }
1381 ASSERT(current == NULL); 1406 ASSERT(current == NULL);
1382 program()->ClearStackChain(); 1407 program()->ClearStackChain();
1383 WriteBuffer buffer; 1408 WriteBuffer buffer;
1384 buffer.WriteInt(number_of_stacks); 1409 buffer.WriteInt(number_of_stacks);
1385 connection()->Send(Connection::kProcessNumberOfStacks, buffer); 1410 connection()->Send(Connection::kProcessNumberOfStacks, buffer);
1386 break; 1411 break;
1387 } 1412 }
1388 1413
1389 case Connection::kProcessGetProcessIds: {
1390 int count = 0;
1391 auto processes = program()->process_list();
1392 for (auto process : *processes) {
1393 USE(process);
1394 ++count;
1395 }
1396 WriteBuffer buffer;
1397 buffer.WriteInt(count);
1398 for (auto process : *processes) {
1399 process->EnsureDebuggerAttached();
1400 buffer.WriteInt(process->debug_info()->process_id());
1401 }
1402 connection()->Send(Connection::kProcessGetProcessIdsResult, buffer);
1403 break;
1404 }
1405
1406 default: { 1414 default: {
1407 return ScheduledState::ProcessMessage(opcode); 1415 return ScheduledState::ProcessMessage(opcode);
1408 } 1416 }
1409 } 1417 }
1410 return this; 1418 return this;
1411 } 1419 }
1412 1420
1413 SessionState* TerminatedState::ProcessMessage(Connection::Opcode opcode) { 1421 SessionState* TerminatedState::ProcessMessage(Connection::Opcode opcode) {
1414 if (opcode == Connection::kSessionEnd) { 1422 if (opcode == Connection::kSessionEnd) {
1415 session()->SignalMainThread(Session::kSessionEnd); 1423 session()->SignalMainThread(Session::kSessionEnd);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 if (program()->was_loaded_from_snapshot()) { 2248 if (program()->was_loaded_from_snapshot()) {
2241 return program()->OffsetOf(HeapObject::cast(klass)); 2249 return program()->OffsetOf(HeapObject::cast(klass));
2242 } else { 2250 } else {
2243 return MapLookupByObject(class_map_id_, klass); 2251 return MapLookupByObject(class_map_id_, klass);
2244 } 2252 }
2245 } 2253 }
2246 2254
2247 } // namespace dartino 2255 } // namespace dartino
2248 2256
2249 #endif // DARTINO_ENABLE_DEBUGGING 2257 #endif // DARTINO_ENABLE_DEBUGGING
OLDNEW
« no previous file with comments | « pkg/dartino_compiler/lib/vm_context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698