diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,15 @@ launchconfigurationpage.ui ) +ecm_qt_declare_logging_category(kdevxdebugcore_PART_SRCS + HEADER debuggerdebug.h + IDENTIFIER KDEV_PHP_DEBUGGER + CATEGORY_NAME "kdevelop.languages.php.debugger" +) + + kdevplatform_add_plugin(kdevxdebug JSON kdevxdebug.json SOURCES ${kdevxdebug_PART_SRCS} ${kdevxdebugcore_PART_SRCS}) + target_link_libraries(kdevxdebug KDev::Interfaces KDev::Debugger diff --git a/breakpointcontroller.cpp b/breakpointcontroller.cpp --- a/breakpointcontroller.cpp +++ b/breakpointcontroller.cpp @@ -26,6 +26,7 @@ #include "debugsession.h" #include "connection.h" +#include "debuggerdebug.h" namespace XDebug { BreakpointController::BreakpointController(DebugSession* parent) @@ -54,7 +55,7 @@ if (breakpoint->enabled()) { QString cmd = m_ids.contains(breakpoint) ? "breakpoint_update" : "breakpoint_set"; QStringList args; - qDebug() << "breakpoint kind" << breakpoint->kind(); + qCDebug(KDEV_PHP_DEBUGGER) << "breakpoint kind" << breakpoint->kind(); if (breakpoint->kind() == KDevelop::Breakpoint::CodeBreakpoint) { if (m_ids.contains(breakpoint)) { args << "-d " + m_ids[breakpoint]; @@ -107,7 +108,7 @@ m_ids[breakpoint] = xml.documentElement().attribute("id"); } if (!xml.documentElement().firstChildElement("error").isNull()) { - qWarning() << "breakpoint error" << xml.documentElement().firstChildElement("error").text(); + qCWarning(KDEV_PHP_DEBUGGER) << "breakpoint error" << xml.documentElement().firstChildElement("error").text(); error(breakpoint, xml.documentElement().firstChildElement("error").text(), KDevelop::Breakpoint::LocationColumn); } } @@ -119,7 +120,7 @@ void BreakpointController::stateChanged(KDevelop::IDebugSession::DebuggerState state) { - qDebug() << state; + qCDebug(KDEV_PHP_DEBUGGER) << state; if (state == KDevelop::IDebugSession::StartingState) { m_ids.clear(); sendMaybeAll(); diff --git a/connection.cpp b/connection.cpp --- a/connection.cpp +++ b/connection.cpp @@ -33,6 +33,7 @@ #include #include "debugsession.h" +#include "debuggerdebug.h" namespace XDebug { Connection::Connection(QTcpSocket* socket, QObject* parent) @@ -64,8 +65,8 @@ void Connection::error(QAbstractSocket::SocketError error) { - //qWarning() << m_socket->errorString(); - qWarning() << error; + //qCWarning(KDEV_PHP_DEBUGGER) << m_socket->errorString(); + qCWarning(KDEV_PHP_DEBUGGER) << error; } void Connection::readyRead() @@ -90,7 +91,7 @@ } data += m_socket->read(length - data.length() + 1); } - //qDebug() << data; + //qCDebug(KDEV_PHP_DEBUGGER) << data; QDomDocument doc; doc.setContent(data); @@ -101,7 +102,7 @@ } else if (doc.documentElement().tagName() == "stream") { processStream(doc); } else { - //qWarning() << "unknown element" << xml->name(); + //qCWarning(KDEV_PHP_DEBUGGER) << "unknown element" << xml->name(); } } } @@ -122,14 +123,14 @@ if (!data.isEmpty()) { out += " -- " + data.toBase64(); } - qDebug() << out; + qCDebug(KDEV_PHP_DEBUGGER) << out; m_socket->write(out); m_socket->write("\0", 1); } void Connection::processInit(const QDomDocument& xml) { - qDebug() << "idekey" << xml.documentElement().attribute("idekey"); + qCDebug(KDEV_PHP_DEBUGGER) << "idekey" << xml.documentElement().attribute("idekey"); sendCommand("feature_get -n encoding"); sendCommand("stderr -c 1"); //copy stderr to IDE @@ -175,8 +176,8 @@ //if callback doesn't handle errors himself QDomElement el = xml.documentElement().firstChildElement(); if (el.nodeName() == "error") { - qWarning() << "error" << el.attribute("code") << "for transaction" << xml.documentElement().attribute("transaction_id"); - qDebug() << el.firstChildElement().text(); + qCWarning(KDEV_PHP_DEBUGGER) << "error" << el.attribute("code") << "for transaction" << xml.documentElement().attribute("transaction_id"); + qCDebug(KDEV_PHP_DEBUGGER) << el.firstChildElement().text(); Q_ASSERT(false); } } @@ -188,7 +189,7 @@ void Connection::setState(DebugSession::DebuggerState state) { - qDebug() << state; + qCDebug(KDEV_PHP_DEBUGGER) << state; if (m_currentState == state) { return; } @@ -211,22 +212,22 @@ } else if (xml->attributes().value("type") == "stderr") { outputType = KDevelop::IRunProvider::StandardError; } else { - qWarning() << "unknown output type" << xml->attributes().value("type"); + qCWarning(KDEV_PHP_DEBUGGER) << "unknown output type" << xml->attributes().value("type"); return; } */ QString c = m_codec->toUnicode(QByteArray::fromBase64(xml.documentElement().text().toUtf8())); - //qDebug() << c; + //qCDebug(KDEV_PHP_DEBUGGER) << c; emit output(c); m_outputLine += c; int pos = m_outputLine.indexOf('\n'); if (pos != -1) { emit outputLine(m_outputLine.left(pos)); m_outputLine = m_outputLine.mid(pos + 1); } } else { - qWarning() << "unknown encoding" << xml.documentElement().attribute("encoding"); + qCWarning(KDEV_PHP_DEBUGGER) << "unknown encoding" << xml.documentElement().attribute("encoding"); } } diff --git a/debugjob.cpp b/debugjob.cpp --- a/debugjob.cpp +++ b/debugjob.cpp @@ -58,6 +58,7 @@ #include "debugsession.h" #include "xdebugplugin.h" #include "connection.h" +#include "debuggerdebug.h" namespace XDebug { XDebugJob::XDebugJob(DebugSession* session, KDevelop::ILaunchConfiguration* cfg, QObject* parent) @@ -107,7 +108,7 @@ } if (envgrp.isEmpty()) { - qWarning() << "Launch Configuration:" << cfg->name() << i18n("No environment group specified, looks like a broken " + qCWarning(KDEV_PHP_DEBUGGER) << "Launch Configuration:" << cfg->name() << i18n("No environment group specified, looks like a broken " "configuration, please check run configuration '%1'. " "Using default environment group.", cfg->name()); #if KDEVPLATFORM_VERSION < QT_VERSION_CHECK(5,1,40) @@ -124,7 +125,7 @@ } if (error() != 0) { - qWarning() << "Launch Configuration:" << cfg->name() << "oops, problem" << errorText(); + qCWarning(KDEV_PHP_DEBUGGER) << "Launch Configuration:" << cfg->name() << "oops, problem" << errorText(); return; } @@ -173,7 +174,7 @@ } program << "XDEBUG_CONFIG=\"remote_enable=1 \""; } - qDebug() << program; + qCDebug(KDEV_PHP_DEBUGGER) << program; program << interpreter; program << "-d xdebug.remote_enable=1"; QString remoteHostSetting = cfg->config().readEntry("RemoteHost", QString()); @@ -186,7 +187,7 @@ program << script.toLocalFile(); program << arguments; - qDebug() << "setting app:" << program; + qCDebug(KDEV_PHP_DEBUGGER) << "setting app:" << program; m_proc->setOutputChannelMode(KProcess::MergedChannels); @@ -198,24 +199,24 @@ void XDebugJob::start() { - qDebug() << "launching?" << m_proc; + qCDebug(KDEV_PHP_DEBUGGER) << "launching?" << m_proc; if (m_proc) { QString err; if (!m_session->listenForConnection(err)) { - qWarning() << "listening for connection failed"; + qCWarning(KDEV_PHP_DEBUGGER) << "listening for connection failed"; setError(-1); setErrorText(err); emitResult(); return; } startOutput(); - qDebug() << "starting" << m_proc->program().join(" "); + qCDebug(KDEV_PHP_DEBUGGER) << "starting" << m_proc->program().join(" "); appendLine(i18n("Starting: %1", m_proc->program().join(" "))); m_proc->start(); } else { - qWarning() << "No process, something went wrong when creating the job"; + qCWarning(KDEV_PHP_DEBUGGER) << "No process, something went wrong when creating the job"; // No process means we've returned early on from the constructor, some bad error happened emitResult(); } @@ -228,7 +229,7 @@ bool XDebugJob::doKill() { - qDebug(); + qCDebug(KDEV_PHP_DEBUGGER); if (m_session) { m_session->stopDebugger(); } @@ -249,7 +250,7 @@ } else { appendLine(i18n("*** Crashed with return code: %1 ***", QString::number(exitCode))); } - qDebug() << "Process done"; + qCDebug(KDEV_PHP_DEBUGGER) << "Process done"; emitResult(); if (m_session && m_session->connection()) { @@ -266,7 +267,7 @@ setErrorText(errmsg); emitResult(); } - qDebug() << "Process error"; + qCDebug(KDEV_PHP_DEBUGGER) << "Process error"; if (m_session && m_session->connection()) { m_session->connection()->setState(DebugSession::EndedState); @@ -323,15 +324,15 @@ void XDebugBrowserJob::start() { - qDebug() << "launching?" << m_url; + qCDebug(KDEV_PHP_DEBUGGER) << "launching?" << m_url; if (!m_url.isValid()) { emitResult(); return; } QString err; if (!m_session->listenForConnection(err)) { - qWarning() << "listening for connection failed"; + qCWarning(KDEV_PHP_DEBUGGER) << "listening for connection failed"; setError(-1); setErrorText(err); emitResult(); @@ -342,7 +343,7 @@ url.setQuery("XDEBUG_SESSION_START=kdev"); if (m_browser.isEmpty()) { if (!QDesktopServices::openUrl(url)) { - qWarning() << "openUrl failed, something went wrong when creating the job"; + qCWarning(KDEV_PHP_DEBUGGER) << "openUrl failed, something went wrong when creating the job"; emitResult(); } } else { @@ -359,13 +360,13 @@ void XDebugBrowserJob::processFailedToStart() { - qWarning() << "Cannot start application" << m_browser; + qCWarning(KDEV_PHP_DEBUGGER) << "Cannot start application" << m_browser; setError(-1); QString errmsg = i18n("Could not start program '%1'. Make sure that the " "path is specified correctly.", m_browser); setErrorText(errmsg); emitResult(); - qDebug() << "Process error"; + qCDebug(KDEV_PHP_DEBUGGER) << "Process error"; if (m_session && m_session->connection()) { m_session->connection()->setState(DebugSession::EndedState); @@ -379,7 +380,7 @@ bool XDebugBrowserJob::doKill() { - qDebug(); + qCDebug(KDEV_PHP_DEBUGGER); m_session->stopDebugger(); QUrl url = m_url; url.setQuery("XDEBUG_SESSION_STOP_NO_EXEC=kdev"); diff --git a/debugsession.cpp b/debugsession.cpp --- a/debugsession.cpp +++ b/debugsession.cpp @@ -37,6 +37,7 @@ #include "framestackmodel.h" #include "variablecontroller.h" #include "launchconfig.h" +#include "debuggerdebug.h" namespace XDebug { DebugSession::DebugSession() @@ -70,13 +71,13 @@ { Q_ASSERT(!m_server); m_server = new QTcpServer(this); - qDebug(); + qCDebug(KDEV_PHP_DEBUGGER); int remotePortSetting = m_launchConfiguration->config().readEntry("RemotePort", 9000); if (m_server->listen(QHostAddress::Any, remotePortSetting)) { connect(m_server, &QTcpServer::newConnection, this, &DebugSession::incomingConnection); } else { error = i18n("Opening port %1 failed: %2.", remotePortSetting, m_server->errorString()); - qWarning() << "Error" << m_server->errorString(); + qCWarning(KDEV_PHP_DEBUGGER) << "Error" << m_server->errorString(); delete m_server; m_server = nullptr; return false; @@ -95,7 +96,7 @@ void DebugSession::incomingConnection() { - qDebug(); + qCDebug(KDEV_PHP_DEBUGGER); QTcpSocket* client = m_server->nextPendingConnection(); if (m_connection) { @@ -132,7 +133,7 @@ void DebugSession::_stateChanged(KDevelop::IDebugSession::DebuggerState state) { - qDebug() << state; + qCDebug(KDEV_PHP_DEBUGGER) << state; if (state == StartingState) { run(); } else if (state == PausedState) { diff --git a/launchconfig.cpp b/launchconfig.cpp --- a/launchconfig.cpp +++ b/launchconfig.cpp @@ -44,6 +44,7 @@ #include "xdebugplugin.h" #include "debugjob.h" #include "launchconfigurationpage.h" +#include "debuggerdebug.h" namespace XDebug { XDebugLauncher::XDebugLauncher(XDebugPlugin* p) : m_plugin(p) @@ -75,7 +76,7 @@ if (launchMode == "debug") { return new XDebugJob(m_plugin->createSession(), cfg); } - qWarning() << "Unknown launch mode" << launchMode << "for config:" << cfg->name(); + qCWarning(KDEV_PHP_DEBUGGER) << "Unknown launch mode" << launchMode << "for config:" << cfg->name(); return nullptr; } @@ -104,7 +105,7 @@ if (launchMode == "debug") { return new XDebugBrowserJob(m_plugin->createSession(), cfg); } - qWarning() << "Unknown launch mode" << launchMode << "for config:" << cfg->name(); + qCWarning(KDEV_PHP_DEBUGGER) << "Unknown launch mode" << launchMode << "for config:" << cfg->name(); return nullptr; } } diff --git a/tests/connectiontest.cpp b/tests/connectiontest.cpp --- a/tests/connectiontest.cpp +++ b/tests/connectiontest.cpp @@ -48,6 +48,7 @@ #include "debugsession.h" #include "launchconfig.h" #include "debugjob.h" +#include "debuggerdebug.h" using namespace XDebug; namespace KParts { @@ -205,7 +206,7 @@ QSignalSpy showStepInSourceSpy(session, SIGNAL(showStepInSource(QUrl,int,QString))); - qDebug() << "************************************************************************************"; + qCDebug(KDEV_PHP_DEBUGGER) << "************************************************************************************"; job.start(); session->waitForConnected(); @@ -565,7 +566,7 @@ job.start(); session->waitForConnected(); session->waitForState(DebugSession::PausedState); - qDebug() << b->errorText(); + qCDebug(KDEV_PHP_DEBUGGER) << b->errorText(); QVERIFY(!b->errorText().isEmpty()); session->run(); diff --git a/variable.cpp b/variable.cpp --- a/variable.cpp +++ b/variable.cpp @@ -33,6 +33,7 @@ #include #include "connection.h" +#include "debuggerdebug.h" namespace XDebug { static bool hasStartedSession() @@ -69,15 +70,15 @@ void execute(const QDomDocument& xml) override { - qDebug() << xml.toString(); + qCDebug(KDEV_PHP_DEBUGGER) << xml.toString(); Q_ASSERT(xml.documentElement().attribute("command") == "property_get"); if (!m_variable) {return;} bool hasValue = false; QDomElement el = xml.documentElement().firstChildElement(); if (el.nodeName() == "error") { - qDebug() << el.firstChildElement().text(); + qCDebug(KDEV_PHP_DEBUGGER) << el.firstChildElement().text(); //hasValue=false } else { el = xml.documentElement().firstChildElement("property"); @@ -122,7 +123,7 @@ // FIXME: Eventually, should be a property of variable. KDevelop::IDebugSession* is = KDevelop::ICore::self()->debugController()->currentSession(); DebugSession* s = static_cast(is); - qDebug() << expression() << m_fullName; + qCDebug(KDEV_PHP_DEBUGGER) << expression() << m_fullName; QStringList args; args << "-n " + m_fullName; args << QString("-d %0").arg(s->frameStackModel()->currentFrame()); @@ -139,14 +140,14 @@ setInScope(true); m_fullName = xml.attribute("fullname"); - //qDebug() << m_fullName; + //qCDebug(KDEV_PHP_DEBUGGER) << m_fullName; if (xml.firstChild().isText()) { QString v = xml.firstChild().toText().data(); if (xml.attribute("encoding") == "base64") { //TODO: use Connection::m_codec->toUnicode v = QString::fromUtf8(QByteArray::fromBase64(xml.text().toUtf8())); } - //qDebug() << "value" << v; + //qCDebug(KDEV_PHP_DEBUGGER) << "value" << v; setValue(v); } @@ -161,7 +162,7 @@ QDomElement el = xml.firstChildElement("property"); while (!el.isNull()) { QString name = el.attribute("name"); - //qDebug() << name; + //qCDebug(KDEV_PHP_DEBUGGER) << name; current << name; Variable* v = nullptr; if (!existing.contains(name)) { @@ -187,7 +188,7 @@ } if (!childCount() && xml.attribute("children") == "1") { - qDebug() << "has more" << this; + qCDebug(KDEV_PHP_DEBUGGER) << "has more" << this; setHasMore(true); if (isExpanded()) { fetchMoreChildren(); diff --git a/xdebugplugin.cpp b/xdebugplugin.cpp --- a/xdebugplugin.cpp +++ b/xdebugplugin.cpp @@ -50,6 +50,7 @@ #include "debugsession.h" #include "launchconfig.h" +#include "debuggerdebug.h" K_PLUGIN_FACTORY_WITH_JSON(KDevXDebugDebuggerFactory, "kdevxdebug.json", registerPlugin();) @@ -60,7 +61,7 @@ { core()->debugController()->initializeUi(); - qDebug(); + qCDebug(KDEV_PHP_DEBUGGER); // connect(m_server, SIGNAL(sessionStarted(DebugSession*)), SLOT(sessionStarted(DebugSession*))); // connect(m_server, SIGNAL(outputLine(DebugSession*,QString,KDevelop::IRunProvider::OutputTypes)), SLOT(outputLine(DebugSession*,QString,KDevelop::IRunProvider::OutputTypes))); // connect(m_server, SIGNAL(stateChanged(DebugSession*,KDevelop::IDebugSession::DebuggerState)), SLOT(debuggerStateChanged(DebugSession*,KDevelop::IDebugSession::DebuggerState))); @@ -95,7 +96,7 @@ void XDebugPlugin::sessionStarted(DebugSession* session) { - qDebug() << session; + qCDebug(KDEV_PHP_DEBUGGER) << session; KDevelop::ICore::self()->debugController()->addSession(session); } @@ -116,7 +117,7 @@ } path += " " + run.arguments().join(" "); path = path.trimmed(); - qDebug() << path; + qCDebug(KDEV_PHP_DEBUGGER) << path; KProcess* process = m_server->startDebugger(path); m_jobs[process] = job;