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

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

Issue 175533003: Handle stepping requests after isolate interrupt event (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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/debugger.cc ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 EXPECT(Dart_GetIsolate(test_isolate_id) == isolate); 1301 EXPECT(Dart_GetIsolate(test_isolate_id) == isolate);
1302 EXPECT(Dart_GetIsolateId(isolate) == test_isolate_id); 1302 EXPECT(Dart_GetIsolateId(isolate) == test_isolate_id);
1303 Dart_ExitScope(); 1303 Dart_ExitScope();
1304 Dart_ShutdownIsolate(); 1304 Dart_ShutdownIsolate();
1305 EXPECT(verify_callback == 0x5); // Only created and shutdown events. 1305 EXPECT(verify_callback == 0x5); // Only created and shutdown events.
1306 } 1306 }
1307 1307
1308 1308
1309 static Monitor* sync = NULL; 1309 static Monitor* sync = NULL;
1310 static bool isolate_interrupted = false; 1310 static bool isolate_interrupted = false;
1311 static bool pause_event_handled = false;
1311 static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID; 1312 static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
1312 static volatile bool continue_isolate_loop = true; 1313 static volatile bool continue_isolate_loop = true;
1313 1314
1314 1315
1316 static void InterruptIsolateHandler(Dart_IsolateId isolateId,
1317 intptr_t breakpointId,
1318 const Dart_CodeLocation& location) {
1319 MonitorLocker ml(sync);
1320 pause_event_handled = true;
1321 ml.Notify();
1322 }
1323
1315 static void TestInterruptIsolate(Dart_IsolateId isolate_id, 1324 static void TestInterruptIsolate(Dart_IsolateId isolate_id,
1316 Dart_IsolateEvent kind) { 1325 Dart_IsolateEvent kind) {
1317 if (kind == kCreated) { 1326 if (kind == kCreated) {
1318 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1327 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1319 // Indicate that the isolate has been created. 1328 // Indicate that the isolate has been created.
1320 { 1329 {
1321 MonitorLocker ml(sync); 1330 MonitorLocker ml(sync);
1322 interrupt_isolate_id = isolate_id; 1331 interrupt_isolate_id = isolate_id;
1323 ml.Notify(); 1332 ml.Notify();
1324 } 1333 }
1325 } else if (kind == kInterrupted) { 1334 } else if (kind == kInterrupted) {
1326 // Indicate that isolate has been interrupted. 1335 // Indicate that isolate has been interrupted.
1327 { 1336 {
1328 MonitorLocker ml(sync); 1337 MonitorLocker ml(sync);
1329 isolate_interrupted = true; 1338 isolate_interrupted = true;
1330 continue_isolate_loop = false; 1339 continue_isolate_loop = false;
1331 ml.Notify(); 1340 Dart_SetStepInto();
1332 } 1341 }
1333 } else if (kind == kShutdown) { 1342 } else if (kind == kShutdown) {
1334 if (interrupt_isolate_id == isolate_id) { 1343 if (interrupt_isolate_id == isolate_id) {
1335 MonitorLocker ml(sync); 1344 MonitorLocker ml(sync);
1336 interrupt_isolate_id = ILLEGAL_ISOLATE_ID; 1345 interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
1337 ml.Notify(); 1346 ml.Notify();
1338 } 1347 }
1339 } 1348 }
1340 } 1349 }
1341 1350
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 EXPECT_VALID(retval); 1396 EXPECT_VALID(retval);
1388 Dart_ExitScope(); 1397 Dart_ExitScope();
1389 Dart_ShutdownIsolate(); 1398 Dart_ShutdownIsolate();
1390 } 1399 }
1391 1400
1392 1401
1393 TEST_CASE(Debug_InterruptIsolate) { 1402 TEST_CASE(Debug_InterruptIsolate) {
1394 Dart_SetIsolateEventHandler(&TestInterruptIsolate); 1403 Dart_SetIsolateEventHandler(&TestInterruptIsolate);
1395 sync = new Monitor(); 1404 sync = new Monitor();
1396 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1405 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1406 Dart_SetPausedEventHandler(InterruptIsolateHandler);
1397 int result = Thread::Start(InterruptIsolateRun, 0); 1407 int result = Thread::Start(InterruptIsolateRun, 0);
1398 EXPECT_EQ(0, result); 1408 EXPECT_EQ(0, result);
1399 1409
1400 // Wait for the test isolate to be created. 1410 // Wait for the test isolate to be created.
1401 { 1411 {
1402 MonitorLocker ml(sync); 1412 MonitorLocker ml(sync);
1403 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) { 1413 while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) {
1404 ml.Wait(); 1414 ml.Wait();
1405 } 1415 }
1406 } 1416 }
1407 EXPECT(interrupt_isolate_id != ILLEGAL_ISOLATE_ID); 1417 EXPECT(interrupt_isolate_id != ILLEGAL_ISOLATE_ID);
1408 1418
1409 Dart_Isolate isolate = Dart_GetIsolate(interrupt_isolate_id); 1419 Dart_Isolate isolate = Dart_GetIsolate(interrupt_isolate_id);
1410 EXPECT(isolate != NULL); 1420 EXPECT(isolate != NULL);
1411 Dart_InterruptIsolate(isolate); 1421 Dart_InterruptIsolate(isolate);
1412 1422
1413 // Wait for the test isolate to be interrupted. 1423 // Wait for the test isolate to be interrupted.
1414 { 1424 {
1415 MonitorLocker ml(sync); 1425 MonitorLocker ml(sync);
1416 while (!isolate_interrupted) { 1426 while (!isolate_interrupted || !pause_event_handled) {
1417 ml.Wait(); 1427 ml.Wait();
1418 } 1428 }
1419 } 1429 }
1420 EXPECT(isolate_interrupted); 1430 EXPECT(isolate_interrupted);
1431 EXPECT(pause_event_handled);
1421 1432
1422 // Wait for the test isolate to shutdown. 1433 // Wait for the test isolate to shutdown.
1423 { 1434 {
1424 MonitorLocker ml(sync); 1435 MonitorLocker ml(sync);
1425 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) { 1436 while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
1426 ml.Wait(); 1437 ml.Wait();
1427 } 1438 }
1428 } 1439 }
1429 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID); 1440 EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
1430 } 1441 }
1431 1442
1432
1433 static void StackTraceDump1BreakpointHandler( 1443 static void StackTraceDump1BreakpointHandler(
1434 Dart_IsolateId isolate_id, 1444 Dart_IsolateId isolate_id,
1435 intptr_t bp_id, 1445 intptr_t bp_id,
1436 const Dart_CodeLocation& location) { 1446 const Dart_CodeLocation& location) {
1437 Dart_StackTrace trace; 1447 Dart_StackTrace trace;
1438 Dart_GetStackTrace(&trace); 1448 Dart_GetStackTrace(&trace);
1439 const int kStackTraceLen = 4; 1449 const int kStackTraceLen = 4;
1440 static const char* expected_trace[kStackTraceLen] = { 1450 static const char* expected_trace[kStackTraceLen] = {
1441 "local_to_main", 1451 "local_to_main",
1442 "Test.local1_to_func1", 1452 "Test.local1_to_func1",
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 2071
2062 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj); 2072 Dart_Handle list_type = Dart_InstanceGetType(list_access_test_obj);
2063 Dart_Handle super_type = Dart_GetSupertype(list_type); 2073 Dart_Handle super_type = Dart_GetSupertype(list_type);
2064 EXPECT(!Dart_IsError(super_type)); 2074 EXPECT(!Dart_IsError(super_type));
2065 super_type = Dart_GetSupertype(super_type); 2075 super_type = Dart_GetSupertype(super_type);
2066 EXPECT(!Dart_IsError(super_type)); 2076 EXPECT(!Dart_IsError(super_type));
2067 EXPECT(super_type == Dart_Null()); 2077 EXPECT(super_type == Dart_Null());
2068 } 2078 }
2069 2079
2070 } // namespace dart 2080 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698