forked from qt-creator/qt-creator
Debugger: Provide way to process debuggee output further
Output coming from the debuggee was limited to be printed inside the DebuggerLog and the Application Output pane, but the output might be useful to process differently or even additionally to the default logging. Provide functionality to be able to add an output processor. Change-Id: I715b90b28c64d3cf95bcc2a047a5aba1a56d1058 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -129,6 +129,10 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfig, DebuggerEngi
|
||||
DebuggerRunControl::~DebuggerRunControl()
|
||||
{
|
||||
disconnect();
|
||||
if (m_outputProcessor) {
|
||||
delete m_outputProcessor;
|
||||
m_outputProcessor = 0;
|
||||
}
|
||||
if (m_engine) {
|
||||
DebuggerEngine *engine = m_engine;
|
||||
m_engine = 0;
|
||||
@@ -149,6 +153,32 @@ bool DebuggerRunControl::supportsReRunning() const
|
||||
return m_engine && !(m_engine->runParameters().languages & QmlLanguage);
|
||||
}
|
||||
|
||||
static OutputFormat outputFormatForChannelType(int channel)
|
||||
{
|
||||
switch (channel) {
|
||||
case AppOutput: return StdOutFormatSameLine;
|
||||
case AppError: return StdErrFormatSameLine;
|
||||
case AppStuff: return DebugFormat;
|
||||
default: return NumberOfFormats;
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerRunControl::handleApplicationOutput(const QString &msg, int channel)
|
||||
{
|
||||
OutputFormat format = outputFormatForChannelType(channel);
|
||||
QTC_ASSERT(format != NumberOfFormats, return);
|
||||
if (m_outputProcessor) {
|
||||
if (m_outputProcessor->logToAppOutputPane)
|
||||
appendMessage(msg, format);
|
||||
if (m_outputProcessor->process) {
|
||||
m_outputProcessor->process(msg, channel == AppError ? OutputProcessor::StandardError
|
||||
: OutputProcessor::StandardOut);
|
||||
}
|
||||
} else {
|
||||
appendMessage(msg, format);
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerRunControl::start()
|
||||
{
|
||||
Debugger::Internal::saveModeToRestore();
|
||||
@@ -277,6 +307,12 @@ DebuggerStartParameters &DebuggerRunControl::startParameters()
|
||||
return m_engine->runParameters();
|
||||
}
|
||||
|
||||
void DebuggerRunControl::setOutputProcessor(OutputProcessor *processor)
|
||||
{
|
||||
delete m_outputProcessor;
|
||||
m_outputProcessor = processor;
|
||||
}
|
||||
|
||||
void DebuggerRunControl::notifyInferiorIll()
|
||||
{
|
||||
m_engine->notifyInferiorIll();
|
||||
|
Reference in New Issue
Block a user