From 530be10612912a804f7b197d9a7100f1b8b19809 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 27 Sep 2016 14:07:04 +0200 Subject: [PATCH] Cdb: Improve command logging For easier copy pasting comands from the log. Change-Id: I60e2737540d403454cd36f42e7b1ac3cf203df07 Reviewed-by: Christian Stenger --- src/plugins/debugger/cdb/cdbengine.cpp | 39 ++++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index a08daae7fd9..0e092d3a246 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1142,25 +1142,28 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) } QString fullCmd; - StringInputStream str(fullCmd); - if (dbgCmd.flags & BuiltinCommand) { - // Post a built-in-command producing free-format output with a callback. - // In order to catch the output, it is enclosed in 'echo' commands - // printing a specially formatted token to be identifiable in the output. - const int token = m_nextCommandToken++; - str << ".echo \"" << m_tokenPrefix << token << "<\"\n" - << cmd << "\n.echo \"" << m_tokenPrefix << token << ">\""; - m_commandForToken.insert(token, dbgCmd); - } else if (dbgCmd.flags & ExtensionCommand) { - // Post an extension command producing one-line output with a callback, - // pass along token for identification in hash. - const int token = m_nextCommandToken++; - str << m_extensionCommandPrefix << dbgCmd.function << " -t " << token; - if (dbgCmd.args.isString()) - str << ' ' << dbgCmd.argsToString(); - m_commandForToken.insert(token, dbgCmd); + if (dbgCmd.flags == NoFlags) { + fullCmd = cmd; } else { - str << cmd; + const int token = m_nextCommandToken++; + StringInputStream str(fullCmd); + if (dbgCmd.flags == BuiltinCommand) { + // Post a built-in-command producing free-format output with a callback. + // In order to catch the output, it is enclosed in 'echo' commands + // printing a specially formatted token to be identifiable in the output. + str << ".echo \"" << m_tokenPrefix << token << "<\"\n" + << cmd << "\n" + << ".echo \"" << m_tokenPrefix << token << ">\""; + } else if (dbgCmd.flags == ExtensionCommand) { + // Post an extension command producing one-line output with a callback, + // pass along token for identification in hash. + str << m_extensionCommandPrefix << dbgCmd.function << "%1%2"; + if (dbgCmd.args.isString()) + str << ' ' << dbgCmd.argsToString(); + cmd = fullCmd.arg("", ""); + fullCmd = fullCmd.arg(" -t ").arg(token); + } + m_commandForToken.insert(token, dbgCmd); } if (debug) { qDebug("CdbEngine::postCommand %dms '%s' %s, pending=%d",