Consolidate client/server functions in debugger commands
Cleaned up some of the superfluous variations of onServer*()/onClient*() in the debugger commands. The separation was a leftover of the days when we had the VM and the compiler. The entire DebuggerCommand interface, what's public/protected/private, etc. could use a serious cleanup, but I'm not going that far now. I mostly wanted to clean this up to make some other work we need to do server-side less complicated.
Esse commit está contido em:
@@ -63,13 +63,6 @@ void CmdEval::setClientOutput(DebuggerClient *client) {
|
||||
}
|
||||
|
||||
bool CmdEval::onServer(DebuggerProxy *proxy) {
|
||||
g_context->setDebuggerBypassCheck(m_bypassAccessCheck);
|
||||
DebuggerProxy::ExecutePHP(m_body, m_output, !proxy->isLocal(), m_frame);
|
||||
g_context->setDebuggerBypassCheck(false);
|
||||
return proxy->sendToClient(this);
|
||||
}
|
||||
|
||||
bool CmdEval::onServerVM(DebuggerProxy *proxy) {
|
||||
VM::PCFilter* locSave = g_vmContext->m_lastLocFilter;
|
||||
g_vmContext->m_lastLocFilter = new VM::PCFilter();
|
||||
g_vmContext->setDebuggerBypassCheck(m_bypassAccessCheck);
|
||||
|
||||
@@ -30,7 +30,6 @@ public:
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
virtual bool onServerVM(DebuggerProxy *proxy);
|
||||
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
@@ -54,7 +54,7 @@ bool CmdInstrument::help(DebuggerClient *client) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CmdInstrument::onClientVM(DebuggerClient *client) {
|
||||
bool CmdInstrument::onClient(DebuggerClient *client) {
|
||||
if (DebuggerCommand::onClient(client)) return true;
|
||||
if (client->argCount() == 1) {
|
||||
if (client->argValue(1) == "list" || client->argValue(1) == "l") {
|
||||
@@ -131,7 +131,7 @@ void CmdInstrument::setClientOutput(DebuggerClient *client) {
|
||||
client->setOTValues(values);
|
||||
}
|
||||
|
||||
bool CmdInstrument::onServerVM(DebuggerProxy *proxy) {
|
||||
bool CmdInstrument::onServer(DebuggerProxy *proxy) {
|
||||
m_instPoints = &m_ips;
|
||||
m_enabled = true;
|
||||
DebuggerProxyVM* proxyVM = static_cast<DebuggerProxyVM*>(proxy);
|
||||
|
||||
@@ -30,16 +30,9 @@ public:
|
||||
m_enabled(false), m_instPoints(nullptr) {}
|
||||
|
||||
virtual bool help(DebuggerClient *client);
|
||||
virtual bool onClient(DebuggerClient *client) {
|
||||
client->error("not supported\n");
|
||||
return true;
|
||||
}
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onClientVM(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy) {
|
||||
return true;
|
||||
}
|
||||
virtual bool onServerVM(DebuggerProxy *proxy);
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
@@ -366,14 +366,6 @@ void CmdPrint::setClientOutput(DebuggerClient *client) {
|
||||
}
|
||||
|
||||
bool CmdPrint::onServer(DebuggerProxy *proxy) {
|
||||
g_context->setDebuggerBypassCheck(m_bypassAccessCheck);
|
||||
m_ret = DebuggerProxy::ExecutePHP(DebuggerProxy::MakePHPReturn(m_body),
|
||||
m_output, !proxy->isLocal(), m_frame);
|
||||
g_context->setDebuggerBypassCheck(false);
|
||||
return proxy->sendToClient(this);
|
||||
}
|
||||
|
||||
bool CmdPrint::onServerVM(DebuggerProxy *proxy) {
|
||||
VM::PCFilter* locSave = g_vmContext->m_lastLocFilter;
|
||||
g_vmContext->m_lastLocFilter = new VM::PCFilter();
|
||||
g_vmContext->setDebuggerBypassCheck(m_bypassAccessCheck);
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
virtual bool onServerVM(DebuggerProxy *proxy);
|
||||
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
@@ -152,7 +152,7 @@ Array CmdVariable::GetGlobalVariables() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CmdVariable::onServerVM(DebuggerProxy *proxy) {
|
||||
bool CmdVariable::onServer(DebuggerProxy *proxy) {
|
||||
m_variables = g_vmContext->getLocalDefinedVariables(m_frame);
|
||||
return proxy->sendToClient(this);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onServerVM(DebuggerProxy *proxy);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
@@ -154,10 +154,6 @@ void CmdWhere::processStackTrace() {
|
||||
}
|
||||
|
||||
bool CmdWhere::onServer(DebuggerProxy *proxy) {
|
||||
const_assert(false);
|
||||
}
|
||||
|
||||
bool CmdWhere::onServerVM(DebuggerProxy *proxy) {
|
||||
m_stacktrace = g_vmContext->debugBacktrace(false, true, false);
|
||||
if (!m_stackArgs) {
|
||||
processStackTrace();
|
||||
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
virtual bool onServerVM(DebuggerProxy *proxy);
|
||||
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
@@ -163,21 +163,21 @@ bool DebuggerCommand::onClient(DebuggerClient *client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void DebuggerCommand::setClientOutput(DebuggerClient *client) {
|
||||
TRACE(2, "DebuggerCommand::setClientOutput\n");
|
||||
// Just default to text
|
||||
client->setOutputType(DebuggerClient::OTText);
|
||||
}
|
||||
|
||||
bool DebuggerCommand::onClientD(DebuggerClient *client) {
|
||||
TRACE(2, "DebuggerCommand::onClientD\n");
|
||||
bool ret = onClientVM(client);
|
||||
bool ret = onClient(client);
|
||||
if (client->isApiMode() && !m_incomplete) {
|
||||
setClientOutput(client);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DebuggerCommand::setClientOutput(DebuggerClient *client) {
|
||||
TRACE(2, "DebuggerCommand::setClientOutput\n");
|
||||
// Just default to text
|
||||
client->setOutputType(DebuggerClient::OTText);
|
||||
}
|
||||
|
||||
bool DebuggerCommand::onServer(DebuggerProxy *proxy) {
|
||||
TRACE(2, "DebuggerCommand::onServer\n");
|
||||
assert(false);
|
||||
|
||||
@@ -98,14 +98,9 @@ public:
|
||||
virtual void list(DebuggerClient *client);
|
||||
virtual bool help(DebuggerClient *client);
|
||||
virtual bool onClient(DebuggerClient *client);
|
||||
virtual bool onClientVM(DebuggerClient *client) { return onClient(client); }
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
bool onClientD(DebuggerClient *client);
|
||||
virtual void setClientOutput(DebuggerClient *client);
|
||||
virtual bool onServer(DebuggerProxy *proxy);
|
||||
virtual bool onServerVM(DebuggerProxy *proxy) { return onServer(proxy); }
|
||||
bool onServerD(DebuggerProxy *proxy) {
|
||||
return onServerVM(proxy);
|
||||
}
|
||||
virtual void sendImpl(DebuggerThriftBuffer &thrift);
|
||||
virtual void recvImpl(DebuggerThriftBuffer &thrift);
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ void DebuggerProxy::pollSignal() {
|
||||
|
||||
// Send CmdSignal over to the client and wait for a response.
|
||||
CmdSignal cmd;
|
||||
if (!cmd.onServerD(this)) break; // on socket error
|
||||
if (!cmd.onServer(this)) break; // on socket error
|
||||
|
||||
DebuggerCommandPtr res;
|
||||
while (!DebuggerCommand::Receive(m_thrift, res,
|
||||
@@ -527,7 +527,7 @@ void DebuggerProxy::checkStop() {
|
||||
void DebuggerProxy::processInterrupt(CmdInterrupt &cmd) {
|
||||
TRACE(2, "DebuggerProxy::processInterrupt\n");
|
||||
// Do the server-side work for this cmd.
|
||||
if (!cmd.onServerD(this)) {
|
||||
if (!cmd.onServer(this)) {
|
||||
Debugger::RemoveProxy(shared_from_this()); // on socket error
|
||||
return;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ void DebuggerProxy::processInterrupt(CmdInterrupt &cmd) {
|
||||
// Any control flow command gets installed here and we continue execution.
|
||||
m_flow = dynamic_pointer_cast<CmdFlowControl>(res);
|
||||
if (m_flow) {
|
||||
m_flow->onServerD(this);
|
||||
m_flow->onServer(this);
|
||||
processFlowControl(cmd);
|
||||
if (m_flow && m_threadMode == Normal) {
|
||||
switchThreadMode(Sticky);
|
||||
@@ -560,14 +560,14 @@ void DebuggerProxy::processInterrupt(CmdInterrupt &cmd) {
|
||||
}
|
||||
try {
|
||||
// Perform the server-size work for this command.
|
||||
if (!res || !res->onServerD(this)) {
|
||||
if (!res || !res->onServer(this)) {
|
||||
Debugger::RemoveProxy(shared_from_this());
|
||||
return;
|
||||
}
|
||||
} catch (const DebuggerException &e) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
Logger::Error("onServerD() throws non DebuggerException: %d",
|
||||
Logger::Error("onServer() throws non DebuggerException: %d",
|
||||
res->getType());
|
||||
Debugger::RemoveProxy(shared_from_this());
|
||||
return;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário