Use the same output formatting for = command as is used for the print command.

The = command uses formatting that is user customizable and subtly different, by default, from the formatting used by the print command and the variable command. This has historical roots. It seems that the debugger used to use print_r, which is brittle, and the customization hook was introduced to work around this brittleness. This work around is no longer necessary since the debugger now has its own, robust way of formatting values as strings. Also, the difference between = and print is a perennial source of confusion for debugger users.
Esse commit está contido em:
Herman Venter
2013-07-25 15:27:48 -07:00
commit de Sara Golemon
commit b7ed094ed2
15 arquivos alterados com 21 adições e 70 exclusões
+1 -1
Ver Arquivo
@@ -52,7 +52,7 @@ void CmdEval::onClientImpl(DebuggerClient &client) {
}
void CmdEval::handleReply(DebuggerClient &client) {
client.print(m_output);
if (!m_output.empty()) client.print(m_output);
}
const StaticString
+14
Ver Arquivo
@@ -67,6 +67,20 @@ void CmdVariable::help(DebuggerClient &client) {
);
}
void CmdVariable::PrintVariable(DebuggerClient &client, CStrRef varName) {
CmdVariable cmd;
cmd.m_frame = client.getFrame();
CmdVariablePtr rcmd = client.xend<CmdVariable>(&cmd);
if (!rcmd->m_variables.empty()) {
for (ArrayIter iter(rcmd->m_variables); iter; ++iter) {
String name = iter.first().toString();
if (!name.equal(varName)) continue;
String value = DebuggerClient::FormatVariable(iter.second(), 200);
client.print("%s", value.data());
}
}
}
void CmdVariable::PrintVariables(DebuggerClient &client, CArrRef variables,
bool global, CStrRef text) {
bool system = true;
+1
Ver Arquivo
@@ -26,6 +26,7 @@ DECLARE_BOOST_TYPES(CmdVariable);
class CmdVariable : public DebuggerCommand {
public:
static Array GetGlobalVariables();
static void PrintVariable(DebuggerClient &client, CStrRef varName);
static void PrintVariables(DebuggerClient &client, CArrRef variables,
bool global, CStrRef text);
+5 -7
Ver Arquivo
@@ -400,7 +400,7 @@ String DebuggerClient::FormatTitle(const char *title) {
///////////////////////////////////////////////////////////////////////////////
DebuggerClient::DebuggerClient(std::string name /* = "" */)
: m_tutorial(0), m_printFunction(""), m_scriptMode(false),
: m_tutorial(0), m_scriptMode(false),
m_logFile(""), m_logFileHandler(nullptr),
m_mainThread(this, &DebuggerClient::run), m_stopped(false),
m_inputState(TakingCommand),
@@ -1919,6 +1919,8 @@ int DebuggerClient::checkEvalEnd() {
return pos;
}
const StaticString s_UNDERSCORE("_");
// Parses the current command line as a code execution command
// and carries out the command.
void DebuggerClient::processTakeCode() {
@@ -1937,8 +1939,9 @@ void DebuggerClient::processTakeCode() {
// strip the trailing ;
m_line = m_line.substr(0, m_line.size() - 1);
}
m_code = string("<?php $_=(") + m_line.substr(1) + "); " + m_printFunction;
m_code = string("<?php $_=(") + m_line.substr(1) + "); ";
processEval();
CmdVariable::PrintVariable(*this, s_UNDERSCORE);
return;
} else if (first != '<') {
usageLogCommand("eval", m_line);
@@ -2360,7 +2363,6 @@ void DebuggerClient::loadConfig() {
m_tutorial = m_config["Tutorial"].getInt32(0);
m_scriptMode = m_config["ScriptMode"].getBool();
std::string pprint = m_config["PrettyPrint"].getString("hphpd_print_value");
setDebuggerBypassCheck(m_config["BypassAccessCheck"].getBool());
setDebuggerClientSmallStep(m_config["SmallStep"].getBool());
int printLevel = m_config["PrintLevel"].getInt16(3);
@@ -2373,10 +2375,6 @@ void DebuggerClient::loadConfig() {
m_config["MaxCodeLines"] = maxCodeLines;
setDebuggerClientMaxCodeLines(maxCodeLines);
m_printFunction = (boost::format(
"(function_exists(\"%s\") ? %s($_) : print_r(print_r($_, true)));")
% pprint % pprint).str();
m_config["Tutorial"]["Visited"].get(m_tutorialVisited);
for (Hdf node = m_config["Macros"].firstChild(); node.exists();
-1
Ver Arquivo
@@ -363,7 +363,6 @@ private:
std::string m_configFileName;
Hdf m_config;
int m_tutorial;
std::string m_printFunction;
std::set<std::string> m_tutorialVisited;
bool m_scriptMode; // Is this client being scripted by a test?
-21
Ver Arquivo
@@ -36,7 +36,6 @@ break clear all
All breakpoints are cleared.
continue
test_break1_suffix
break foo()
Breakpoint 1 set upon entering foo()
@ foo('test_break2')
@@ -51,11 +50,9 @@ break clear all
All breakpoints are cleared.
continue
test_break2_suffix
break cls::pubObj()
Breakpoint 1 set upon entering cls::pubObj()
@ $break3=new cls()
@ $break3->pubObj('test_break3')
Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -70,7 +67,6 @@ break break3->pubObj()
Breakpoint was not set in right format.
continue
pubObj:test_break3
break cls::pubCls()
Breakpoint 1 set upon entering cls::pubCls()
@ cls::pubCls('test_break4')
@@ -87,9 +83,7 @@ break cls::break4->pubCls()
Breakpoint was not set in right format.
continue
pubCls:test_break4
@ $break5=new cls()
@ $break5->pubHardBreak('test_break5')
pubHardBreak:test_break5
Break at cls::pubHardBreak() on line 19 of %s/break1.php
@@ -99,7 +93,6 @@ Break at cls::pubHardBreak() on line 19 of %s/break1.php
continue
pubHardBreak:done
break clear all
There is no breakpoint to clear or toggle.
break cls::nosuchMethod()
@@ -118,7 +111,6 @@ Breakpoint 1 set upon entering derived::pubObj()
break list
1 ALWAYS upon entering derived::pubObj()
@ $break6 = new derived()
@ $break6->pubObj('test_break6')
Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -127,13 +119,11 @@ Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
continue
pubObj:test_break6
break clear all
All breakpoints are cleared.
b cls::pubObj() if $x == 'yes'
Breakpoint 1 set upon entering cls::pubObj() if $x == 'yes'
@ $break7 = new cls()
@ $break7->pubObj('yes');
Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -157,16 +147,13 @@ break clear all
All breakpoints are cleared.
continue
pubObj:yes sir
break derived::callPubObj=>cls::pubObj()
Breakpoint 1 set upon entering cls::pubObj() called by derived::callPubObj()
break list
1 ALWAYS upon entering cls::pubObj() called by derived::callPubObj()
@ $break8 = new derived();
@ $break8->pubObj('no')
pubObj:no
@ $break8->callPubObj('yes')
Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -177,16 +164,13 @@ break clear all
All breakpoints are cleared.
continue
pubObj:yes
break derived::callCallPubObj=>derived::callPubObj=>cls::pubObj()
Breakpoint 1 set upon entering cls::pubObj() called by derived::callPubObj() called by derived::callCallPubObj()
break list
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 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -197,16 +181,13 @@ break clear all
All breakpoints are cleared.
continue
pubObj:yes
break derived::callCallPubObj=>cls::pubObj()
Breakpoint 1 set upon entering cls::pubObj() called by derived::callCallPubObj()
break list
1 ALWAYS upon entering cls::pubObj() called by derived::callCallPubObj()
@ $break10 = new derived();
@ $break10->callPubObj('no')
pubObj:no
@ $break10->callCallPubObj('yes')
Breakpoint 1 reached at cls::pubObj() on line 12 of %s/break1.php
11 public function pubObj($x) {
@@ -217,7 +198,6 @@ break clear all
All breakpoints are cleared.
continue
pubObj:yes
break foo()
Breakpoint 1 set upon entering foo()
break break1.php:6
@@ -235,7 +215,6 @@ Breakpoint 2 reached at foo() on line 6 of %s/break1.php
continue
test_break7_suffix
break clear all
All breakpoints are cleared.
quit
@@ -37,7 +37,6 @@ Breakpoint 1 reached at foo2() on line 7 of %s/break2.php
8 }
@ $break6=new cls2()
@ $break6->pubObj('test_break6')
Breakpoint 3 reached at cls2::pubObj() on line 12 of %s/break2.php
11 public function pubObj($x) {
@@ -46,7 +45,6 @@ Breakpoint 3 reached at cls2::pubObj() on line 12 of %s/break2.php
continue
pubObj2:test_break6
@ cls2::pubCls('test_break6')
Breakpoint 4 reached at cls2::pubCls() on line 15 of %s/break2.php
14 public static function pubCls($x) {
@@ -57,5 +55,4 @@ break clear all
All breakpoints are cleared.
continue
pubCls2:test_break6
quit
@@ -16,11 +16,9 @@ break clear all
All breakpoints are cleared.
continue
test_break1_TestNs
break TestNs\cls::pubObj()
Breakpoint 1 set upon entering TestNs\cls::pubObj()
@ $break8=new \TestNs\cls()
@ $break8->pubObj('test_break2')
Breakpoint 1 reached at TestNs\cls::pubObj() on line 13 of %s/break3.php
12 public function pubObj($x) {
@@ -37,7 +35,6 @@ break TestNs\cls::break8->pubObj()
Breakpoint was not set in right format.
continue
pubObj:test_break2
break \TestNs\cls::pubCls()
Breakpoint 1 set upon entering TestNs\cls::pubCls()
@ \TestNs\cls::pubCls('test_break3')
@@ -52,7 +49,6 @@ break clear all
All breakpoints are cleared.
continue
pubCls:test_break3
break \TestNs\Nested\foo()
Breakpoint 1 set upon entering TestNs\Nested\foo()
@ \TestNs\Nested\foo('test_break4')
@@ -67,11 +63,9 @@ break clear all
All breakpoints are cleared.
continue
test_break4_TestNs\Nested
break TestNs\Nested\cls::pubObj()
Breakpoint 1 set upon entering TestNs\Nested\cls::pubObj()
@ $break8=new \TestNs\Nested\cls()
@ $break8->pubObj('test_break5')
Breakpoint 1 reached at TestNs\Nested\cls::pubObj() on line 29 of %s/break3.php
28 public function pubObj($x) {
@@ -84,7 +78,6 @@ break clear all
All breakpoints are cleared.
continue
pubObj:test_break5_TestNs\Nested
break \TestNs\Nested\cls::pubCls()
Breakpoint 1 set upon entering TestNs\Nested\cls::pubCls()
@ \TestNs\Nested\cls::pubCls('test_break6')
@@ -99,5 +92,4 @@ break clear all
All breakpoints are cleared.
continue
pubCls:test_break6_TestNs\Nested
quit
-9
Ver Arquivo
@@ -5,12 +5,10 @@ Program %s/eval1.php exited normally.
print function_exists('test1')
false
@ function test1($x){error_log($x);return $x+1;}
print function_exists('test1')
true
@ $eval1=test1(4)
4
print $eval1
5
print class_exists('test2')
@@ -31,15 +29,12 @@ class test2 {
}
}
?>
print class_exists('test2')
true
set bac off
BypassAccessCheck(bac) set to off
@ $eval2 = new test2()
@ $eval2->a = 3
@ $eval2->b = 4
Hit fatal : Cannot access protected property
#0 at [:1]
@@ -51,7 +46,6 @@ set bac on
BypassAccessCheck(bac) set to on.
All code executed from debugger is bypassing access check!
@ $eval2->b = 4
print $eval2->ab()
"3:4"
break eval1.php:12
@@ -67,9 +61,7 @@ All breakpoints are cleared.
set bac off
BypassAccessCheck(bac) set to off
@ $this->pub = 21
@ $this->pri = 22
next
Break at cls::meth() on line 13 of %s/eval1.php
12 $b = $this->pub.':'.$this->pri;
@@ -88,7 +80,6 @@ set bac on
BypassAccessCheck(bac) set to on.
All code executed from debugger is bypassing access check!
@ $this->pub = $x->seven()
continue
"11:12-21:22-7:22"
quit
-7
Ver Arquivo
@@ -47,7 +47,6 @@ break clear all
All breakpoints are cleared.
continue
test done 1
break flow.php:18
Breakpoint 1 set on line 18 of flow.php
@test(2)
@@ -107,7 +106,6 @@ continue
out pri:2
out pub:2
test done 2
break flow.php:6
Breakpoint 1 set on line 6 of flow.php
@test(3)
@@ -132,7 +130,6 @@ continue
out pri:3
out pub:3
test done 3
break flow.php:7
Breakpoint 1 set on line 7 of flow.php
@test(4)
@@ -181,7 +178,6 @@ Break at test() on line 62 of %s/flow.php
continue
test done 4
break flow.php:46
Breakpoint 1 set on line 46 of flow.php
test(5)
@@ -222,7 +218,6 @@ continue
out pri:5
out pub:5
test done 5
break flow.php:46
Breakpoint 1 set on line 46 of flow.php
test(6)
@@ -263,7 +258,6 @@ continue
out pri:6
out pub:6
test done 6
break flow.php:7
Breakpoint 1 set on line 7 of flow.php
@test(7)
@@ -292,5 +286,4 @@ break clear all
All breakpoints are cleared.
continue
test done 7
quit
@@ -31,7 +31,6 @@ Breakpoint 2 reached at main() on line 27 of %s/flow_break_interference.php
p $a
42
$a = 7
n
Break at main() on line 28 of %s/flow_break_interference.php
27 $z = $a;
@@ -60,7 +60,6 @@ break clear all
All breakpoints are cleared.
continue
test done 1
break flow_small.php:18
Breakpoint 1 set on line 18 of flow_small.php
@test(2)
@@ -183,7 +182,6 @@ continue
out pri:2
out pub:2
test done 2
break flow_small.php:6
Breakpoint 1 set on line 6 of flow_small.php
@test(3)
@@ -208,7 +206,6 @@ continue
out pri:3
out pub:3
test done 3
break flow_small.php:7
Breakpoint 1 set on line 7 of flow_small.php
@test(4)
@@ -257,7 +254,6 @@ Break at test() on line 62 of %s/flow_small.php
continue
test done 4
break flow_small.php:46
Breakpoint 1 set on line 46 of flow_small.php
test(5)
@@ -298,7 +294,6 @@ continue
out pri:5
out pub:5
test done 5
break flow_small.php:46
Breakpoint 1 set on line 46 of flow_small.php
test(6)
@@ -339,7 +334,6 @@ continue
out pri:6
out pub:6
test done 6
break flow_small.php:7
Breakpoint 1 set on line 7 of flow_small.php
@test(7)
@@ -368,5 +362,4 @@ break clear all
All breakpoints are cleared.
continue
test done 7
quit
-2
Ver Arquivo
@@ -1,6 +1,5 @@
Program %s/info1.php loaded. Type '[r]un' or '[c]ontinue' to go.
@
info array_key_exists
/**
* ( excerpt from http://php.net/manual/en/function.array_key_exists.php )
@@ -21,7 +20,6 @@ class stdClass {
run
Program %s/info1.php exited normally.
@
info myfunc
// defined on line 3 to 5 of %s/info1.php
function myfunc($a, $b);
@@ -95,7 +95,6 @@ StackArgs(sa) set to on.
continue
out pub:1 0
test done 1 0
break stack1.php:9
Breakpoint 1 set on line 9 of stack1.php
@ test(2, 2)
@@ -161,7 +160,6 @@ down
#6 foo (2, 1)
at %s/stack1.php:28
@ $x=3
continue
out pri:2 0
out pub:2 0
@@ -67,7 +67,6 @@ Break at test_sleep() on line 17 of %s/test1.php
18 return $a;
@ $a = 0
break test1.php:18
Breakpoint 1 set on line 18 of test1.php
continue