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

Side by Side Diff: src/debug.cc

Issue 6234: Refactored the logic for entering the debugger into one abstraction EnterDebu... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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 | « src/debug.h ('k') | src/mirror-delay.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // Get the top-most JavaScript frame. 624 // Get the top-most JavaScript frame.
625 JavaScriptFrameIterator it; 625 JavaScriptFrameIterator it;
626 JavaScriptFrame* frame = it.frame(); 626 JavaScriptFrame* frame = it.frame();
627 627
628 // Just continue if breaks are disabled or debugger cannot be loaded. 628 // Just continue if breaks are disabled or debugger cannot be loaded.
629 if (disable_break() || !Load()) { 629 if (disable_break() || !Load()) {
630 SetAfterBreakTarget(frame); 630 SetAfterBreakTarget(frame);
631 return Heap::undefined_value(); 631 return Heap::undefined_value();
632 } 632 }
633 633
634 SaveBreakFrame save; 634 // Enter the debugger.
635 EnterDebuggerContext enter; 635 EnterDebugger debugger;
636 if (debugger.FailedToEnter()) {
637 return Heap::undefined_value();
638 }
636 639
637 // Postpone interrupt during breakpoint processing. 640 // Postpone interrupt during breakpoint processing.
638 PostponeInterruptsScope postpone; 641 PostponeInterruptsScope postpone;
639 642
640 // Get the debug info (create it if it does not exist). 643 // Get the debug info (create it if it does not exist).
641 Handle<SharedFunctionInfo> shared = 644 Handle<SharedFunctionInfo> shared =
642 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); 645 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
643 Handle<DebugInfo> debug_info = GetDebugInfo(shared); 646 Handle<DebugInfo> debug_info = GetDebugInfo(shared);
644 647
645 // Find the break point where execution has stopped. 648 // Find the break point where execution has stopped.
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // Bail out if exception breaks are not active 1411 // Bail out if exception breaks are not active
1409 if (uncaught) { 1412 if (uncaught) {
1410 // Uncaught exceptions are reported by either flags. 1413 // Uncaught exceptions are reported by either flags.
1411 if (!(Debug::break_on_uncaught_exception() || 1414 if (!(Debug::break_on_uncaught_exception() ||
1412 Debug::break_on_exception())) return; 1415 Debug::break_on_exception())) return;
1413 } else { 1416 } else {
1414 // Caught exceptions are reported is activated. 1417 // Caught exceptions are reported is activated.
1415 if (!Debug::break_on_exception()) return; 1418 if (!Debug::break_on_exception()) return;
1416 } 1419 }
1417 1420
1418 // Enter the debugger. Bail out if the debugger cannot be loaded. 1421 // Enter the debugger.
1419 if (!Debug::Load()) return; 1422 EnterDebugger debugger;
1420 SaveBreakFrame save; 1423 if (debugger.FailedToEnter()) return;
1421 EnterDebuggerContext enter;
1422 1424
1423 // Clear all current stepping setup. 1425 // Clear all current stepping setup.
1424 Debug::ClearStepping(); 1426 Debug::ClearStepping();
1425 // Create the event data object. 1427 // Create the event data object.
1426 bool caught_exception = false; 1428 bool caught_exception = false;
1427 Handle<Object> exec_state = MakeExecutionState(&caught_exception); 1429 Handle<Object> exec_state = MakeExecutionState(&caught_exception);
1428 Handle<Object> event_data; 1430 Handle<Object> event_data;
1429 if (!caught_exception) { 1431 if (!caught_exception) {
1430 event_data = MakeExceptionEvent(exec_state, exception, uncaught, 1432 event_data = MakeExceptionEvent(exec_state, exception, uncaught,
1431 &caught_exception); 1433 &caught_exception);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 1474
1473 1475
1474 void Debugger::OnBeforeCompile(Handle<Script> script) { 1476 void Debugger::OnBeforeCompile(Handle<Script> script) {
1475 HandleScope scope; 1477 HandleScope scope;
1476 1478
1477 // Bail out based on state or if there is no listener for this event 1479 // Bail out based on state or if there is no listener for this event
1478 if (Debug::InDebugger()) return; 1480 if (Debug::InDebugger()) return;
1479 if (compiling_natives()) return; 1481 if (compiling_natives()) return;
1480 if (!EventActive(v8::BeforeCompile)) return; 1482 if (!EventActive(v8::BeforeCompile)) return;
1481 1483
1482 // Enter the debugger. Bail out if the debugger cannot be loaded. 1484 // Enter the debugger.
1483 if (!Debug::Load()) return; 1485 EnterDebugger debugger;
1484 SaveBreakFrame save; 1486 if (debugger.FailedToEnter()) return;
1485 EnterDebuggerContext enter;
1486 1487
1487 // Create the event data object. 1488 // Create the event data object.
1488 bool caught_exception = false; 1489 bool caught_exception = false;
1489 Handle<Object> event_data = MakeCompileEvent(script, 1490 Handle<Object> event_data = MakeCompileEvent(script,
1490 Factory::undefined_value(), 1491 Factory::undefined_value(),
1491 &caught_exception); 1492 &caught_exception);
1492 // Bail out and don't call debugger if exception. 1493 // Bail out and don't call debugger if exception.
1493 if (caught_exception) { 1494 if (caught_exception) {
1494 return; 1495 return;
1495 } 1496 }
1496 1497
1497 // Process debug event 1498 // Process debug event
1498 ProcessDebugEvent(v8::BeforeCompile, event_data); 1499 ProcessDebugEvent(v8::BeforeCompile, event_data);
1499 } 1500 }
1500 1501
1501 1502
1502 // Handle debugger actions when a new script is compiled. 1503 // Handle debugger actions when a new script is compiled.
1503 void Debugger::OnAfterCompile(Handle<Script> script, Handle<JSFunction> fun) { 1504 void Debugger::OnAfterCompile(Handle<Script> script, Handle<JSFunction> fun) {
1504 HandleScope scope; 1505 HandleScope scope;
1505 1506
1506 // No compile events while compiling natives. 1507 // No compile events while compiling natives.
1507 if (compiling_natives()) return; 1508 if (compiling_natives()) return;
1508 1509
1509 // No more to do if not debugging. 1510 // No more to do if not debugging.
1510 if (!debugger_active()) return; 1511 if (!debugger_active()) return;
1511 1512
1512 // Enter the debugger. Bail out if the debugger cannot be loaded. 1513 // Enter the debugger.
1513 if (!Debug::Load()) return; 1514 EnterDebugger debugger;
1514 SaveBreakFrame save; 1515 if (debugger.FailedToEnter()) return;
1515 EnterDebuggerContext enter;
1516 1516
1517 // If debugging there might be script break points registered for this 1517 // If debugging there might be script break points registered for this
1518 // script. Make sure that these break points are set. 1518 // script. Make sure that these break points are set.
1519 1519
1520 // Get the function UpdateScriptBreakPoints (defined in debug-delay.js). 1520 // Get the function UpdateScriptBreakPoints (defined in debug-delay.js).
1521 Handle<Object> update_script_break_points = 1521 Handle<Object> update_script_break_points =
1522 Handle<Object>(Debug::debug_context()->global()->GetProperty( 1522 Handle<Object>(Debug::debug_context()->global()->GetProperty(
1523 *Factory::LookupAsciiSymbol("UpdateScriptBreakPoints"))); 1523 *Factory::LookupAsciiSymbol("UpdateScriptBreakPoints")));
1524 if (!update_script_break_points->IsJSFunction()) { 1524 if (!update_script_break_points->IsJSFunction()) {
1525 return; 1525 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 1560
1561 void Debugger::OnNewFunction(Handle<JSFunction> function) { 1561 void Debugger::OnNewFunction(Handle<JSFunction> function) {
1562 return; 1562 return;
1563 HandleScope scope; 1563 HandleScope scope;
1564 1564
1565 // Bail out based on state or if there is no listener for this event 1565 // Bail out based on state or if there is no listener for this event
1566 if (Debug::InDebugger()) return; 1566 if (Debug::InDebugger()) return;
1567 if (compiling_natives()) return; 1567 if (compiling_natives()) return;
1568 if (!Debugger::EventActive(v8::NewFunction)) return; 1568 if (!Debugger::EventActive(v8::NewFunction)) return;
1569 1569
1570 // Enter the debugger. Bail out if the debugger cannot be loaded. 1570 // Enter the debugger.
1571 if (!Debug::Load()) return; 1571 EnterDebugger debugger;
1572 SaveBreakFrame save; 1572 if (debugger.FailedToEnter()) return;
1573 EnterDebuggerContext enter;
1574 1573
1575 // Create the event object. 1574 // Create the event object.
1576 bool caught_exception = false; 1575 bool caught_exception = false;
1577 Handle<Object> event_data = MakeNewFunctionEvent(function, &caught_exception); 1576 Handle<Object> event_data = MakeNewFunctionEvent(function, &caught_exception);
1578 // Bail out and don't call debugger if exception. 1577 // Bail out and don't call debugger if exception.
1579 if (caught_exception) { 1578 if (caught_exception) {
1580 return; 1579 return;
1581 } 1580 }
1582 // Process debug event. 1581 // Process debug event.
1583 ProcessDebugEvent(v8::NewFunction, event_data); 1582 ProcessDebugEvent(v8::NewFunction, event_data);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 } 1964 }
1966 1965
1967 1966
1968 void LockingMessageQueue::Clear() { 1967 void LockingMessageQueue::Clear() {
1969 ScopedLock sl(lock_); 1968 ScopedLock sl(lock_);
1970 queue_.Clear(); 1969 queue_.Clear();
1971 } 1970 }
1972 1971
1973 1972
1974 } } // namespace v8::internal 1973 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/mirror-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698