From 10f93d48280941e55286993927851d2d258b7db2 Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Mon, 15 Jul 2013 11:01:27 -0700 Subject: [PATCH] Do not report start, end and psp breakpoints as unbound when connected to a sandbox. break start/end/psp currently always report themselves as unbound. If the client is connected to a sanbox, these should instead be treated as bound. Also, break clear all currently removes breakpoints without running their destructors in the right order, which causes the break point counter to not reset to 1. --- hphp/runtime/debugger/cmd/cmd_break.cpp | 20 +++++++++++--- hphp/test/ext/debugger_tests/break.php | 2 +- hphp/test/quick/debugger/break1.php.expectf | 30 ++++++++++++++------- hphp/test/quick/debugger/break1.php.in | 3 +++ hphp/test/quick/debugger/flow2.php.expectf | 8 +++--- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/hphp/runtime/debugger/cmd/cmd_break.cpp b/hphp/runtime/debugger/cmd/cmd_break.cpp index 409002962..308cda786 100644 --- a/hphp/runtime/debugger/cmd/cmd_break.cpp +++ b/hphp/runtime/debugger/cmd/cmd_break.cpp @@ -202,8 +202,14 @@ void CmdBreak::processList(DebuggerClient &client) { updateServer(client); for (int i = 0; i < (int)m_breakpoints->size(); i++) { BreakPointInfoPtr bpi = m_breakpoints->at(i); - const char* boundStr = - bpi->m_bindState == BreakPointInfo::Unknown ? " (unbound)" : ""; + bool bound = bpi->m_bindState != BreakPointInfo::Unknown; + if (!bound && !client.isLocal() && + (bpi->m_interruptType == RequestStarted || + bpi->m_interruptType == RequestEnded || + bpi->m_interruptType == PSPEnded)) { + bound = true; + } + const char* boundStr = bound ? "" : " (unbound)"; client.print(" %d\t%s %s%s", bpi->index(), bpi->state(true).c_str(), bpi->desc().c_str(), boundStr); } @@ -276,7 +282,9 @@ void CmdBreak::processStatusChange(DebuggerClient &client) { if (client.arg(2, "all")) { if (hasClearArg(client)) { - m_breakpoints->clear(); + while (m_breakpoints->size() > 0) { + m_breakpoints->erase(m_breakpoints->end()); + } updateServer(client); client.info("All breakpoints are cleared."); return; @@ -411,6 +419,12 @@ void ReportBreakpointBindState(DebuggerClient &client, BreakPointInfoPtr bpi) { } else if (!bpi->getExceptionClass().empty()) { client.info("But note that class %s has yet been loaded.", bpi->getExceptionClass().c_str()); + } else if (bpi->m_interruptType == RequestStarted || + bpi->m_interruptType == RequestEnded || + bpi->m_interruptType == PSPEnded) { + if (client.isLocal()) { + client.info("But wont break until connected to a server."); + } } else { client.info("But wont break until file %s has been loaded.", bpi->m_file.c_str()); diff --git a/hphp/test/ext/debugger_tests/break.php b/hphp/test/ext/debugger_tests/break.php index bc4ebdaa5..cd347cda5 100644 --- a/hphp/test/ext/debugger_tests/break.php +++ b/hphp/test/ext/debugger_tests/break.php @@ -158,7 +158,7 @@ function break9($c) { function break10($c) { $o = $c->processCmd('break', array(':fb:my:thing::doIt()')); - VS($o['text'], "Breakpoint 4 set upon entering xhp_fb__my__thing::doIt()\n"); + VS($o['text'], "Breakpoint 1 set upon entering xhp_fb__my__thing::doIt()\n"); VS($o['values'][0]['func'], 'doIt'); VS($o['values'][0]['class'], 'xhp_fb__my__thing'); VS($o['values'][0]['namespace'], ''); diff --git a/hphp/test/quick/debugger/break1.php.expectf b/hphp/test/quick/debugger/break1.php.expectf index 922a20a78..27a295cdf 100644 --- a/hphp/test/quick/debugger/break1.php.expectf +++ b/hphp/test/quick/debugger/break1.php.expectf @@ -18,8 +18,20 @@ Breakpoint 1 reached at foo() on line 7 of %s/break1.php variable $x = "test_break1" $y = "test_break1_suffix" +break start +Breakpoint 2 set start of request +But wont break until connected to a server. +break end +Breakpoint 3 set end of request or start of psp +But wont break until connected to a server. +break psp +Breakpoint 4 set end of psp +But wont break until connected to a server. break list 1 ALWAYS on line 7 of break1.php + 2 ALWAYS start of request (unbound) + 3 ALWAYS end of request or start of psp (unbound) + 4 ALWAYS end of psp (unbound) break clear all All breakpoints are cleared. continue @@ -143,16 +155,16 @@ continue pubObj:yes sir break derived::callPubObj=>cls::pubObj() -Breakpoint 2 set upon entering cls::pubObj() called by derived::callPubObj() +Breakpoint 1 set upon entering cls::pubObj() called by derived::callPubObj() break list - 2 ALWAYS upon entering cls::pubObj() called by derived::callPubObj() + 1 ALWAYS upon entering cls::pubObj() called by derived::callPubObj() @ $break8 = new derived(); @ $break8->pubObj('no') pubObj:no @ $break8->callPubObj('yes') -Breakpoint 2 reached at cls::pubObj() on line 12 of %s/break1.php +Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php 11 public function pubObj($x) { 12 error_log("pubObj:".$x); 13 } @@ -163,16 +175,16 @@ continue pubObj:yes break derived::callCallPubObj=>derived::callPubObj=>cls::pubObj() -Breakpoint 2 set upon entering cls::pubObj() called by derived::callPubObj() called by derived::callCallPubObj() +Breakpoint 1 set upon entering cls::pubObj() called by derived::callPubObj() called by derived::callCallPubObj() break list - 2 ALWAYS upon entering cls::pubObj() called by derived::callPubObj() called by derived::callCallPubObj() + 1 ALWAYS upon entering cls::pubObj() called by derived::callPubObj() called by derived::callCallPubObj() @ $break9 = new derived(); @ $break9->callPubObj('no') pubObj:no @ $break9->callCallPubObj('yes') -Breakpoint 2 reached at cls::pubObj() on line 12 of %s/break1.php +Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php 11 public function pubObj($x) { 12 error_log("pubObj:".$x); 13 } @@ -183,16 +195,16 @@ continue pubObj:yes break derived::callCallPubObj=>cls::pubObj() -Breakpoint 2 set upon entering cls::pubObj() called by derived::callCallPubObj() +Breakpoint 1 set upon entering cls::pubObj() called by derived::callCallPubObj() break list - 2 ALWAYS upon entering cls::pubObj() called by derived::callCallPubObj() + 1 ALWAYS upon entering cls::pubObj() called by derived::callCallPubObj() @ $break10 = new derived(); @ $break10->callPubObj('no') pubObj:no @ $break10->callCallPubObj('yes') -Breakpoint 2 reached at cls::pubObj() on line 12 of %s/break1.php +Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php 11 public function pubObj($x) { 12 error_log("pubObj:".$x); 13 } diff --git a/hphp/test/quick/debugger/break1.php.in b/hphp/test/quick/debugger/break1.php.in index 4bd18de54..b6324840f 100644 --- a/hphp/test/quick/debugger/break1.php.in +++ b/hphp/test/quick/debugger/break1.php.in @@ -4,6 +4,9 @@ break break1.php:77 break list @ foo('test_break1') variable +break start +break end +break psp break list break clear all continue diff --git a/hphp/test/quick/debugger/flow2.php.expectf b/hphp/test/quick/debugger/flow2.php.expectf index c0df8b1d1..7742b0ba0 100644 --- a/hphp/test/quick/debugger/flow2.php.expectf +++ b/hphp/test/quick/debugger/flow2.php.expectf @@ -151,12 +151,12 @@ object(C1)#3 (1) { } break flow2.php:26 -Breakpoint 2 set on line 26 of flow2.php +Breakpoint 1 set on line 26 of flow2.php @test(3) Constructor Finished in genFoo Constructor -Breakpoint 2 reached at C1::__destruct() on line 26 of %s/flow2.php +Breakpoint 1 reached at C1::__destruct() on line 26 of %s/flow2.php 25 public function __destruct() { 26 error_log('Destructor'); 27 } @@ -170,14 +170,14 @@ Break at foo() on line 44 of %s/flow2.php continue Constructor -Breakpoint 2 reached at C1::__destruct() on line 26 of %s/flow2.php +Breakpoint 1 reached at C1::__destruct() on line 26 of %s/flow2.php 25 public function __destruct() { 26 error_log('Destructor'); 27 } out Destructor -Breakpoint 2 reached at C1::__destruct() on line 26 of %s/flow2.php +Breakpoint 1 reached at C1::__destruct() on line 26 of %s/flow2.php 25 public function __destruct() { 26 error_log('Destructor'); 27 }