Change hphpd –h option to make it a little easier to use, provide warning when no server specified

People sometimes make mistakes and launch hphpd without connecting to a server, but expect to be in the server environment when evaluating expressions. Modified the –h option to not require a host specification, and default to localhost, so "hphpd –h" is a valid way to launch now. Provide a warning on launch when no args are specified at all warning the user that they're not connected, and giving suggestions for how to connect if necessary. There are reasonable use cases for launching hphpd with no args (so, no connection and no local script to debug) and I didn't want to take those away by automatically connecting to a server at localhost if launched with no args. I'm hoping the warning is sufficiently helpful.
Esse commit está contido em:
Mike Magruder
2013-06-19 15:42:34 -07:00
commit de Sara Golemon
commit 6e6ebfe8d8
5 arquivos alterados com 17 adições e 8 exclusões
+4 -2
Ver Arquivo
@@ -815,7 +815,8 @@ static int execute_program_impl(int argc, char **argv) {
"start admin listener at specified port")
("debug-config", value<string>(&po.debugger_options.configFName),
"load specified debugger config file")
("debug-host,h", value<string>(&po.debugger_options.host),
("debug-host,h",
value<string>(&po.debugger_options.host)->implicit_value("localhost"),
"connect to debugger server at specified address")
("debug-port", value<int>(&po.debugger_options.port)->default_value(-1),
"connect to debugger server at specified port")
@@ -1070,6 +1071,7 @@ static int execute_program_impl(int argc, char **argv) {
if (po.mode == "debug") {
StackTraceNoHeap::AddExtraLogging("IsDebugger", "True");
RuntimeOption::EnableDebugger = true;
po.debugger_options.fileName = file;
Eval::DebuggerProxyPtr localProxy =
Eval::Debugger::StartClient(po.debugger_options);
if (!localProxy) {
@@ -1090,7 +1092,7 @@ static int execute_program_impl(int argc, char **argv) {
// go unused until we finally stop it when the user quits the
// debugger.
g_context->setSandboxId(localProxy->getDummyInfo().id());
Eval::Debugger::DebuggerSession(po.debugger_options, file, restart);
Eval::Debugger::DebuggerSession(po.debugger_options, restart);
restart = false;
execute_command_line_end(po.xhprofFlags, true, file.c_str());
} catch (const Eval::DebuggerRestartException &e) {
+5 -5
Ver Arquivo
@@ -129,7 +129,7 @@ void Debugger::CleanupDummySandboxThreads() {
}
void Debugger::DebuggerSession(const DebuggerClientOptions& options,
const std::string& file, bool restart) {
bool restart) {
TRACE(2, "Debugger::DebuggerSession: restart=%d\n", restart);
if (options.extension.empty()) {
// even if it's empty, still need to call for warmup
@@ -141,14 +141,14 @@ void Debugger::DebuggerSession(const DebuggerClientOptions& options,
ti->m_reqInjectionData.setDebugger(true);
if (!restart) {
DebuggerDummyEnv dde;
Debugger::InterruptSessionStarted(file.c_str());
Debugger::InterruptSessionStarted(options.fileName.c_str());
}
if (!file.empty()) {
hphp_invoke_simple(file);
if (!options.fileName.empty()) {
hphp_invoke_simple(options.fileName);
}
{
DebuggerDummyEnv dde;
Debugger::InterruptSessionEnded(file.c_str());
Debugger::InterruptSessionEnded(options.fileName.c_str());
}
}
+1 -1
Ver Arquivo
@@ -70,7 +70,7 @@ public:
// Debugger session to be called in a loop
static void DebuggerSession(const DebuggerClientOptions& options,
const std::string& file, bool restart);
bool restart);
// Called from differnt time point of execution thread.
static void InterruptSessionStarted(const char *file,
+1
Ver Arquivo
@@ -35,6 +35,7 @@ struct DebuggerClientOptions {
std::string user;
bool apiMode;
std::string configFName;
std::string fileName;
DebuggerClientOptions() : port(-1), apiMode(false) {}
};
+6
Ver Arquivo
@@ -638,6 +638,12 @@ void DebuggerClient::init(const DebuggerClientOptions &options) {
if (!options.host.empty()) {
connectRemote(options.host, options.port);
} else {
if (options.fileName.empty()) {
help("Note: no server specified, debugging local scripts only.");
help("If you want to connect to a server, launch with \"-h\" or use:");
help(" [m]achine [c]onnect <servername>\n");
}
}
}