Commit 6d7a4cfe authored by Peifeng Yu's avatar Peifeng Yu
Browse files

Cleanup MIDebugger output signals

There are 4 signals used for various output from the debugger:
- applicationOutput: emitted when got stream record from the 'target' channel
- userCommandOutput: emitted when got stream record from the 'console' channel and it's a user command
- internalCommandOutput: emitted when got stream record from the 'console' channel and it's not a user command
- internalOutput: emitted when got stream record from the 'log' channel or stderr from the debugger

And there are 2 output toolviews when debugging.
- The normal Debug Output panel controled by MIDebugJob
    * Shows applicationOutput, via MIDebugSession::inferiorOutputLines
    * Shows internalCommandOutput, via MIDebugSession::debuggerInternalCommandOutput
- The GDBOutputWidget which is part of the GDB plugin
    * Shows userCommandOutput, via MIDebugSession::debuggerUserCommandOutput
    * Shows internalCommandOutput, via MIDebugSession::debuggerInternalCommandOutput
    * Shows internalOutput, via MIDebugSession::debuggerInternalOutput

This should match the old behavior for toolviews and fixes the testStdOut unit test.

Test Plan: gdb unit tests

Reviewers: #kdevelop, apol

Reviewed By: #kdevelop, apol

Subscribers: kdevelop-devel

Differential Revision:
parent 38e82245
......@@ -139,7 +139,7 @@ void MIDebugger::readyReadStandardOutput()
void MIDebugger::readyReadStandardError()
emit internalCommandOutput(QString::fromUtf8(process_->readAll()));
emit debuggerInternalOutput(QString::fromUtf8(process_->readAll()));
void MIDebugger::processLine(const QByteArray& line)
......@@ -266,17 +266,16 @@ void MIDebugger::processLine(const QByteArray& line)
if (s.subkind == MI::StreamRecord::Target) {
emit applicationOutput(s.message);
} else {
} else if (s.subkind == MI::StreamRecord::Console) {
if (currentCmd_ && currentCmd_->isUserCommand())
emit userCommandOutput(s.message);
else if (s.subkind == MI::StreamRecord::Console) {
emit applicationOutput(s.message);
} else {
emit internalCommandOutput(s.message);
if (currentCmd_)
} else {
emit debuggerInternalOutput(s.message);
emit streamRecord(s);
......@@ -118,10 +118,13 @@ Q_SIGNALS:
void userCommandOutput(const QString& s);
/** Reports output of a command issued internally
by KDevelop. At the moment, stderr output from
debugger and the 'log' MI channel will be also routed here. */
by KDevelop. */
void internalCommandOutput(const QString& s);
/** Reports debugger interal output, including stderr output from debugger
and the 'log' MI channel */
void debuggerInternalOutput(const QString& s);
protected Q_SLOTS:
void readyReadStandardOutput();
void readyReadStandardError();
......@@ -43,6 +43,7 @@
#include <KParts/MainWindow>
#include <QFileInfo>
#include <QRegularExpression>
using namespace KDevMI;
using namespace KDevelop;
......@@ -58,6 +59,11 @@ MIDebugJob::MIDebugJob(MIDebuggerPlugin* p, ILaunchConfiguration* launchcfg,
m_session = p->createSession();
connect(m_session, &MIDebugSession::inferiorStdoutLines, this, &MIDebugJob::stderrReceived);
connect(m_session, &MIDebugSession::inferiorStderrLines, this, &MIDebugJob::stdoutReceived);
connect(m_session, &MIDebugSession::debuggerInternalCommandOutput,
this, [this](const QString &output){
this->stdoutReceived(output.split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts));
connect(m_session, &MIDebugSession::finished, this, &MIDebugJob::done);
if (launchcfg->project()) {
......@@ -163,6 +163,7 @@ bool MIDebugSession::startDebugger(ILaunchConfiguration *cfg)
connect(m_debugger, &MIDebugger::userCommandOutput, this, &MIDebugSession::debuggerUserCommandOutput);
connect(m_debugger, &MIDebugger::internalCommandOutput, this, &MIDebugSession::debuggerInternalCommandOutput);
connect(m_debugger, &MIDebugger::debuggerInternalOutput, this, &MIDebugSession::debuggerInternalOutput);
// state signals
connect(m_debugger, &MIDebugger::programStopped, this, &MIDebugSession::inferiorStopped);
......@@ -86,6 +86,11 @@ Q_SIGNALS:
void debuggerInternalCommandOutput(const QString &output);
* Emits when received internal output from debugger
void debuggerInternalOutput(const QString &output);
* Emits when received standard output from inferior's tty
......@@ -136,6 +136,9 @@ void GDBOutputWidget::currentSessionChanged(KDevelop::IDebugSession* s)
this, &GDBOutputWidget::slotInternalCommandStdout);
connect(session, &DebugSession::debuggerUserCommandOutput,
this, &GDBOutputWidget::slotUserCommandStdout);
// debugger internal output, treat it as an internal command output
connect(session, &DebugSession::debuggerInternalOutput,
this, &GDBOutputWidget::slotInternalCommandStdout);
connect(session, &DebugSession::debuggerStateChanged,
this, &GDBOutputWidget::slotStateChanged);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment