diff --git a/hphp/runtime/debugger/cmd/cmd_zend.cpp b/hphp/runtime/debugger/cmd/cmd_zend.cpp index e63bb13df..549d25c5c 100644 --- a/hphp/runtime/debugger/cmd/cmd_zend.cpp +++ b/hphp/runtime/debugger/cmd/cmd_zend.cpp @@ -31,9 +31,10 @@ void CmdZend::help(DebuggerClient &client) { client.helpBody( "This is mainly for comparing results from PHP vs. HipHop. After you type " "in some PHP code, it will be evaluated immediately in HipHop. Then you " - "can type '[z]end' command to re-run the same script in Zend PHP. Please " - "note that only the most recent block of code you manually typed in was " - "evaluated, not any earlier ones, nor the ones from a PHP file." + "can type '[z]end' command to re-run the same script with your " + "system-default PHP. Please note that only the most recent block of code " + "you manually typed in is evaluated, not any earlier ones, nor the ones " + "from a PHP file." ); } @@ -42,12 +43,16 @@ void CmdZend::onClientImpl(DebuggerClient &client) { if (client.argCount() == 0) { const std::string &code = client.getCode(); - string out; - Process::Exec("php", nullptr, code.c_str(), out, &out, true); - client.print(out); - } else { - help(client); + if (!code.empty()) { + const std::string zendExe = client.getZendExecutable(); + client.info("Executing last PHP block with \"%s\"...", zendExe.c_str()); + string out; + Process::Exec(zendExe.c_str(), nullptr, code.c_str(), out, &out, true); + client.print(out); + return; + } } + help(client); } /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/debugger/debugger_client.cpp b/hphp/runtime/debugger/debugger_client.cpp index 1c492d7de..441a6b4ab 100644 --- a/hphp/runtime/debugger/debugger_client.cpp +++ b/hphp/runtime/debugger/debugger_client.cpp @@ -2385,6 +2385,7 @@ void DebuggerClient::loadConfig() { } m_sourceRoot = m_config["SourceRoot"].getString(); + m_zendExe = m_config["ZendExecutable"].getString("php"); if (needToWriteFile) { saveConfig(); // so to generate a starter for people diff --git a/hphp/runtime/debugger/debugger_client.h b/hphp/runtime/debugger/debugger_client.h index 6f5467d11..f3d3f6aed 100644 --- a/hphp/runtime/debugger/debugger_client.h +++ b/hphp/runtime/debugger/debugger_client.h @@ -349,6 +349,8 @@ public: void usageLogEvent(const std::string &eventName, const std::string &data = ""); + std::string getZendExecutable() const { return m_zendExe; } + private: enum InputState { TakingCommand, @@ -494,6 +496,9 @@ private: // usage logging const char *getUsageMode(); + + // Zend executable for CmdZend, overridable via config. + std::string m_zendExe; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/util/process.cpp b/hphp/util/process.cpp index 6d982246c..ee36b59cf 100644 --- a/hphp/util/process.cpp +++ b/hphp/util/process.cpp @@ -157,9 +157,11 @@ bool Process::Exec(const char *path, const char *argv[], const char *in, if (WEXITSTATUS(status) != 0) { Logger::Verbose("Status %d running command: `%s'\n", WEXITSTATUS(status), path); - while (*argv) { - Logger::Verbose(" arg: `%s'\n", *argv); - argv++; + if (argv) { + while (*argv) { + Logger::Verbose(" arg: `%s'\n", *argv); + argv++; + } } } else { ret = true;