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

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: cleanup 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
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 stack->set_next(Smi::FromWord(0)); 1385 stack->set_next(Smi::FromWord(0));
1361 } 1386 }
1362 ASSERT(current == NULL); 1387 ASSERT(current == NULL);
1363 program()->ClearStackChain(); 1388 program()->ClearStackChain();
1364 WriteBuffer buffer; 1389 WriteBuffer buffer;
1365 buffer.WriteInt(number_of_stacks); 1390 buffer.WriteInt(number_of_stacks);
1366 connection()->Send(Connection::kProcessNumberOfStacks, buffer); 1391 connection()->Send(Connection::kProcessNumberOfStacks, buffer);
1367 break; 1392 break;
1368 } 1393 }
1369 1394
1370 case Connection::kProcessGetProcessIds: {
1371 int count = 0;
1372 auto processes = program()->process_list();
1373 for (auto process : *processes) {
1374 USE(process);
1375 ++count;
1376 }
1377 WriteBuffer buffer;
1378 buffer.WriteInt(count);
1379 for (auto process : *processes) {
1380 process->EnsureDebuggerAttached();
1381 buffer.WriteInt(process->debug_info()->process_id());
1382 }
1383 connection()->Send(Connection::kProcessGetProcessIdsResult, buffer);
1384 break;
1385 }
1386
1387 default: { 1395 default: {
1388 return ScheduledState::ProcessMessage(opcode); 1396 return ScheduledState::ProcessMessage(opcode);
1389 } 1397 }
1390 } 1398 }
1391 return this; 1399 return this;
1392 } 1400 }
1393 1401
1394 SessionState* TerminatedState::ProcessMessage(Connection::Opcode opcode) { 1402 SessionState* TerminatedState::ProcessMessage(Connection::Opcode opcode) {
1395 if (opcode == Connection::kSessionEnd) { 1403 if (opcode == Connection::kSessionEnd) {
1396 session()->SignalMainThread(Session::kSessionEnd); 1404 session()->SignalMainThread(Session::kSessionEnd);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 if (program()->was_loaded_from_snapshot()) { 2229 if (program()->was_loaded_from_snapshot()) {
2222 return program()->OffsetOf(HeapObject::cast(klass)); 2230 return program()->OffsetOf(HeapObject::cast(klass));
2223 } else { 2231 } else {
2224 return MapLookupByObject(class_map_id_, klass); 2232 return MapLookupByObject(class_map_id_, klass);
2225 } 2233 }
2226 } 2234 }
2227 2235
2228 } // namespace dartino 2236 } // namespace dartino
2229 2237
2230 #endif // DARTINO_ENABLE_DEBUGGING 2238 #endif // DARTINO_ENABLE_DEBUGGING
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698