diff options
author | hjk <hjk@theqtcompany.com> | 2016-06-07 17:04:53 +0200 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2016-06-09 08:09:46 +0000 |
commit | 726b907cc356995b7a9c28ee8dc8b2f2314e9103 (patch) | |
tree | 3c7b9b8a4d6cdeb7ce8fc27fc9c7a8d711b147e3 | |
parent | 3333352e3b78df0348502e981def87185f57b222 (diff) | |
download | qt-creator-726b907cc356995b7a9c28ee8dc8b2f2314e9103.tar.gz |
Debugger: Remove debuggerstringutils.h
With QT_RESTRICTED_CAST_FROM_ASCII making GdbMi etc operate on
QString is feasible again. Take this as opportunity to move
debugger encoding handling closer to a 'conversion on input and
output if needed, storage in QString only' scheme.
Change-Id: I2f10c9fa8a6c62c44f4e6682efe3769e9fba30f7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
67 files changed, 1997 insertions, 2172 deletions
diff --git a/share/qtcreator/debugger/creatortypes.py b/share/qtcreator/debugger/creatortypes.py index 85abfd23d6..3dfaff03c8 100644 --- a/share/qtcreator/debugger/creatortypes.py +++ b/share/qtcreator/debugger/creatortypes.py @@ -97,9 +97,9 @@ def qdump__Core__Id(d, value): d.putPlainChildren(value) def qdump__Debugger__Internal__GdbMi(d, value): - str = d.encodeByteArray(value["m_name"]) + "3a20" \ - + d.encodeByteArray(value["m_data"]) - d.putValue(str, "latin1") + val = d.encodeString(value["m_name"]) + "3a002000" \ + + d.encodeString(value["m_data"]) + d.putValue(val, "utf16") d.putPlainChildren(value) def qdump__Debugger__Internal__DisassemblerLine(d, value): @@ -107,11 +107,11 @@ def qdump__Debugger__Internal__DisassemblerLine(d, value): d.putPlainChildren(value) def qdump__Debugger__Internal__WatchData(d, value): - d.putByteArrayValue(value["iname"]) + d.putStringValue(value["iname"]) d.putPlainChildren(value) def qdump__Debugger__Internal__WatchItem(d, value): - d.putByteArrayValue(value["iname"]) + d.putStringValue(value["iname"]) d.putPlainChildren(value) def qdump__Debugger__Internal__BreakpointModelId(d, value): diff --git a/src/plugins/baremetal/baremetalruncontrolfactory.cpp b/src/plugins/baremetal/baremetalruncontrolfactory.cpp index abe98cdb1d..240cf35830 100644 --- a/src/plugins/baremetal/baremetalruncontrolfactory.cpp +++ b/src/plugins/baremetal/baremetalruncontrolfactory.cpp @@ -117,7 +117,7 @@ RunControl *BareMetalRunControlFactory::create( foreach (const BareMetalGdbCommandsDeployStep *bs, bsl->allOfType<BareMetalGdbCommandsDeployStep>()) { if (!sp.commandsAfterConnect.endsWith("\n")) sp.commandsAfterConnect.append("\n"); - sp.commandsAfterConnect.append(bs->gdbCommands().toLatin1()); + sp.commandsAfterConnect.append(bs->gdbCommands()); } } } @@ -126,8 +126,8 @@ RunControl *BareMetalRunControlFactory::create( sp.inferior.commandLineArguments = rc->arguments(); sp.symbolFile = bin; sp.startMode = AttachToRemoteServer; - sp.commandsAfterConnect = p->initCommands().toLatin1(); - sp.commandsForReset = p->resetCommands().toLatin1(); + sp.commandsAfterConnect = p->initCommands(); + sp.commandsForReset = p->resetCommands(); sp.remoteChannel = p->channel(); sp.useContinueInsteadOfRun = true; diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 57ea837fcc..22cec4ee29 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -30,7 +30,6 @@ #include "debuggerengine.h" #include "debuggericons.h" #include "debuggerinternalconstants.h" -#include "debuggerstringutils.h" #include "simplifytype.h" #include <coreplugin/coreconstants.h> @@ -425,44 +424,43 @@ Breakpoint BreakHandler::findWatchpoint(const BreakpointParameters ¶ms) cons void BreakHandler::saveBreakpoints() { - const QString one = _("1"); QList<QVariant> list; foreach (TreeItem *n, rootItem()->children()) { BreakpointItem *b = static_cast<BreakpointItem *>(n); const BreakpointParameters ¶ms = b->m_params; QMap<QString, QVariant> map; if (params.type != BreakpointByFileAndLine) - map.insert(_("type"), params.type); + map.insert("type", params.type); if (!params.fileName.isEmpty()) - map.insert(_("filename"), params.fileName); + map.insert("filename", params.fileName); if (params.lineNumber) - map.insert(_("linenumber"), params.lineNumber); + map.insert("linenumber", params.lineNumber); if (!params.functionName.isEmpty()) - map.insert(_("funcname"), params.functionName); + map.insert("funcname", params.functionName); if (params.address) - map.insert(_("address"), params.address); + map.insert("address", params.address); if (!params.condition.isEmpty()) - map.insert(_("condition"), params.condition); + map.insert("condition", params.condition); if (params.ignoreCount) - map.insert(_("ignorecount"), params.ignoreCount); + map.insert("ignorecount", params.ignoreCount); if (params.threadSpec >= 0) - map.insert(_("threadspec"), params.threadSpec); + map.insert("threadspec", params.threadSpec); if (!params.enabled) - map.insert(_("disabled"), one); + map.insert("disabled", "1"); if (params.oneShot) - map.insert(_("oneshot"), one); + map.insert("oneshot", "1"); if (params.pathUsage != BreakpointPathUsageEngineDefault) - map.insert(_("usefullpath"), QString::number(params.pathUsage)); + map.insert("usefullpath", QString::number(params.pathUsage)); if (params.tracepoint) - map.insert(_("tracepoint"), one); + map.insert("tracepoint", "1"); if (!params.module.isEmpty()) - map.insert(_("module"), params.module); + map.insert("module", params.module); if (!params.command.isEmpty()) - map.insert(_("command"), params.command); + map.insert("command", params.command); if (!params.expression.isEmpty()) - map.insert(_("expression"), params.expression); + map.insert("expression", params.expression); if (!params.message.isEmpty()) - map.insert(_("message"), params.message); + map.insert("message", params.message); list.append(map); } setSessionValue("Breakpoints", list); @@ -475,52 +473,52 @@ void BreakHandler::loadBreakpoints() foreach (const QVariant &var, list) { const QMap<QString, QVariant> map = var.toMap(); BreakpointParameters params(BreakpointByFileAndLine); - QVariant v = map.value(_("filename")); + QVariant v = map.value("filename"); if (v.isValid()) params.fileName = v.toString(); - v = map.value(_("linenumber")); + v = map.value("linenumber"); if (v.isValid()) params.lineNumber = v.toString().toInt(); - v = map.value(_("condition")); + v = map.value("condition"); if (v.isValid()) - params.condition = v.toString().toLatin1(); - v = map.value(_("address")); + params.condition = v.toString(); + v = map.value("address"); if (v.isValid()) params.address = v.toString().toULongLong(); - v = map.value(_("ignorecount")); + v = map.value("ignorecount"); if (v.isValid()) params.ignoreCount = v.toString().toInt(); - v = map.value(_("threadspec")); + v = map.value("threadspec"); if (v.isValid()) params.threadSpec = v.toString().toInt(); - v = map.value(_("funcname")); + v = map.value("funcname"); if (v.isValid()) params.functionName = v.toString(); - v = map.value(_("disabled")); + v = map.value("disabled"); if (v.isValid()) params.enabled = !v.toInt(); - v = map.value(_("oneshot")); + v = map.value("oneshot"); if (v.isValid()) params.oneShot = v.toInt(); - v = map.value(_("usefullpath")); + v = map.value("usefullpath"); if (v.isValid()) params.pathUsage = static_cast<BreakpointPathUsage>(v.toInt()); - v = map.value(_("tracepoint")); + v = map.value("tracepoint"); if (v.isValid()) params.tracepoint = bool(v.toInt()); - v = map.value(_("type")); + v = map.value("type"); if (v.isValid() && v.toInt() != UnknownBreakpointType) params.type = BreakpointType(v.toInt()); - v = map.value(_("module")); + v = map.value("module"); if (v.isValid()) params.module = v.toString(); - v = map.value(_("command")); + v = map.value("command"); if (v.isValid()) params.command = v.toString(); - v = map.value(_("expression")); + v = map.value("expression"); if (v.isValid()) params.expression = v.toString(); - v = map.value(_("message")); + v = map.value("message"); if (v.isValid()) params.message = v.toString(); if (params.isValid()) @@ -732,7 +730,7 @@ PROPERTY(QString, fileName, setFileName) PROPERTY(QString, functionName, setFunctionName) PROPERTY(BreakpointType, type, setType) PROPERTY(int, threadSpec, setThreadSpec) -PROPERTY(QByteArray, condition, setCondition) +PROPERTY(QString, condition, setCondition) PROPERTY(QString, command, setCommand) PROPERTY(quint64, address, setAddress) PROPERTY(QString, expression, setExpression) @@ -753,16 +751,16 @@ const BreakpointParameters &Breakpoint::parameters() const void Breakpoint::addToCommand(DebuggerCommand *cmd) const { - cmd->arg("modelid", id().toByteArray()); + cmd->arg("modelid", id().toString()); cmd->arg("id", int(response().id.majorPart())); cmd->arg("type", type()); cmd->arg("ignorecount", ignoreCount()); - cmd->arg("condition", condition().toHex()); - cmd->arg("command", command().toUtf8().toHex()); - cmd->arg("function", functionName().toUtf8()); + cmd->arg("condition", toHex(condition())); + cmd->arg("command", toHex(command())); + cmd->arg("function", functionName()); cmd->arg("oneshot", isOneShot()); cmd->arg("enabled", isEnabled()); - cmd->arg("file", fileName().toUtf8()); + cmd->arg("file", fileName()); cmd->arg("line", lineNumber()); cmd->arg("address", address()); cmd->arg("expression", expression()); diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 7569d92127..e3856b6044 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -93,8 +93,8 @@ public: // obtained the BreakpointItem pointer. BreakpointPathUsage pathUsage() const; void setPathUsage(const BreakpointPathUsage &u); - QByteArray condition() const; - void setCondition(const QByteArray &condition); + QString condition() const; + void setCondition(const QString &condition); int ignoreCount() const; void setIgnoreCount(const int &count); int threadSpec() const; diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 23de8df709..3313448fe4 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -46,24 +46,12 @@ QDebug operator<<(QDebug d, const BreakpointIdBase &id) return d; } -QByteArray BreakpointIdBase::toByteArray() const -{ - if (!isValid()) - return "<invalid bkpt>"; - QByteArray ba = QByteArray::number(m_majorPart); - if (isMinor()) { - ba.append('.'); - ba.append(QByteArray::number(m_minorPart)); - } - return ba; -} - QString BreakpointIdBase::toString() const { if (!isValid()) return QLatin1String("<invalid bkpt>"); if (isMinor()) - return QString::fromLatin1("%1.%2").arg(m_majorPart).arg(m_minorPart); + return QString("%1.%2").arg(m_majorPart).arg(m_minorPart); return QString::number(m_majorPart); } @@ -79,7 +67,7 @@ QString BreakpointIdBase::toString() const */ -BreakpointModelId::BreakpointModelId(const QByteArray &ba) +BreakpointModelId::BreakpointModelId(const QString &ba) { int pos = ba.indexOf('\''); if (pos == -1) { @@ -102,7 +90,7 @@ BreakpointModelId::BreakpointModelId(const QByteArray &ba) are deleted, so, the ID is used. */ -BreakpointResponseId::BreakpointResponseId(const QByteArray &ba) +BreakpointResponseId::BreakpointResponseId(const QString &ba) { int pos = ba.indexOf('.'); if (pos == -1) { @@ -203,23 +191,23 @@ bool BreakpointParameters::equals(const BreakpointParameters &rhs) const return !differencesTo(rhs); } -bool BreakpointParameters::conditionsMatch(const QByteArray &other) const +bool BreakpointParameters::conditionsMatch(const QString &other) const { // Some versions of gdb "beautify" the passed condition. - QByteArray s1 = condition; + QString s1 = condition; s1.replace(' ', ""); - QByteArray s2 = other; + QString s2 = other; s2.replace(' ', ""); return s1 == s2; } -void BreakpointParameters::updateLocation(const QByteArray &location) +void BreakpointParameters::updateLocation(const QString &location) { if (location.size()) { int pos = location.indexOf(':'); lineNumber = location.mid(pos + 1).toInt(); - QString file = QString::fromUtf8(location.left(pos)); - if (file.startsWith(QLatin1Char('"')) && file.endsWith(QLatin1Char('"'))) + QString file = location.left(pos); + if (file.startsWith('"') && file.endsWith('"')) file = file.mid(1, file.size() - 2); QFileInfo fi(file); if (fi.isReadable()) @@ -238,9 +226,9 @@ bool BreakpointParameters::isCppBreakpoint() const if (type == BreakpointByFileAndLine) { auto qmlExtensionString = QString::fromLocal8Bit(qgetenv("QTC_QMLDEBUGGER_FILEEXTENSIONS")); if (qmlExtensionString.isEmpty()) - qmlExtensionString = QLatin1Literal(".qml;.js"); + qmlExtensionString = ".qml;.js"; - auto qmlFileExtensions = qmlExtensionString.split(QLatin1Literal(";"), QString::SkipEmptyParts); + auto qmlFileExtensions = qmlExtensionString.split(";", QString::SkipEmptyParts); foreach (QString extension, qmlFileExtensions) { if (fileName.endsWith(extension, Qt::CaseInsensitive)) return false; diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index 51c0378f3b..d186b1a3b7 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -48,7 +48,6 @@ public: bool operator!() const { return !isValid(); } operator const void*() const { return isValid() ? this : 0; } quint32 toInternalId() const { return m_majorPart | (m_minorPart << 16); } - QByteArray toByteArray() const; QString toString() const; bool operator==(const BreakpointIdBase &id) const { return m_majorPart == id.m_majorPart && m_minorPart == id.m_minorPart; } @@ -66,7 +65,7 @@ public: BreakpointModelId() { m_majorPart = m_minorPart = 0; } explicit BreakpointModelId(quint16 ma) { m_majorPart = ma; m_minorPart = 0; } BreakpointModelId(quint16 ma, quint16 mi) { m_majorPart = ma; m_minorPart = mi; } - explicit BreakpointModelId(const QByteArray &ba); // "21.2" + explicit BreakpointModelId(const QString &ba); // "21.2" }; class BreakpointResponseId : public BreakpointIdBase @@ -75,7 +74,7 @@ public: BreakpointResponseId() { m_majorPart = m_minorPart = 0; } explicit BreakpointResponseId(quint16 ma) { m_majorPart = ma; m_minorPart = 0; } BreakpointResponseId(quint16 ma, quint16 mi) { m_majorPart = ma; m_minorPart = mi; } - explicit BreakpointResponseId(const QByteArray &ba); // "21.2" + explicit BreakpointResponseId(const QString &ba); // "21.2" }; @@ -183,7 +182,7 @@ public: BreakpointParts differencesTo(const BreakpointParameters &rhs) const; bool isValid() const; bool equals(const BreakpointParameters &rhs) const; - bool conditionsMatch(const QByteArray &other) const; + bool conditionsMatch(const QString &other) const; bool isWatchpoint() const { return type == WatchpointAtAddress || type == WatchpointAtExpression; } // Enough for now. @@ -191,7 +190,7 @@ public: bool isTracepoint() const { return tracepoint; } bool isCppBreakpoint() const; QString toString() const; - void updateLocation(const QByteArray &location); // file.cpp:42 + void updateLocation(const QString &location); // file.cpp:42 bool operator==(const BreakpointParameters &p) const { return equals(p); } bool operator!=(const BreakpointParameters &p) const { return !equals(p); } @@ -200,7 +199,7 @@ public: bool enabled; //!< Should we talk to the debugger engine? BreakpointPathUsage pathUsage; //!< Should we use the full path when setting the bp? QString fileName; //!< Short name of source file. - QByteArray condition; //!< Condition associated with breakpoint. + QString condition; //!< Condition associated with breakpoint. int ignoreCount; //!< Ignore count associated with breakpoint. int lineNumber; //!< Line in source file. quint64 address; //!< Address for address based data breakpoints. diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index aaf695e0dd..54e20e72f6 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -460,7 +460,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data) data->expression = m_lineEditExpression->text(); if (partsMask & ConditionPart) - data->condition = m_lineEditCondition->text().toUtf8(); + data->condition = m_lineEditCondition->text(); if (partsMask & IgnoreCountPart) data->ignoreCount = m_spinBoxIgnoreCount->text().toInt(); if (partsMask & ThreadSpecPart) @@ -510,7 +510,7 @@ void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data) } if (mask & ConditionPart) - m_lineEditCondition->setText(QString::fromUtf8(data.condition)); + m_lineEditCondition->setText(data.condition); if (mask & IgnoreCountPart) m_spinBoxIgnoreCount->setValue(data.ignoreCount); if (mask & ThreadSpecPart) @@ -916,7 +916,7 @@ void BreakTreeView::editBreakpoints(const Breakpoints &bps) return; MultiBreakPointsDialog dialog; - dialog.setCondition(QString::fromLatin1(bp.condition())); + dialog.setCondition(bp.condition()); dialog.setIgnoreCount(bp.ignoreCount()); dialog.setThreadSpec(bp.threadSpec()); @@ -929,7 +929,7 @@ void BreakTreeView::editBreakpoints(const Breakpoints &bps) foreach (Breakpoint bp, bps) { if (bp) { - bp.setCondition(newCondition.toLatin1()); + bp.setCondition(newCondition); bp.setIgnoreCount(newIgnoreCount); bp.setThreadSpec(newThreadSpec); } diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri index 2191c4150b..2be8c3c91b 100644 --- a/src/plugins/debugger/cdb/cdb.pri +++ b/src/plugins/debugger/cdb/cdb.pri @@ -1,12 +1,12 @@ HEADERS += $$PWD/cdbengine.h \ - cdb/bytearrayinputstream.h \ cdb/cdbparsehelpers.h \ - cdb/cdboptionspage.h + cdb/cdboptionspage.h \ + cdb/stringinputstream.h SOURCES += $$PWD/cdbengine.cpp \ - cdb/bytearrayinputstream.cpp \ cdb/cdbparsehelpers.cpp \ - cdb/cdboptionspage.cpp + cdb/cdboptionspage.cpp \ + cdb/stringinputstream.cpp FORMS += cdb/cdboptionspagewidget.ui diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 1343fc32c0..c7a8783f48 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -25,7 +25,7 @@ #include "cdbengine.h" -#include "bytearrayinputstream.h" +#include "stringinputstream.h" #include "cdboptionspage.h" #include "cdbparsehelpers.h" @@ -232,7 +232,7 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) : m_specialStopMode(NoSpecialStop), m_nextCommandToken(0), m_currentBuiltinResponseToken(-1), - m_extensionCommandPrefixBA("!" QT_CREATOR_CDB_EXT "."), + m_extensionCommandPrefix("!" QT_CREATOR_CDB_EXT "."), m_operateByInstructionPending(true), m_operateByInstruction(true), // Default CDB setting m_hasDebuggee(false), @@ -243,7 +243,7 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) : m_watchPointY(0), m_ignoreCdbOutput(false) { - setObjectName(QLatin1String("CdbEngine")); + setObjectName("CdbEngine"); connect(action(OperateByInstruction), &QAction::triggered, this, &CdbEngine::operateByInstructionTriggered); @@ -323,8 +323,8 @@ void CdbEngine::syncOperateByInstruction(bool operateByInstruction) return; QTC_ASSERT(m_accessible, return); m_operateByInstruction = operateByInstruction; - runCommand({m_operateByInstruction ? "l-t" : "l+t", NoFlags}); - runCommand({m_operateByInstruction ? "l-s" : "l+s", NoFlags}); + runCommand({QLatin1String(m_operateByInstruction ? "l-t" : "l+t"), NoFlags}); + runCommand({QLatin1String(m_operateByInstruction ? "l-s" : "l+s"), NoFlags}); } bool CdbEngine::canHandleToolTip(const DebuggerToolTipContext &context) const @@ -356,7 +356,7 @@ static QStringList mergeEnvironment(QStringList runConfigEnvironment, static const char cdbExtensionPathVariableC[] = "_NT_DEBUGGER_EXTENSION_PATH"; const QByteArray oldCdbExtensionPath = qgetenv(cdbExtensionPathVariableC); if (!oldCdbExtensionPath.isEmpty()) { - cdbExtensionPath.append(QLatin1Char(';')); + cdbExtensionPath.append(';'); cdbExtensionPath.append(QString::fromLocal8Bit(oldCdbExtensionPath)); } // We do not assume someone sets _NT_DEBUGGER_EXTENSION_PATH in the run @@ -410,7 +410,7 @@ bool CdbEngine::startConsole(const DebuggerRunParameters &sp, QString *errorMess void CdbEngine::consoleStubError(const QString &msg) { if (debug) - qDebug("consoleStubProcessMessage() in %s %s", stateName(state()), qPrintable(msg)); + qDebug("consoleStubProcessMessage() in %s %s", qPrintable(stateName(state())), qPrintable(msg)); if (state() == EngineSetupRequested) { STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed") notifyEngineSetupFailed(); @@ -432,7 +432,7 @@ void CdbEngine::consoleStubProcessStarted() attachParameters.attachPID = m_consoleStub->applicationPID(); attachParameters.startMode = AttachExternal; attachParameters.useTerminal = false; - showMessage(QString::fromLatin1("Attaching to %1...").arg(attachParameters.attachPID), LogMisc); + showMessage(QString("Attaching to %1...").arg(attachParameters.attachPID), LogMisc); QString errorMessage; if (!launchCDB(attachParameters, &errorMessage)) { showMessage(errorMessage, LogError); @@ -449,7 +449,7 @@ void CdbEngine::consoleStubExited() void CdbEngine::createFullBacktrace() { runCommand({"~*kp", BuiltinCommand, [this](const DebuggerResponse &response) { - Internal::openTextEditor(QLatin1String("Backtrace $"), response.data.toLatin1()); + Internal::openTextEditor("Backtrace $", response.data.data()); }}); } @@ -503,7 +503,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage { if (debug) qDebug("launchCDB startMode=%d", sp.startMode); - const QChar blank(QLatin1Char(' ')); + const QChar blank(' '); // Start engine which will run until initial breakpoint: // Determine binary (force MSVC), extension lib name and path to use // The extension is passed as relative name with the path variable set @@ -519,9 +519,9 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage m_wow64State = noWow64Stack; const QFileInfo extensionFi(CdbEngine::extensionLibraryName(cdbIs64Bit)); if (!extensionFi.isFile()) { - *errorMessage = QString::fromLatin1("Internal error: The extension %1 cannot be found.\n" - "If you build Qt Creator from sources, check out " - "https://code.qt.io/cgit/qt-creator/binary-artifacts.git/."). + *errorMessage = QString("Internal error: The extension %1 cannot be found.\n" + "If you build Qt Creator from sources, check out " + "https://code.qt.io/cgit/qt-creator/binary-artifacts.git/."). arg(QDir::toNativeSeparators(extensionFi.absoluteFilePath())); return false; } @@ -530,23 +530,23 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage QStringList arguments; const bool isRemote = sp.startMode == AttachToRemoteServer; if (isRemote) { // Must be first - arguments << QLatin1String("-remote") << sp.remoteChannel; + arguments << "-remote" << sp.remoteChannel; } else { - arguments << (QLatin1String("-a") + extensionFileName); + arguments << ("-a" + extensionFileName); } // Source line info/No terminal breakpoint / Pull extension - arguments << QLatin1String("-lines") << QLatin1String("-G") + arguments << "-lines" << "-G" // register idle (debuggee stop) notification - << QLatin1String("-c") - << QLatin1String(".idle_cmd ") + QString::fromLatin1(m_extensionCommandPrefixBA) + QLatin1String("idle"); + << "-c" + << ".idle_cmd " + m_extensionCommandPrefix + "idle"; if (sp.useTerminal) // Separate console - arguments << QLatin1String("-2"); + arguments << "-2"; if (boolSetting(IgnoreFirstChanceAccessViolation)) - arguments << QLatin1String("-x"); + arguments << "-x"; const QStringList &sourcePaths = stringListSetting(CdbSourcePaths); if (!sourcePaths.isEmpty()) - arguments << QLatin1String("-srcpath") << sourcePaths.join(QLatin1Char(';')); + arguments << "-srcpath" << sourcePaths.join(';'); // Compile argument string preserving quotes QString nativeArguments = expand(stringSetting(CdbAdditionalArguments)); @@ -562,19 +562,19 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage break; case AttachExternal: case AttachCrashedExternal: - arguments << QLatin1String("-p") << QString::number(sp.attachPID); + arguments << "-p" << QString::number(sp.attachPID); if (sp.startMode == AttachCrashedExternal) { - arguments << QLatin1String("-e") << sp.crashParameter << QLatin1String("-g"); + arguments << "-e" << sp.crashParameter << "-g"; } else { if (isCreatorConsole(runParameters())) - arguments << QLatin1String("-pr") << QLatin1String("-pb"); + arguments << "-pr" << "-pb"; } break; case AttachCore: - arguments << QLatin1String("-z") << sp.coreFile; + arguments << "-z" << sp.coreFile; break; default: - *errorMessage = QString::fromLatin1("Internal error: Unsupported start mode %1.").arg(sp.startMode); + *errorMessage = QString("Internal error: Unsupported start mode %1.").arg(sp.startMode); return false; } if (!sp.inferior.commandLineArguments.isEmpty()) { // Complete native argument string. @@ -583,7 +583,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage nativeArguments += sp.inferior.commandLineArguments; } - const QString msg = QString::fromLatin1("Launching %1 %2\nusing %3 of %4."). + const QString msg = QString("Launching %1 %2\nusing %3 of %4."). arg(QDir::toNativeSeparators(executable), arguments.join(blank) + blank + nativeArguments, QDir::toNativeSeparators(extensionFi.absoluteFilePath()), @@ -605,18 +605,18 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage #endif m_process.start(executable, arguments); if (!m_process.waitForStarted()) { - *errorMessage = QString::fromLatin1("Internal error: Cannot start process %1: %2"). + *errorMessage = QString("Internal error: Cannot start process %1: %2"). arg(QDir::toNativeSeparators(executable), m_process.errorString()); return false; } const qint64 pid = m_process.processId(); - showMessage(QString::fromLatin1("%1 running as %2"). + showMessage(QString("%1 running as %2"). arg(QDir::toNativeSeparators(executable)).arg(pid), LogMisc); m_hasDebuggee = true; if (isRemote) { // We do not get an 'idle' in a remote session, but are accessible m_accessible = true; - runCommand({".load " + extensionFileName.toLocal8Bit(), NoFlags}); + runCommand({".load " + extensionFileName, NoFlags}); STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupOk") notifyEngineSetupOk(); } @@ -636,29 +636,30 @@ void CdbEngine::setupInferior() if (rp.breakOnMain) { const BreakpointParameters bp(BreakpointAtMain); BreakpointModelId id(quint16(-1)); - runCommand({cdbAddBreakpointCommand(bp, m_sourcePathMappings, id, true), BuiltinCommand, + QString function = cdbAddBreakpointCommand(bp, m_sourcePathMappings, id, true); + runCommand({function, BuiltinCommand, [this, id](const DebuggerResponse &r) { handleBreakInsert(r, id); }}); } // setting up symbol search path QStringList symbolPaths = stringListSetting(CdbSymbolPaths); const QProcessEnvironment &env = m_process.processEnvironment(); - QString symbolPath = env.value(QLatin1String("_NT_ALT_SYMBOL_PATH")); + QString symbolPath = env.value("_NT_ALT_SYMBOL_PATH"); if (!symbolPath.isEmpty()) symbolPaths += symbolPath; - symbolPath = env.value(QLatin1String("_NT_SYMBOL_PATH")); + symbolPath = env.value("_NT_SYMBOL_PATH"); if (!symbolPath.isEmpty()) symbolPaths += symbolPath; - runCommand({".sympath \"" + symbolPaths.join(QLatin1Char(';')).toLatin1() + '"', NoFlags}); + runCommand({".sympath \"" + symbolPaths.join(';') + '"', NoFlags}); runCommand({"!sym noisy", NoFlags}); // Show symbol load information. runCommand({"sxn 0x4000001f", NoFlags}); // Do not break on WowX86 exceptions. runCommand({"sxn ibp", NoFlags}); // Do not break on initial breakpoints. runCommand({".asm source_line", NoFlags}); // Source line in assembly - runCommand({m_extensionCommandPrefixBA + "setparameter maxStringLength=" - + action(MaximalStringLength)->value().toByteArray() + runCommand({m_extensionCommandPrefix + "setparameter maxStringLength=" + + action(MaximalStringLength)->value().toString() + " maxStackDepth=" - + action(MaximalStackDepth)->value().toByteArray(), NoFlags}); + + action(MaximalStackDepth)->value().toString(), NoFlags}); runCommand({"pid", ExtensionCommand, [this](const DebuggerResponse &response) { // Fails for core dumps. @@ -668,39 +669,39 @@ void CdbEngine::setupInferior() STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk") notifyInferiorSetupOk(); } else { - showMessage(QString::fromLatin1("Failed to determine inferior pid: %1"). - arg(response.data["msg"].toLatin1()), LogError); + showMessage(QString("Failed to determine inferior pid: %1"). + arg(response.data["msg"].data()), LogError); STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupFailed") notifyInferiorSetupFailed(); } }}); } -static QByteArray msvcRunTime(const Abi::OSFlavor flavour) +static QString msvcRunTime(const Abi::OSFlavor flavour) { switch (flavour) { case Abi::WindowsMsvc2005Flavor: - return "MSVCR80"; + return QLatin1String("MSVCR80"); case Abi::WindowsMsvc2008Flavor: - return "MSVCR90"; + return QLatin1String("MSVCR90"); case Abi::WindowsMsvc2010Flavor: - return "MSVCR100"; + return QLatin1String("MSVCR100"); case Abi::WindowsMsvc2012Flavor: - return "MSVCR110"; + return QLatin1String("MSVCR110"); case Abi::WindowsMsvc2013Flavor: - return "MSVCR120"; + return QLatin1String("MSVCR120"); case Abi::WindowsMsvc2015Flavor: - return "MSVCR140"; + return QLatin1String("MSVCR140"); default: break; } - return "MSVCRT"; // MinGW, others. + return QLatin1String("MSVCRT"); // MinGW, others. } -static QByteArray breakAtFunctionCommand(const QByteArray &function, - const QByteArray &module = QByteArray()) +static QString breakAtFunctionCommand(const QString &function, + const QString &module = QString()) { - QByteArray result = "bu "; + QString result = "bu "; if (!module.isEmpty()) { result += module; result += '!'; @@ -716,17 +717,17 @@ void CdbEngine::runEngine() const QStringList breakEvents = stringListSetting(CdbBreakEvents); foreach (const QString &breakEvent, breakEvents) - runCommand({"sxe " + breakEvent.toLatin1(), NoFlags}); + runCommand({"sxe " + breakEvent, NoFlags}); // Break functions: each function must be fully qualified, // else the debugger will slow down considerably. const auto cb = [this](const DebuggerResponse &r) { handleBreakInsert(r, BreakpointModelId()); }; if (boolSetting(CdbBreakOnCrtDbgReport)) { - const QByteArray module = msvcRunTime(runParameters().toolChainAbi.osFlavor()); - const QByteArray debugModule = module + 'D'; - const QByteArray wideFunc = QByteArray(CdbOptionsPage::crtDbgReport).append('W'); - runCommand({breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, module), BuiltinCommand, cb}); + const QString module = msvcRunTime(runParameters().toolChainAbi.osFlavor()); + const QString debugModule = module + 'D'; + const QString wideFunc = QString::fromLatin1(CdbOptionsPage::crtDbgReport).append('W'); + runCommand({breakAtFunctionCommand(QLatin1String(CdbOptionsPage::crtDbgReport), module), BuiltinCommand, cb}); runCommand({breakAtFunctionCommand(wideFunc, module), BuiltinCommand, cb}); - runCommand({breakAtFunctionCommand(CdbOptionsPage::crtDbgReport, debugModule), BuiltinCommand, cb}); + runCommand({breakAtFunctionCommand(QLatin1String(CdbOptionsPage::crtDbgReport), debugModule), BuiltinCommand, cb}); } if (boolSetting(BreakOnWarning)) { runCommand({"bm /( QtCored4!qWarning", BuiltinCommand}); // 'bm': All overloads. @@ -753,8 +754,8 @@ bool CdbEngine::commandsPending() const void CdbEngine::shutdownInferior() { if (debug) - qDebug("CdbEngine::shutdownInferior in state '%s', process running %d", stateName(state()), - isCdbProcessRunning()); + qDebug("CdbEngine::shutdownInferior in state '%s', process running %d", + qPrintable(stateName(state())), isCdbProcessRunning()); if (!isCdbProcessRunning()) { // Direct launch: Terminated with process. if (debug) @@ -772,13 +773,13 @@ void CdbEngine::shutdownInferior() } else { // A command got stuck. if (commandsPending()) { - showMessage(QLatin1String("Cannot shut down inferior due to pending commands."), LogWarning); + showMessage("Cannot shut down inferior due to pending commands.", LogWarning); STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") notifyInferiorShutdownFailed(); return; } if (!canInterruptInferior()) { - showMessage(QLatin1String("Cannot interrupt the inferior."), LogWarning); + showMessage("Cannot interrupt the inferior.", LogWarning); STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") notifyInferiorShutdownFailed(); return; @@ -800,7 +801,7 @@ void CdbEngine::shutdownEngine() if (debug) qDebug("CdbEngine::shutdownEngine in state '%s', process running %d," "accessible=%d,commands pending=%d", - stateName(state()), isCdbProcessRunning(), m_accessible, + qPrintable(stateName(state())), isCdbProcessRunning(), m_accessible, commandsPending()); if (!isCdbProcessRunning()) { // Direct launch: Terminated with process. @@ -818,7 +819,7 @@ void CdbEngine::shutdownEngine() detachDebugger(); // Remote requires a bit more force to quit. if (m_effectiveStartMode == AttachToRemoteServer) { - runCommand({m_extensionCommandPrefixBA + "shutdownex", NoFlags}); + runCommand({m_extensionCommandPrefix + "shutdownex", NoFlags}); runCommand({"qq", NoFlags}); } else { runCommand({"q", NoFlags}); @@ -833,11 +834,11 @@ void CdbEngine::abortDebugger() { if (targetState() == DebuggerFinished) { // We already tried. Try harder. - showMessage(QLatin1String("ABORTING DEBUGGER. SECOND TIME.")); + showMessage("ABORTING DEBUGGER. SECOND TIME."); m_process.kill(); } else { // Be friendly the first time. This will change targetState(). - showMessage(QLatin1String("ABORTING DEBUGGER. FIRST TIME.")); + showMessage("ABORTING DEBUGGER. FIRST TIME."); quitDebugger(); } } @@ -846,11 +847,10 @@ void CdbEngine::processFinished() { if (debug) qDebug("CdbEngine::processFinished %dms '%s' (exit state=%d, ex=%d)", - elapsedLogTime(), stateName(state()), m_process.exitStatus(), m_process.exitCode()); + elapsedLogTime(), qPrintable(stateName(state())), + m_process.exitStatus(), m_process.exitCode()); - notifyDebuggerProcessFinished(m_process.exitCode(), - m_process.exitStatus(), - QLatin1String("CDB")); + notifyDebuggerProcessFinished(m_process.exitCode(), m_process.exitStatus(), "CDB"); } void CdbEngine::detachDebugger() @@ -858,7 +858,7 @@ void CdbEngine::detachDebugger() runCommand({".detach", NoFlags}); } -static inline bool isWatchIName(const QByteArray &iname) +static inline bool isWatchIName(const QString &iname) { return iname.startsWith("watch"); } @@ -958,7 +958,7 @@ void CdbEngine::doInterruptInferiorCustomSpecialStop(const QVariant &v) void CdbEngine::handleDoInterruptInferior(const QString &errorMessage) { if (errorMessage.isEmpty()) { - showMessage(QLatin1String("Interrupted ") + QString::number(inferiorPid())); + showMessage("Interrupted " + QString::number(inferiorPid())); } else { showMessage(errorMessage, LogError); notifyInferiorStopFailed(); @@ -969,7 +969,7 @@ void CdbEngine::handleDoInterruptInferior(const QString &errorMessage) void CdbEngine::doInterruptInferior(SpecialStopMode sm) { - showMessage(QString::fromLatin1("Interrupting process %1...").arg(inferiorPid()), LogMisc); + showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc); QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed(); return;); m_signalOperation = runParameters().device->signalOperation(); @@ -1010,13 +1010,10 @@ void CdbEngine::executeRunToFunction(const QString &functionName) continueInferior(); } -void CdbEngine::setRegisterValue(const QByteArray &name, const QString &value) +void CdbEngine::setRegisterValue(const QString &name, const QString &value) { // Value is decimal or 0x-hex-prefixed - QByteArray cmd; - ByteArrayInputStream str(cmd); - str << "r " << name << '=' << value; - runCommand({cmd, NoFlags}); + runCommand({"r " + name + '=' + value, NoFlags}); reloadRegisters(); } @@ -1028,8 +1025,8 @@ void CdbEngine::executeJumpToLine(const ContextData &data) gotoLocation(Location(data.address)); } else { // Jump to source line: Resolve source line address and go to that location - QByteArray cmd; - ByteArrayInputStream str(cmd); + QString cmd; + StringInputStream str(cmd); str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`'; runCommand({cmd, BuiltinCommand, [this, data](const DebuggerResponse &r) { handleJumpToLineAddressResolution(r, data); }}); @@ -1039,8 +1036,8 @@ void CdbEngine::executeJumpToLine(const ContextData &data) void CdbEngine::jumpToAddress(quint64 address) { // Fake a jump to address by setting the PC register. - QByteArray cmd; - ByteArrayInputStream str(cmd); + QString cmd; + StringInputStream str(cmd); // PC-register depending on 64/32bit. str << "r " << (runParameters().toolChainAbi.wordWidth() == 64 ? "rip" : "eip") << '='; str.setHexPrefix(true); @@ -1051,11 +1048,11 @@ void CdbEngine::jumpToAddress(quint64 address) void CdbEngine::handleJumpToLineAddressResolution(const DebuggerResponse &response, const ContextData &context) { - if (response.data.toLatin1().isEmpty()) + if (response.data.data().isEmpty()) return; // Evaluate expression: 5365511549 = 00000001`3fcf357d // Set register 'rip' to hex address and goto lcoation - QByteArray answer = response.data.data().trimmed(); + QString answer = response.data.data().trimmed(); const int equalPos = answer.indexOf(" = "); if (equalPos == -1) return; @@ -1089,24 +1086,23 @@ void CdbEngine::assignValueInDebugger(WatchItem *w, const QString &expr, const Q qWarning("Internal error: assignValueInDebugger: Invalid state or no stack frame."); return; } - QByteArray cmd; - ByteArrayInputStream str(cmd); + QString cmd; + StringInputStream str(cmd); switch (value.type()) { case QVariant::String: { // Convert qstring to Utf16 data not considering endianness for Windows. const QString s = value.toString(); if (isAsciiWord(s)) { - str << m_extensionCommandPrefixBA << "assign \"" << w->iname << '=' - << s.toLatin1() << '"'; + str << m_extensionCommandPrefix << "assign \"" << w->iname << '=' << s << '"'; } else { const QByteArray utf16(reinterpret_cast<const char *>(s.utf16()), 2 * s.size()); - str << m_extensionCommandPrefixBA << "assign -u " << w->iname << '=' - << utf16.toHex(); + str << m_extensionCommandPrefix << "assign -u " << w->iname << '=' + << QString::fromLatin1(utf16.toHex()); } } break; default: - str << m_extensionCommandPrefixBA << "assign " << w->iname << '=' + str << m_extensionCommandPrefix << "assign " << w->iname << '=' << value.toString(); break; } @@ -1121,36 +1117,36 @@ void CdbEngine::handleThreads(const DebuggerResponse &response) { if (debug) { qDebug("CdbEngine::handleThreads %s", - DebuggerResponse::stringFromResultClass(response.resultClass).data()); + qPrintable(DebuggerResponse::stringFromResultClass(response.resultClass))); } if (response.resultClass == ResultDone) { threadsHandler()->updateThreads(response.data); // Continue sequence reloadFullStack(); } else { - showMessage(response.data["msg"].toLatin1(), LogError); + showMessage(response.data["msg"].data(), LogError); } } void CdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages) { if (languages & CppLanguage) - runCommand({command.toLocal8Bit(), NoFlags}); + runCommand({command, NoFlags}); } // Post command to the cdb process void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) { - QByteArray cmd = dbgCmd.function + dbgCmd.argsToString(); + QString cmd = dbgCmd.function + dbgCmd.argsToString(); if (!m_accessible) { - const QString msg = QString::fromLatin1("Attempt to issue command \"%1\" to non-accessible session (%2)") - .arg(QString::fromLocal8Bit(cmd), QString::fromLatin1(stateName(state()))); + const QString msg = QString("Attempt to issue command \"%1\" to non-accessible session (%2)") + .arg(cmd, stateName(state())); showMessage(msg, LogError); return; } - QByteArray fullCmd; - ByteArrayInputStream str(fullCmd); + 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 @@ -1163,7 +1159,7 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) // 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_extensionCommandPrefixBA << dbgCmd.function << " -t " << token; + str << m_extensionCommandPrefix << dbgCmd.function << " -t " << token; if (dbgCmd.args.isString()) str << ' ' << dbgCmd.argsToString(); m_commandForToken.insert(token, dbgCmd); @@ -1172,15 +1168,14 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) } if (debug) { qDebug("CdbEngine::postCommand %dms '%s' %s, pending=%d", - elapsedLogTime(), dbgCmd.function.data(), stateName(state()), + elapsedLogTime(), qPrintable(dbgCmd.function), qPrintable(stateName(state())), m_commandForToken.size()); } if (debug > 1) { - qDebug("CdbEngine::postCommand: resulting command '%s'\n", - fullCmd.constData()); + qDebug("CdbEngine::postCommand: resulting command '%s'\n", qPrintable(fullCmd)); } - showMessage(QString::fromLocal8Bit(cmd), LogInput); - m_process.write(fullCmd + '\n'); + showMessage(cmd, LogInput); + m_process.write(fullCmd.toLocal8Bit() + '\n'); } void CdbEngine::activateFrame(int index) @@ -1210,7 +1205,7 @@ void CdbEngine::activateFrame(int index) void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) { - typedef QHash<QByteArray, int> WatcherHash; + typedef QHash<QString, int> WatcherHash; const bool partialUpdate = !updateParameters.partialVariable.isEmpty(); const bool isWatch = isWatchIName(updateParameters.partialVariable); @@ -1232,17 +1227,17 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) * thread 0/frame 0 -> thread 1/assembly -> thread 0/frame 0 will otherwise re-use it * and cause errors as it seems to go 'stale' when switching threads. * Initial expand, get uninitialized and query */ - QByteArray arguments; - ByteArrayInputStream str(arguments); + QString arguments; + StringInputStream str(arguments); if (!partialUpdate) { str << "-D"; // Pre-expand - const QSet<QByteArray> expanded = watchHandler()->expandedINames(); + const QSet<QString> expanded = watchHandler()->expandedINames(); if (!expanded.isEmpty()) { str << blankSeparator << "-e "; int i = 0; - foreach (const QByteArray &e, expanded) { + foreach (const QString &e, expanded) { if (i++) str << ','; str << e; @@ -1254,10 +1249,10 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) str << blankSeparator << "-c"; if (boolSetting(SortStructMembers)) str << blankSeparator << "-a"; - const QByteArray typeFormats = watchHandler()->typeFormatRequests(); + const QString typeFormats = watchHandler()->typeFormatRequests(); if (!typeFormats.isEmpty()) str << blankSeparator << "-T " << typeFormats; - const QByteArray individualFormats = watchHandler()->individualFormatRequests(); + const QString individualFormats = watchHandler()->individualFormatRequests(); if (!individualFormats.isEmpty()) str << blankSeparator << "-I " << individualFormats; // Uninitialized variables if desired. Quote as safeguard against shadowed @@ -1285,7 +1280,7 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) if (!watcherHash.isEmpty()) { const WatcherHash::const_iterator cend = watcherHash.constEnd(); for (WatcherHash::const_iterator it = watcherHash.constBegin(); it != cend; ++it) { - str << blankSeparator << "-w " << "watch." + QByteArray::number(it.value()) + str << blankSeparator << "-w " << "watch." + QString::number(it.value()) << " \"" << it.key() << '"'; } } @@ -1298,7 +1293,7 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) str << blankSeparator << updateParameters.partialVariable; DebuggerCommand cmd("locals", ExtensionCommand); - cmd.args = QLatin1String(arguments); + cmd.args = arguments; cmd.callback = [this, partialUpdate](const DebuggerResponse &r) { handleLocals(r, partialUpdate); }; runCommand(cmd); } @@ -1315,7 +1310,7 @@ void CdbEngine::selectThread(ThreadId threadId) threadsHandler()->setCurrentThread(threadId); - runCommand({'~' + QByteArray::number(threadId.raw()) + " s", BuiltinCommand, + runCommand({'~' + QString::number(threadId.raw()) + " s", BuiltinCommand, [this](const DebuggerResponse &) { reloadFullStack(); }}); } @@ -1359,9 +1354,11 @@ void CdbEngine::postDisassemblerCommand(quint64 address, DisassemblerAgent *agen void CdbEngine::postDisassemblerCommand(quint64 address, quint64 endAddress, DisassemblerAgent *agent) { - DebuggerCommand cmd; - ByteArrayInputStream str(cmd.function); + QString ba; + StringInputStream str(ba); str << "u " << hex <<hexPrefixOn << address << ' ' << endAddress; + DebuggerCommand cmd; + cmd.function = ba; cmd.callback = [this, agent](const DebuggerResponse &response) { // Parse: "00000000`77606060 cc int 3" agent->setContents(parseCdbDisassembler(response.data.data())); @@ -1373,27 +1370,27 @@ void CdbEngine::postDisassemblerCommand(quint64 address, quint64 endAddress, void CdbEngine::postResolveSymbol(const QString &module, const QString &function, DisassemblerAgent *agent) { - QString symbol = module.isEmpty() ? QString(QLatin1Char('*')) : module; - symbol += QLatin1Char('!'); + QString symbol = module.isEmpty() ? QString('*') : module; + symbol += '!'; symbol += function; const QList<quint64> addresses = m_symbolAddressCache.values(symbol); if (addresses.isEmpty()) { - showMessage(QLatin1String("Resolving symbol: ") + symbol + QLatin1String("..."), LogMisc); - runCommand({"x " + symbol.toLatin1(), BuiltinCommand, + showMessage("Resolving symbol: " + symbol + "...", LogMisc); + runCommand({"x " + symbol, BuiltinCommand, [this, symbol, agent](const DebuggerResponse &r) { handleResolveSymbol(r, symbol, agent); }}); } else { - showMessage(QString::fromLatin1("Using cached addresses for %1.").arg(symbol), LogMisc); + showMessage(QString("Using cached addresses for %1.").arg(symbol), LogMisc); handleResolveSymbolHelper(addresses, agent); } } // Parse address from 'x' response. // "00000001`3f7ebe80 module!foo (void)" -static inline quint64 resolvedAddress(const QByteArray &line) +static inline quint64 resolvedAddress(const QString &line) { const int blankPos = line.indexOf(' '); if (blankPos >= 0) { - QByteArray addressBA = line.left(blankPos); + QString addressBA = line.left(blankPos); if (addressBA.size() > 9 && addressBA.at(8) == '`') addressBA.remove(8, 1); bool ok; @@ -1409,17 +1406,15 @@ void CdbEngine::handleResolveSymbol(const DebuggerResponse &response, const QStr { // Insert all matches of (potentially) ambiguous symbols if (!response.data.data().isEmpty()) { - foreach (QByteArray line, response.data.data().split('\n')) { + foreach (const QString &line, response.data.data().split('\n')) { if (const quint64 address = resolvedAddress(line)) { m_symbolAddressCache.insert(symbol, address); - showMessage(QString::fromLatin1("Obtained 0x%1 for %2"). + showMessage(QString("Obtained 0x%1 for %2"). arg(address, 0, 16).arg(symbol), LogMisc); } } } else { - showMessage(QLatin1String("Symbol resolution failed: ") - + response.data["msg"].toLatin1(), - LogError); + showMessage("Symbol resolution failed: " + response.data["msg"].data(), LogError); } handleResolveSymbolHelper(m_symbolAddressCache.values(symbol), agent); } @@ -1519,17 +1514,17 @@ void CdbEngine::fetchMemory(MemoryAgent *agent, QObject *editor, quint64 addr, q void CdbEngine::postFetchMemory(const MemoryViewCookie &cookie) { DebuggerCommand cmd("memory", ExtensionCommand); - QByteArray args; - ByteArrayInputStream str(args); + QString args; + StringInputStream str(args); str << cookie.address << ' ' << cookie.length; - cmd.args = QLatin1String(args); + cmd.args = args; cmd.callback = [this, cookie](const DebuggerResponse &response) { if (response.resultClass == ResultDone && cookie.agent) { - const QByteArray data = QByteArray::fromHex(response.data.data()); + const QByteArray data = QByteArray::fromHex(response.data.data().toUtf8()); if (unsigned(data.size()) == cookie.length) cookie.agent->addLazyData(cookie.editorToken, cookie.address, data); } else { - showMessage(response.data["msg"].toLatin1(), LogWarning); + showMessage(response.data["msg"].data(), LogWarning); } }; runCommand(cmd); @@ -1600,8 +1595,8 @@ void CdbEngine::handleModules(const DebuggerResponse &response) handler->beginUpdateAll(); foreach (const GdbMi &gdbmiModule, response.data.children()) { Module module; - module.moduleName = QString::fromLatin1(gdbmiModule["name"].data()); - module.modulePath = QString::fromLatin1(gdbmiModule["image"].data()); + module.moduleName = gdbmiModule["name"].data(); + module.modulePath = gdbmiModule["image"].data(); module.startAddress = gdbmiModule["start"].data().toULongLong(0, 0); module.endAddress = gdbmiModule["end"].data().toULongLong(0, 0); if (gdbmiModule["deferred"].type() == GdbMi::Invalid) @@ -1610,12 +1605,12 @@ void CdbEngine::handleModules(const DebuggerResponse &response) } handler->endUpdateAll(); } else { - showMessage(QString::fromLatin1("Parse error in modules response."), LogError); - qWarning("Parse error in modules response:\n%s", response.data.data().data()); + showMessage("Parse error in modules response.", LogError); + qWarning("Parse error in modules response:\n%s", qPrintable(response.data.data())); } } else { - showMessage(QString::fromLatin1("Failed to determine modules: %1"). - arg(response.data["msg"].toLatin1()), LogError); + showMessage(QString("Failed to determine modules: %1"). + arg(response.data["msg"].data()), LogError); } } @@ -1637,36 +1632,36 @@ void CdbEngine::handleRegistersExt(const DebuggerResponse &response) reg.kind = VectorRegister; else reg.kind = OtherRegister; - reg.value.fromByteArray(item["value"].data(), HexadecimalFormat); + reg.value.fromString(item["value"].data(), HexadecimalFormat); reg.size = item["size"].data().toInt(); handler->updateRegister(reg); } handler->commitUpdates(); } else { - showMessage(QString::fromLatin1("Parse error in registers response."), LogError); - qWarning("Parse error in registers response:\n%s", response.data.data().data()); + showMessage("Parse error in registers response.", LogError); + qWarning("Parse error in registers response:\n%s", qPrintable(response.data.data())); } } else { - showMessage(QString::fromLatin1("Failed to determine registers: %1"). - arg(response.data["msg"].toLatin1()), LogError); + showMessage(QString("Failed to determine registers: %1"). + arg(response.data["msg"].data()), LogError); } } void CdbEngine::handleLocals(const DebuggerResponse &response, bool partialUpdate) { if (response.resultClass == ResultDone) { - showMessage(QLatin1String(response.data.toString()), LogDebug); + showMessage(response.data.toString(), LogDebug); GdbMi partial; partial.m_name = "partial"; - partial.m_data = QByteArray::number(partialUpdate ? 1 : 0); + partial.m_data = QString::number(partialUpdate ? 1 : 0); GdbMi all; all.m_children.push_back(response.data); all.m_children.push_back(partial); updateLocalsView(all); } else { - showMessage(response.data["msg"].toLatin1(), LogWarning); + showMessage(response.data["msg"].data(), LogWarning); } watchHandler()->notifyUpdateFinished(); } @@ -1674,7 +1669,7 @@ void CdbEngine::handleLocals(const DebuggerResponse &response, bool partialUpdat void CdbEngine::handleExpandLocals(const DebuggerResponse &response) { if (response.resultClass != ResultDone) - showMessage(response.data["msg"].toLatin1(), LogError); + showMessage(response.data["msg"].data(), LogError); } enum CdbExecutionStatus { @@ -1747,11 +1742,11 @@ static inline QString msgTracePointTriggered(BreakpointModelId id, const int num } static inline QString msgCheckingConditionalBreakPoint(BreakpointModelId id, const int number, - const QByteArray &condition, + const QString &condition, const QString &threadId) { return CdbEngine::tr("Conditional breakpoint %1 (%2) in thread %3 triggered, examining expression \"%4\".") - .arg(id.toString()).arg(number).arg(threadId, QString::fromLatin1(condition)); + .arg(id.toString()).arg(number).arg(threadId, condition); } unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, @@ -1764,8 +1759,8 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, if (targetState() == DebuggerFinished) rc |= StopShutdownInProgress; if (debug) - qDebug("%s", stopReason.toString(true, 4).constData()); - const QByteArray reason = stopReason["reason"].data(); + qDebug("%s", qPrintable(stopReason.toString(true, 4))); + const QString reason = stopReason["reason"].data(); if (reason.isEmpty()) { *message = tr("Malformed stop response received."); rc |= StopReportParseError|StopNotifyStop; @@ -1773,8 +1768,7 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, } // Additional stop messages occurring for debuggee function calls (widgetAt, etc). Just log. if (state() == InferiorStopOk) { - *message = QString::fromLatin1("Ignored stop notification from function call (%1)."). - arg(QString::fromLatin1(reason)); + *message = QString("Ignored stop notification from function call (%1).").arg(reason); rc |= StopReportLog; return rc; } @@ -1789,7 +1783,7 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, if (bp.engine() == this) { const BreakpointResponse parameters = bp.response(); if (!parameters.message.isEmpty()) { - showMessage(parameters.message + QLatin1Char('\n'), AppOutput); + showMessage(parameters.message + '\n', AppOutput); showMessage(parameters.message, LogMisc); } // Trace point? Just report. @@ -1802,13 +1796,13 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, if (!conditionalBreakPointTriggered && !parameters.condition.isEmpty()) { *message = msgCheckingConditionalBreakPoint(id, number, parameters.condition, QString::number(threadId)); - DebuggerCommand cmd("expression", ExtensionCommand); - QByteArray args = parameters.condition; + QString args = parameters.condition; if (args.contains(' ') && !args.startsWith('"')) { args.prepend('"'); args.append('"'); } - cmd.args = QLatin1String(args); + DebuggerCommand cmd("expression", ExtensionCommand); + cmd.args = args; cmd.callback = [this, id, stopReason](const DebuggerResponse &response) { handleExpression(response, id, stopReason); }; @@ -1858,64 +1852,12 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, rc |= StopShowExceptionMessageBox|StopReportStatusMessage|StopNotifyStop; return rc; } - *message = msgStopped(QLatin1String(reason)); + *message = msgStopped(reason); rc |= StopReportStatusMessage|StopNotifyStop; return rc; } -void CdbEngine::handleSessionIdle(const QByteArray &messageBA) -{ - if (!m_hasDebuggee) - return; - - if (debug) - qDebug("CdbEngine::handleSessionIdle %dms '%s' in state '%s', special mode %d", - elapsedLogTime(), messageBA.constData(), - stateName(state()), m_specialStopMode); - - // Switch source level debugging - syncOperateByInstruction(m_operateByInstructionPending); - - // Engine-special stop reasons: Breakpoints and setup - const SpecialStopMode specialStopMode = m_specialStopMode; - - m_specialStopMode = NoSpecialStop; - - switch (specialStopMode) { - case SpecialStopSynchronizeBreakpoints: - if (debug) - qDebug("attemptBreakpointSynchronization in special stop"); - attemptBreakpointSynchronization(); - doContinueInferior(); - return; - case SpecialStopGetWidgetAt: - postWidgetAtCommand(); - return; - case CustomSpecialStop: - foreach (const QVariant &data, m_customSpecialStopData) - handleCustomSpecialStop(data); - m_customSpecialStopData.clear(); - doContinueInferior(); - return; - case NoSpecialStop: - break; - } - if (state() == EngineSetupRequested) { // Temporary stop at beginning - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupOk") - notifyEngineSetupOk(); - // Store stop reason to be handled in runEngine(). - if (runParameters().startMode == AttachCore) { - m_coreStopReason.reset(new GdbMi); - m_coreStopReason->fromString(messageBA); - } - return; - } - - GdbMi stopReason; - stopReason.fromString(messageBA); - processStop(stopReason, false); -} void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointTriggered) { @@ -1950,7 +1892,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT } // Prevent further commands from being sent if shutdown is in progress if (stopFlags & StopShutdownInProgress) { - showMessage(QString::fromLatin1("Shutdown request detected...")); + showMessage("Shutdown request detected..."); return; } const bool sourceStepInto = m_sourceStepInto; @@ -1978,7 +1920,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT break; } } else { - showMessage(QString::fromLatin1(stopReason["stackerror"].data()), LogError); + showMessage(stopReason["stackerror"].data(), LogError); } } const GdbMi threads = stopReason["threads"]; @@ -1987,7 +1929,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT if (forcedThreadId.isValid()) threadsHandler()->setCurrentThread(forcedThreadId); } else { - showMessage(QString::fromLatin1(stopReason["threaderror"].data()), LogError); + showMessage(stopReason["threaderror"].data(), LogError); } // Fire off remaining commands asynchronously if (!m_pendingBreakpointMap.isEmpty() && !m_pendingSubBreakpointMap.isEmpty()) @@ -2005,11 +1947,11 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT void CdbEngine::handleBreakInsert(const DebuggerResponse &response, const BreakpointModelId &bpId) { - const QList<QByteArray> &reply = response.data.data().split('\n'); + const QStringList reply = response.data.data().split('\n'); if (reply.isEmpty()) return; - foreach (const QByteArray &line, reply) - showMessage(QString::fromLocal8Bit(line)); + foreach (const QString &line, reply) + showMessage(line); if (!reply.last().startsWith("Ambiguous symbol error") && (reply.length() < 2 || !reply.at(reply.length() - 2).startsWith("Ambiguous symbol error"))) { return; @@ -2029,9 +1971,8 @@ void CdbEngine::handleBreakInsert(const DebuggerResponse &response, const Breakp return; Breakpoint bp = breakHandler()->breakpointById(bpId); // add break point for every match - const QList<QByteArray>::const_iterator &end = reply.constEnd(); int subBreakPointID = 0; - for (QList<QByteArray>::const_iterator line = reply.constBegin(); line != end; ++line) { + for (auto line = reply.constBegin(), end = reply.constEnd(); line != end; ++line) { if (!line->startsWith("Matched: ")) continue; const int addressStartPos = line->lastIndexOf('(') + 1; @@ -2039,7 +1980,7 @@ void CdbEngine::handleBreakInsert(const DebuggerResponse &response, const Breakp if (addressStartPos == 0 || addressEndPos == -1) continue; - QByteArray addressString = line->mid(addressStartPos, addressEndPos - addressStartPos); + QString addressString = line->mid(addressStartPos, addressEndPos - addressStartPos); addressString.replace("`", ""); bool ok = true; quint64 address = addressString.toULongLong(&ok, 16); @@ -2077,7 +2018,7 @@ void CdbEngine::ensureUsing32BitStackInWow64(const DebuggerResponse &response, c { // Parsing the header of the stack output to check which bitness // the cdb is currently using. - foreach (const QByteArray &line, response.data.data().split('\n')) { + foreach (const QString &line, response.data.data().split('\n')) { if (!line.startsWith("Child")) continue; if (line.startsWith("ChildEBP")) { @@ -2114,7 +2055,8 @@ void CdbEngine::handleSessionAccessible(unsigned long cdbExState) if (debug) qDebug("CdbEngine::handleSessionAccessible %dms in state '%s'/'%s', special mode %d", - elapsedLogTime(), cdbStatusName(cdbExState), stateName(state()), m_specialStopMode); + elapsedLogTime(), cdbStatusName(cdbExState), + qPrintable(stateName(state())), m_specialStopMode); switch (s) { case EngineShutdownRequested: @@ -2138,7 +2080,8 @@ void CdbEngine::handleSessionInaccessible(unsigned long cdbExState) if (debug) qDebug("CdbEngine::handleSessionInaccessible %dms in state '%s', '%s', special mode %d", - elapsedLogTime(), cdbStatusName(cdbExState), stateName(state()), m_specialStopMode); + elapsedLogTime(), cdbStatusName(cdbExState), + qPrintable(stateName(state())), m_specialStopMode); switch (state()) { case EngineSetupRequested: @@ -2169,7 +2112,61 @@ void CdbEngine::handleSessionInaccessible(unsigned long cdbExState) } } -void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what, const QByteArray &message) +void CdbEngine::handleSessionIdle(const QString &message) +{ + if (!m_hasDebuggee) + return; + + if (debug) + qDebug("CdbEngine::handleSessionIdle %dms '%s' in state '%s', special mode %d", + elapsedLogTime(), qPrintable(message), + qPrintable(stateName(state())), m_specialStopMode); + + // Switch source level debugging + syncOperateByInstruction(m_operateByInstructionPending); + + // Engine-special stop reasons: Breakpoints and setup + const SpecialStopMode specialStopMode = m_specialStopMode; + + m_specialStopMode = NoSpecialStop; + + switch (specialStopMode) { + case SpecialStopSynchronizeBreakpoints: + if (debug) + qDebug("attemptBreakpointSynchronization in special stop"); + attemptBreakpointSynchronization(); + doContinueInferior(); + return; + case SpecialStopGetWidgetAt: + postWidgetAtCommand(); + return; + case CustomSpecialStop: + foreach (const QVariant &data, m_customSpecialStopData) + handleCustomSpecialStop(data); + m_customSpecialStopData.clear(); + doContinueInferior(); + return; + case NoSpecialStop: + break; + } + + if (state() == EngineSetupRequested) { // Temporary stop at beginning + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupOk") + notifyEngineSetupOk(); + // Store stop reason to be handled in runEngine(). + if (runParameters().startMode == AttachCore) { + m_coreStopReason.reset(new GdbMi); + m_coreStopReason->fromString(message); + } + return; + } + + GdbMi stopReason; + stopReason.fromString(message); + processStop(stopReason, false); +} + +void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, const QString &message) { if (debug > 1) { QDebug nospace = qDebug().nospace(); @@ -2184,14 +2181,14 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what // Is there a reply expected, some command queued? if (t == 'R' || t == 'N') { if (token == -1) { // Default token, user typed in extension command - showMessage(QString::fromLatin1(message), LogMisc); + showMessage(message, LogMisc); return; } // Did the command finish? Take off queue and complete, invoke CB const DebuggerCommand command = m_commandForToken.take(token); if (debug) qDebug("### Completed extension command '%s' for token=%d, pending=%d", - command.function.data(), token, m_commandForToken.size()); + qPrintable(command.function), token, m_commandForToken.size()); if (!command.callback) return; @@ -2218,7 +2215,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what } if (what == "debuggee_output") { - const QByteArray decoded = QByteArray::fromHex(message); + const QByteArray decoded = QByteArray::fromHex(message.toUtf8()); showMessage(QString::fromUtf16(reinterpret_cast<const ushort *>(decoded.data()), decoded.size() / 2), AppOutput); return; @@ -2227,7 +2224,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what if (what == "event") { if (message.startsWith("Process exited")) notifyInferiorExited(); - showStatusMessage(QString::fromLatin1(message), 5000); + showStatusMessage(message, 5000); return; } @@ -2267,13 +2264,12 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what showStatusMessage(message); // Report C++ exception in application output as well. if (exception.exceptionCode == winExceptionCppException) - showMessage(message + QLatin1Char('\n'), AppOutput); + showMessage(message + '\n', AppOutput); if (!isDebuggerWinException(exception.exceptionCode)) { const Task::TaskType type = isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning; - const FileName fileName = exception.file.isEmpty() ? - FileName() : - FileName::fromUserInput(QString::fromLocal8Bit(exception.file)); + const FileName fileName = exception.file.isEmpty() + ? FileName() : FileName::fromUserInput(exception.file); TaskHub::addTask(type, exception.toString(false).trimmed(), Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, fileName, exception.lineNumber); @@ -2285,24 +2281,26 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what // Check for a CDB prompt '0:000> ' ('process:thread> ')..no regexps for QByteArray... enum { CdbPromptLength = 7 }; -static inline bool isCdbPrompt(const QByteArray &c) +static inline bool isCdbPrompt(const QString &c) { return c.size() >= CdbPromptLength && c.at(6) == ' ' && c.at(5) == '>' && c.at(1) == ':' - && std::isdigit(c.at(0)) && std::isdigit(c.at(2)) && std::isdigit(c.at(3)) - && std::isdigit(c.at(4)); + && std::isdigit(c.at(0).unicode()) + && std::isdigit(c.at(2).unicode()) + && std::isdigit(c.at(3).unicode()) + && std::isdigit(c.at(4).unicode()); } // Check for '<token>32>' or '<token>32<' -static inline bool checkCommandToken(const QByteArray &tokenPrefix, const QByteArray &c, +static inline bool checkCommandToken(const QString &tokenPrefix, const QString &c, int *token, bool *isStart) { *token = 0; *isStart = false; const int tokenPrefixSize = tokenPrefix.size(); const int size = c.size(); - if (size < tokenPrefixSize + 2 || !std::isdigit(c.at(tokenPrefixSize))) + if (size < tokenPrefixSize + 2 || !std::isdigit(c.at(tokenPrefixSize).unicode())) return false; - switch (c.at(size - 1)) { + switch (c.at(size - 1).unicode()) { case '>': *isStart = false; break; @@ -2319,7 +2317,7 @@ static inline bool checkCommandToken(const QByteArray &tokenPrefix, const QByteA return ok; } -void CdbEngine::parseOutputLine(QByteArray line) +void CdbEngine::parseOutputLine(QString line) { // The hooked output callback in the extension suppresses prompts, // it should happen only in initial and exit stages. Note however that @@ -2328,10 +2326,10 @@ void CdbEngine::parseOutputLine(QByteArray line) while (isCdbPrompt(line)) line.remove(0, CdbPromptLength); // An extension notification (potentially consisting of several chunks) - static const QByteArray creatorExtPrefix = "<qtcreatorcdbext>|"; + static const QString creatorExtPrefix = "<qtcreatorcdbext>|"; if (line.startsWith(creatorExtPrefix)) { // "<qtcreatorcdbext>|type_char|token|remainingChunks|serviceName|message" - const char type = line.at(creatorExtPrefix.size()); + const char type = line.at(creatorExtPrefix.size()).unicode(); // integer token const int tokenPos = creatorExtPrefix.size() + 2; const int tokenEndPos = line.indexOf('|', tokenPos); @@ -2346,7 +2344,7 @@ void CdbEngine::parseOutputLine(QByteArray line) const int whatPos = remainingChunksEndPos + 1; const int whatEndPos = line.indexOf('|', whatPos); QTC_ASSERT(whatEndPos != -1, return); - const QByteArray what = line.mid(whatPos, whatEndPos - whatPos); + const QString what = line.mid(whatPos, whatEndPos - whatPos); // Build up buffer, call handler once last chunk was encountered m_extensionMessageBuffer += line.mid(whatEndPos + 1); if (remainingChunks == 0) { @@ -2362,7 +2360,7 @@ void CdbEngine::parseOutputLine(QByteArray line) const bool isCommandToken = checkCommandToken(m_tokenPrefix, line, &token, &isStartToken); if (debug > 1) qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d", - line.constData(), isCommandToken, token, isStartToken); + qPrintable(line), isCommandToken, token, isStartToken); // If there is a current command, wait for end of output indicated by token, // command, trigger handler and finish, else append to its output. @@ -2373,10 +2371,10 @@ void CdbEngine::parseOutputLine(QByteArray line) const DebuggerCommand &command = m_commandForToken.take(token); if (debug) qDebug("### Completed builtin command '%s' for token=%d, %d lines, pending=%d", - command.function.data(), m_currentBuiltinResponseToken, + qPrintable(command.function), m_currentBuiltinResponseToken, m_currentBuiltinResponse.count('\n'), m_commandForToken.size() - 1); QTC_ASSERT(token == m_currentBuiltinResponseToken, return); - showMessage(QLatin1String(m_currentBuiltinResponse), LogMisc); + showMessage(m_currentBuiltinResponse, LogMisc); if (command.callback) { DebuggerResponse response; response.token = token; @@ -2405,15 +2403,15 @@ void CdbEngine::parseOutputLine(QByteArray line) } const char versionString[] = "Microsoft (R) Windows Debugger Version"; if (line.startsWith(versionString)) { - QRegExp versionRegEx(QLatin1String("(\\d+)\\.(\\d+)\\.\\d+\\.\\d+")); - if (versionRegEx.indexIn(QLatin1String(line)) > -1) { + QRegExp versionRegEx("(\\d+)\\.(\\d+)\\.\\d+\\.\\d+"); + if (versionRegEx.indexIn(line) > -1) { bool ok = true; int major = versionRegEx.cap(1).toInt(&ok); int minor = versionRegEx.cap(2).toInt(&ok); if (ok) { // for some incomprehensible reasons Microsoft cdb version 6.2 is newer than 6.12 m_autoBreakPointCorrection = major > 6 || (major == 6 && minor >= 2 && minor < 10); - showMessage(QString::fromLocal8Bit(line), LogMisc); + showMessage(line, LogMisc); showMessage(QString::fromLatin1("Using ") + QLatin1String(m_autoBreakPointCorrection ? "CDB " : "codemodel ") + QString::fromLatin1("based breakpoint correction."), LogMisc); @@ -2422,12 +2420,11 @@ void CdbEngine::parseOutputLine(QByteArray line) } else if (line.startsWith("ModLoad: ")) { // output(64): ModLoad: 00007ffb`842b0000 00007ffb`843ee000 C:\Windows\system32\KERNEL32.DLL // output(32): ModLoad: 00007ffb 00007ffb C:\Windows\system32\KERNEL32.DLL - QRegExp moduleRegExp(QLatin1String( - "[0-9a-fA-F]+(`[0-9a-fA-F]+)? [0-9a-fA-F]+(`[0-9a-fA-F]+)? (.*)")); - if (moduleRegExp.indexIn(QLatin1String(line)) > -1) + QRegExp moduleRegExp("[0-9a-fA-F]+(`[0-9a-fA-F]+)? [0-9a-fA-F]+(`[0-9a-fA-F]+)? (.*)"); + if (moduleRegExp.indexIn(line) > -1) showStatusMessage(tr("Module loaded: ") + moduleRegExp.cap(3).trimmed(), 3000); } else { - showMessage(QString::fromLocal8Bit(line), LogMisc); + showMessage(line, LogMisc); } } @@ -2446,7 +2443,7 @@ void CdbEngine::readyReadStandardOut() QByteArray line = m_outputBuffer.left(endOfLinePos); if (!line.isEmpty() && line.at(line.size() - 1) == '\r') line.truncate(line.size() - 1); - parseOutputLine(line); + parseOutputLine(QString::fromLocal8Bit(line)); m_outputBuffer.remove(0, endOfLinePos + 1); } } @@ -2566,7 +2563,7 @@ unsigned BreakpointCorrectionContext::fixLineNumber(const QString &fileName, void CdbEngine::attemptBreakpointSynchronization() { if (debug) - qDebug("attemptBreakpointSynchronization in %s", stateName(state())); + qDebug("attemptBreakpointSynchronization in %s", qPrintable(stateName(state()))); // Check if there is anything to be done at all. BreakHandler *handler = breakHandler(); // Take ownership of the breakpoint. Requests insertion. TODO: Cpp only? @@ -2601,7 +2598,7 @@ void CdbEngine::attemptBreakpointSynchronization() if (debugBreakpoints) qDebug("attemptBreakpointSynchronizationI %dms accessible=%d, %s %d breakpoints, changed=%d", - elapsedLogTime(), m_accessible, stateName(state()), bps.size(), changed); + elapsedLogTime(), m_accessible, qPrintable(stateName(state())), bps.size(), changed); if (!changed) return; @@ -2638,14 +2635,14 @@ void CdbEngine::attemptBreakpointSynchronization() lineCorrection.reset(new BreakpointCorrectionContext(Internal::cppCodeModelSnapshot(), CppTools::CppModelManager::instance()->workingCopy())); response.lineNumber = lineCorrection->fixLineNumber(parameters.fileName, parameters.lineNumber); - QByteArray cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, id, false); + QString cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, id, false); runCommand({cmd, BuiltinCommand, handleBreakInsertCB}); } else { - QByteArray cmd = cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false); + QString cmd = cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false); runCommand({cmd, BuiltinCommand, handleBreakInsertCB}); } if (!parameters.enabled) - runCommand({"bd " + QByteArray::number(breakPointIdToCdbId(id)), NoFlags}); + runCommand({"bd " + QString::number(breakPointIdToCdbId(id)), NoFlags}); bp.notifyBreakpointInsertProceeding(); bp.notifyBreakpointInsertOk(); m_pendingBreakpointMap.insert(id, response); @@ -2665,7 +2662,7 @@ void CdbEngine::attemptBreakpointSynchronization() if (parameters.enabled != bp.response().enabled) { // Change enabled/disabled breakpoints without triggering update. runCommand({(parameters.enabled ? "be " : "bd ") - + QByteArray::number(breakPointIdToCdbId(id)), NoFlags}); + + QString::number(breakPointIdToCdbId(id)), NoFlags}); response.pending = false; response.enabled = parameters.enabled; bp.setResponse(response); @@ -2673,7 +2670,7 @@ void CdbEngine::attemptBreakpointSynchronization() // Delete and re-add, triggering update addedChanged = true; runCommand({cdbClearBreakpointCommand(id), NoFlags}); - QByteArray cmd(cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false)); + QString cmd(cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false)); runCommand({cmd, BuiltinCommand, handleBreakInsertCB}); m_pendingBreakpointMap.insert(id, response); } @@ -2723,7 +2720,7 @@ CdbEngine::NormalizedSourceFileName CdbEngine::sourceMapNormalizeFileNameFromDeb NormalizedSourceFileName result(QDir::cleanPath(normalized.isEmpty() ? fileName : normalized), exists); if (!exists) { // At least upper case drive letter if failed. - if (result.fileName.size() > 2 && result.fileName.at(1) == QLatin1Char(':')) + if (result.fileName.size() > 2 && result.fileName.at(1) == ':') result.fileName[0] = result.fileName.at(0).toUpper(); } m_normalizedFileCache.insert(f, result); @@ -2749,18 +2746,18 @@ static StackFrames parseFrames(const GdbMi &gdbmi, bool *incomplete = 0) break; } StackFrame frame; - frame.level = QByteArray::number(i); + frame.level = QString::number(i); const GdbMi fullName = frameMi["fullname"]; if (fullName.isValid()) { - frame.file = QFile::decodeName(fullName.data()); + frame.file = fullName.data(); frame.line = frameMi["line"].data().toInt(); frame.usable = false; // To be decided after source path mapping. const GdbMi languageMi = frameMi["language"]; if (languageMi.isValid() && languageMi.data() == "js") frame.language = QmlLanguage; } - frame.function = QLatin1String(frameMi["function"].data()); - frame.module = QLatin1String(frameMi["from"].data()); + frame.function = frameMi["function"].data(); + frame.module = frameMi["from"].data(); frame.context = frameMi["context"].data(); frame.address = frameMi["address"].data().toULongLong(0, 16); rc.push_back(frame); @@ -2782,26 +2779,23 @@ unsigned CdbEngine::parseStackTrace(const GdbMi &data, bool sourceStepInto) const int count = frames.size(); for (int i = 0; i < count; i++) { if (m_wow64State == wow64Uninitialized) { - showMessage(QString::fromLatin1("Checking for wow64 subsystem..."), LogMisc); + showMessage("Checking for wow64 subsystem...", LogMisc); return ParseStackWow64; } const bool hasFile = !frames.at(i).file.isEmpty(); // jmp-frame hit by step into, do another 't' and abort sequence. if (!hasFile && i == 0 && sourceStepInto) { - if (frames.at(i).function.contains(QLatin1String("ILT+"))) { - showMessage(QString::fromLatin1("Step into: Call instruction hit, " - "performing additional step..."), LogMisc); + if (frames.at(i).function.contains("ILT+")) { + showMessage("Step into: Call instruction hit, performing additional step...", LogMisc); return ParseStackStepInto; } - showMessage(QString::fromLatin1("Step into: Hit frame with no source, " - "step out..."), LogMisc); + showMessage("Step into: Hit frame with no source, step out...", LogMisc); return ParseStackStepOut; } if (hasFile) { const NormalizedSourceFileName fileName = sourceMapNormalizeFileNameFromDebugger(frames.at(i).file); if (!fileName.exists && i == 0 && sourceStepInto) { - showMessage(QString::fromLatin1("Step into: Hit frame with no source, " - "step out..."), LogMisc); + showMessage("Step into: Hit frame with no source, step out...", LogMisc); return ParseStackStepOut; } frames[i].file = fileName.fileName; @@ -2828,17 +2822,17 @@ void CdbEngine::handleAdditionalQmlStack(const DebuggerResponse &response) QString errorMessage; do { if (response.resultClass != ResultDone) { - errorMessage = response.data["msg"].toLatin1(); + errorMessage = response.data["msg"].data(); break; } if (!response.data.isValid()) { - errorMessage = QLatin1String("GDBMI parser error"); + errorMessage = "GDBMI parser error"; break; } StackFrames qmlFrames = parseFrames(response.data); const int qmlFrameCount = qmlFrames.size(); if (!qmlFrameCount) { - errorMessage = QLatin1String("Empty stack"); + errorMessage = "Empty stack"; break; } for (int i = 0; i < qmlFrameCount; ++i) @@ -2846,7 +2840,7 @@ void CdbEngine::handleAdditionalQmlStack(const DebuggerResponse &response) stackHandler()->prependFrames(qmlFrames); } while (false); if (!errorMessage.isEmpty()) - showMessage(QLatin1String("Unable to obtain QML stack trace: ") + errorMessage, LogError); + showMessage("Unable to obtain QML stack trace: " + errorMessage, LogError); } void CdbEngine::mergeStartParametersSourcePathMap() @@ -2869,7 +2863,7 @@ void CdbEngine::handleStackTrace(const DebuggerResponse &response) [this, stack](const DebuggerResponse &r) { handleCheckWow64(r, stack); }}); } } else { - showMessage(stack["msg"].toLatin1(), LogError); + showMessage(stack["msg"].data(), LogError); } } @@ -2879,7 +2873,7 @@ void CdbEngine::handleExpression(const DebuggerResponse &response, BreakpointMod if (response.resultClass == ResultDone) value = response.data.toInt(); else - showMessage(response.data["msg"].toLatin1(), LogError); + showMessage(response.data["msg"].data(), LogError); // Is this a conditional breakpoint? const QString message = value ? tr("Value %1 obtained from evaluating the condition of breakpoint %2, stopping."). @@ -2900,24 +2894,24 @@ void CdbEngine::handleWidgetAt(const DebuggerResponse &response) QString message; do { if (response.resultClass != ResultDone) { - message = response.data["msg"].toLatin1(); + message = response.data["msg"].data(); break; } // Should be "namespace::QWidget:0x555" - QString watchExp = response.data.toLatin1(); - const int sepPos = watchExp.lastIndexOf(QLatin1Char(':')); + QString watchExp = response.data.data(); + const int sepPos = watchExp.lastIndexOf(':'); if (sepPos == -1) { - message = QString::fromLatin1("Invalid output: %1").arg(watchExp); + message = QString("Invalid output: %1").arg(watchExp); break; } // 0x000 -> nothing found if (!watchExp.mid(sepPos + 1).toULongLong(0, 0)) { - message = QString::fromLatin1("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY); + message = QString("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY); break; } // Turn into watch expression: "*(namespace::QWidget*)0x555" - watchExp.replace(sepPos, 1, QLatin1String("*)")); - watchExp.insert(0, QLatin1String("*(")); + watchExp.replace(sepPos, 1, "*)"); + watchExp.insert(0, "*("); watchHandler()->watchExpression(watchExp); success = true; } while (false); @@ -2948,14 +2942,14 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response) { if (debugBreakpoints) { qDebug("CdbEngine::handleBreakPoints: success=%d: %s", - response.resultClass == ResultDone, QLatin1String(response.data.toString()).data()); + response.resultClass == ResultDone, qPrintable(response.data.toString())); } if (response.resultClass != ResultDone) { - showMessage(response.data["msg"].toLatin1(), LogError); + showMessage(response.data["msg"].data(), LogError); return; } if (response.data.type() != GdbMi::List) { - showMessage(QString::fromLatin1("Unable to parse breakpoints reply"), LogError); + showMessage("Unable to parse breakpoints reply", LogError); return; } @@ -3010,9 +3004,9 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response) } // not pending reported } // foreach if (m_pendingBreakpointMap.empty()) - str << QLatin1String("All breakpoints have been resolved.\n"); + str << "All breakpoints have been resolved.\n"; else - str << QString::fromLatin1("%1 breakpoint(s) pending...\n").arg(m_pendingBreakpointMap.size()); + str << QString("%1 breakpoint(s) pending...\n").arg(m_pendingBreakpointMap.size()); showMessage(message, LogMisc); } @@ -3033,7 +3027,7 @@ void CdbEngine::watchPoint(const QPoint &p) break; default: showMessage(tr("\"Select Widget to Watch\": Not supported in state \"%1\"."). - arg(QString::fromLatin1(stateName(state()))), LogWarning); + arg(stateName(state())), LogWarning); break; } } @@ -3041,7 +3035,7 @@ void CdbEngine::watchPoint(const QPoint &p) void CdbEngine::postWidgetAtCommand() { DebuggerCommand cmd("widgetat", ExtensionCommand); - cmd.args = QString::fromLatin1("%1 %2").arg(m_watchPointX, m_watchPointY); + cmd.args = QString("%1 %2").arg(m_watchPointX, m_watchPointY); runCommand(cmd); } diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index fd5118e50f..f62e255586 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -45,7 +45,7 @@ namespace Internal { class DisassemblerAgent; class CdbCommand; struct MemoryViewCookie; -class ByteArrayInputStream; +class StringInputStream; class GdbMi; class CdbEngine : public DebuggerEngine @@ -74,7 +74,7 @@ public: void detachDebugger() override; bool hasCapability(unsigned cap) const override; void watchPoint(const QPoint &) override; - void setRegisterValue(const QByteArray &name, const QString &value) override; + void setRegisterValue(const QString &name, const QString &value) override; void executeStep() override; void executeStepOut() override; @@ -169,17 +169,17 @@ private: bool conditionalBreakPointTriggered = false); void processStop(const GdbMi &stopReason, bool conditionalBreakPointTriggered = false); bool commandsPending() const; - void handleExtensionMessage(char t, int token, const QByteArray &what, const QByteArray &message); + void handleExtensionMessage(char t, int token, const QString &what, const QString &message); bool doSetupEngine(QString *errorMessage); bool launchCDB(const DebuggerRunParameters &sp, QString *errorMessage); void handleSessionAccessible(unsigned long cdbExState); void handleSessionInaccessible(unsigned long cdbExState); - void handleSessionIdle(const QByteArray &message); + void handleSessionIdle(const QString &message); void doInterruptInferior(SpecialStopMode sm); void doInterruptInferiorCustomSpecialStop(const QVariant &v); void doContinueInferior(); - inline void parseOutputLine(QByteArray line); - inline bool isCdbProcessRunning() const { return m_process.state() != QProcess::NotRunning; } + void parseOutputLine(QString line); + bool isCdbProcessRunning() const { return m_process.state() != QProcess::NotRunning; } bool canInterruptInferior() const; void syncOperateByInstruction(bool operateByInstruction); void postWidgetAtCommand(); @@ -219,7 +219,7 @@ private: unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto); void mergeStartParametersSourcePathMap(); - const QByteArray m_tokenPrefix; + const QString m_tokenPrefix; QProcess m_process; QScopedPointer<Utils::ConsoleProcess> m_consoleStub; @@ -231,10 +231,10 @@ private: ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation; int m_nextCommandToken; QHash<int, DebuggerCommand> m_commandForToken; - QByteArray m_currentBuiltinResponse; + QString m_currentBuiltinResponse; int m_currentBuiltinResponseToken; QMap<QString, NormalizedSourceFileName> m_normalizedFileCache; - const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix + const QString m_extensionCommandPrefix; //!< Library name used as prefix bool m_operateByInstructionPending; //!< Creator operate by instruction action changed. bool m_operateByInstruction; bool m_hasDebuggee; @@ -246,7 +246,7 @@ private: } m_wow64State; QTime m_logTime; mutable int m_elapsedLogTime; - QByteArray m_extensionMessageBuffer; + QString m_extensionMessageBuffer; bool m_sourceStepInto; int m_watchPointX; int m_watchPointY; diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 8a7640223b..6f612b6517 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -25,7 +25,7 @@ #include "cdbparsehelpers.h" -#include "bytearrayinputstream.h" +#include "stringinputstream.h" #include <debugger/debuggerprotocol.h> #include <debugger/disassemblerlines.h> @@ -168,14 +168,14 @@ BreakpointResponseId cdbIdToBreakpointResponseId(const GdbMi &id) return cdbIdToBreakpointId<BreakpointResponseId>(id); } -QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, - const QList<QPair<QString, QString> > &sourcePathMapping, - BreakpointModelId id /* = BreakpointId() */, - bool oneshot) +QString cdbAddBreakpointCommand(const BreakpointParameters &bpIn, + const QList<QPair<QString, QString> > &sourcePathMapping, + BreakpointModelId id /* = BreakpointId() */, + bool oneshot) { const BreakpointParameters bp = fixWinMSVCBreakpoint(bpIn); - QByteArray rc; - ByteArrayInputStream str(rc); + QString rc; + StringInputStream str(rc); if (bp.threadSpec >= 0) str << '~' << bp.threadSpec << ' '; @@ -201,7 +201,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, case BreakpointAtJavaScriptThrow: case UnknownBreakpointType: case LastBreakpointType: - QTC_ASSERT(false, return QByteArray()); + QTC_ASSERT(false, return QString()); break; case BreakpointByAddress: str << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; @@ -231,14 +231,14 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, return rc; } -QByteArray cdbClearBreakpointCommand(const BreakpointModelId &id) +QString cdbClearBreakpointCommand(const BreakpointModelId &id) { const int firstBreakPoint = breakPointIdToCdbId(id); if (id.isMinor()) - return "bc " + QByteArray::number(firstBreakPoint); + return "bc " + QString::number(firstBreakPoint); // If this is a major break point we also want to delete all sub break points const int lastBreakPoint = firstBreakPoint + cdbBreakPointIdMinorPart - 1; - return "bc " + QByteArray::number(firstBreakPoint) + '-' + QByteArray::number(lastBreakPoint); + return "bc " + QString::number(firstBreakPoint) + '-' + QString::number(lastBreakPoint); } // Helper to retrieve an int child from GDBMI @@ -280,10 +280,10 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, r->id = cdbIdToBreakpointResponseId(gdbmi["id"]); const GdbMi moduleG = gdbmi["module"]; if (moduleG.isValid()) - r->module = QString::fromLocal8Bit(moduleG.data()); + r->module = moduleG.data(); const GdbMi sourceFileName = gdbmi["srcfile"]; if (sourceFileName.isValid()) { - r->fileName = QString::fromLocal8Bit(sourceFileName.data()); + r->fileName = sourceFileName.data(); const GdbMi lineNumber = gdbmi["srcline"]; if (lineNumber.isValid()) r->lineNumber = lineNumber.data().toULongLong(0, 0); @@ -291,7 +291,7 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, if (expression) { const GdbMi expressionG = gdbmi["expression"]; if (expressionG.isValid()) - *expression = QString::fromLocal8Bit(expressionG.data()); + *expression = expressionG.data(); } const GdbMi addressG = gdbmi["address"]; if (addressG.isValid()) @@ -301,10 +301,10 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, gdbmiChildToInt(gdbmi, "thread", &(r->threadSpec)); } -QByteArray cdbWriteMemoryCommand(quint64 addr, const QByteArray &data) +QString cdbWriteMemoryCommand(quint64 addr, const QByteArray &data) { - QByteArray cmd; - ByteArrayInputStream str(cmd); + QString cmd; + StringInputStream str(cmd); str.setIntegerBase(16); str << "f " << addr << " L" << data.size(); const int count = data.size(); @@ -384,10 +384,10 @@ QString WinException::toString(bool includeLocation) const str << " (first chance)"; if (includeLocation) { if (lineNumber) { - str << " at " << QLatin1String(file) << ':' << lineNumber; + str << " at " << file << ':' << lineNumber; } else { if (!function.isEmpty()) - str << " in " << QLatin1String(function); + str << " in " << function; } } return rc; @@ -525,7 +525,7 @@ bool parseCdbDisassemblerLine(const QString &line, DisassemblerLine *dLine, uint return true; } -DisassemblerLines parseCdbDisassembler(const QByteArray &a) +DisassemblerLines parseCdbDisassembler(const QString &a) { DisassemblerLines result; quint64 functionAddress = 0; @@ -534,8 +534,7 @@ DisassemblerLines parseCdbDisassembler(const QByteArray &a) quint64 functionOffset = 0; QString sourceFile; - foreach (const QByteArray &lineBA, a.split('\n')) { - const QString line = QString::fromLatin1(lineBA); + foreach (const QString &line, a.split('\n')) { // New function. Append as comment line. if (parseCdbDisassemblerFunctionLine(line, ¤tFunction, &functionOffset, &sourceFile)) { functionAddress = 0; @@ -552,7 +551,7 @@ DisassemblerLines parseCdbDisassembler(const QByteArray &a) result.appendSourceLine(sourceFile, sourceLine); } } else { - qWarning("Unable to parse assembly line '%s'", lineBA.constData()); + qWarning("Unable to parse assembly line '%s'", qPrintable(line)); disassemblyLine.fromString(line); } // Determine address of function from the first assembler line after a diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.h b/src/plugins/debugger/cdb/cdbparsehelpers.h index ebed376db5..d8df9b63ec 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.h +++ b/src/plugins/debugger/cdb/cdbparsehelpers.h @@ -59,21 +59,21 @@ BreakpointModelId cdbIdToBreakpointModelId(const GdbMi &id); BreakpointResponseId cdbIdToBreakpointResponseId(const GdbMi &id); // Convert breakpoint in CDB syntax (applying source path mappings using native paths). -QByteArray cdbAddBreakpointCommand(const BreakpointParameters &d, - const QList<QPair<QString, QString> > &sourcePathMapping, - BreakpointModelId id = BreakpointModelId(quint16(-1)), bool oneshot = false); -QByteArray cdbClearBreakpointCommand(const BreakpointModelId &id); +QString cdbAddBreakpointCommand(const BreakpointParameters &d, + const QList<QPair<QString, QString> > &sourcePathMapping, + BreakpointModelId id = BreakpointModelId(quint16(-1)), bool oneshot = false); +QString cdbClearBreakpointCommand(const BreakpointModelId &id); // Parse extension command listing breakpoints. // Note that not all fields are returned, since file, line, function are encoded // in the expression (that is in addition deleted on resolving for a bp-type breakpoint). void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, QString *expression = 0); // Write memory (f ...). -QByteArray cdbWriteMemoryCommand(quint64 addr, const QByteArray &data); +QString cdbWriteMemoryCommand(quint64 addr, const QByteArray &data); QString debugByteArray(const QByteArray &a); -DisassemblerLines parseCdbDisassembler(const QByteArray &a); +DisassemblerLines parseCdbDisassembler(const QString &a); // Model EXCEPTION_RECORD + firstchance struct WinException @@ -88,9 +88,9 @@ struct WinException quint64 info1; quint64 info2; bool firstChance; - QByteArray file; + QString file; int lineNumber; - QByteArray function; + QString function; }; QDebug operator<<(QDebug s, const WinException &e); diff --git a/src/plugins/debugger/cdb/bytearrayinputstream.cpp b/src/plugins/debugger/cdb/stringinputstream.cpp index 6f2911a8d7..a76f7183fc 100644 --- a/src/plugins/debugger/cdb/bytearrayinputstream.cpp +++ b/src/plugins/debugger/cdb/stringinputstream.cpp @@ -23,45 +23,45 @@ ** ****************************************************************************/ -#include "bytearrayinputstream.h" +#include "stringinputstream.h" #include <ctype.h> namespace Debugger { namespace Internal { -ByteArrayInputStream::ByteArrayInputStream(QByteArray &ba) : - m_target(ba), m_integerBase(10), m_hexPrefix(false), m_width(0) +StringInputStream::StringInputStream(QString &str) : + m_target(str), m_integerBase(10), m_hexPrefix(false), m_width(0) { } -void ByteArrayInputStream::appendSeparator(char c) +void StringInputStream::appendSeparator(char c) { if (!m_target.isEmpty() && !m_target.endsWith(c)) m_target.append(c); } -void hexPrefixOn(ByteArrayInputStream &bs) +void hexPrefixOn(StringInputStream &bs) { bs.setHexPrefix(true); } -void hexPrefixOff(ByteArrayInputStream &bs) +void hexPrefixOff(StringInputStream &bs) { bs.setHexPrefix(false); } -void hex(ByteArrayInputStream &bs) +void hex(StringInputStream &bs) { bs.setIntegerBase(16); } -void dec(ByteArrayInputStream &bs) +void dec(StringInputStream &bs) { bs.setIntegerBase(10); } -void blankSeparator(ByteArrayInputStream &bs) +void blankSeparator(StringInputStream &bs) { bs.appendSeparator(); } diff --git a/src/plugins/debugger/cdb/bytearrayinputstream.h b/src/plugins/debugger/cdb/stringinputstream.h index 2d2a0f5083..0ee46094b1 100644 --- a/src/plugins/debugger/cdb/bytearrayinputstream.h +++ b/src/plugins/debugger/cdb/stringinputstream.h @@ -30,27 +30,26 @@ namespace Debugger { namespace Internal { -class ByteArrayInputStream +class StringInputStream { - Q_DISABLE_COPY(ByteArrayInputStream) + Q_DISABLE_COPY(StringInputStream) public: - typedef void (ModifierFunc)(ByteArrayInputStream &s); + typedef void (ModifierFunc)(StringInputStream &s); - explicit ByteArrayInputStream(QByteArray &ba); + explicit StringInputStream(QString &str); - ByteArrayInputStream &operator<<(char a) { m_target.append(a); return *this; } - ByteArrayInputStream &operator<<(const QByteArray &a) { m_target.append(a); return *this; } - ByteArrayInputStream &operator<<(const char *a) { m_target.append(a); return *this; } - ByteArrayInputStream &operator<<(const QString &a) { m_target.append(a.toLatin1()); return *this; } + StringInputStream &operator<<(char a) { m_target.append(a); return *this; } + StringInputStream &operator<<(const char *a) { m_target.append(QString::fromUtf8(a)); return *this; } + StringInputStream &operator<<(const QString &a) { m_target.append(a); return *this; } - ByteArrayInputStream &operator<<(int i) { appendInt(i); return *this; } - ByteArrayInputStream &operator<<(unsigned i) { appendInt(i); return *this; } - ByteArrayInputStream &operator<<(quint64 i) { appendInt(i); return *this; } - ByteArrayInputStream &operator<<(qint64 i) { appendInt(i); return *this; } + StringInputStream &operator<<(int i) { appendInt(i); return *this; } + StringInputStream &operator<<(unsigned i) { appendInt(i); return *this; } + StringInputStream &operator<<(quint64 i) { appendInt(i); return *this; } + StringInputStream &operator<<(qint64 i) { appendInt(i); return *this; } // Stream a modifier by invoking it - ByteArrayInputStream &operator<<(ModifierFunc mf) { mf(*this); return *this; } + StringInputStream &operator<<(ModifierFunc mf) { mf(*this); return *this; } void setHexPrefix(bool hp) { m_hexPrefix = hp; } bool hexPrefix() const { return m_hexPrefix; } @@ -62,35 +61,35 @@ public: private: template <class IntType> void appendInt(IntType i); - QByteArray &m_target; + QString &m_target; int m_integerBase; bool m_hexPrefix; int m_width; }; template <class IntType> -void ByteArrayInputStream::appendInt(IntType i) +void StringInputStream::appendInt(IntType i) { const bool hexPrefix = m_integerBase == 16 && m_hexPrefix; if (hexPrefix) m_target.append("0x"); - const QByteArray n = QByteArray::number(i, m_integerBase); + const QString n = QString::number(i, m_integerBase); if (m_width > 0) { int pad = m_width - n.size(); if (hexPrefix) pad -= 2; if (pad > 0) - m_target.append(QByteArray(pad, '0')); + m_target.append(QString('0', pad)); } m_target.append(n); } -// Streamable modifiers for ByteArrayInputStream -void hexPrefixOn(ByteArrayInputStream &bs); -void hexPrefixOff(ByteArrayInputStream &bs); -void hex(ByteArrayInputStream &bs); -void dec(ByteArrayInputStream &bs); -void blankSeparator(ByteArrayInputStream &bs); +// Streamable modifiers for StringInputStream +void hexPrefixOn(StringInputStream &bs); +void hexPrefixOff(StringInputStream &bs); +void hex(StringInputStream &bs); +void dec(StringInputStream &bs); +void blankSeparator(StringInputStream &bs); // Bytearray parse helpers QByteArray trimFront(QByteArray in); diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 08d0e25fd8..a09fbb7232 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -32,7 +32,6 @@ HEADERS += \ debuggerrunconfigurationaspect.h \ debuggerruncontrol.h \ debuggerstartparameters.h \ - debuggerstringutils.h \ debuggerkitconfigwidget.h \ debuggerkitinformation.h \ disassembleragent.h \ diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index 2fcce2f42b..9896b33bab 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -63,7 +63,6 @@ QtcPlugin { "debuggerruncontrol.cpp", "debuggerruncontrol.h", "debuggersourcepathmappingwidget.cpp", "debuggersourcepathmappingwidget.h", "debuggerstartparameters.h", - "debuggerstringutils.h", "debuggertooltipmanager.cpp", "debuggertooltipmanager.h", "disassembleragent.cpp", "disassembleragent.h", "disassemblerlines.cpp", "disassemblerlines.h", @@ -106,7 +105,7 @@ QtcPlugin { name: "cdb" prefix: "cdb/" files: [ - "bytearrayinputstream.cpp", "bytearrayinputstream.h", + "stringinputstream.cpp", "stringinputstream.h", "cdbengine.cpp", "cdbengine.h", "cdboptionspage.cpp", "cdboptionspage.h", "cdboptionspagewidget.ui", diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h index 9a89a55842..c8398a7a14 100644 --- a/src/plugins/debugger/debuggercore.h +++ b/src/plugins/debugger/debuggercore.h @@ -90,8 +90,8 @@ QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions(); WatchTreeView *inspectorView(); QVariant sessionValue(const QByteArray &name); void setSessionValue(const QByteArray &name, const QVariant &value); -QVariant configValue(const QByteArray &name); -void setConfigValue(const QByteArray &name, const QVariant &value); +QVariant configValue(const QString &name); +void setConfigValue(const QString &name, const QVariant &value); bool isTestRun(); diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 9607840ec9..00849f84e9 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -28,7 +28,6 @@ #include "debuggerkitinformation.h" #include "debuggerstartparameters.h" #include "debuggerruncontrol.h" -#include "debuggerstringutils.h" #include "cdb/cdbengine.h" #include <coreplugin/icore.h> @@ -185,31 +184,31 @@ QString StartApplicationParameters::displayName() const void StartApplicationParameters::toSettings(QSettings *settings) const { - settings->setValue(_("LastKitId"), kitId.toSetting()); - settings->setValue(_("LastServerPort"), serverPort); - settings->setValue(_("LastServerAddress"), serverAddress); - settings->setValue(_("LastExternalExecutable"), runnable.executable); - settings->setValue(_("LastExternalExecutableArguments"), runnable.commandLineArguments); - settings->setValue(_("LastExternalWorkingDirectory"), runnable.workingDirectory); - settings->setValue(_("LastExternalBreakAtMain"), breakAtMain); - settings->setValue(_("LastExternalRunInTerminal"), runnable.runMode == ApplicationLauncher::Console); - settings->setValue(_("LastServerStartScript"), serverStartScript); - settings->setValue(_("LastDebugInfoLocation"), debugInfoLocation); + settings->setValue("LastKitId", kitId.toSetting()); + settings->setValue("LastServerPort", serverPort); + settings->setValue("LastServerAddress", serverAddress); + settings->setValue("LastExternalExecutable", runnable.executable); + settings->setValue("LastExternalExecutableArguments", runnable.commandLineArguments); + settings->setValue("LastExternalWorkingDirectory", runnable.workingDirectory); + settings->setValue("LastExternalBreakAtMain", breakAtMain); + settings->setValue("LastExternalRunInTerminal", runnable.runMode == ApplicationLauncher::Console); + settings->setValue("LastServerStartScript", serverStartScript); + settings->setValue("LastDebugInfoLocation", debugInfoLocation); } void StartApplicationParameters::fromSettings(const QSettings *settings) { - kitId = Id::fromSetting(settings->value(_("LastKitId"))); - serverPort = settings->value(_("LastServerPort")).toUInt(); - serverAddress = settings->value(_("LastServerAddress")).toString(); - runnable.executable = settings->value(_("LastExternalExecutable")).toString(); - runnable.commandLineArguments = settings->value(_("LastExternalExecutableArguments")).toString(); - runnable.workingDirectory = settings->value(_("LastExternalWorkingDirectory")).toString(); - breakAtMain = settings->value(_("LastExternalBreakAtMain")).toBool(); - runnable.runMode = settings->value(_("LastExternalRunInTerminal")).toBool() + kitId = Id::fromSetting(settings->value("LastKitId")); + serverPort = settings->value("LastServerPort").toUInt(); + serverAddress = settings->value("LastServerAddress").toString(); + runnable.executable = settings->value("LastExternalExecutable").toString(); + runnable.commandLineArguments = settings->value("LastExternalExecutableArguments").toString(); + runnable.workingDirectory = settings->value("LastExternalWorkingDirectory").toString(); + breakAtMain = settings->value("LastExternalBreakAtMain").toBool(); + runnable.runMode = settings->value("LastExternalRunInTerminal").toBool() ? ApplicationLauncher::Console : ApplicationLauncher::Gui; - serverStartScript = settings->value(_("LastServerStartScript")).toString(); - debugInfoLocation = settings->value(_("LastDebugInfoLocation")).toString(); + serverStartScript = settings->value("LastServerStartScript").toString(); + debugInfoLocation = settings->value("LastDebugInfoLocation").toString(); } /////////////////////////////////////////////////////////////////////// diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 77687b6336..117808f909 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -29,7 +29,6 @@ #include "debuggeractions.h" #include "debuggercore.h" #include "debuggerruncontrol.h" -#include "debuggerstringutils.h" #include "debuggerstartparameters.h" #include "debuggertooltipmanager.h" @@ -336,10 +335,10 @@ public: bool m_isStateDebugging; Utils::FileInProjectFinder m_fileFinder; - QByteArray m_qtNamespace; + QString m_qtNamespace; // Safety net to avoid infinite lookups. - QSet<QByteArray> m_lookupRequests; // FIXME: Integrate properly. + QSet<QString> m_lookupRequests; // FIXME: Integrate properly. }; @@ -359,9 +358,9 @@ DebuggerEngine::~DebuggerEngine() delete d; } -const char *DebuggerEngine::stateName(int s) +QString DebuggerEngine::stateName(int s) { -# define SN(x) case x: return #x; +# define SN(x) case x: return QLatin1String(#x); switch (s) { SN(DebuggerNotReady) SN(EngineSetupRequested) @@ -387,7 +386,7 @@ const char *DebuggerEngine::stateName(int s) SN(EngineShutdownFailed) SN(DebuggerFinished) } - return "<unknown>"; + return QLatin1String("<unknown>"); # undef SN } @@ -503,7 +502,7 @@ void DebuggerEngine::changeMemory(MemoryAgent *, QObject *, Q_UNUSED(data); } -void DebuggerEngine::setRegisterValue(const QByteArray &name, const QString &value) +void DebuggerEngine::setRegisterValue(const QString &name, const QString &value) { Q_UNUSED(name); Q_UNUSED(value); @@ -759,7 +758,7 @@ void DebuggerEngine::setupSlaveEngine() void DebuggerEnginePrivate::doSetupEngine() { - m_engine->showMessage(_("CALL: SETUP ENGINE")); + m_engine->showMessage("CALL: SETUP ENGINE"); QTC_ASSERT(state() == EngineSetupRequested, qDebug() << m_engine << state()); m_engine->validateExecutable(&m_runParameters); m_engine->setupEngine(); @@ -767,7 +766,7 @@ void DebuggerEnginePrivate::doSetupEngine() void DebuggerEngine::notifyEngineSetupFailed() { - showMessage(_("NOTE: ENGINE SETUP FAILED")); + showMessage("NOTE: ENGINE SETUP FAILED"); QTC_ASSERT(d->remoteSetupState() == RemoteSetupNone || d->remoteSetupState() == RemoteSetupRequested || d->remoteSetupState() == RemoteSetupSucceeded, @@ -784,14 +783,14 @@ void DebuggerEngine::notifyEngineSetupFailed() void DebuggerEngine::notifyEngineSetupOk() { - showMessage(_("NOTE: ENGINE SETUP OK")); + showMessage("NOTE: ENGINE SETUP OK"); QTC_ASSERT(d->remoteSetupState() == RemoteSetupNone || d->remoteSetupState() == RemoteSetupSucceeded, qDebug() << this << "remoteSetupState" << d->remoteSetupState()); QTC_ASSERT(state() == EngineSetupRequested, qDebug() << this << state()); setState(EngineSetupOk); - showMessage(_("QUEUE: SETUP INFERIOR")); + showMessage("QUEUE: SETUP INFERIOR"); if (isMasterEngine()) d->queueSetupInferior(); } @@ -804,7 +803,7 @@ void DebuggerEngine::setupSlaveInferior() void DebuggerEnginePrivate::doSetupInferior() { - m_engine->showMessage(_("CALL: SETUP INFERIOR")); + m_engine->showMessage("CALL: SETUP INFERIOR"); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << m_engine << state()); m_progress.setProgressValue(250); m_engine->setupInferior(); @@ -812,7 +811,7 @@ void DebuggerEnginePrivate::doSetupInferior() void DebuggerEngine::notifyInferiorSetupFailed() { - showMessage(_("NOTE: INFERIOR SETUP FAILED")); + showMessage("NOTE: INFERIOR SETUP FAILED"); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << this << state()); showStatusMessage(tr("Setup failed.")); setState(InferiorSetupFailed); @@ -826,7 +825,7 @@ void DebuggerEngine::notifyInferiorSetupOk() CALLGRIND_START_INSTRUMENTATION; #endif aboutToNotifyInferiorSetupOk(); - showMessage(_("NOTE: INFERIOR SETUP OK")); + showMessage("NOTE: INFERIOR SETUP OK"); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << this << state()); setState(InferiorSetupOk); if (isMasterEngine()) @@ -842,7 +841,7 @@ void DebuggerEngine::runSlaveEngine() void DebuggerEnginePrivate::doRunEngine() { - m_engine->showMessage(_("CALL: RUN ENGINE")); + m_engine->showMessage("CALL: RUN ENGINE"); QTC_ASSERT(state() == EngineRunRequested, qDebug() << m_engine << state()); m_progress.setProgressValue(300); m_engine->runEngine(); @@ -850,7 +849,7 @@ void DebuggerEnginePrivate::doRunEngine() void DebuggerEngine::notifyEngineRunOkAndInferiorUnrunnable() { - showMessage(_("NOTE: INFERIOR UNRUNNABLE")); + showMessage("NOTE: INFERIOR UNRUNNABLE"); d->m_progress.setProgressValue(1000); d->m_progress.reportFinished(); QTC_ASSERT(state() == EngineRunRequested, qDebug() << this << state()); @@ -882,7 +881,7 @@ void DebuggerEngine::notifyEngineRequestRemoteSetup() emit requestRemoteSetup(); } -void DebuggerEngine::notifyEngineRemoteServerRunning(const QByteArray &, int /*pid*/) +void DebuggerEngine::notifyEngineRemoteServerRunning(const QString &, int /*pid*/) { showMessage("NOTE: REMOTE SERVER RUNNING IN MULTIMODE"); } @@ -1347,11 +1346,6 @@ QString DebuggerEngine::expand(const QString &string) const return d->m_runParameters.macroExpander->expand(string); } -QByteArray DebuggerEngine::expand(const QByteArray &string) const -{ - return d->m_runParameters.macroExpander->expand(string); -} - void DebuggerEngine::updateBreakpointMarker(const Breakpoint &bp) { d->m_disassemblerAgent.updateBreakpointMarker(bp); @@ -1484,7 +1478,7 @@ Terminal *DebuggerEngine::terminal() const return &d->m_terminal; } -void DebuggerEngine::selectWatchData(const QByteArray &) +void DebuggerEngine::selectWatchData(const QString &) { } @@ -1563,12 +1557,12 @@ bool DebuggerEngine::isSynchronous() const return false; } -QByteArray DebuggerEngine::qtNamespace() const +QString DebuggerEngine::qtNamespace() const { return d->m_qtNamespace; } -void DebuggerEngine::setQtNamespace(const QByteArray &ns) +void DebuggerEngine::setQtNamespace(const QString &ns) { d->m_qtNamespace = ns; } @@ -1891,7 +1885,7 @@ void DebuggerEngine::validateExecutable(DebuggerRunParameters *sp) Utils::ElfData elfData = reader.readHeaders(); QString error = reader.errorString(); - Internal::showMessage(_("EXAMINING ") + symbolFile, LogDebug); + Internal::showMessage("EXAMINING " + symbolFile, LogDebug); QByteArray msg = "ELF SECTIONS: "; static const QList<QByteArray> interesting = { @@ -1914,17 +1908,15 @@ void DebuggerEngine::validateExecutable(DebuggerRunParameters *sp) if (interesting.contains(header.name)) seen.insert(header.name); } - Internal::showMessage(_(msg), LogDebug); + Internal::showMessage(QString::fromUtf8(msg), LogDebug); if (!error.isEmpty()) { - Internal::showMessage(_("ERROR WHILE READING ELF SECTIONS: ") + error, - LogDebug); + Internal::showMessage("ERROR WHILE READING ELF SECTIONS: " + error, LogDebug); return; } if (elfData.sectionHeaders.isEmpty()) { - Internal::showMessage(_("NO SECTION HEADERS FOUND. IS THIS AN EXECUTABLE?"), - LogDebug); + Internal::showMessage("NO SECTION HEADERS FOUND. IS THIS AN EXECUTABLE?", LogDebug); return; } @@ -1975,7 +1967,7 @@ void DebuggerEngine::validateExecutable(DebuggerRunParameters *sp) foreach (const QByteArray &name, interesting) { const QString found = seen.contains(name) ? tr("Found.") : tr("Not found."); - detailedWarning.append(QLatin1Char('\n') + tr("Section %1: %2").arg(_(name)).arg(found)); + detailedWarning.append('\n' + tr("Section %1: %2").arg(QString::fromUtf8(name)).arg(found)); } break; } @@ -2009,11 +2001,11 @@ void DebuggerEngine::updateLocalsView(const GdbMi &all) const GdbMi ns = all["qtnamespace"]; if (ns.isValid()) { setQtNamespace(ns.data()); - showMessage(_("FOUND NAMESPACED QT: " + ns.data())); + showMessage("FOUND NAMESPACED QT: " + ns.data()); } static int count = 0; - showMessage(_("<Rebuild Watchmodel %1 @ %2 >") + showMessage(QString("<Rebuild Watchmodel %1 @ %2 >") .arg(++count).arg(LogWindow::logTimeStamp()), LogMiscInput); showStatusMessage(GdbEngine::tr("Finished retrieving data"), 400); // FIXME: String @@ -2029,10 +2021,10 @@ bool DebuggerEngine::canHandleToolTip(const DebuggerToolTipContext &context) con return state() == InferiorStopOk && context.isCppEditor; } -void DebuggerEngine::updateItem(const QByteArray &iname) +void DebuggerEngine::updateItem(const QString &iname) { if (d->m_lookupRequests.contains(iname)) { - showMessage(QString::fromLatin1("IGNORING REPEATED REQUEST TO EXPAND " + iname)); + showMessage(QString("IGNORING REPEATED REQUEST TO EXPAND " + iname)); WatchHandler *handler = watchHandler(); WatchItem *item = handler->findItem(iname); QTC_CHECK(item); @@ -2056,7 +2048,7 @@ void DebuggerEngine::updateItem(const QByteArray &iname) doUpdateLocals(params); } -void DebuggerEngine::updateWatchData(const QByteArray &iname) +void DebuggerEngine::updateWatchData(const QString &iname) { // This is used in cases where re-evaluation is ok for the same iname // e.g. when changing the expression in a watcher. @@ -2065,7 +2057,7 @@ void DebuggerEngine::updateWatchData(const QByteArray &iname) doUpdateLocals(params); } -void DebuggerEngine::expandItem(const QByteArray &iname) +void DebuggerEngine::expandItem(const QString &iname) { updateItem(iname); } @@ -2076,7 +2068,7 @@ void DebuggerEngine::checkState(DebuggerState state, const char *file, int line) if (current == state) return; - QString msg = QString::fromLatin1("UNEXPECTED STATE: %1 WANTED: %2 IN %3:%4") + QString msg = QString("UNEXPECTED STATE: %1 WANTED: %2 IN %3:%4") .arg(current).arg(state).arg(QLatin1String(file)).arg(line); showMessage(msg, LogError); diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 9b430a628f..9fab50b063 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -124,15 +124,15 @@ class UpdateParameters public: UpdateParameters() {} - QList<QByteArray> partialVariables() const + QStringList partialVariables() const { - QList<QByteArray> result; + QStringList result; if (!partialVariable.isEmpty()) result.append(partialVariable); return result; } - QByteArray partialVariable; + QString partialVariable; }; class Location @@ -198,10 +198,10 @@ public: DebuggerRunParameters &runParameters(); virtual bool canHandleToolTip(const DebuggerToolTipContext &) const; - virtual void expandItem(const QByteArray &iname); // Called when item in tree gets expanded. - virtual void updateItem(const QByteArray &iname); // Called for fresh watch items. - void updateWatchData(const QByteArray &iname); // FIXME: Merge with above. - virtual void selectWatchData(const QByteArray &iname); + virtual void expandItem(const QString &iname); // Called when item in tree gets expanded. + virtual void updateItem(const QString &iname); // Called for fresh watch items. + void updateWatchData(const QString &iname); // FIXME: Merge with above. + virtual void selectWatchData(const QString &iname); virtual void startDebugger(DebuggerRunControl *runControl); virtual void prepareForRestart() {} @@ -240,14 +240,14 @@ public: virtual void loadAdditionalQmlStack(); virtual void reloadDebuggingHelpers(); - virtual void setRegisterValue(const QByteArray &name, const QString &value); + virtual void setRegisterValue(const QString &name, const QString &value); virtual void addOptionPages(QList<Core::IOptionsPage*> *) const; virtual bool hasCapability(unsigned cap) const = 0; virtual void debugLastCommand() {} virtual bool isSynchronous() const; - virtual QByteArray qtNamespace() const; - void setQtNamespace(const QByteArray &ns); + virtual QString qtNamespace() const; + void setQtNamespace(const QString &ns); virtual void createSnapshot(); virtual void updateAll(); @@ -293,7 +293,7 @@ public: DebuggerState targetState() const; bool isDying() const; - static const char *stateName(int s); + static QString stateName(int s); void notifyInferiorPid(qint64 pid); qint64 inferiorPid() const; @@ -325,7 +325,6 @@ public: void removeBreakpointMarker(const Breakpoint &bp); QString expand(const QString &string) const; - QByteArray expand(const QByteArray &string) const; signals: void stateChanged(Debugger::DebuggerState state); @@ -352,7 +351,7 @@ protected: virtual void notifyEngineRequestRemoteSetup(); public: - virtual void notifyEngineRemoteServerRunning(const QByteArray &, int pid); + virtual void notifyEngineRemoteServerRunning(const QString &, int pid); virtual void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result); protected: diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 3bfa4f9771..a6366ea029 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -39,7 +39,6 @@ #include "debuggermainwindow.h" #include "debuggerrunconfigurationaspect.h" #include "debuggerruncontrol.h" -#include "debuggerstringutils.h" #include "debuggeroptionspage.h" #include "debuggerkitinformation.h" #include "memoryagent.h" @@ -1082,7 +1081,7 @@ DebuggerEngine *DebuggerPluginPrivate::dummyEngine() if (!m_dummyEngine) { m_dummyEngine = new DummyEngine; m_dummyEngine->setParent(this); - m_dummyEngine->setObjectName(_("DummyEngine")); + m_dummyEngine->setObjectName("DummyEngine"); } return m_dummyEngine; } @@ -1134,7 +1133,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, const QString &option = *it; // '-debug <pid>' // '-debug <exe>[,server=<server:port>][,core=<core>][,kit=<kit>][,terminal={0,1}]' - if (*it == _("-debug")) { + if (*it == "-debug") { ++it; if (it == cend) { *errorMessage = msgParameterMissing(*it); @@ -1201,7 +1200,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, // This is created by $QTC/src/tools/qtcdebugger/main.cpp: // args << QLatin1String("-wincrashevent") // << QString::fromLatin1("%1:%2").arg(argWinCrashEvent).arg(argProcessId); - if (*it == _("-wincrashevent")) { + if (*it == "-wincrashevent") { ++it; if (it == cend) { *errorMessage = msgParameterMissing(*it); @@ -1884,14 +1883,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, return true; } -void setConfigValue(const QByteArray &name, const QVariant &value) +void setConfigValue(const QString &name, const QVariant &value) { - ICore::settings()->setValue(_("DebugMode/" + name), value); + ICore::settings()->setValue("DebugMode/" + name, value); } -QVariant configValue(const QByteArray &name) +QVariant configValue(const QString &name) { - return ICore::settings()->value(_("DebugMode/" + name)); + return ICore::settings()->value("DebugMode/" + name); } void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) @@ -1978,7 +1977,7 @@ void DebuggerPluginPrivate::attachCore() void DebuggerPluginPrivate::startRemoteCdbSession() { - const QByteArray connectionKey = "CdbRemoteConnection"; + const QString connectionKey = "CdbRemoteConnection"; DebuggerRunParameters rp; Kit *kit = findUniversalCdbKit(); QTC_ASSERT(kit, return); diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index b772452b77..f513193cd4 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -55,31 +55,31 @@ uchar fromhex(uchar c) return UCHAR_MAX; } -void skipCommas(const char *&from, const char *to) +void skipCommas(const QChar *&from, const QChar *to) { while (*from == ',' && from != to) ++from; } -void GdbMi::parseResultOrValue(const char *&from, const char *to) +void GdbMi::parseResultOrValue(const QChar *&from, const QChar *to) { - while (from != to && isspace(*from)) + while (from != to && isspace(from->unicode())) ++from; - //qDebug() << "parseResultOrValue: " << QByteArray(from, to - from); + //qDebug() << "parseResultOrValue: " << QString(from, to - from); parseValue(from, to); if (isValid()) { - //qDebug() << "no valid result in " << QByteArray(from, to - from); + //qDebug() << "no valid result in " << QString(from, to - from); return; } if (from == to || *from == '(') return; - const char *ptr = from; + const QChar *ptr = from; while (ptr < to && *ptr != '=' && *ptr != ':') { //qDebug() << "adding" << QChar(*ptr) << "to name"; ++ptr; } - m_name = QByteArray(from, ptr - from); + m_name = QString(from, ptr - from); from = ptr; if (from < to && *from == '=') { ++from; @@ -87,21 +87,21 @@ void GdbMi::parseResultOrValue(const char *&from, const char *to) } } -QByteArray GdbMi::parseCString(const char *&from, const char *to) +QString GdbMi::parseCString(const QChar *&from, const QChar *to) { - QByteArray result; - //qDebug() << "parseCString: " << QByteArray(from, to - from); + QString result; + //qDebug() << "parseCString: " << QString(from, to - from); if (*from != '"') { qDebug() << "MI Parse Error, double quote expected"; ++from; // So we don't hang - return QByteArray(); + return QString(); } - const char *ptr = from; + const QChar *ptr = from; ++ptr; while (ptr < to) { if (*ptr == '"') { ++ptr; - result = QByteArray(from + 1, ptr - from - 2); + result = QString(from + 1, ptr - from - 2); break; } if (*ptr == '\\') { @@ -109,7 +109,7 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) if (ptr == to) { qDebug() << "MI Parse Error, unterminated backslash escape"; from = ptr; // So we don't hang - return QByteArray(); + return QString(); } } ++ptr; @@ -118,11 +118,11 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) int idx = result.indexOf('\\'); if (idx >= 0) { - char *dst = result.data() + idx; - const char *src = dst + 1, *end = result.data() + result.length(); + QChar *dst = result.data() + idx; + const QChar *src = dst + 1, *end = result.data() + result.length(); do { - char c = *src++; - switch (c) { + QChar c = *src++; + switch (c.unicode()) { case 'a': *dst++ = '\a'; break; case 'b': *dst++ = '\b'; break; case 'f': *dst++ = '\f'; break; @@ -137,7 +137,7 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) int chars = 0; uchar prod = 0; while (true) { - uchar val = fromhex(c); + uchar val = fromhex(c.unicode()); if (val == UCHAR_MAX) break; prod = prod * 16 + val; @@ -147,7 +147,7 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) } if (!chars) { qDebug() << "MI Parse Error, unrecognized hex escape"; - return QByteArray(); + return QString(); } *dst++ = prod; break; @@ -161,20 +161,20 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) --src; break; } - prod = prod * 8 + c - '0'; + prod = prod * 8 + c.unicode() - '0'; if (++chars == 3 || src == end) break; c = *src++; } if (!chars) { qDebug() << "MI Parse Error, unrecognized backslash escape"; - return QByteArray(); + return QString(); } *dst++ = prod; } } while (src != end) { - char c = *src++; + QChar c = *src++; if (c == '\\') break; *dst++ = c; @@ -187,10 +187,10 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) return result; } -void GdbMi::parseValue(const char *&from, const char *to) +void GdbMi::parseValue(const QChar *&from, const QChar *to) { - //qDebug() << "parseValue: " << QByteArray(from, to - from); - switch (*from) { + //qDebug() << "parseValue: " << QString(from, to - from); + switch (from->unicode()) { case '{': parseTuple(from, to); break; @@ -206,19 +206,18 @@ void GdbMi::parseValue(const char *&from, const char *to) } } - -void GdbMi::parseTuple(const char *&from, const char *to) +void GdbMi::parseTuple(const QChar *&from, const QChar *to) { - //qDebug() << "parseTuple: " << QByteArray(from, to - from); + //qDebug() << "parseTuple: " << QString(from, to - from); //QTC_CHECK(*from == '{'); ++from; parseTuple_helper(from, to); } -void GdbMi::parseTuple_helper(const char *&from, const char *to) +void GdbMi::parseTuple_helper(const QChar *&from, const QChar *to) { skipCommas(from, to); - //qDebug() << "parseTuple_helper: " << QByteArray(from, to - from); + //qDebug() << "parseTuple_helper: " << QString(from, to - from); m_type = Tuple; while (from < to) { if (*from == '}') { @@ -235,9 +234,9 @@ void GdbMi::parseTuple_helper(const char *&from, const char *to) } } -void GdbMi::parseList(const char *&from, const char *to) +void GdbMi::parseList(const QChar *&from, const QChar *to) { - //qDebug() << "parseList: " << QByteArray(from, to - from); + //qDebug() << "parseList: " << QString(from, to - from); //QTC_CHECK(*from == '['); ++from; m_type = List; @@ -255,12 +254,12 @@ void GdbMi::parseList(const char *&from, const char *to) } } -static QByteArray ind(int indent) +static QString ind(int indent) { - return QByteArray(2 * indent, ' '); + return QString(2 * indent, QChar(' ')); } -void GdbMi::dumpChildren(QByteArray * str, bool multiline, int indent) const +void GdbMi::dumpChildren(QString * str, bool multiline, int indent) const { for (int i = 0; i < m_children.size(); ++i) { if (i != 0) { @@ -274,12 +273,12 @@ void GdbMi::dumpChildren(QByteArray * str, bool multiline, int indent) const } } -QByteArray GdbMi::escapeCString(const QByteArray &ba) +QString GdbMi::escapeCString(const QString &ba) { - QByteArray ret; + QString ret; ret.reserve(ba.length() * 2); for (int i = 0; i < ba.length(); ++i) { - const uchar c = ba.at(i); + const ushort c = ba.at(i).unicode(); switch (c) { case '\\': ret += "\\\\"; break; case '\a': ret += "\\a"; break; @@ -304,9 +303,9 @@ QByteArray GdbMi::escapeCString(const QByteArray &ba) return ret; } -QByteArray GdbMi::toString(bool multiline, int indent) const +QString GdbMi::toString(bool multiline, int indent) const { - QByteArray result; + QString result; switch (m_type) { case Invalid: if (multiline) @@ -349,17 +348,17 @@ QByteArray GdbMi::toString(bool multiline, int indent) const return result; } -void GdbMi::fromString(const QByteArray &ba) +void GdbMi::fromString(const QString &ba) { - const char *from = ba.constBegin(); - const char *to = ba.constEnd(); + const QChar *from = ba.constBegin(); + const QChar *to = ba.constEnd(); parseResultOrValue(from, to); } -void GdbMi::fromStringMultiple(const QByteArray &ba) +void GdbMi::fromStringMultiple(const QString &ba) { - const char *from = ba.constBegin(); - const char *to = ba.constEnd(); + const QChar *from = ba.constBegin(); + const QChar *to = ba.constEnd(); parseTuple_helper(from, to); } @@ -367,14 +366,14 @@ const GdbMi &GdbMi::operator[](const char *name) const { static GdbMi empty; for (int i = 0, n = int(m_children.size()); i < n; ++i) - if (m_children.at(i).m_name == name) + if (m_children.at(i).m_name == QLatin1String(name)) return m_children.at(i); return empty; } qulonglong GdbMi::toAddress() const { - QByteArray ba = m_data; + QString ba = m_data; if (ba.endsWith('L')) ba.chop(1); if (ba.startsWith('*') || ba.startsWith('@')) @@ -388,23 +387,23 @@ qulonglong GdbMi::toAddress() const // ////////////////////////////////////////////////////////////////////////////////// -QByteArray DebuggerResponse::stringFromResultClass(ResultClass resultClass) +QString DebuggerResponse::stringFromResultClass(ResultClass resultClass) { switch (resultClass) { - case ResultDone: return "done"; - case ResultRunning: return "running"; - case ResultConnected: return "connected"; - case ResultError: return "error"; - case ResultExit: return "exit"; - default: return "unknown"; + case ResultDone: return QLatin1String("done"); + case ResultRunning: return QLatin1String("running"); + case ResultConnected: return QLatin1String("connected"); + case ResultError: return QLatin1String("error"); + case ResultExit: return QLatin1String("exit"); + default: return QLatin1String("unknown"); } } -QByteArray DebuggerResponse::toString() const +QString DebuggerResponse::toString() const { - QByteArray result; + QString result; if (token != -1) - result = QByteArray::number(token); + result = QString::number(token); result += '^'; result += stringFromResultClass(resultClass); if (data.isValid()) @@ -482,12 +481,12 @@ void extractGdbVersion(const QString &msg, // ////////////////////////////////////////////////////////////////////////////////// -static QString quoteUnprintableLatin1(const QByteArray &ba) +static QString quoteUnprintableLatin1(const QString &ba) { QString res; char buf[10]; for (int i = 0, n = ba.size(); i != n; ++i) { - const unsigned char c = ba.at(i); + const unsigned char c = ba.at(i).unicode(); if (isprint(c)) { res += QLatin1Char(c); } else { @@ -555,7 +554,7 @@ static void getDateTime(qint64 msecs, int status, QDate *date, QTime *time) *time = (status & NullTime) ? QTime() : QTime::fromMSecsSinceStartOfDay(ds); } -QString decodeData(const QByteArray &ba, const QByteArray &encoding) +QString decodeData(const QString &ba, const QString &encoding) { if (encoding.isEmpty()) return quoteUnprintableLatin1(ba); // The common case. @@ -593,28 +592,28 @@ QString decodeData(const QByteArray &ba, const QByteArray &encoding) break; } case DebuggerEncoding::HexEncodedLocal8Bit: { - const QByteArray decodedBa = QByteArray::fromHex(ba); + const QByteArray decodedBa = QByteArray::fromHex(ba.toUtf8()); result = QString::fromLocal8Bit(decodedBa.data(), decodedBa.size()); break; } case DebuggerEncoding::HexEncodedLatin1: { - const QByteArray decodedBa = QByteArray::fromHex(ba); + const QByteArray decodedBa = QByteArray::fromHex(ba.toUtf8()); result = QString::fromLatin1(decodedBa.data(), decodedBa.size()); break; } case DebuggerEncoding::HexEncodedUtf8: { - const QByteArray decodedBa = QByteArray::fromHex(ba); + const QByteArray decodedBa = QByteArray::fromHex(ba.toUtf8()); result = QString::fromUtf8(decodedBa.data(), decodedBa.size()); break; } case DebuggerEncoding::HexEncodedUtf16: { - const QByteArray decodedBa = QByteArray::fromHex(ba); + const QByteArray decodedBa = QByteArray::fromHex(ba.toUtf8()); result = QString::fromUtf16(reinterpret_cast<const ushort *> (decodedBa.data()), decodedBa.size() / 2); break; } case DebuggerEncoding::HexEncodedUcs4: { - const QByteArray decodedBa = QByteArray::fromHex(ba); + const QByteArray decodedBa = QByteArray::fromHex(ba.toUtf8()); result = QString::fromUcs4(reinterpret_cast<const uint *> (decodedBa.data()), decodedBa.size() / 4); break; @@ -639,7 +638,7 @@ QString decodeData(const QByteArray &ba, const QByteArray &encoding) qDebug("not implemented"); // Only used in Arrays, see watchdata.cpp return QString(); case DebuggerEncoding::HexEncodedFloat: { - const QByteArray s = QByteArray::fromHex(ba); + const QByteArray s = QByteArray::fromHex(ba.toUtf8()); if (enc.size == 4) { union { char c[4]; float f; } u = { { s[3], s[2], s[1], s[0] } }; return QString::number(u.f); @@ -651,11 +650,11 @@ QString decodeData(const QByteArray &ba, const QByteArray &encoding) } case DebuggerEncoding::IPv6AddressAndHexScopeId: { // 16 hex-encoded bytes, "%" and the string-encoded scope const int p = ba.indexOf('%'); - QHostAddress ip6(QString::fromLatin1(p == -1 ? ba : ba.left(p))); + QHostAddress ip6(p == -1 ? ba : ba.left(p)); if (ip6.isNull()) break; - const QByteArray scopeId = p == -1 ? QByteArray() : QByteArray::fromHex(ba.mid(p + 1)); + const QByteArray scopeId = p == -1 ? QByteArray() : QByteArray::fromHex(ba.mid(p + 1).toUtf8()); if (!scopeId.isEmpty()) ip6.setScopeId(QString::fromUtf16(reinterpret_cast<const ushort *>(scopeId.constData()), scopeId.length() / 2)); @@ -673,7 +672,7 @@ QString decodeData(const QByteArray &ba, const QByteArray &encoding) ++p1; qulonglong offset = ba.mid(p1, p2 - p1).toInt(); ++p2; - QByteArray timeZoneId = QByteArray::fromHex(ba.mid(p2, p3 - p2)); + QByteArray timeZoneId = QByteArray::fromHex(ba.mid(p2, p3 - p2).toUtf8()); ++p3; int status = ba.mid(p3).toInt(); @@ -740,11 +739,6 @@ void DebuggerCommand::arg(const char *name, const QString &value) args = addToJsonObject(args, name, value); } -void DebuggerCommand::arg(const char *name, const QByteArray &value) -{ - args = addToJsonObject(args, name, QLatin1String(value)); -} - void DebuggerCommand::arg(const char *name, const char *value) { args = addToJsonObject(args, name, QLatin1String(value)); @@ -806,25 +800,25 @@ static QJsonValue translateJsonToPython(const QJsonValue &value) } } -QByteArray DebuggerCommand::argsToPython() const +QString DebuggerCommand::argsToPython() const { QJsonValue pythonCompatible(translateJsonToPython(args)); if (pythonCompatible.isArray()) - return QJsonDocument(pythonCompatible.toArray()).toJson(QJsonDocument::Compact); + return QString::fromUtf8(QJsonDocument(pythonCompatible.toArray()).toJson(QJsonDocument::Compact)); else - return QJsonDocument(pythonCompatible.toObject()).toJson(QJsonDocument::Compact); + return QString::fromUtf8(QJsonDocument(pythonCompatible.toObject()).toJson(QJsonDocument::Compact)); } -QByteArray DebuggerCommand::argsToString() const +QString DebuggerCommand::argsToString() const { - return args.toString().toLatin1(); + return args.toString(); } -DebuggerEncoding::DebuggerEncoding(const QByteArray &data) +DebuggerEncoding::DebuggerEncoding(const QString &data) { - const QByteArrayList l = data.split(':'); + const QStringList l = data.split(':'); - const QByteArray &t = l.at(0); + const QString &t = l.at(0); if (t == "latin1") { type = HexEncodedLatin1; size = 1; @@ -874,7 +868,17 @@ DebuggerEncoding::DebuggerEncoding(const QByteArray &data) QString DebuggerEncoding::toString() const { - return QString::fromLatin1("%1:%2:%3").arg(type).arg(size).arg(quotes); + return QString("%1:%2:%3").arg(type).arg(size).arg(quotes); +} + +QString fromHex(const QString &str) +{ + return QString::fromLatin1(QByteArray::fromHex(str.toUtf8())); +} + +QString toHex(const QString &str) +{ + return QString::fromUtf8(str.toUtf8().toHex()); } } // namespace Internal diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index 6bf081e4d6..f24d3b951a 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -46,10 +46,10 @@ public: typedef std::function<void(const DebuggerResponse &)> Callback; DebuggerCommand() {} - DebuggerCommand(const QByteArray &f) : function(f), flags(0) {} - DebuggerCommand(const QByteArray &f, const QJsonValue &a) : function(f), args(a), flags(0) {} - DebuggerCommand(const QByteArray &f, int fl) : function(f), flags(fl) {} - DebuggerCommand(const QByteArray &f, int fl, const Callback &cb) : function(f), callback(cb), flags(fl) {} + DebuggerCommand(const QString &f) : function(f), flags(0) {} + DebuggerCommand(const QString &f, const QJsonValue &a) : function(f), args(a), flags(0) {} + DebuggerCommand(const QString &f, int fl) : function(f), flags(fl) {} + DebuggerCommand(const QString &f, int fl, const Callback &cb) : function(f), callback(cb), flags(fl) {} void arg(const char *value); void arg(const char *name, bool value); @@ -57,15 +57,14 @@ public: void arg(const char *name, qlonglong value); void arg(const char *name, qulonglong value); void arg(const char *name, const QString &value); - void arg(const char *name, const QByteArray &value); void arg(const char *name, const char *value); void arg(const char *name, const QList<int> &list); void arg(const char *name, const QJsonValue &value); - QByteArray argsToPython() const; - QByteArray argsToString() const; + QString argsToPython() const; + QString argsToString() const; - QByteArray function; + QString function; QJsonValue args; Callback callback; uint postTime; // msecsSinceStartOfDay @@ -81,8 +80,8 @@ class GdbMi public: GdbMi() : m_type(Invalid) {} - QByteArray m_name; - QByteArray m_data; + QString m_name; + QString m_data; QVector<GdbMi> m_children; enum Type { Invalid, Const, Tuple, List }; @@ -90,39 +89,41 @@ public: Type m_type; Type type() const { return m_type; } - const QByteArray &name() const { return m_name; } - bool hasName(const char *name) const { return m_name == name; } + const QString &name() const { return m_name; } + bool hasName(const QString &name) const { return m_name == name; } bool isValid() const { return m_type != Invalid; } bool isList() const { return m_type == List; } - const QByteArray &data() const { return m_data; } + const QString &data() const { return m_data; } const QVector<GdbMi> &children() const { return m_children; } int childCount() const { return int(m_children.size()); } const GdbMi &childAt(int index) const { return m_children[index]; } const GdbMi &operator[](const char *name) const; - QByteArray toString(bool multiline = false, int indent = 0) const; + QString toString(bool multiline = false, int indent = 0) const; qulonglong toAddress() const; int toInt() const { return m_data.toInt(); } - QString toUtf8() const { return QString::fromUtf8(m_data); } - QString toLatin1() const { return QString::fromLatin1(m_data); } - void fromString(const QByteArray &str); - void fromStringMultiple(const QByteArray &str); - - static QByteArray parseCString(const char *&from, const char *to); - static QByteArray escapeCString(const QByteArray &ba); - void parseResultOrValue(const char *&from, const char *to); - void parseValue(const char *&from, const char *to); - void parseTuple(const char *&from, const char *to); - void parseTuple_helper(const char *&from, const char *to); - void parseList(const char *&from, const char *to); + void fromString(const QString &str); + void fromStringMultiple(const QString &str); + + static QString parseCString(const QChar *&from, const QChar *to); + static QString escapeCString(const QString &ba); + void parseResultOrValue(const QChar *&from, const QChar *to); + void parseValue(const QChar *&from, const QChar *to); + void parseTuple(const QChar *&from, const QChar *to); + void parseTuple_helper(const QChar *&from, const QChar *to); + void parseList(const QChar *&from, const QChar *to); private: - void dumpChildren(QByteArray *str, bool multiline, int indent) const; + void dumpChildren(QString *str, bool multiline, int indent) const; }; +QString fromHex(const QString &str); +QString toHex(const QString &str); + + enum ResultClass { // "done" | "running" | "connected" | "error" | "exit" @@ -138,14 +139,14 @@ class DebuggerResponse { public: DebuggerResponse() : token(-1), resultClass(ResultUnknown) {} - QByteArray toString() const; - static QByteArray stringFromResultClass(ResultClass resultClass); - - int token; - ResultClass resultClass; - GdbMi data; - QByteArray logStreamOutput; - QByteArray consoleStreamOutput; + QString toString() const; + static QString stringFromResultClass(ResultClass resultClass); + + int token; + ResultClass resultClass; + GdbMi data; + QString logStreamOutput; + QString consoleStreamOutput; }; void extractGdbVersion(const QString &msg, @@ -173,7 +174,7 @@ public: }; DebuggerEncoding() {} - explicit DebuggerEncoding(const QByteArray &data); + explicit DebuggerEncoding(const QString &data); QString toString() const; EncodingType type = Unencoded; @@ -182,7 +183,7 @@ public: }; // Decode string data as returned by the dumper helpers. -QString decodeData(const QByteArray &baIn, const QByteArray &encoding); +QString decodeData(const QString &baIn, const QString &encoding); // These enum values correspond to possible value display format requests, diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index de79d03df1..4358b14752 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -33,7 +33,6 @@ #include "debuggerplugin.h" #include "debuggerrunconfigurationaspect.h" #include "debuggerstartparameters.h" -#include "debuggerstringutils.h" #include "breakhandler.h" #include "shared/peutils.h" @@ -83,27 +82,27 @@ DebuggerEngine *createLldbEngine(const DebuggerRunParameters &rp); } // namespace Internal -static const char *engineTypeName(DebuggerEngineType et) +static QLatin1String engineTypeName(DebuggerEngineType et) { switch (et) { case Debugger::NoEngineType: break; case Debugger::GdbEngineType: - return "Gdb engine"; + return QLatin1String("Gdb engine"); case Debugger::CdbEngineType: - return "Cdb engine"; + return QLatin1String("Cdb engine"); case Debugger::PdbEngineType: - return "Pdb engine"; + return QLatin1String("Pdb engine"); case Debugger::QmlEngineType: - return "QML engine"; + return QLatin1String("QML engine"); case Debugger::QmlCppEngineType: - return "QML C++ engine"; + return QLatin1String("QML C++ engine"); case Debugger::LldbEngineType: - return "LLDB command line engine"; + return QLatin1String("LLDB command line engine"); case Debugger::AllEngineTypes: break; } - return "No engine"; + return QLatin1String("No engine"); } DebuggerRunControl *createHelper(RunConfiguration *runConfig, Internal::DebuggerEngine *engine) @@ -216,7 +215,7 @@ void DebuggerRunControl::startFailed() void DebuggerRunControl::notifyEngineRemoteServerRunning(const QByteArray &msg, int pid) { - m_engine->notifyEngineRemoteServerRunning(msg, pid); + m_engine->notifyEngineRemoteServerRunning(QString::fromUtf8(msg), pid); } void DebuggerRunControl::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) @@ -325,7 +324,8 @@ DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters return createQmlCppEngine(rp, errors); default: if (errors) - errors->append(DebuggerPlugin::tr("Unknown debugger type \"%1\"").arg(_(engineTypeName(et)))); + errors->append(DebuggerPlugin::tr("Unknown debugger type \"%1\"") + .arg(engineTypeName(et))); } return 0; } @@ -390,7 +390,7 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration * if (runConfig && runConfig->property("supportsDebugger").toBool()) { QString mainScript = runConfig->property("mainScript").toString(); QString interpreter = runConfig->property("interpreter").toString(); - if (!interpreter.isEmpty() && mainScript.endsWith(_(".py"))) { + if (!interpreter.isEmpty() && mainScript.endsWith(".py")) { rp.mainScript = mainScript; rp.interpreter = interpreter; QString args = runConfig->property("arguments").toString(); @@ -507,7 +507,7 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration * DebuggerEngine *engine = createEngine(rp.masterEngineType, rp, errors); if (!engine) { errors->append(DebuggerPlugin::tr("Unable to create a debugger engine of the type \"%1\""). - arg(_(engineTypeName(rp.masterEngineType)))); + arg(engineTypeName(rp.masterEngineType))); rp.startMode = NoStartMode; return 0; } @@ -529,7 +529,7 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration * static bool isDebuggableScript(RunConfiguration *runConfig) { QString mainScript = runConfig->property("mainScript").toString(); - return mainScript.endsWith(_(".py")); // Only Python for now. + return mainScript.endsWith(".py"); // Only Python for now. } class DebuggerRunControlFactory : public IRunControlFactory diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index 376cfe258d..a97114d36a 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -85,12 +85,12 @@ public: QMap<QString, QString> sourcePathMap; // Used by baremetal plugin - QByteArray commandsForReset; // commands used for resetting the inferior + QString commandsForReset; // commands used for resetting the inferior bool useContinueInsteadOfRun = false; // if connected to a hw debugger run is not possible but continue is used - QByteArray commandsAfterConnect; // additional commands to post after connection to debug target + QString commandsAfterConnect; // additional commands to post after connection to debug target // Used by Valgrind - QVector<QByteArray> expectedSignals; + QStringList expectedSignals; // For QNX debugging bool useCtrlCStub = false; diff --git a/src/plugins/debugger/debuggerstringutils.h b/src/plugins/debugger/debuggerstringutils.h deleted file mode 100644 index 11cf8f2aab..0000000000 --- a/src/plugins/debugger/debuggerstringutils.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#ifndef qdoc - -#include <QString> - -namespace Debugger { -namespace Internal { - -inline QString _(const char *s) { return QString::fromLatin1(s); } -inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); } - -#define STRINGIFY_INTERNAL(x) #x -#define STRINGIFY(x) STRINGIFY_INTERNAL(x) - -} // namespace Internal -} // namespace Debugger - -#endif // qdoc diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index bfcf0be1e3..a34a0b41c0 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -207,7 +207,7 @@ public: QString expression; QColor valueColor; bool expandable; - QByteArray iname; + QString iname; }; ToolTipWatchItem::ToolTipWatchItem(TreeItem *item) @@ -217,7 +217,7 @@ ToolTipWatchItem::ToolTipWatchItem(TreeItem *item) name = model->data(idx.sibling(idx.row(), 0), Qt::DisplayRole).toString(); value = model->data(idx.sibling(idx.row(), 1), Qt::DisplayRole).toString(); type = model->data(idx.sibling(idx.row(), 2), Qt::DisplayRole).toString(); - iname = model->data(idx.sibling(idx.row(), 0), LocalsINameRole).toByteArray(); + iname = model->data(idx.sibling(idx.row(), 0), LocalsINameRole).toString(); valueColor = model->data(idx.sibling(idx.row(), 1), Qt::ForegroundRole).value<QColor>(); expandable = item->hasChildren(); expression = model->data(idx.sibling(idx.row(), 0), Qt::EditRole).toString(); @@ -247,14 +247,14 @@ public: void expandNode(const QModelIndex &idx) { - m_expandedINames.insert(idx.data(LocalsINameRole).toByteArray()); + m_expandedINames.insert(idx.data(LocalsINameRole).toString()); if (canFetchMore(idx)) fetchMore(idx); } void collapseNode(const QModelIndex &idx) { - m_expandedINames.remove(idx.data(LocalsINameRole).toByteArray()); + m_expandedINames.remove(idx.data(LocalsINameRole).toString()); } void fetchMore(const QModelIndex &idx) @@ -264,7 +264,7 @@ public: auto item = dynamic_cast<ToolTipWatchItem *>(itemForIndex(idx)); if (!item) return; - QByteArray iname = item->iname; + QString iname = item->iname; if (!m_engine) return; @@ -276,7 +276,7 @@ public: void restoreTreeModel(QXmlStreamReader &r); QPointer<DebuggerEngine> m_engine; - QSet<QByteArray> m_expandedINames; + QSet<QString> m_expandedINames; bool m_enabled; }; @@ -472,7 +472,7 @@ public: { TreeItem *item = model.itemForIndex(idx); QTC_ASSERT(item, return); - QByteArray iname = item->data(0, LocalsINameRole).toByteArray(); + QString iname = item->data(0, LocalsINameRole).toString(); bool shouldExpand = model.m_expandedINames.contains(iname); if (shouldExpand) { if (!treeView->isExpanded(idx)) { @@ -754,7 +754,7 @@ QDebug operator<<(QDebug d, const DebuggerToolTipContext &c) DebuggerToolTipHolder::DebuggerToolTipHolder(const DebuggerToolTipContext &context_) { widget = new DebuggerToolTipWidget; - widget->setObjectName(QLatin1String("DebuggerTreeViewToolTipWidget: ") + QLatin1String(context_.iname)); + widget->setObjectName("DebuggerTreeViewToolTipWidget: " + context_.iname); context = context_; context.creationDate = QDate::currentDate(); @@ -919,7 +919,7 @@ void DebuggerToolTipHolder::saveSessionData(QXmlStreamWriter &w) const attributes.append(QLatin1String(offsetYAttributeC), QString::number(offset.y())); attributes.append(QLatin1String(engineTypeAttributeC), context.engineType); attributes.append(QLatin1String(treeExpressionAttributeC), context.expression); - attributes.append(QLatin1String(treeInameAttributeC), QLatin1String(context.iname)); + attributes.append(QLatin1String(treeInameAttributeC), context.iname); w.writeAttributes(attributes); w.writeStartElement(QLatin1String(treeElementC)); @@ -1070,7 +1070,7 @@ void DebuggerToolTipManager::loadSessionData() offset.setY(attributes.value(offsetYAttribute).toString().toInt()); context.mousePosition = offset; - context.iname = attributes.value(QLatin1String(treeInameAttributeC)).toString().toLatin1(); + context.iname = attributes.value(QLatin1String(treeInameAttributeC)).toString(); context.expression = attributes.value(QLatin1String(treeExpressionAttributeC)).toString(); // const QStringRef className = attributes.value(QLatin1String(toolTipClassAttributeC)); @@ -1172,7 +1172,7 @@ static void slotTooltipOverrideRequested // Prefer a filter on an existing local variable if it can be found. const WatchItem *localVariable = engine->watchHandler()->findCppLocalVariable(context.expression); if (localVariable) { - context.expression = QLatin1String(localVariable->exp); + context.expression = localVariable->exp; if (context.expression.isEmpty()) context.expression = localVariable->name; context.iname = localVariable->iname; @@ -1199,7 +1199,7 @@ static void slotTooltipOverrideRequested } else { - context.iname = "tooltip." + context.expression.toLatin1().toHex(); + context.iname = "tooltip." + toHex(context.expression); auto reusable = [context] (DebuggerToolTipHolder *tooltip) { return tooltip->context.isSame(context); }; diff --git a/src/plugins/debugger/debuggertooltipmanager.h b/src/plugins/debugger/debuggertooltipmanager.h index 6a5f7ee45f..78f48d9769 100644 --- a/src/plugins/debugger/debuggertooltipmanager.h +++ b/src/plugins/debugger/debuggertooltipmanager.h @@ -64,7 +64,7 @@ public: QPoint mousePosition; QString expression; - QByteArray iname; + QString iname; bool isCppEditor; }; diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index eeaff248e6..b1d43ede8a 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -31,7 +31,6 @@ #include "debuggerengine.h" #include "debuggerinternalconstants.h" #include "debuggerstartparameters.h" -#include "debuggerstringutils.h" #include "disassemblerlines.h" #include "sourceutils.h" @@ -138,7 +137,7 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine) : document(0), engine(engine), locationMark(engine, QString(), 0), - mimeType(_("text/x-qtcreator-generic-asm")), + mimeType("text/x-qtcreator-generic-asm"), resetLocationScheduled(false) {} @@ -238,7 +237,7 @@ void DisassemblerAgent::setLocation(const Location &loc) if (index != -1) { const FrameKey &key = d->cache.at(index).first; const QString msg = - _("Using cached disassembly for 0x%1 (0x%2-0x%3) in \"%4\"/ \"%5\"") + QString("Using cached disassembly for 0x%1 (0x%2-0x%3) in \"%4\"/ \"%5\"") .arg(loc.address(), 0, 16) .arg(key.startAddress, 0, 16).arg(key.endAddress, 0, 16) .arg(loc.functionName(), QDir::toNativeSeparators(loc.fileName())); @@ -327,7 +326,7 @@ void DisassemblerAgent::setContentsToDocument(const DisassemblerLines &contents) d->document->setPlainText(contents.toString()); - d->document->setPreferredDisplayName(_("Disassembler (%1)") + d->document->setPreferredDisplayName(QString("Disassembler (%1)") .arg(d->location.functionName())); Breakpoints bps = breakHandler()->engineBreakpoints(d->engine); diff --git a/src/plugins/debugger/disassemblerlines.cpp b/src/plugins/debugger/disassemblerlines.cpp index 3e97b490a6..16fa277f76 100644 --- a/src/plugins/debugger/disassemblerlines.cpp +++ b/src/plugins/debugger/disassemblerlines.cpp @@ -25,7 +25,6 @@ #include "disassemblerlines.h" #include "debuggerengine.h" -#include "debuggerstringutils.h" #include "sourceutils.h" #include <QDebug> @@ -186,7 +185,7 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed) QString function = address.mid(pos1, pos2 - pos1); if (function != m_lastFunction) { DisassemblerLine dl; - dl.data = _("Function: ") + function; + dl.data = "Function: " + function; m_data.append(dl); m_lastFunction = function; } @@ -214,25 +213,25 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed) QString DisassemblerLine::toString(int maxOp) const { - const QString someSpace = _(" "); + const QString someSpace = " "; QString str; if (isAssembler()) { if (address) - str += _("0x%1 ").arg(address, 0, 16); + str += QString("0x%1 ").arg(address, 0, 16); if (offset) - str += _("<+0x%2> ").arg(offset, 4, 16, QLatin1Char('0')); + str += QString("<+0x%2> ").arg(offset, 4, 16, QLatin1Char('0')); else - str += _(" "); - str += _(" %1 ").arg(bytes); + str += " "; + str += QString(" %1 ").arg(bytes); str += QString(maxOp - bytes.size(), QLatin1Char(' ')); str += data; } else if (isCode()) { str += someSpace; str += QString::number(lineNumber); if (hunk) - str += _(" [%1]").arg(hunk); + str += QString(" [%1]").arg(hunk); else - str += _(" "); + str += " "; str += data; } else { str += someSpace; diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index f2bdb94a35..aa49d6a00e 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -28,7 +28,6 @@ #include <coreplugin/messagebox.h> #include <debugger/debuggerprotocol.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggerstartparameters.h> #include <utils/qtcassert.h> @@ -50,7 +49,7 @@ GdbAttachEngine::GdbAttachEngine(const DebuggerRunParameters &startParameters) void GdbAttachEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); if (!runParameters().inferior.workingDirectory.isEmpty()) m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory); @@ -71,7 +70,7 @@ void GdbAttachEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); const qint64 pid = runParameters().attachPID; - runCommand({"attach " + QByteArray::number(pid), NoFlags, + runCommand({"attach " + QString::number(pid), NoFlags, [this](const DebuggerResponse &r) { handleAttach(r); }}); showStatusMessage(tr("Attached to process %1.").arg(inferiorPid())); } @@ -83,7 +82,7 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response) switch (response.resultClass) { case ResultDone: case ResultRunning: - showMessage(_("INFERIOR ATTACHED")); + showMessage("INFERIOR ATTACHED"); if (state() == EngineRunRequested) { // Happens e.g. for "Attach to unstarted application" // We will get a '*stopped' later that we'll interpret as 'spontaneous' @@ -109,7 +108,7 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response) // if msg != "ptrace: ..." fall through default: showStatusMessage(tr("Failed to attach to application: %1") - .arg(QString::fromLocal8Bit(response.data["msg"].data()))); + .arg(QString(response.data["msg"].data()))); notifyEngineIll(); } } diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index a0fddc6380..b7a5428571 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -30,7 +30,6 @@ #include <debugger/debuggercore.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> @@ -77,7 +76,7 @@ GdbCoreEngine::~GdbCoreEngine() void GdbCoreEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); const DebuggerRunParameters &rp = runParameters(); m_executable = rp.inferior.executable; @@ -208,7 +207,7 @@ void GdbCoreEngine::setupInferior() setLinuxOsAbi(); // Do that first, otherwise no symbols are loaded. QFileInfo fi(m_executable); - QByteArray path = fi.absoluteFilePath().toLocal8Bit(); + QString path = fi.absoluteFilePath(); runCommand({"-file-exec-and-symbols \"" + path + '"', NoFlags, CB(handleFileExecAndSymbols)}); } @@ -222,10 +221,10 @@ void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response) handleInferiorPrepared(); } else { QString msg = tr("No symbols found in core file <i>%1</i>.").arg(core) - + _(" ") + tr("This can be caused by a path length limitation " - "in the core file.") - + _(" ") + tr("Try to specify the binary using the " - "<i>Debug->Start Debugging->Attach to Core</i> dialog."); + + ' ' + tr("This can be caused by a path length limitation " + "in the core file.") + + ' ' + tr("Try to specify the binary using the " + "<i>Debug->Start Debugging->Attach to Core</i> dialog."); notifyInferiorSetupFailed(msg); } } @@ -233,7 +232,7 @@ void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response) void GdbCoreEngine::runEngine() { CHECK_STATE(EngineRunRequested); - runCommand({"target core " + coreFileName().toLocal8Bit(), NoFlags, + runCommand({"target core " + coreFileName(), NoFlags, CB(handleTargetCore)}); } @@ -247,8 +246,8 @@ void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response) // Even without the stack, the user can find interesting stuff by exploring // the memory, globals etc. showStatusMessage(tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile) - + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data()) - + QLatin1Char('\n') + tr("Continuing nevertheless.")); + + '\n' + response.data["msg"].data() + + '\n' + tr("Continuing nevertheless.")); } // Due to the auto-solib-add off setting, we don't have any // symbols yet. Load them in order of importance. @@ -288,7 +287,7 @@ static QString tempCoreFilename() void GdbCoreEngine::unpackCoreIfNeeded() { QStringList arguments; - const QString msg = _("Unpacking core file to %1"); + const QString msg = "Unpacking core file to %1"; if (m_coreName.endsWith(QLatin1String(".lzo"))) { m_tempCoreName = tempCoreFilename(); showMessage(msg.arg(m_tempCoreName)); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 83e1de521f..0e513e337f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -41,7 +41,6 @@ #include <debugger/debuggermainwindow.h> #include <debugger/debuggerplugin.h> #include <debugger/debuggerprotocol.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggertooltipmanager.h> #include <debugger/disassembleragent.h> #include <debugger/memoryagent.h> @@ -96,9 +95,9 @@ enum { debugPending = 0 }; #define CHECK_STATE(s) do { checkState(s, __FILE__, __LINE__); } while (0) -QByteArray GdbEngine::tooltipIName(const QString &exp) +QString GdbEngine::tooltipIName(const QString &exp) { - return "tooltip." + exp.toLatin1().toHex(); + return "tooltip." + toHex(exp); } static bool stateAcceptsGdbCommands(DebuggerState state) @@ -139,9 +138,9 @@ static int ¤tToken() return token; } -static QByteArray parsePlainConsoleStream(const DebuggerResponse &response) +static QString parsePlainConsoleStream(const DebuggerResponse &response) { - QByteArray out = response.consoleStreamOutput; + QString out = response.consoleStreamOutput; // FIXME: proper decoding needed if (out.endsWith("\\n")) out.chop(2); @@ -151,7 +150,7 @@ static QByteArray parsePlainConsoleStream(const DebuggerResponse &response) return out.mid(pos + 3); } -static bool isMostlyHarmlessMessage(const QByteArray &msg) +static bool isMostlyHarmlessMessage(const QString &msg) { return msg == "warning: GDB: Failed to set controlling terminal: " "Inappropriate ioctl for device\\n" @@ -213,7 +212,7 @@ private: GdbEngine::GdbEngine(const DebuggerRunParameters &startParameters) : DebuggerEngine(startParameters) { - setObjectName(_("GdbEngine")); + setObjectName("GdbEngine"); m_busy = false; m_gdbVersion = 100; @@ -299,7 +298,7 @@ QString GdbEngine::errorMessage(QProcess::ProcessError error) #if 0 static void dump(const char *first, const char *middle, const QString & to) { - QByteArray ba(first, middle - first); + QString ba(first, middle - first); Q_UNUSED(to) // note that qDebug cuts off output after a certain size... (bug?) qDebug("\n>>>>> %s\n%s\n====\n%s\n<<<<<\n", @@ -314,7 +313,7 @@ static void dump(const char *first, const char *middle, const QString & to) // Parse "~:gdb: unknown target exception 0xc0000139 at 0x77bef04e\n" // and return an exception message -static inline QString msgWinException(const QByteArray &data, unsigned *exCodeIn = 0) +static inline QString msgWinException(const QString &data, unsigned *exCodeIn = 0) { if (exCodeIn) *exCodeIn = 0; @@ -335,22 +334,13 @@ static inline QString msgWinException(const QByteArray &data, unsigned *exCodeIn return rc; } -void GdbEngine::readDebugeeOutput(const QByteArray &data) -{ - if (isMostlyHarmlessMessage(data.mid(2, data.size() - 4))) - return; - QString msg = m_outputCodec->toUnicode(data.constData(), data.length(), - &m_outputCodecState); - showMessage(msg, AppOutput); -} - -static bool isNameChar(char c) +static bool isNameChar(int c) { // could be 'stopped' or 'shlibs-added' return (c >= 'a' && c <= 'z') || c == '-'; } -static bool contains(const QByteArray &message, const char *pattern, int size) +static bool contains(const QString &message, const QString &pattern, int size) { const int s = message.size(); if (s < size) @@ -363,7 +353,7 @@ static bool contains(const QByteArray &message, const char *pattern, int size) return beginFits && endFits; } -static bool isGdbConnectionError(const QByteArray &message) +static bool isGdbConnectionError(const QString &message) { // Handle messages gdb client produces when the target exits (gdbserver) // @@ -381,16 +371,16 @@ static bool isGdbConnectionError(const QByteArray &message) || contains(message, msg3, sizeof(msg3) - 1); } -void GdbEngine::handleResponse(const QByteArray &buff) +void GdbEngine::handleResponse(const QString &buff) { - showMessage(QString::fromLocal8Bit(buff, buff.length()), LogOutput); + showMessage(buff, LogOutput); if (buff.isEmpty() || buff == "(gdb) ") return; - const char *from = buff.constData(); - const char *to = from + buff.size(); - const char *inner; + const QChar *from = buff.constData(); + const QChar *to = from + buff.size(); + const QChar *inner; int token = -1; // Token is a sequence of numbers. @@ -398,20 +388,20 @@ void GdbEngine::handleResponse(const QByteArray &buff) if (*inner < '0' || *inner > '9') break; if (from != inner) { - token = QByteArray(from, inner - from).toInt(); + token = QString(from, inner - from).toInt(); from = inner; } // Next char decides kind of response. - const char c = *from++; - switch (c) { + const QChar c = *from++; + switch (c.unicode()) { case '*': case '+': case '=': { - QByteArray asyncClass; + QString asyncClass; for (; from != to; ++from) { - const char c = *from; - if (!isNameChar(c)) + const QChar c = *from; + if (!isNameChar(c.unicode())) break; asyncClass += *from; } @@ -438,7 +428,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) } case '~': { - QByteArray data = GdbMi::parseCString(from, to); + QString data = GdbMi::parseCString(from, to); if (data.startsWith("bridgemessage={")) { // It's already logged. break; @@ -456,7 +446,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) if (data.startsWith("interpreterasync={")) { GdbMi allData; allData.fromStringMultiple(data); - QByteArray asyncClass = allData["asyncclass"].data(); + QString asyncClass = allData["asyncclass"].data(); if (asyncClass == "breakpointmodified") handleInterpreterBreakpointModified(allData["interpreterasync"]); break; @@ -466,30 +456,30 @@ void GdbEngine::handleResponse(const QByteArray &buff) // Parse pid from noise. if (!inferiorPid()) { // Linux/Mac gdb: [New [Tt]hread 0x545 (LWP 4554)] - static QRegExp re1(_("New .hread 0x[0-9a-f]+ \\(LWP ([0-9]*)\\)")); + static QRegExp re1("New .hread 0x[0-9a-f]+ \\(LWP ([0-9]*)\\)"); // MinGW 6.8: [New thread 2437.0x435345] - static QRegExp re2(_("New .hread ([0-9]+)\\.0x[0-9a-f]*")); + static QRegExp re2("New .hread ([0-9]+)\\.0x[0-9a-f]*"); // Mac: [Switching to process 9294 local thread 0x2e03] or // [Switching to process 31773] - static QRegExp re3(_("Switching to process ([0-9]+)")); + static QRegExp re3("Switching to process ([0-9]+)"); QTC_ASSERT(re1.isValid() && re2.isValid(), return); - if (re1.indexIn(_(data)) != -1) + if (re1.indexIn(data) != -1) maybeHandleInferiorPidChanged(re1.cap(1)); - else if (re2.indexIn(_(data)) != -1) + else if (re2.indexIn(data) != -1) maybeHandleInferiorPidChanged(re2.cap(1)); - else if (re3.indexIn(_(data)) != -1) + else if (re3.indexIn(data) != -1) maybeHandleInferiorPidChanged(re3.cap(1)); } // Show some messages to give the impression something happens. if (data.startsWith("Reading symbols from ")) { - showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000); + showStatusMessage(tr("Reading %1...").arg(data.mid(21)), 1000); progressPing(); } else if (data.startsWith("[New ") || data.startsWith("[Thread ")) { if (data.endsWith('\n')) data.chop(1); progressPing(); - showStatusMessage(_(data), 1000); + showStatusMessage(data, 1000); } else if (data.startsWith("gdb: unknown target exception 0x")) { // [Windows, most likely some DLL/Entry point not found]: // "gdb: unknown target exception 0xc0000139 at 0x77bef04e" @@ -504,20 +494,23 @@ void GdbEngine::handleResponse(const QByteArray &buff) } case '@': { - readDebugeeOutput(GdbMi::parseCString(from, to)); + QString data = GdbMi::parseCString(from, to); + QString msg = data.mid(2, data.size() - 4); + if (!isMostlyHarmlessMessage(msg)) + showMessage(msg, AppOutput); break; } case '&': { - QByteArray data = GdbMi::parseCString(from, to); + QString data = GdbMi::parseCString(from, to); // On Windows, the contents seem to depend on the debugger // version and/or OS version used. if (data.startsWith("warning:")) { if (isMostlyHarmlessMessage(data)) { - showMessage(_("Mostly harmless terminal warning suppressed."), LogWarning); + showMessage("Mostly harmless terminal warning suppressed.", LogWarning); break; } - showMessage(_(data.mid(9)), AppStuff); // Cut "warning: " + showMessage(data.mid(9), AppStuff); // Cut "warning: " } m_pendingLogStreamOutput += data; @@ -531,9 +524,9 @@ void GdbEngine::handleResponse(const QByteArray &buff) // From SuSE's gdb: >&"Missing separate debuginfo for ...\n" // ">&"Try: zypper install -C \"debuginfo(build-id)=c084ee5876ed1ac12730181c9f07c3e027d8e943\"\n" if (data.startsWith("Missing separate debuginfo for ")) { - m_lastMissingDebugInfo = QString::fromLocal8Bit(data.mid(32)); + m_lastMissingDebugInfo = data.mid(32); } else if (data.startsWith("Try: zypper")) { - QString cmd = QString::fromLocal8Bit(data.mid(4)); + QString cmd = data.mid(4); Task task(Task::Warning, tr("Missing debug information for %1\nTry: %2") @@ -560,7 +553,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) if (*inner < 'a' || *inner > 'z') break; - QByteArray resultClass = QByteArray::fromRawData(from, inner - from); + QString resultClass = QString::fromRawData(from, inner - from); if (resultClass == "done") response.resultClass = ResultDone; else if (resultClass == "running") @@ -605,11 +598,11 @@ void GdbEngine::handleResponse(const QByteArray &buff) } } -void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &result) +void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result) { if (asyncClass == "stopped") { if (m_inUpdateLocals) { - showMessage(_("UNEXPECTED *stopped NOTIFICATION IGNORED"), LogWarning); + showMessage("UNEXPECTED *stopped NOTIFICATION IGNORED", LogWarning); } else { handleStopResponse(result); m_pendingLogStreamOutput.clear(); @@ -617,7 +610,7 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res } } else if (asyncClass == "running") { if (m_inUpdateLocals) { - showMessage(_("UNEXPECTED *running NOTIFICATION IGNORED"), LogWarning); + showMessage("UNEXPECTED *running NOTIFICATION IGNORED", LogWarning); } else { GdbMi threads = result["thread-id"]; threadsHandler()->notifyRunning(threads.data()); @@ -630,8 +623,8 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res // we request a stop. } else if (state() == InferiorRunOk || state() == InferiorSetupRequested) { // We get multiple *running after thread creation and in Windows terminals. - showMessage(QString::fromLatin1("NOTE: INFERIOR STILL RUNNING IN STATE %1."). - arg(QLatin1String(DebuggerEngine::stateName(state())))); + showMessage(QString("NOTE: INFERIOR STILL RUNNING IN STATE %1."). + arg(DebuggerEngine::stateName(state()))); } else { notifyInferiorRunOk(); } @@ -646,24 +639,24 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res // target-name="/lib/i386-linux-gnu/libc.so.6" // host-name="/lib/i386-linux-gnu/libc.so.6" // symbols-loaded="0",thread-group="i1" - QByteArray id = result["id"].data(); + QString id = result["id"].data(); if (!id.isEmpty()) - showStatusMessage(tr("Library %1 loaded").arg(_(id)), 1000); + showStatusMessage(tr("Library %1 loaded").arg(id), 1000); progressPing(); Module module; module.startAddress = 0; module.endAddress = 0; - module.hostPath = _(result["host-name"].data()); - module.modulePath = _(result["target-name"].data()); + module.hostPath = result["host-name"].data(); + module.modulePath = result["target-name"].data(); module.moduleName = QFileInfo(module.hostPath).baseName(); modulesHandler()->updateModule(module); } else if (asyncClass == "library-unloaded") { // Archer has 'id="/usr/lib/libdrm.so.2", // target-name="/usr/lib/libdrm.so.2", // host-name="/usr/lib/libdrm.so.2" - QByteArray id = result["id"].data(); + QString id = result["id"].data(); progressPing(); - showStatusMessage(tr("Library %1 unloaded").arg(_(id)), 1000); + showStatusMessage(tr("Library %1 unloaded").arg(id), 1000); } else if (asyncClass == "thread-group-added") { // 7.1-symbianelf has "{id="i1"}" } else if (asyncClass == "thread-group-created" @@ -673,8 +666,8 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res // 7.0.x, there was a *-created instead. progressPing(); // 7.1.50 has thread-group-started,id="i1",pid="3529" - QByteArray id = result["id"].data(); - showStatusMessage(tr("Thread group %1 created").arg(_(id)), 1000); + QString id = result["id"].data(); + showStatusMessage(tr("Thread group %1 created").arg(id), 1000); int pid = id.toInt(); if (!pid) { id = result["pid"].data(); @@ -685,27 +678,27 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res handleThreadGroupCreated(result); } else if (asyncClass == "thread-created") { //"{id="1",group-id="28902"}" - QByteArray id = result["id"].data(); - showStatusMessage(tr("Thread %1 created").arg(_(id)), 1000); + QString id = result["id"].data(); + showStatusMessage(tr("Thread %1 created").arg(id), 1000); ThreadData thread; thread.id = ThreadId(id.toLong()); thread.groupId = result["group-id"].data(); threadsHandler()->updateThread(thread); } else if (asyncClass == "thread-group-exited") { // Archer has "{id="28902"}" - QByteArray id = result["id"].data(); - showStatusMessage(tr("Thread group %1 exited").arg(_(id)), 1000); + QString id = result["id"].data(); + showStatusMessage(tr("Thread group %1 exited").arg(id), 1000); handleThreadGroupExited(result); } else if (asyncClass == "thread-exited") { //"{id="1",group-id="28902"}" - QByteArray id = result["id"].data(); - QByteArray groupid = result["group-id"].data(); + QString id = result["id"].data(); + QString groupid = result["group-id"].data(); showStatusMessage(tr("Thread %1 in group %2 exited") - .arg(_(id)).arg(_(groupid)), 1000); + .arg(id).arg(groupid), 1000); threadsHandler()->removeThread(ThreadId(id.toLong())); } else if (asyncClass == "thread-selected") { - QByteArray id = result["id"].data(); - showStatusMessage(tr("Thread %1 selected").arg(_(id)), 1000); + QString id = result["id"].data(); + showStatusMessage(tr("Thread %1 selected").arg(id), 1000); //"{id="2"}" } else if (asyncClass == "breakpoint-modified") { // New in FSF gdb since 2011-04-27. @@ -719,7 +712,7 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res // Note the leading comma in original-location. Filter it out. // We don't need the field anyway. - QByteArray ba = result.toString(); + QString ba = result.toString(); ba = '[' + ba.mid(6, ba.size() - 7) + ']'; const int pos1 = ba.indexOf(",original-location"); const int pos2 = ba.indexOf("\":", pos1 + 2); @@ -731,7 +724,7 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res Breakpoint bp; BreakpointResponse br; foreach (const GdbMi &bkpt, res.children()) { - const QByteArray nr = bkpt["number"].data(); + const QString nr = bkpt["number"].data(); BreakpointResponseId rid(nr); if (nr.contains('.')) { // A sub-breakpoint. @@ -764,7 +757,7 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res } else if (asyncClass == "breakpoint-deleted") { // "breakpoint-deleted" "{id="1"}" // New in FSF gdb since 2011-04-27. - QByteArray nr = result["id"].data(); + QString nr = result["id"].data(); BreakpointResponseId rid(nr); if (Breakpoint bp = breakHandler()->findBreakpointByResponseId(rid)) { // This also triggers when a temporary breakpoint is hit. @@ -792,8 +785,8 @@ void GdbEngine::handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &res void GdbEngine::readGdbStandardError() { - QByteArray err = m_gdbProc.readAllStandardError(); - showMessage(_("UNEXPECTED GDB STDERR: " + err)); + QString err = QString::fromUtf8(m_gdbProc.readAllStandardError()); + showMessage("UNEXPECTED GDB STDERR: " + err); if (err == "Undefined command: \"bb\". Try \"help\".\n") return; if (err.startsWith("BFD: reopening")) @@ -801,6 +794,12 @@ void GdbEngine::readGdbStandardError() qWarning() << "Unexpected GDB stderr:" << err; } +void GdbEngine::readDebuggeeOutput(const QByteArray &ba) +{ + QString msg = m_outputCodec->toUnicode(ba.constData(), ba.size(), &m_outputCodecState); + handleResponse(msg); +} + void GdbEngine::readGdbStandardOutput() { m_commandTimer.start(); // Restart timer. @@ -832,8 +831,11 @@ void GdbEngine::readGdbStandardOutput() continue; } m_busy = true; - QByteArray ba = QByteArray::fromRawData(m_inbuffer.constData() + start, end - start); - handleResponse(ba); + + QString msg = m_outputCodec->toUnicode(m_inbuffer.constData() + start, end - start, + &m_outputCodecState); + + handleResponse(msg); m_busy = false; } m_inbuffer.clear(); @@ -850,7 +852,7 @@ void GdbEngine::interruptInferior() runCommand({"-exec-interrupt", NoFlags}); } else { showStatusMessage(tr("Stop requested..."), 5000); - showMessage(_("TRYING TO INTERRUPT INFERIOR")); + showMessage("TRYING TO INTERRUPT INFERIOR"); if (HostOsInfo::isWindowsHost() && !m_isQnxGdb) { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state(); notifyInferiorStopFailed()); QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed()); @@ -870,7 +872,7 @@ void GdbEngine::interruptInferior() void GdbEngine::handleInterruptDeviceInferior(const QString &error) { if (error.isEmpty()) { - showMessage(QLatin1String("Interrupted ") + QString::number(inferiorPid())); + showMessage("Interrupted " + QString::number(inferiorPid())); notifyInferiorStopOk(); } else { showMessage(error, LogError); @@ -884,13 +886,13 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) { const qint64 pid = pid0.toLongLong(); if (pid == 0) { - showMessage(_("Cannot parse PID from %1").arg(pid0)); + showMessage(QString("Cannot parse PID from %1").arg(pid0)); return; } if (pid == inferiorPid()) return; - showMessage(_("FOUND PID %1").arg(pid)); + showMessage(QString("FOUND PID %1").arg(pid)); notifyInferiorPid(pid); } @@ -905,9 +907,8 @@ void GdbEngine::runCommand(const DebuggerCommand &command) } if (!stateAcceptsGdbCommands(state())) { - PENDING_DEBUG(_("NO GDB PROCESS RUNNING, CMD IGNORED: " + cmd.function)); - showMessage(_("NO GDB PROCESS RUNNING, CMD IGNORED: %1 %2") - .arg(_(cmd.function)).arg(state())); + showMessage(QString("NO GDB PROCESS RUNNING, CMD IGNORED: %1 %2") + .arg(cmd.function).arg(state())); return; } @@ -924,13 +925,13 @@ void GdbEngine::runCommand(const DebuggerCommand &command) ++m_nonDiscardableCount; if (command.flags & NeedsStop) { - showMessage(_("RUNNING NEEDS-STOP COMMAND " + cmd.function)); + showMessage("RUNNING NEEDS-STOP COMMAND " + cmd.function); if (state() == InferiorStopRequested) { if (command.flags & LosesChild) { notifyInferiorIll(); return; } - showMessage(_("CHILD ALREADY BEING INTERRUPTED. STILL HOPING.")); + showMessage("CHILD ALREADY BEING INTERRUPTED. STILL HOPING."); // Calling shutdown() here breaks all situations where two // NeedsStop commands are issued in quick succession. } else if (!m_temporaryStopPending && state() == InferiorRunOk) { @@ -947,20 +948,20 @@ void GdbEngine::runCommand(const DebuggerCommand &command) m_flagsForToken[token] = command.flags; if (command.flags & ConsoleCommand) cmd.function = "-interpreter-exec console \"" + cmd.function + '"'; - cmd.function = QByteArray::number(token) + cmd.function; - showMessage(_(cmd.function), LogInput); + cmd.function = QString::number(token) + cmd.function; + showMessage(cmd.function, LogInput); if (m_scheduledTestResponses.contains(token)) { // Fake response for test cases. - QByteArray buffer = m_scheduledTestResponses.value(token); - buffer.replace("@TOKEN@", QByteArray::number(token)); + QString buffer = m_scheduledTestResponses.value(token); + buffer.replace("@TOKEN@", QString::number(token)); m_scheduledTestResponses.remove(token); - showMessage(_("FAKING TEST RESPONSE (TOKEN: %2, RESPONSE: %3)") - .arg(token).arg(_(buffer))); + showMessage(QString("FAKING TEST RESPONSE (TOKEN: %2, RESPONSE: %3)") + .arg(token).arg(buffer)); QMetaObject::invokeMethod(this, "handleResponse", - Q_ARG(QByteArray, buffer)); + Q_ARG(QString, buffer)); } else { - write(cmd.function + "\r\n"); + write(cmd.function.toUtf8() + "\r\n"); // Start Watchdog. if (m_commandTimer.interval() <= 20000) @@ -991,15 +992,14 @@ void GdbEngine::commandTimeout() foreach (int key, keys) { const DebuggerCommand &cmd = m_commandForToken.value(key); killIt = true; - showMessage(_(QByteArray::number(key) + ": " + cmd.function)); + showMessage(QString::number(key) + ": " + cmd.function); } QStringList commands; foreach (const DebuggerCommand &cmd, m_commandForToken) - commands << QString(_("\"%1\"")).arg( - QString::fromLatin1(cmd.function)); + commands << QString("\"%1\"").arg(cmd.function); if (killIt) { - showMessage(_("TIMED OUT WAITING FOR GDB REPLY. " - "COMMANDS STILL IN PROGRESS: ") + commands.join(_(", "))); + showMessage(QString("TIMED OUT WAITING FOR GDB REPLY. " + "COMMANDS STILL IN PROGRESS: ") + commands.join(", ")); int timeOut = m_commandTimer.interval(); //m_commandTimer.stop(); const QString msg = tr("The gdb process has not responded " @@ -1013,15 +1013,16 @@ void GdbEngine::commandTimeout() mb->button(QMessageBox::Cancel)->setText(tr("Give GDB more time")); mb->button(QMessageBox::Ok)->setText(tr("Stop debugging")); if (mb->exec() == QMessageBox::Ok) { - showMessage(_("KILLING DEBUGGER AS REQUESTED BY USER")); + showMessage("KILLING DEBUGGER AS REQUESTED BY USER"); // This is an undefined state, so we just pull the emergency brake. m_gdbProc.kill(); notifyEngineShutdownFailed(); } else { - showMessage(_("CONTINUE DEBUGGER AS REQUESTED BY USER")); + showMessage("CONTINUE DEBUGGER AS REQUESTED BY USER"); } } else { - showMessage(_("\nNON-CRITICAL TIMEOUT\nCOMMANDS STILL IN PROGRESS: ") + commands.join(_(", "))); + showMessage(QString("\nNON-CRITICAL TIMEOUT\nCOMMANDS STILL IN PROGRESS: ") + + commands.join(", ")); } } @@ -1040,44 +1041,41 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) // reported in the "first" response to the command) in practice it // does. We try to handle a few situations we are aware of gracefully. // Ideally, this code should not be present at all. - showMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN (%2). " - "TWO RESPONSES FOR ONE COMMAND?").arg(token). - arg(QString::fromLatin1(stateName(state())))); + showMessage(QString("COOKIE FOR TOKEN %1 ALREADY EATEN (%2). " + "TWO RESPONSES FOR ONE COMMAND?").arg(token). + arg(stateName(state()))); if (response->resultClass == ResultError) { - QByteArray msg = response->data["msg"].data(); + QString msg = response->data["msg"].data(); if (msg == "Cannot find new threads: generic error") { // Handle a case known to occur on Linux/gdb 6.8 when debugging moc // with helpers enabled. In this case we get a second response with // msg="Cannot find new threads: generic error" - showMessage(_("APPLYING WORKAROUND #1")); - AsynchronousMessageBox::critical( - tr("Executable failed"), QString::fromLocal8Bit(msg)); + showMessage("APPLYING WORKAROUND #1"); + AsynchronousMessageBox::critical(tr("Executable failed"), msg); showStatusMessage(tr("Process failed to start")); //shutdown(); notifyInferiorIll(); } else if (msg == "\"finish\" not meaningful in the outermost frame.") { // Handle a case known to appear on GDB 6.4 symbianelf when // the stack is cut due to access to protected memory. - //showMessage(_("APPLYING WORKAROUND #2")); + //showMessage("APPLYING WORKAROUND #2"); notifyInferiorStopOk(); } else if (msg.startsWith("Cannot find bounds of current function")) { // Happens when running "-exec-next" in a function for which // there is no debug information. Divert to "-exec-next-step" - showMessage(_("APPLYING WORKAROUND #3")); + showMessage("APPLYING WORKAROUND #3"); notifyInferiorStopOk(); executeNextI(); } else if (msg.startsWith("Couldn't get registers: No such process.")) { // Happens on archer-tromey-python 6.8.50.20090910-cvs // There might to be a race between a process shutting down // and library load messages. - showMessage(_("APPLYING WORKAROUND #4")); + showMessage("APPLYING WORKAROUND #4"); notifyInferiorStopOk(); //notifyInferiorIll(); - //showStatusMessage(tr("Executable failed: %1") - // .arg(QString::fromLocal8Bit(msg))); + //showStatusMessage(tr("Executable failed: %1").arg(msg)); //shutdown(); - //Core::AsynchronousMessageBox::critical( - // tr("Executable failed"), QString::fromLocal8Bit(msg)); + //Core::AsynchronousMessageBox::critical(tr("Executable failed"), msg); } else if (msg.contains("Cannot insert breakpoint")) { // For breakpoints set by address to non-existent addresses we // might get something like "6^error,msg="Warning:\nCannot insert @@ -1089,9 +1087,8 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) // We are probably sitting at _start and can't proceed as // long as the breakpoints are enabled. // FIXME: Should we silently disable the offending breakpoints? - showMessage(_("APPLYING WORKAROUND #5")); - AsynchronousMessageBox::critical( - tr("Setting breakpoints failed"), QString::fromLocal8Bit(msg)); + showMessage("APPLYING WORKAROUND #5"); + AsynchronousMessageBox::critical(tr("Setting breakpoints failed"), msg); QTC_CHECK(state() == InferiorRunOk); notifyInferiorSpontaneousStop(); notifyEngineIll(); @@ -1104,8 +1101,8 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) notifyInferiorExited(); QString logMsg; if (!m_lastWinException.isEmpty()) - logMsg = m_lastWinException + QLatin1Char('\n'); - logMsg += QString::fromLocal8Bit(msg); + logMsg = m_lastWinException + '\n'; + logMsg += msg; AsynchronousMessageBox::critical(tr("Executable Failed"), logMsg); showStatusMessage(tr("Executable failed: %1").arg(logMsg)); } @@ -1116,8 +1113,8 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) DebuggerCommand cmd = m_commandForToken.take(token); const int flags = m_flagsForToken.take(token); if (boolSetting(LogTimeStamps)) { - showMessage(_("Response time: %1: %2 s") - .arg(_(cmd.function)) + showMessage(QString("Response time: %1: %2 s") + .arg(cmd.function) .arg(QTime::fromMSecsSinceStartOfDay(cmd.postTime).msecsTo(QTime::currentTime()) / 1000.), LogTime); } @@ -1150,10 +1147,10 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) { // Ignore spurious 'running' responses to 'attach'. } else { - QByteArray rsp = DebuggerResponse::stringFromResultClass(response->resultClass); + QString rsp = DebuggerResponse::stringFromResultClass(response->resultClass); rsp = "UNEXPECTED RESPONSE '" + rsp + "' TO COMMAND '" + cmd.function + "'"; - qWarning() << rsp << " AT " __FILE__ ":" STRINGIFY(__LINE__); - showMessage(_(rsp)); + qWarning("%s", qPrintable(rsp)); + showMessage(rsp); } } @@ -1184,7 +1181,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) // event loop is entered, and let individual commands have a flag to suppress // that behavior. if (m_commandsDoneCallback && m_commandForToken.isEmpty()) { - showMessage(_("ALL COMMANDS DONE; INVOKING CALLBACK")); + showMessage("ALL COMMANDS DONE; INVOKING CALLBACK"); CommandsDoneCallback cont = m_commandsDoneCallback; m_commandsDoneCallback = 0; if (response->resultClass != ResultRunning) //only start if the thing is not already running @@ -1209,7 +1206,7 @@ void GdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages if (!(languages & CppLanguage)) return; QTC_CHECK(acceptsDebuggerCommands()); - runCommand({command.toLatin1(), NoFlags}); + runCommand({command, NoFlags}); } // This is triggered when switching snapshots. @@ -1242,10 +1239,10 @@ void GdbEngine::handleQuerySources(const DebuggerResponse &response) if (fileName.data().endsWith("<built-in>")) continue; GdbMi fullName = item["fullname"]; - QString file = QString::fromLocal8Bit(fileName.data()); + QString file = fileName.data(); QString full; if (fullName.isValid()) { - full = cleanupFullName(QString::fromLocal8Bit(fullName.data())); + full = cleanupFullName(fullName.data()); m_fullToShortName[full] = file; } m_shortToFullName[file] = full; @@ -1264,9 +1261,9 @@ void GdbEngine::handleExecuteJumpToLine(const DebuggerResponse &response) } else if (response.resultClass == ResultError) { // Could be "Unreasonable jump request" or similar. QString out = tr("Cannot jump. Stopped"); - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); if (!msg.isEmpty()) - out += QString::fromLatin1(". " + msg); + out += ". " + msg; showStatusMessage(out); notifyInferiorRunFailed(); } else if (response.resultClass == ResultDone) { @@ -1295,7 +1292,7 @@ void GdbEngine::handleExecuteRunToLine(const DebuggerResponse &response) } } -static bool isExitedReason(const QByteArray &reason) +static bool isExitedReason(const QString &reason) { return reason == "exited-normally" // inferior exited normally || reason == "exited-signalled" // inferior exited because of a signal @@ -1310,7 +1307,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) if (m_terminalTrap && (!data.isValid() || !data["reason"].isValid()) && Abi::hostAbi().os() == Abi::WindowsOS) { m_terminalTrap = false; - showMessage(_("IGNORING TERMINAL SIGTRAP"), LogMisc); + showMessage("IGNORING TERMINAL SIGTRAP", LogMisc); return; } @@ -1322,7 +1319,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) GdbMi threads = data["stopped-thread"]; threadsHandler()->notifyStopped(threads.data()); - const QByteArray reason = data["reason"].data(); + const QString reason = data["reason"].data(); if (isExitedReason(reason)) { // // The user triggered a stop, but meanwhile the app simply exited ... // QTC_ASSERT(state() == InferiorStopRequested @@ -1331,10 +1328,10 @@ void GdbEngine::handleStopResponse(const GdbMi &data) QString msg; if (reason == "exited") { msg = tr("Application exited with exit code %1") - .arg(_(data["exit-code"].toString())); + .arg(data["exit-code"].toString()); } else if (reason == "exited-signalled" || reason == "signal-received") { msg = tr("Application exited after receiving signal %1") - .arg(_(data["signal-name"].toString())); + .arg(data["signal-name"].toString()); } else { msg = tr("Application exited normally"); } @@ -1345,21 +1342,21 @@ void GdbEngine::handleStopResponse(const GdbMi &data) // Ignore signals from the process stub. const GdbMi frame = data["frame"]; - const QByteArray func = frame["from"].data(); + const QString func = frame["from"].data(); if (runParameters().useTerminal && data["reason"].data() == "signal-received" && data["signal-name"].data() == "SIGSTOP" && (func.endsWith("/ld-linux.so.2") || func.endsWith("/ld-linux-x86-64.so.2"))) { - showMessage(_("INTERNAL CONTINUE AFTER SIGSTOP FROM STUB"), LogMisc); + showMessage("INTERNAL CONTINUE AFTER SIGSTOP FROM STUB", LogMisc); notifyInferiorSpontaneousStop(); continueInferiorInternal(); return; } if (m_temporaryStopPending) { - showMessage(_("INTERNAL CONTINUE AFTER TEMPORARY STOP"), LogMisc); + showMessage("INTERNAL CONTINUE AFTER TEMPORARY STOP", LogMisc); m_temporaryStopPending = false; notifyInferiorStopOk(); continueInferiorInternal(); @@ -1377,8 +1374,8 @@ void GdbEngine::handleStopResponse(const GdbMi &data) BreakpointResponseId rid(data["bkptno"].data()); int lineNumber = 0; QString fullName; - QByteArray function; - QByteArray language; + QString function; + QString language; if (frame.isValid()) { const GdbMi lineNumberG = frame["line"]; function = frame["function"].data(); // V4 protocol @@ -1387,12 +1384,12 @@ void GdbEngine::handleStopResponse(const GdbMi &data) language = frame["language"].data(); if (lineNumberG.isValid()) { lineNumber = lineNumberG.toInt(); - fullName = cleanupFullName(QString::fromLocal8Bit(frame["fullname"].data())); + fullName = cleanupFullName(frame["fullname"].data()); if (fullName.isEmpty()) - fullName = QString::fromLocal8Bit(frame["file"].data()); + fullName = frame["file"].data(); } // found line number } else { - showMessage(_("INVALID STOPPED REASON"), LogWarning); + showMessage("INVALID STOPPED REASON", LogWarning); } if (rid.isValid() && frame.isValid()) { @@ -1456,9 +1453,9 @@ void GdbEngine::handleStopResponse(const GdbMi &data) handleStop1(data); } -static QByteArray stopSignal(const Abi &abi) +static QString stopSignal(const Abi &abi) { - return (abi.os() == Abi::WindowsOS) ? QByteArray("SIGTRAP") : QByteArray("SIGINT"); + return QLatin1String(abi.os() == Abi::WindowsOS ? "SIGTRAP" : "SIGINT"); } void GdbEngine::handleStop1(const GdbMi &data) @@ -1466,7 +1463,7 @@ void GdbEngine::handleStop1(const GdbMi &data) CHECK_STATE(InferiorStopOk); QTC_ASSERT(!isDying(), return); const GdbMi frame = data["frame"]; - const QByteArray reason = data["reason"].data(); + const QString reason = data["reason"].data(); // This was seen on XP after removing a breakpoint while running // >945*stopped,reason="signal-received",signal-name="SIGTRAP", @@ -1490,8 +1487,8 @@ void GdbEngine::handleStop1(const GdbMi &data) if (boolSetting(SkipKnownFrames)) { if (reason == "end-stepping-range" || reason == "function-finished") { //showMessage(frame.toString()); - QString funcName = _(frame["function"].data()); - QString fileName = QString::fromLocal8Bit(frame["file"].data()); + QString funcName = frame["function"].data(); + QString fileName = frame["file"].data(); if (isLeavableFunction(funcName, fileName)) { //showMessage(_("LEAVING ") + funcName); ++stepCounter; @@ -1563,7 +1560,7 @@ void GdbEngine::handleStop2(const GdbMi &data) // dNOTE: INFERIOR STOP OK // dState changed from InferiorStopRequested(13) to InferiorStopOk(14). - const QByteArray reason = data["reason"].data(); + const QString reason = data["reason"].data(); const DebuggerRunParameters &rp = runParameters(); bool isStopperThread = false; @@ -1598,9 +1595,9 @@ void GdbEngine::handleStop2(const GdbMi &data) GdbMi oldValue = value["old"]; GdbMi newValue = value["new"]; if (oldValue.isValid() && newValue.isValid()) { - msg += QLatin1Char(' '); + msg += ' '; msg += tr("Value changed from %1 to %2.") - .arg(_(oldValue.data())).arg(_(newValue.data())); + .arg(oldValue.data()).arg(newValue.data()); } showStatusMessage(msg); } else if (reason == "breakpoint-hit") { @@ -1608,25 +1605,25 @@ void GdbEngine::handleStop2(const GdbMi &data) if (!gNumber.isValid()) gNumber = data["number"]; const BreakpointResponseId rid(gNumber.data()); - const QByteArray threadId = data["thread-id"].data(); + const QString threadId = data["thread-id"].data(); const Breakpoint bp = breakHandler()->findBreakpointByResponseId(rid); - showStatusMessage(bp.msgBreakpointTriggered(rid.majorPart(), _(threadId))); + showStatusMessage(bp.msgBreakpointTriggered(rid.majorPart(), threadId)); m_currentThread = threadId; } else { - QString reasontr = msgStopped(_(reason)); + QString reasontr = msgStopped(reason); if (reason == "signal-received") { - QByteArray name = data["signal-name"].data(); - QByteArray meaning = data["signal-meaning"].data(); + QString name = data["signal-name"].data(); + QString meaning = data["signal-meaning"].data(); // Ignore these as they are showing up regularly when // stopping debugging. if (name == stopSignal(rp.toolChainAbi) || rp.expectedSignals.contains(name)) { - showMessage(_(name + " CONSIDERED HARMLESS. CONTINUING.")); + showMessage(name + " CONSIDERED HARMLESS. CONTINUING."); } else { - showMessage(_("HANDLING SIGNAL " + name)); + showMessage("HANDLING SIGNAL " + name); if (boolSetting(UseMessageBoxForSignals) && !isStopperThread) - showStoppedBySignalMessageBox(_(meaning), _(name)); + showStoppedBySignalMessageBox(meaning, name); if (!name.isEmpty() && !meaning.isEmpty()) - reasontr = msgStoppedBySignal(_(meaning), _(name)); + reasontr = msgStoppedBySignal(meaning, name); } } if (reason.isEmpty()) @@ -1650,22 +1647,22 @@ void GdbEngine::handleStop3() void GdbEngine::handleInfoProc(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { - static QRegExp re(_("\\bprocess ([0-9]+)\n")); + static QRegExp re("\\bprocess ([0-9]+)\n"); QTC_ASSERT(re.isValid(), return); - if (re.indexIn(_(response.consoleStreamOutput)) != -1) + if (re.indexIn(response.consoleStreamOutput) != -1) maybeHandleInferiorPidChanged(re.cap(1)); } } void GdbEngine::handleShowVersion(const DebuggerResponse &response) { - showMessage(_("PARSING VERSION: " + response.toString())); + showMessage("PARSING VERSION: " + response.toString()); if (response.resultClass == ResultDone) { bool isMacGdb = false; int gdbBuildVersion = -1; m_gdbVersion = 100; m_isQnxGdb = false; - QString msg = QString::fromLocal8Bit(response.consoleStreamOutput); + QString msg = response.consoleStreamOutput; extractGdbVersion(msg, &m_gdbVersion, &gdbBuildVersion, &isMacGdb, &m_isQnxGdb); @@ -1674,12 +1671,12 @@ void GdbEngine::handleShowVersion(const DebuggerResponse &response) // on Android 7.3.1. bool isSupported = m_gdbVersion >= 70300; if (isSupported) - showMessage(_("SUPPORTED GDB VERSION ") + msg); + showMessage("SUPPORTED GDB VERSION " + msg); else - showMessage(_("UNSUPPORTED GDB VERSION ") + msg); + showMessage("UNSUPPORTED GDB VERSION " + msg); - showMessage(_("USING GDB VERSION: %1, BUILD: %2%3").arg(m_gdbVersion) - .arg(gdbBuildVersion).arg(_(isMacGdb ? " (APPLE)" : ""))); + showMessage(QString("USING GDB VERSION: %1, BUILD: %2%3").arg(m_gdbVersion) + .arg(gdbBuildVersion).arg(QLatin1String(isMacGdb ? " (APPLE)" : ""))); if (usesExecInterrupt()) runCommand({"set target-async on", ConsoleCommand}); @@ -1695,7 +1692,7 @@ void GdbEngine::handleShowVersion(const DebuggerResponse &response) void GdbEngine::handleListFeatures(const DebuggerResponse &response) { - showMessage(_("FEATURES: " + response.toString())); + showMessage("FEATURES: " + response.toString()); } void GdbEngine::handlePythonSetup(const DebuggerResponse &response) @@ -1709,7 +1706,7 @@ void GdbEngine::handlePythonSetup(const DebuggerResponse &response) if (m_pythonVersion < 20700) { int pythonMajor = m_pythonVersion / 10000; int pythonMinor = (m_pythonVersion / 100) % 100; - QString out = _("<p>") + QString out = "<p>" + tr("The selected build of GDB supports Python scripting, " "but the used version %1.%2 is not sufficient for " "Qt Creator. Supported versions are Python 2.7 and 3.x.") @@ -1719,15 +1716,15 @@ void GdbEngine::handlePythonSetup(const DebuggerResponse &response) } loadInitScript(); CHECK_STATE(EngineSetupRequested); - showMessage(_("ENGINE SUCCESSFULLY STARTED")); + showMessage("ENGINE SUCCESSFULLY STARTED"); notifyEngineSetupOk(); } else { - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); if (msg.contains("Python scripting is not supported in this copy of GDB.")) { - QString out1 = _("The selected build of GDB does not support Python scripting."); - QString out2 = _("It cannot be used in Qt Creator."); - showStatusMessage(out1 + QLatin1Char(' ') + out2); - AsynchronousMessageBox::critical(tr("Execution Error"), out1 + _("<br>") + out2); + QString out1 = "The selected build of GDB does not support Python scripting."; + QString out2 = "It cannot be used in Qt Creator."; + showStatusMessage(out1 + ' ' + out2); + AsynchronousMessageBox::critical(tr("Execution Error"), out1 + "<br>" + out2); } notifyEngineSetupFailed(); } @@ -1736,7 +1733,7 @@ void GdbEngine::handlePythonSetup(const DebuggerResponse &response) void GdbEngine::showExecutionError(const QString &message) { AsynchronousMessageBox::critical(tr("Execution Error"), - tr("Cannot continue debugged process:") + QLatin1Char('\n') + message); + tr("Cannot continue debugged process:") + '\n' + message); } void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) @@ -1747,7 +1744,7 @@ void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) notifyInferiorRunOk(); // Only needed for gdb < 7.0. return; } - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function")) { notifyInferiorRunFailed(); if (isDying()) @@ -1763,13 +1760,13 @@ void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) return; CHECK_STATE(InferiorStopOk); // FIXME: Fix translation in master. - showStatusMessage(QString::fromLocal8Bit(msg), 5000); + showStatusMessage(msg, 5000); gotoLocation(stackHandler()->currentFrame()); } else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) { - showExecutionError(QString::fromLocal8Bit(msg)); + showExecutionError(msg); notifyInferiorRunFailed() ; } else { - showExecutionError(QString::fromLocal8Bit(msg)); + showExecutionError(msg); notifyInferiorIll(); } } @@ -1802,19 +1799,19 @@ QString GdbEngine::cleanupFullName(const QString &fileName) const QString sysroot = runParameters().sysRoot; if (QFileInfo(cleanFilePath).isReadable()) return cleanFilePath; - if (!sysroot.isEmpty() && fileName.startsWith(QLatin1Char('/'))) { + if (!sysroot.isEmpty() && fileName.startsWith('/')) { cleanFilePath = sysroot + fileName; if (QFileInfo(cleanFilePath).isReadable()) return cleanFilePath; } if (m_baseNameToFullName.isEmpty()) { - QString debugSource = sysroot + QLatin1String("/usr/src/debug"); + QString debugSource = sysroot + "/usr/src/debug"; if (QFileInfo(debugSource).isDir()) { QDirIterator it(debugSource, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); QString name = it.fileName(); - if (!name.startsWith(QLatin1Char('.'))) { + if (!name.startsWith('.')) { QString path = it.filePath(); m_baseNameToFullName.insert(name, path); } @@ -1839,7 +1836,7 @@ void GdbEngine::shutdownInferior() { CHECK_STATE(InferiorShutdownRequested); DebuggerCommand cmd; - cmd.function = runParameters().closeMode == DetachAtClose ? "detach" : "kill"; + cmd.function = QLatin1String(runParameters().closeMode == DetachAtClose ? "detach" : "kill"); cmd.callback = CB(handleInferiorShutdown); cmd.flags = NeedsStop|LosesChild; runCommand(cmd); @@ -1855,23 +1852,22 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) } // "kill" got stuck, or similar. CHECK_STATE(InferiorShutdownRequested); - QByteArray ba = response.data["msg"].data(); - if (ba.contains(": No such file or directory.")) { + QString msg = response.data["msg"].data(); + if (msg.contains(": No such file or directory.")) { // This happens when someone removed the binary behind our back. // It is not really an error from a user's point of view. - showMessage(_("NOTE: " + ba)); + showMessage("NOTE: " + msg); notifyInferiorShutdownOk(); return; } - AsynchronousMessageBox::critical( - tr("Failed to shut down application"), - msgInferiorStopFailed(QString::fromLocal8Bit(ba))); + AsynchronousMessageBox::critical(tr("Failed to shut down application"), + msgInferiorStopFailed(msg)); notifyInferiorShutdownFailed(); } void GdbEngine::notifyAdapterShutdownFailed() { - showMessage(_("ADAPTER SHUTDOWN FAILED")); + showMessage("ADAPTER SHUTDOWN FAILED"); CHECK_STATE(EngineShutdownRequested); notifyEngineShutdownFailed(); } @@ -1879,7 +1875,7 @@ void GdbEngine::notifyAdapterShutdownFailed() void GdbEngine::notifyAdapterShutdownOk() { CHECK_STATE(EngineShutdownRequested); - showMessage(_("INITIATE GDBENGINE SHUTDOWN IN STATE %1, PROC: %2") + showMessage(QString("INITIATE GDBENGINE SHUTDOWN IN STATE %1, PROC: %2") .arg(lastGoodState()).arg(m_gdbProc.state())); m_commandsDoneCallback = 0; switch (m_gdbProc.state()) { @@ -1894,7 +1890,7 @@ void GdbEngine::notifyAdapterShutdownOk() notifyEngineShutdownOk(); break; case QProcess::Starting: - showMessage(_("GDB NOT REALLY RUNNING; KILLING IT")); + showMessage("GDB NOT REALLY RUNNING; KILLING IT"); m_gdbProc.kill(); notifyEngineShutdownFailed(); break; @@ -1904,14 +1900,13 @@ void GdbEngine::notifyAdapterShutdownOk() void GdbEngine::handleGdbExit(const DebuggerResponse &response) { if (response.resultClass == ResultExit) { - showMessage(_("GDB CLAIMS EXIT; WAITING")); + showMessage("GDB CLAIMS EXIT; WAITING"); // Don't set state here, this will be handled in handleGdbFinished() //notifyEngineShutdownOk(); } else { - QString msg = msgGdbStopFailed( - QString::fromLocal8Bit(response.data["msg"].data())); - qDebug() << (_("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); - showMessage(_("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); + QString msg = msgGdbStopFailed(response.data["msg"].data()); + qDebug() << QString("GDB WON'T EXIT (%1); KILLING IT").arg(msg); + showMessage(QString("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); m_gdbProc.kill(); notifyEngineShutdownFailed(); } @@ -1938,14 +1933,14 @@ void GdbEngine::detachDebugger() void GdbEngine::handleThreadGroupCreated(const GdbMi &result) { - QByteArray groupId = result["id"].data(); - QByteArray pid = result["pid"].data(); + QString groupId = result["id"].data(); + QString pid = result["pid"].data(); threadsHandler()->notifyGroupCreated(groupId, pid); } void GdbEngine::handleThreadGroupExited(const GdbMi &result) { - QByteArray groupId = result["id"].data(); + QString groupId = result["id"].data(); if (threadsHandler()->notifyGroupExited(groupId)) { if (m_rerunPending) m_rerunPending = false; @@ -2037,7 +2032,9 @@ void GdbEngine::executeStep() cmd.callback = CB(handleExecuteStep); runCommand(cmd); } else { - DebuggerCommand cmd(isReverseDebugging() ? "reverse-step" : "-exec-step", RunRequest); + DebuggerCommand cmd; + cmd.flags = RunRequest; + cmd.function = QLatin1String(isReverseDebugging() ? "reverse-step" : "-exec-step"); cmd.callback = CB(handleExecuteStep); runCommand(cmd); } @@ -2057,7 +2054,7 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response) notifyInferiorRunOk(); // Only needed for gdb < 7.0. return; } - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function") || msg.contains("Error accessing memory address") || msg.startsWith("Cannot access memory at address")) { @@ -2068,13 +2065,13 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response) return; executeStepI(); // Fall back to instruction-wise stepping. } else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) { - showExecutionError(QString::fromLocal8Bit(msg)); + showExecutionError(msg); notifyInferiorRunFailed(); } else if (msg.startsWith("warning: SuspendThread failed")) { // On Win: would lead to "PC register is not available" or "\312" continueInferiorInternal(); } else { - showExecutionError(QString::fromLocal8Bit(msg)); + showExecutionError(msg); notifyInferiorIll(); } } @@ -2085,7 +2082,9 @@ void GdbEngine::executeStepI() setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step by instruction requested..."), 5000); - DebuggerCommand cmd(isReverseDebugging() ? "reverse-stepi" : "-exec-step-instruction", RunRequest); + DebuggerCommand cmd; + cmd.flags = RunRequest; + cmd.function = QLatin1String(isReverseDebugging() ? "reverse-stepi" : "-exec-step-instruction"); cmd.callback = CB(handleExecuteContinue); runCommand(cmd); } @@ -2119,7 +2118,9 @@ void GdbEngine::executeNext() DebuggerCommand cmd("executeNext", RunRequest|PythonCommand); runCommand(cmd); } else { - DebuggerCommand cmd(isReverseDebugging() ? "reverse-next" : "-exec-next", RunRequest); + DebuggerCommand cmd; + cmd.flags = RunRequest; + cmd.function = QLatin1String(isReverseDebugging() ? "reverse-next" : "-exec-next"); cmd.callback = CB(handleExecuteNext); runCommand(cmd); } @@ -2140,18 +2141,18 @@ void GdbEngine::handleExecuteNext(const DebuggerResponse &response) return; } CHECK_STATE(InferiorStopOk); - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function") || msg.contains("Error accessing memory address ")) { notifyInferiorRunFailed(); if (!isDying()) executeNextI(); // Fall back to instruction-wise stepping. } else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) { - showExecutionError(QString::fromLocal8Bit(msg)); + showExecutionError(msg); notifyInferiorRunFailed(); } else { AsynchronousMessageBox::critical(tr("Execution Error"), - tr("Cannot continue debugged process:") + QLatin1Char('\n') + QString::fromLocal8Bit(msg)); + tr("Cannot continue debugged process:") + '\n' + msg); notifyInferiorIll(); } } @@ -2162,14 +2163,16 @@ void GdbEngine::executeNextI() setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step next instruction requested..."), 5000); - DebuggerCommand cmd(isReverseDebugging() ? "reverse-nexti" : "-exec-next-instruction", RunRequest); + DebuggerCommand cmd; + cmd.flags = RunRequest; + cmd.function = QLatin1String(isReverseDebugging() ? "reverse-nexti" : "-exec-next-instruction"); cmd.callback = CB(handleExecuteContinue); runCommand(cmd); } -static QByteArray addressSpec(quint64 address) +static QString addressSpec(quint64 address) { - return "*0x" + QByteArray::number(address, 16); + return "*0x" + QString::number(address, 16); } void GdbEngine::executeRunToLine(const ContextData &data) @@ -2179,20 +2182,18 @@ void GdbEngine::executeRunToLine(const ContextData &data) notifyInferiorRunRequested(); showStatusMessage(tr("Run to line %1 requested...").arg(data.lineNumber), 5000); #if 1 - QByteArray loc; + QString loc; if (data.address) loc = addressSpec(data.address); else - loc = '"' + breakLocation(data.fileName).toLocal8Bit() + '"' + ':' - + QByteArray::number(data.lineNumber); + loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber); runCommand({"tbreak " + loc, NoFlags}); runCommand({"continue", RunRequest, CB(handleExecuteRunToLine)}); #else // Seems to jump to unpredicatable places. Observed in the manual // tests in the Foo::Foo() constructor with both gdb 6.8 and 7.1. - QByteArray args = '"' + breakLocation(fileName).toLocal8Bit() + '"' + ':' - + QByteArray::number(lineNumber); + QString args = '"' + breakLocation(fileName) + '"' + ':' + QString::number(lineNumber); runCommand("-exec-until " + args, RunRequest, CB(handleExecuteContinue)); #endif } @@ -2201,7 +2202,7 @@ void GdbEngine::executeRunToFunction(const QString &functionName) { CHECK_STATE(InferiorStopOk); setTokenBarrier(); - runCommand({"-break-insert -t " + functionName.toLatin1(), NoFlags}); + runCommand({"-break-insert -t " + functionName, NoFlags}); showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000); continueInferiorInternal(); } @@ -2209,12 +2210,11 @@ void GdbEngine::executeRunToFunction(const QString &functionName) void GdbEngine::executeJumpToLine(const ContextData &data) { CHECK_STATE(InferiorStopOk); - QByteArray loc; + QString loc; if (data.address) loc = addressSpec(data.address); else - loc = '"' + breakLocation(data.fileName).toLocal8Bit() + '"' + ':' - + QByteArray::number(data.lineNumber); + loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber); runCommand({"tbreak " + loc, NoFlags}); notifyInferiorRunRequested(); @@ -2268,7 +2268,7 @@ void GdbEngine::setTokenBarrier() } QTC_ASSERT(good, return); PENDING_DEBUG("\n--- token barrier ---\n"); - showMessage(_("--- token barrier ---"), LogMiscInput); + showMessage("--- token barrier ---", LogMiscInput); if (boolSetting(LogTimeStamps)) showMessage(LogWindow::logTimeStamp(), LogMiscInput); m_oldestAcceptableToken = currentToken(); @@ -2286,18 +2286,19 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) { QTC_ASSERT(bkpt.isValid(), return); - QByteArray originalLocation; + QString originalLocation; + QString file; + QString fullName; response.multiple = false; response.enabled = true; response.pending = false; response.condition.clear(); - QByteArray file, fullName; foreach (const GdbMi &child, bkpt.children()) { if (child.hasName("number")) { response.id = BreakpointResponseId(child.data()); } else if (child.hasName("func")) { - response.functionName = _(child.data()); + response.functionName = child.data(); } else if (child.hasName("addr")) { // <MULTIPLE> happens in constructors, inline functions, and // at other places like 'foreach' lines. In this case there are @@ -2332,10 +2333,10 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) response.pending = true; } else if (child.hasName("at")) { // Happens with gdb 6.4 symbianelf. - QByteArray ba = child.data(); + QString ba = child.data(); if (ba.startsWith('<') && ba.endsWith('>')) ba = ba.mid(1, ba.size() - 2); - response.functionName = _(ba); + response.functionName = ba; } else if (child.hasName("thread")) { response.threadSpec = child.toInt(); } else if (child.hasName("type")) { @@ -2345,16 +2346,16 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) if (child.data().contains("tracepoint")) { response.tracepoint = true; } else if (child.data() == "hw watchpoint" || child.data() == "watchpoint") { - QByteArray what = bkpt["what"].data(); + QString what = bkpt["what"].data(); if (what.startsWith("*0x")) { response.type = WatchpointAtAddress; response.address = what.mid(1).toULongLong(0, 0); } else { response.type = WatchpointAtExpression; - response.expression = QString::fromLocal8Bit(what); + response.expression = what; } } else if (child.data() == "breakpoint") { - QByteArray catchType = bkpt["catch-type"].data(); + QString catchType = bkpt["catch-type"].data(); if (catchType == "throw") response.type = BreakpointAtThrow; else if (catchType == "catch") @@ -2379,12 +2380,12 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) QString name; if (!fullName.isEmpty()) { - name = cleanupFullName(QFile::decodeName(fullName)); + name = cleanupFullName(fullName); response.fileName = name; //if (data->markerFileName().isEmpty()) // data->setMarkerFileName(name); } else { - name = QFile::decodeName(file); + name = file; // Use fullName() once we have a mapping which is more complete than // gdb's own. No point in assigning markerFileName for now. } @@ -2403,20 +2404,20 @@ QString GdbEngine::breakLocation(const QString &file) const return where; } -QByteArray GdbEngine::breakpointLocation(const BreakpointParameters &data) +QString GdbEngine::breakpointLocation(const BreakpointParameters &data) { - QTC_ASSERT(data.type != UnknownBreakpointType, return QByteArray()); + QTC_ASSERT(data.type != UnknownBreakpointType, return QString()); // FIXME: Non-GCC-runtime if (data.type == BreakpointAtThrow) - return "__cxa_throw"; + return QLatin1String("__cxa_throw"); if (data.type == BreakpointAtCatch) - return "__cxa_begin_catch"; + return QLatin1String("__cxa_begin_catch"); if (data.type == BreakpointAtMain) { const Abi abi = runParameters().toolChainAbi; - return (abi.os() == Abi::WindowsOS) ? "qMain" : "main"; + return QLatin1String(abi.os() == Abi::WindowsOS ? "qMain" : "main"); } if (data.type == BreakpointByFunction) - return '"' + data.functionName.toUtf8() + '"'; + return '"' + data.functionName + '"'; if (data.type == BreakpointByAddress) return addressSpec(data.address); @@ -2428,11 +2429,11 @@ QByteArray GdbEngine::breakpointLocation(const BreakpointParameters &data) ? data.fileName : breakLocation(data.fileName); // The argument is simply a C-quoted version of the argument to the // non-MI "break" command, including the "original" quoting it wants. - return "\"\\\"" + GdbMi::escapeCString(fileName.toLocal8Bit()) + "\\\":" - + QByteArray::number(data.lineNumber) + '"'; + return "\"\\\"" + GdbMi::escapeCString(fileName) + "\\\":" + + QString::number(data.lineNumber) + '"'; } -QByteArray GdbEngine::breakpointLocation2(const BreakpointParameters &data) +QString GdbEngine::breakpointLocation2(const BreakpointParameters &data) { BreakpointPathUsage usage = data.pathUsage; if (usage == BreakpointPathUsageEngineDefault) @@ -2440,8 +2441,7 @@ QByteArray GdbEngine::breakpointLocation2(const BreakpointParameters &data) const QString fileName = usage == BreakpointUseFullPath ? data.fileName : breakLocation(data.fileName); - return GdbMi::escapeCString(fileName.toLocal8Bit()) + ':' - + QByteArray::number(data.lineNumber); + return GdbMi::escapeCString(fileName) + ':' + QString::number(data.lineNumber); } void GdbEngine::handleInsertInterpreterBreakpoint(const DebuggerResponse &response, Breakpoint bp) @@ -2472,13 +2472,13 @@ void GdbEngine::handleWatchInsert(const DebuggerResponse &response, Breakpoint b if (bp && response.resultClass == ResultDone) { BreakpointResponse br = bp.response(); // "Hardware watchpoint 2: *0xbfffed40\n" - QByteArray ba = response.consoleStreamOutput; + QString ba = response.consoleStreamOutput; GdbMi wpt = response.data["wpt"]; if (wpt.isValid()) { // Mac yields: //>32^done,wpt={number="4",exp="*4355182176"} br.id = BreakpointResponseId(wpt["number"].data()); - QByteArray exp = wpt["exp"].data(); + QString exp = wpt["exp"].data(); if (exp.startsWith('*')) br.address = exp.mid(1).toULongLong(0, 0); bp.setResponse(br); @@ -2489,7 +2489,7 @@ void GdbEngine::handleWatchInsert(const DebuggerResponse &response, Breakpoint b // Non-Mac: "Hardware watchpoint 2: *0xbfffed40\n" const int end = ba.indexOf(':'); const int begin = ba.lastIndexOf(' ', end) + 1; - const QByteArray address = ba.mid(end + 2).trimmed(); + const QString address = ba.mid(end + 2).trimmed(); br.id = BreakpointResponseId(ba.mid(begin, end - begin)); if (address.startsWith('*')) br.address = address.mid(1).toULongLong(0, 0); @@ -2497,7 +2497,7 @@ void GdbEngine::handleWatchInsert(const DebuggerResponse &response, Breakpoint b QTC_CHECK(!bp.needsChange()); bp.notifyBreakpointInsertOk(); } else { - showMessage(_("CANNOT PARSE WATCHPOINT FROM " + ba)); + showMessage("CANNOT PARSE WATCHPOINT FROM " + ba); } } } @@ -2512,7 +2512,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, Breakpoint bp) { BreakpointResponse br = bp.response(); QTC_ASSERT(bp, return); - const QByteArray nr = bkpt["number"].data(); + const QString nr = bkpt["number"].data(); const BreakpointResponseId rid(nr); QTC_ASSERT(rid.isValid(), return); if (nr.contains('.')) { @@ -2531,7 +2531,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, Breakpoint bp) if (locations.isValid()) { foreach (const GdbMi &loc, locations.children()) { // A sub-breakpoint. - const QByteArray subnr = loc["number"].data(); + const QString subnr = loc["number"].data(); const BreakpointResponseId subrid(subnr); BreakpointResponse sub; updateResponse(sub, loc); @@ -2580,7 +2580,7 @@ void GdbEngine::handleBreakInsert1(const DebuggerResponse &response, Breakpoint // ^error,msg="mi_cmd_break_insert: Unknown option ``a''" const QString fileName = bp.fileName(); const int lineNumber = bp.lineNumber(); - DebuggerCommand cmd("trace \"" + GdbMi::escapeCString(fileName.toLocal8Bit()) + "\":" + DebuggerCommand cmd("trace \"" + GdbMi::escapeCString(fileName) + "\":" + QByteArray::number(lineNumber), NeedsStop | RebuildBreakpointModel); runCommand(cmd); @@ -2743,7 +2743,7 @@ void GdbEngine::insertBreakpoint(Breakpoint bp) cmd.function = "watch " + addressSpec(bp.address()); cmd.callback = handleWatch; } else if (type == WatchpointAtExpression) { - cmd.function = "watch " + bp.expression().toLocal8Bit(), + cmd.function = "watch " + bp.expression(); cmd.callback = handleWatch; } else if (type == BreakpointAtFork) { cmd.function = "catch fork"; @@ -2765,7 +2765,7 @@ void GdbEngine::insertBreakpoint(Breakpoint bp) int spec = bp.threadSpec(); cmd.function = "-break-insert "; if (spec >= 0) - cmd.function += "-p " + QByteArray::number(spec); + cmd.function += "-p " + QString::number(spec); cmd.function += " -f "; } @@ -2776,9 +2776,9 @@ void GdbEngine::insertBreakpoint(Breakpoint bp) cmd.function += "-d "; if (int ignoreCount = bp.ignoreCount()) - cmd.function += "-i " + QByteArray::number(ignoreCount) + ' '; + cmd.function += "-i " + QString::number(ignoreCount) + ' '; - QByteArray condition = bp.condition(); + QString condition = bp.condition(); if (!condition.isEmpty()) cmd.function += " -c \"" + condition.replace('"', "\\\"") + "\" "; @@ -2795,7 +2795,7 @@ void GdbEngine::changeBreakpoint(Breakpoint bp) QTC_ASSERT(data.type != UnknownBreakpointType, return); const BreakpointResponse &response = bp.response(); QTC_ASSERT(response.id.isValid(), return); - const QByteArray bpnr = response.id.toByteArray(); + const QString bpnr = response.id.toString(); const BreakpointState state = bp.state(); if (state == BreakpointChangeRequested) bp.notifyBreakpointChangeProceeding(); @@ -2815,7 +2815,7 @@ void GdbEngine::changeBreakpoint(Breakpoint bp) cmd.function = "-break-commands " + bpnr; foreach (const QString &command, data.command.split(QLatin1String("\n"))) { if (!command.isEmpty()) - cmd.function += " \"" + command.toLatin1() + '"'; + cmd.function += " \"" + command + '"'; } cmd.callback = [this, bp](const DebuggerResponse &r) { handleBreakIgnore(r, bp); }; } else if (!data.conditionsMatch(response.condition)) { @@ -2855,8 +2855,8 @@ void GdbEngine::removeBreakpoint(Breakpoint bp) if (br.id.isValid()) { // We already have a fully inserted breakpoint. bp.notifyBreakpointRemoveProceeding(); - showMessage(_("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName())); - DebuggerCommand cmd("-break-delete " + br.id.toByteArray(), NeedsStop | RebuildBreakpointModel); + showMessage(QString("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName())); + DebuggerCommand cmd("-break-delete " + br.id.toString(), NeedsStop | RebuildBreakpointModel); runCommand(cmd); // Pretend it succeeds without waiting for response. Feels better. @@ -2878,10 +2878,18 @@ void GdbEngine::removeBreakpoint(Breakpoint bp) // ////////////////////////////////////////////////////////////////////// +static QString dotEscape(QString str) +{ + str.replace(' ', '.'); + str.replace('\\', '.'); + str.replace('/', '.'); + return str; +} + void GdbEngine::loadSymbols(const QString &modulePath) { // FIXME: gdb does not understand quoted names here (tested with 6.8) - runCommand({"sharedlibrary " + dotEscape(modulePath.toLocal8Bit()), NoFlags}); + runCommand({"sharedlibrary " + dotEscape(modulePath), NoFlags}); reloadModulesInternal(); reloadStack(); updateLocals(); @@ -2900,13 +2908,12 @@ void GdbEngine::loadSymbolsForStack() bool needUpdate = false; const Modules &modules = modulesHandler()->modules(); foreach (const StackFrame &frame, stackHandler()->frames()) { - if (frame.function == _("??")) { + if (frame.function == "??") { //qDebug() << "LOAD FOR " << frame.address; foreach (const Module &module, modules) { if (module.startAddress <= frame.address && frame.address < module.endAddress) { - runCommand({"sharedlibrary " + dotEscape(module.modulePath.toLocal8Bit()), - NoFlags}); + runCommand({"sharedlibrary " + dotEscape(module.modulePath), NoFlags}); needUpdate = true; } } @@ -2929,7 +2936,7 @@ static void handleShowModuleSymbols(const DebuggerResponse &response, // Object file /opt/dev/qt/lib/libQtNetworkMyns.so.4: // [ 0] A 0x16bd64 _DYNAMIC moc_qudpsocket.cpp // [12] S 0xe94680 _ZN4myns5QFileC1Ev section .plt myns::QFile::QFile() - foreach (const QByteArray &line, file.readAll().split('\n')) { + foreach (const QString &line, QString::fromLocal8Bit(file.readAll()).split('\n')) { if (line.isEmpty()) continue; if (line.at(0) != '[') @@ -2962,11 +2969,11 @@ static void handleShowModuleSymbols(const DebuggerResponse &response, if (posDemangled != -1) lenDemangled = line.size() - posDemangled; Symbol symbol; - symbol.state = _(line.mid(posCode, 1)); - symbol.address = _(line.mid(posAddress, lenAddress)); - symbol.name = _(line.mid(posName, lenName)); - symbol.section = _(line.mid(posSection, lenSection)); - symbol.demangled = _(line.mid(posDemangled, lenDemangled)); + symbol.state = line.mid(posCode, 1); + symbol.address = line.mid(posAddress, lenAddress); + symbol.name = line.mid(posName, lenName); + symbol.section = line.mid(posSection, lenSection); + symbol.demangled = line.mid(posDemangled, lenDemangled); symbols.push_back(symbol); } file.close(); @@ -2980,13 +2987,12 @@ static void handleShowModuleSymbols(const DebuggerResponse &response, void GdbEngine::requestModuleSymbols(const QString &modulePath) { - QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols")); + QTemporaryFile tf(QDir::tempPath() + "/gdbsymbols"); if (!tf.open()) return; QString fileName = tf.fileName(); tf.close(); - DebuggerCommand cmd("maint print msymbols \"" + fileName.toLocal8Bit() - + "\" " + modulePath.toLocal8Bit(), NeedsStop); + DebuggerCommand cmd("maint print msymbols \"" + fileName + "\" " + modulePath, NeedsStop); cmd.callback = [modulePath, fileName](const DebuggerResponse &r) { handleShowModuleSymbols(r, modulePath, fileName); }; @@ -3009,7 +3015,7 @@ void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, // ~" Object file: /usr/lib/i386-linux-gnu/libffi.so.6\n" // ~" 0xb44a6114->0xb44a6138 at 0x00000114: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS\n" if (response.resultClass == ResultDone) { - const QStringList lines = QString::fromLocal8Bit(response.consoleStreamOutput).split(QLatin1Char('\n')); + const QStringList lines = response.consoleStreamOutput.split('\n'); const QString prefix = QLatin1String(" Object file: "); const QString needle = prefix + moduleName; Sections sections; @@ -3022,9 +3028,9 @@ void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, active = true; } else { if (active) { - QStringList items = line.split(QLatin1Char(' '), QString::SkipEmptyParts); + QStringList items = line.split(' ', QString::SkipEmptyParts); QString fromTo = items.value(0, QString()); - const int pos = fromTo.indexOf(QLatin1Char('-')); + const int pos = fromTo.indexOf('-'); QTC_ASSERT(pos >= 0, continue); Section section; section.from = fromTo.left(pos); @@ -3064,25 +3070,25 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response) Module module; // That's console-based output, likely Linux or Windows, // but we can avoid the target dependency here. - QString data = QString::fromLocal8Bit(response.consoleStreamOutput); + QString data = response.consoleStreamOutput; QTextStream ts(&data, QIODevice::ReadOnly); bool found = false; while (!ts.atEnd()) { QString line = ts.readLine(); QString symbolsRead; QTextStream ts(&line, QIODevice::ReadOnly); - if (line.startsWith(QLatin1String("0x"))) { + if (line.startsWith("0x")) { ts >> module.startAddress >> module.endAddress >> symbolsRead; module.modulePath = ts.readLine().trimmed(); module.moduleName = nameFromPath(module.modulePath); module.symbolsRead = - (symbolsRead == QLatin1String("Yes") ? Module::ReadOk : Module::ReadFailed); + (symbolsRead == "Yes" ? Module::ReadOk : Module::ReadFailed); handler->updateModule(module); found = true; - } else if (line.trimmed().startsWith(QLatin1String("No"))) { + } else if (line.trimmed().startsWith("No")) { // gdb 6.4 symbianelf ts >> symbolsRead; - QTC_ASSERT(symbolsRead == QLatin1String("No"), continue); + QTC_ASSERT(symbolsRead == "No", continue); module.startAddress = 0; module.endAddress = 0; module.modulePath = ts.readLine().trimmed(); @@ -3098,8 +3104,7 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response) // loaded_addr="0x8fe00000",slide="0x0",prefix="__dyld_"}, // shlib-info={...}... foreach (const GdbMi &item, response.data.children()) { - module.modulePath = - QString::fromLocal8Bit(item["path"].data()); + module.modulePath = item["path"].data(); module.moduleName = nameFromPath(module.modulePath); module.symbolsRead = (item["state"].data() == "Y") ? Module::ReadOk : Module::ReadFailed; @@ -3146,10 +3151,10 @@ void GdbEngine::reloadSourceFiles() if (fileName.data().endsWith("<built-in>")) continue; GdbMi fullName = item["fullname"]; - QString file = QString::fromLocal8Bit(fileName.data()); + QString file = fileName.data(); QString full; if (fullName.isValid()) { - full = cleanupFullName(QString::fromLocal8Bit(fullName.data())); + full = cleanupFullName(fullName.data()); m_fullToShortName[full] = file; } m_shortToFullName[file] = full; @@ -3174,7 +3179,7 @@ void GdbEngine::selectThread(ThreadId threadId) threadsHandler()->setCurrentThread(threadId); showStatusMessage(tr("Retrieving data for stack view thread 0x%1...") .arg(threadId.raw(), 0, 16), 10000); - DebuggerCommand cmd("-thread-select " + QByteArray::number(threadId.raw()), Discardable); + DebuggerCommand cmd("-thread-select " + QString::number(threadId.raw()), Discardable); cmd.callback = [this](const DebuggerResponse &) { QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk); showStatusMessage(tr("Retrieving data for stack view..."), 3000); @@ -3196,15 +3201,15 @@ void GdbEngine::reloadFullStack() static QString msgCannotLoadQmlStack(const QString &why) { - return _("Unable to load QML stack: ") + why; + return "Unable to load QML stack: " + why; } -static quint64 findJsExecutionContextAddress(const GdbMi &stackArgsResponse, const QByteArray &qtNamespace) +static quint64 findJsExecutionContextAddress(const GdbMi &stackArgsResponse, const QString &qtNamespace) { const GdbMi frameList = stackArgsResponse.childAt(0); if (!frameList.childCount()) return 0; - QByteArray jsExecutionContextType = qtNamespace; + QString jsExecutionContextType = qtNamespace; if (!jsExecutionContextType.isEmpty()) jsExecutionContextType.append("::"); jsExecutionContextType.append("QV4::ExecutionContext *"); @@ -3227,17 +3232,18 @@ void GdbEngine::loadAdditionalQmlStack() DebuggerCommand cmd("-stack-list-arguments --simple-values", NeedsStop); cmd.callback = [this](const DebuggerResponse &response) { if (!response.data.isValid()) { - showMessage(msgCannotLoadQmlStack(_("No stack obtained.")), LogError); + showMessage(msgCannotLoadQmlStack("No stack obtained."), LogError); return; } const quint64 contextAddress = findJsExecutionContextAddress(response.data, qtNamespace()); if (!contextAddress) { - showMessage(msgCannotLoadQmlStack(_("The address of the JS execution context could not be found.")), LogError); + showMessage(msgCannotLoadQmlStack("The address of the JS execution context could not be found."), LogError); return; } // Call the debug function of QML with the context address to obtain the QML stack trace. - DebuggerCommand cmd("-data-evaluate-expression \"qt_v4StackTrace((QV4::ExecutionContext *)0x" - + QByteArray::number(contextAddress, 16) + ")\""); + DebuggerCommand cmd; + cmd.function = "-data-evaluate-expression \"qt_v4StackTrace((QV4::ExecutionContext *)0x" + + QString::number(contextAddress, 16) + ")\""; cmd.callback = CB(handleQmlStackTrace); runCommand(cmd); }; @@ -3248,14 +3254,14 @@ void GdbEngine::loadAdditionalQmlStack() void GdbEngine::handleQmlStackTrace(const DebuggerResponse &response) { if (!response.data.isValid()) { - showMessage(msgCannotLoadQmlStack(_("No result obtained.")), LogError); + showMessage(msgCannotLoadQmlStack("No result obtained."), LogError); return; } // Prepend QML stack frames to existing C++ stack frames. - QByteArray stackData = response.data["value"].data(); + QString stackData = response.data["value"].data(); const int index = stackData.indexOf("stack="); if (index == -1) { - showMessage(msgCannotLoadQmlStack(_("Malformed result.")), LogError); + showMessage(msgCannotLoadQmlStack("Malformed result."), LogError); return; } stackData.remove(0, index); @@ -3264,7 +3270,7 @@ void GdbEngine::handleQmlStackTrace(const DebuggerResponse &response) stackMi.fromString(stackData); const int qmlFrameCount = stackMi.childCount(); if (!qmlFrameCount) { - showMessage(msgCannotLoadQmlStack(_("No stack frames obtained.")), LogError); + showMessage(msgCannotLoadQmlStack("No stack frames obtained."), LogError); return; } QList<StackFrame> qmlFrames; @@ -3335,7 +3341,7 @@ void GdbEngine::activateFrame(int frameIndex) // after a response to this -stack-select-frame here. //if (!m_currentThread.isEmpty()) // cmd += " --thread " + m_currentThread; - runCommand({"-stack-select-frame " + QByteArray::number(frameIndex), Discardable}); + runCommand({"-stack-select-frame " + QString::number(frameIndex), Discardable}); } updateLocals(); @@ -3355,7 +3361,7 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response) } updateViews(); // Adjust Threads combobox. if (boolSetting(ShowThreadNames)) { - runCommand({"threadnames " + action(MaximalStackDepth)->value().toByteArray(), + runCommand({"threadnames " + action(MaximalStackDepth)->value().toString(), Discardable, CB(handleThreadNames)}); } reloadStack(); // Will trigger register reload. @@ -3406,12 +3412,12 @@ void GdbEngine::handleThreadNames(const DebuggerResponse &response) void GdbEngine::createSnapshot() { QString fileName; - QTemporaryFile tf(QDir::tempPath() + _("/gdbsnapshot")); + QTemporaryFile tf(QDir::tempPath() + "/gdbsnapshot"); if (tf.open()) { fileName = tf.fileName(); tf.close(); // This must not be quoted, it doesn't work otherwise. - DebuggerCommand cmd("gcore " + fileName.toLocal8Bit(), NeedsStop | ConsoleCommand); + DebuggerCommand cmd("gcore " + fileName, NeedsStop | ConsoleCommand); cmd.callback = [this, fileName](const DebuggerResponse &r) { handleMakeSnapshot(r, fileName); }; runCommand(cmd); } else { @@ -3428,18 +3434,18 @@ void GdbEngine::handleMakeSnapshot(const DebuggerResponse &response, const QStri rp.coreFile = coreFile; //snapshot.setDate(QDateTime::currentDateTime()); StackFrames frames = stackHandler()->frames(); - QString function = _("<unknown>"); + QString function = "<unknown>"; if (!frames.isEmpty()) { const StackFrame &frame = frames.at(0); - function = frame.function + _(":") + QString::number(frame.line); + function = frame.function + ":" + QString::number(frame.line); } - rp.displayName = function + _(": ") + QDateTime::currentDateTime().toString(); + rp.displayName = function + ": " + QDateTime::currentDateTime().toString(); rp.isSnapshot = true; createAndScheduleRun(rp, 0); } else { - QByteArray msg = response.data["msg"].data(); + QString msg = response.data["msg"].data(); AsynchronousMessageBox::critical(tr("Snapshot Creation Error"), - tr("Cannot create snapshot:") + QLatin1Char('\n') + QString::fromLocal8Bit(msg)); + tr("Cannot create snapshot:") + '\n' + msg); } } @@ -3476,7 +3482,7 @@ void GdbEngine::reloadRegisters() } } -static QByteArray readWord(const QByteArray &ba, int *pos) +static QString readWord(const QString &ba, int *pos) { const int n = ba.size(); while (*pos < n && ba.at(*pos) == ' ') @@ -3492,7 +3498,7 @@ void GdbEngine::handleMaintPrintRegisters(const DebuggerResponse &response) if (response.resultClass != ResultDone) return; - const QByteArray &ba = response.consoleStreamOutput; + const QString &ba = response.consoleStreamOutput; RegisterHandler *handler = registerHandler(); //0 1 2 3 4 5 6 //0123456789012345678901234567890123456789012345678901234567890 @@ -3526,18 +3532,18 @@ void GdbEngine::handleMaintPrintRegisters(const DebuggerResponse &response) readWord(ba, &pos); // Offset reg.size = readWord(ba, &pos).toInt(); reg.reportedType = readWord(ba, &pos); - reg.value.fromByteArray(readWord(ba, &pos), HexadecimalFormat); + reg.value.fromString(readWord(ba, &pos), HexadecimalFormat); handler->updateRegister(reg); } handler->commitUpdates(); } -void GdbEngine::setRegisterValue(const QByteArray &name, const QString &value) +void GdbEngine::setRegisterValue(const QString &name, const QString &value) { - QByteArray fullName = name; + QString fullName = name; if (name.startsWith("xmm")) fullName += ".uint128"; - runCommand({"set $" + fullName + "=" + value.toLatin1(), NoFlags}); + runCommand({"set $" + fullName + "=" + value, NoFlags}); reloadRegisters(); } @@ -3575,17 +3581,16 @@ void GdbEngine::handleRegisterListing(const DebuggerResponse &response) // >~" '' 145 145 536 0 int0_t <invalid>\n" m_registers.clear(); - QList<QByteArray> lines = response.consoleStreamOutput.split('\n'); + QStringList lines = response.consoleStreamOutput.split('\n'); for (int i = 1; i < lines.size(); ++i) { - QStringList parts = QString::fromLatin1(lines.at(i)) - .split(QLatin1Char(' '), QString::SkipEmptyParts); + QStringList parts = QString(lines.at(i)).split(' ', QString::SkipEmptyParts); if (parts.size() < 7) continue; int gdbRegisterNumber = parts.at(1).toInt(); Register reg; - reg.name = parts.at(0).toLatin1(); + reg.name = parts.at(0); reg.size = parts.at(4).toInt(); - reg.reportedType = parts.at(5).toLatin1(); + reg.reportedType = parts.at(5); m_registers[gdbRegisterNumber] = reg; } } @@ -3601,9 +3606,9 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response) foreach (const GdbMi &item, values.children()) { const int number = item["number"].toInt(); Register reg = m_registers[number]; - QByteArray data = item["value"].data(); + QString data = item["value"].data(); if (data.startsWith("0x")) { - reg.value.fromByteArray(data, HexadecimalFormat); + reg.value.fromString(data, HexadecimalFormat); } else if (data == "<error reading variable>") { // Nothing. See QTCREATORBUG-14029. } else { @@ -3618,16 +3623,16 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response) // Try to make sense of it using the int32 chunks. // Android gdb 7.10 has u32 = {0x00000000, 0x40340000}. // Use that if available. - QByteArray result; + QString result; int pos1 = data.indexOf("_int32"); if (pos1 == -1) pos1 = data.indexOf("u32"); const int pos2 = data.indexOf('{', pos1) + 1; const int pos3 = data.indexOf('}', pos2); - QByteArray inner = data.mid(pos2, pos3 - pos2); - QList<QByteArray> list = inner.split(','); + QString inner = data.mid(pos2, pos3 - pos2); + QStringList list = inner.split(','); for (int i = list.size(); --i >= 0; ) { - QByteArray chunk = list.at(i); + QString chunk = list.at(i); if (chunk.startsWith(' ')) chunk.remove(0, 1); if (chunk.startsWith("0x")) @@ -3635,7 +3640,7 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response) QTC_ASSERT(chunk.size() == 8, continue); result.append(chunk); } - reg.value.fromByteArray(result, HexadecimalFormat); + reg.value.fromString(result, HexadecimalFormat); } handler->updateRegister(reg); } @@ -3666,9 +3671,9 @@ void GdbEngine::assignValueInDebugger(WatchItem *item, const QString &expression, const QVariant &value) { DebuggerCommand cmd("assignValue", PythonCommand); - cmd.arg("type", item->type.toHex()); - cmd.arg("expr", expression.toLatin1().toHex()); - cmd.arg("value", value.toString().toLatin1().toHex()); + cmd.arg("type", toHex(item->type)); + cmd.arg("expr", toHex(expression)); + cmd.arg("value", toHex(value.toString())); cmd.arg("simpleType", isIntOrFloatType(item->type)); cmd.callback = CB(handleVarAssign); runCommand(cmd); @@ -3676,8 +3681,8 @@ void GdbEngine::assignValueInDebugger(WatchItem *item, void GdbEngine::watchPoint(const QPoint &pnt) { - QByteArray x = QByteArray::number(pnt.x()); - QByteArray y = QByteArray::number(pnt.y()); + QString x = QString::number(pnt.x()); + QString y = QString::number(pnt.y()); runCommand({"print " + qtNamespace() + "QApplication::widgetAt(" + x + ',' + y + ')', NeedsStop, CB(handleWatchPoint)}); } @@ -3686,15 +3691,15 @@ void GdbEngine::handleWatchPoint(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { // "$5 = (void *) 0xbfa7ebfc\n" - const QByteArray ba = parsePlainConsoleStream(response); + const QString ba = parsePlainConsoleStream(response); const int pos0x = ba.indexOf("0x"); if (pos0x == -1) { - showStatusMessage(tr("Cannot read widget data: %1").arg(_(ba))); + showStatusMessage(tr("Cannot read widget data: %1").arg(ba)); } else { - const QByteArray addr = ba.mid(pos0x); + const QString addr = ba.mid(pos0x); if (addr.toULongLong(0, 0)) { // Non-null pointer - const QByteArray type = "::" + qtNamespace() + "QWidget"; - const QString exp = _("{%1}%2").arg(_(type)).arg(_(addr)); + const QString type = "::" + qtNamespace() + "QWidget"; + const QString exp = QString("{%1}%2").arg(type).arg(addr); watchHandler()->watchExpression(exp); } else { showStatusMessage(tr("Could not find a widget.")); @@ -3725,9 +3730,9 @@ public: void GdbEngine::changeMemory(MemoryAgent *, QObject *, quint64 addr, const QByteArray &data) { - DebuggerCommand cmd("-data-write-memory 0x" + QByteArray::number(addr, 16) + " d 1", NeedsStop); + DebuggerCommand cmd("-data-write-memory 0x" + QString::number(addr, 16) + " d 1", NeedsStop); foreach (unsigned char c, data) - cmd.function += ' ' + QByteArray::number(uint(c)); + cmd.function += ' ' + QString::number(uint(c)); runCommand(cmd); } @@ -3747,8 +3752,8 @@ void GdbEngine::fetchMemory(MemoryAgent *agent, QObject *token, quint64 addr, void GdbEngine::fetchMemoryHelper(const MemoryAgentCookie &ac) { DebuggerCommand cmd("-data-read-memory 0x" - + QByteArray::number(ac.base + ac.offset, 16) + " x 1 1 " - + QByteArray::number(ac.length), + + QString::number(ac.base + ac.offset, 16) + " x 1 1 " + + QString::number(ac.length), NeedsStop); cmd.callback = [this, ac](const DebuggerResponse &r) { handleFetchMemory(r, ac); }; runCommand(cmd); @@ -3761,7 +3766,7 @@ void GdbEngine::handleFetchMemory(const DebuggerResponse &response, MemoryAgentC // prev-page="0x08910c78",memory=[{addr="0x08910c88", // data=["1","0","0","0","5","0","0","0","0","0","0","0","0","0","0","0"]}] --*ac.pendingRequests; - showMessage(QString::fromLatin1("PENDING: %1").arg(*ac.pendingRequests)); + showMessage(QString("PENDING: %1").arg(*ac.pendingRequests)); QTC_ASSERT(ac.agent, return); if (response.resultClass == ResultDone) { GdbMi memory = response.data["memory"]; @@ -3822,19 +3827,19 @@ void GdbEngine::fetchDisassembler(DisassemblerAgent *agent) fetchDisassemblerByCliPointMixed(agent); } -static inline QByteArray disassemblerCommand(const Location &location, bool mixed) +static inline QString disassemblerCommand(const Location &location, bool mixed) { - QByteArray command = "disassemble /r"; + QString command = "disassemble /r"; if (mixed) command += 'm'; command += ' '; if (const quint64 address = location.address()) { command += "0x"; - command += QByteArray::number(address, 16); + command += QString::number(address, 16); } else if (!location.functionName().isEmpty()) { - command += location.functionName().toLatin1(); + command += location.functionName(); } else { - QTC_ASSERT(false, return QByteArray(); ); + QTC_ASSERT(false, return QString(); ); } return command; } @@ -3858,8 +3863,8 @@ void GdbEngine::fetchDisassemblerByCliRangeMixed(const DisassemblerAgentCookie & { QTC_ASSERT(ac.agent, return); const quint64 address = ac.agent->address(); - QByteArray start = QByteArray::number(address - 20, 16); - QByteArray end = QByteArray::number(address + 100, 16); + QString start = QString::number(address - 20, 16); + QString end = QString::number(address + 100, 16); DebuggerCommand cmd("disassemble /rm 0x" + start + ",0x" + end, Discardable | ConsoleCommand); cmd.callback = [this, ac](const DebuggerResponse &response) { if (response.resultClass == ResultDone) @@ -3875,8 +3880,8 @@ void GdbEngine::fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie & DisassemblerAgentCookie ac = ac0; QTC_ASSERT(ac.agent, return); const quint64 address = ac.agent->address(); - QByteArray start = QByteArray::number(address - 20, 16); - QByteArray end = QByteArray::number(address + 100, 16); + QString start = QString::number(address - 20, 16); + QString end = QString::number(address + 100, 16); DebuggerCommand cmd("disassemble /r 0x" + start + ",0x" + end, Discardable); cmd.callback = [this, ac](const DebuggerResponse &response) { if (response.resultClass == ResultDone) @@ -3886,9 +3891,8 @@ void GdbEngine::fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie & //76^error,msg="No function contains program counter for selected..." //76^error,msg="No function contains specified address." //>568^error,msg="Line number 0 out of range; - QByteArray msg = response.data["msg"].data(); - showStatusMessage(tr("Disassembler failed: %1") - .arg(QString::fromLocal8Bit(msg)), 5000); + QString msg = response.data["msg"].data(); + showStatusMessage(tr("Disassembler failed: %1").arg(msg), 5000); }; runCommand(cmd); } @@ -3901,14 +3905,14 @@ struct LineData int function; }; -bool GdbEngine::handleCliDisassemblerResult(const QByteArray &output, DisassemblerAgent *agent) +bool GdbEngine::handleCliDisassemblerResult(const QString &output, DisassemblerAgent *agent) { QTC_ASSERT(agent, return true); // First line is something like // "Dump of assembler code from 0xb7ff598f to 0xb7ff5a07:" DisassemblerLines dlines; - foreach (const QByteArray &line, output.split('\n')) - dlines.appendUnparsed(_(line)); + foreach (const QString &line, output.split('\n')) + dlines.appendUnparsed(line); QVector<DisassemblerLine> lines = dlines.data(); @@ -3975,11 +3979,11 @@ static SourcePathMap mergeStartParametersSourcePathMap(const DebuggerRunParamete void GdbEngine::startGdb(const QStringList &args) { - const QByteArray tests = qgetenv("QTC_DEBUGGER_TESTS"); - foreach (const QByteArray &test, tests.split(',')) + const QString tests = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_TESTS")); + foreach (const QString &test, tests.split(',')) m_testCases.insert(test.toInt()); foreach (int test, m_testCases) - showMessage(_("ENABLING TEST CASE: " + QByteArray::number(test))); + showMessage("ENABLING TEST CASE: " + QString::number(test)); m_gdbProc.disconnect(); // From any previous runs @@ -3993,10 +3997,10 @@ void GdbEngine::startGdb(const QStringList &args) return; } QStringList gdbArgs; - gdbArgs << _("-i"); - gdbArgs << _("mi"); + gdbArgs << "-i"; + gdbArgs << "mi"; if (!boolSetting(LoadGdbInit)) - gdbArgs << _("-n"); + gdbArgs << "-n"; gdbArgs += args; connect(&m_gdbProc, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), @@ -4006,10 +4010,10 @@ void GdbEngine::startGdb(const QStringList &args) connect(&m_gdbProc, &QtcProcess::readyReadStandardOutput, this, &GdbEngine::readGdbStandardOutput); connect(&m_gdbProc, &QtcProcess::readyReadStandardError, this, &GdbEngine::readGdbStandardError); - showMessage(_("STARTING ") + m_gdb + _(" ") + gdbArgs.join(QLatin1Char(' '))); + showMessage("STARTING " + m_gdb + " " + gdbArgs.join(' ')); m_gdbProc.setCommand(m_gdb, QtcProcess::joinArgs(gdbArgs)); Environment env = Environment(m_gdbProc.systemEnvironment()); - env.set(QLatin1String("LC_NUMERIC"), QLatin1String("C")); + env.set("LC_NUMERIC", "C"); m_gdbProc.setEnvironment(env); m_gdbProc.start(); @@ -4020,7 +4024,7 @@ void GdbEngine::startGdb(const QStringList &args) return; } - showMessage(_("GDB STARTED, INITIALIZING IT")); + showMessage("GDB STARTED, INITIALIZING IT"); runCommand({"show version", NoFlags, CB(handleShowVersion)}); //runCommand("-list-features", CB(handleListFeatures)); runCommand({"show debug-file-directory", NoFlags, CB(handleDebugInfoLocation)}); @@ -4094,7 +4098,7 @@ void GdbEngine::startGdb(const QStringList &args) module.startAddress = 0; module.endAddress = 0; module.modulePath = rp.inferior.executable; - module.moduleName = QLatin1String("<executable>"); + module.moduleName = "<executable>"; modulesHandler()->updateModule(module); // Apply source path mappings from global options. @@ -4107,24 +4111,22 @@ void GdbEngine::startGdb(const QStringList &args) for (auto it = completeSourcePathMap.constBegin(), cend = completeSourcePathMap.constEnd(); it != cend; ++it) { - runCommand({"set substitute-path " + it.key().toLocal8Bit() - + " " + it.value().toLocal8Bit(), NoFlags}); + runCommand({"set substitute-path " + it.key() + " " + it.value(), NoFlags}); } // Spaces just will not work. foreach (const QString &src, rp.debugSourceLocation) { if (QDir(src).exists()) - runCommand({"directory " + src.toLocal8Bit(), NoFlags}); + runCommand({"directory " + src, NoFlags}); else - showMessage(_("# directory does not exist: ") + src, LogInput); + showMessage("# directory does not exist: " + src, LogInput); } - const QByteArray sysroot = rp.sysRoot.toLocal8Bit(); - if (!sysroot.isEmpty()) { - runCommand({"set sysroot " + sysroot, NoFlags}); + if (!rp.sysRoot.isEmpty()) { + runCommand({"set sysroot " + rp.sysRoot, NoFlags}); // sysroot is not enough to correctly locate the sources, so explicitly // relocate the most likely place for the debug source - runCommand({"set substitute-path /usr/src " + sysroot + "/usr/src", NoFlags}); + runCommand({"set substitute-path /usr/src " + rp.sysRoot + "/usr/src", NoFlags}); } //QByteArray ba = QFileInfo(sp.dumperLibrary).path().toLocal8Bit(); @@ -4146,15 +4148,13 @@ void GdbEngine::startGdb(const QStringList &args) // We need to guarantee a roundtrip before the adapter proceeds. // Make sure this stays the last command in startGdb(). // Don't use ConsoleCommand, otherwise Mac won't markup the output. - const QByteArray dumperSourcePath = - ICore::resourcePath().toLocal8Bit() + "/debugger/"; + const QString dumperSourcePath = ICore::resourcePath() + "/debugger/"; if (terminal()->isUsable()) - runCommand({"set inferior-tty " + terminal()->slaveDevice(), NoFlags}); + runCommand({"set inferior-tty " + QString::fromUtf8(terminal()->slaveDevice()), NoFlags}); const QFileInfo gdbBinaryFile(m_gdb); - const QByteArray uninstalledData = gdbBinaryFile.absolutePath().toLocal8Bit() - + "/data-directory/python"; + const QString uninstalledData = gdbBinaryFile.absolutePath() + "/data-directory/python"; runCommand({"python sys.path.insert(1, '" + dumperSourcePath + "')", NoFlags}); runCommand({"python sys.path.append('" + uninstalledData + "')", NoFlags}); @@ -4163,13 +4163,13 @@ void GdbEngine::startGdb(const QStringList &args) const QString path = stringSetting(ExtraDumperFile); if (!path.isEmpty() && QFileInfo(path).isReadable()) { DebuggerCommand cmd("addDumperModule", PythonCommand); - cmd.arg("path", path.toUtf8()); + cmd.arg("path", path); runCommand(cmd); } const QString commands = stringSetting(ExtraDumperCommands); if (!commands.isEmpty()) - runCommand({commands.toLocal8Bit(), NoFlags}); + runCommand({commands, NoFlags}); runCommand({"loadDumpers", PythonCommand, CB(handlePythonSetup)}); } @@ -4183,7 +4183,7 @@ void GdbEngine::loadInitScript() const QString script = runParameters().overrideStartScript; if (!script.isEmpty()) { if (QFileInfo(script).isReadable()) { - runCommand({"source " + script.toLocal8Bit(), NoFlags}); + runCommand({"source " + script, NoFlags}); } else { AsynchronousMessageBox::warning( tr("Cannot find debugger initialization script"), @@ -4195,7 +4195,7 @@ void GdbEngine::loadInitScript() } else { const QString commands = expand(stringSetting(GdbStartupCommands)); if (!commands.isEmpty()) - runCommand({commands.toLocal8Bit(), NoFlags}); + runCommand({commands, NoFlags}); } } @@ -4205,10 +4205,10 @@ void GdbEngine::setEnvironmentVariables() Environment runEnv = runParameters().inferior.environment; foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) { if (item.unset) - runCommand({"unset environment " + item.name.toUtf8(), NoFlags}); + runCommand({"unset environment " + item.name, NoFlags}); else - runCommand({"-gdb-set environment " + item.name.toUtf8() + '=' - + item.value.toUtf8(), NoFlags}); + runCommand({"-gdb-set environment " + item.name + '=' + + item.value, NoFlags}); } } @@ -4221,7 +4221,7 @@ void GdbEngine::reloadDebuggingHelpers() void GdbEngine::handleGdbError(QProcess::ProcessError error) { const QString msg = errorMessage(error); - showMessage(_("HANDLE GDB ERROR: ") + msg); + showMessage("HANDLE GDB ERROR: " + msg); // Show a message box for asynchronously reported issues. switch (error) { case QProcess::FailedToStart: @@ -4246,18 +4246,18 @@ void GdbEngine::handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus) if (m_commandTimer.isActive()) m_commandTimer.stop(); - notifyDebuggerProcessFinished(exitCode, exitStatus, QLatin1String("GDB")); + notifyDebuggerProcessFinished(exitCode, exitStatus, "GDB"); } void GdbEngine::abortDebugger() { if (targetState() == DebuggerFinished) { // We already tried. Try harder. - showMessage(_("ABORTING DEBUGGER. SECOND TIME.")); + showMessage("ABORTING DEBUGGER. SECOND TIME."); m_gdbProc.kill(); } else { // Be friendly the first time. This will change targetState(). - showMessage(_("ABORTING DEBUGGER. FIRST TIME.")); + showMessage("ABORTING DEBUGGER. FIRST TIME."); quitDebugger(); } } @@ -4265,8 +4265,8 @@ void GdbEngine::abortDebugger() void GdbEngine::resetInferior() { if (!runParameters().commandsForReset.isEmpty()) { - const QByteArray commands = expand(runParameters().commandsForReset); - foreach (QByteArray command, commands.split('\n')) { + const QString commands = expand(runParameters().commandsForReset); + foreach (QString command, commands.split('\n')) { command = command.trimmed(); if (!command.isEmpty()) runCommand({command, ConsoleCommand | NeedsStop}); @@ -4280,7 +4280,7 @@ void GdbEngine::resetInferior() void GdbEngine::handleAdapterStartFailed(const QString &msg, Id settingsIdHint) { CHECK_STATE(EngineSetupOk); - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!msg.isEmpty() && !Internal::isTestRun()) { const QString title = tr("Adapter start failed"); if (!settingsIdHint.isValid()) { @@ -4315,15 +4315,15 @@ void GdbEngine::handleInferiorPrepared() CHECK_STATE(InferiorSetupRequested); if (!rp.commandsAfterConnect.isEmpty()) { - const QByteArray commands = expand(rp.commandsAfterConnect); - foreach (QByteArray command, commands.split('\n')) + const QString commands = expand(rp.commandsAfterConnect); + foreach (const QString &command, commands.split('\n')) runCommand({command, NoFlags}); } //runCommand("set follow-exec-mode new"); if (rp.breakOnMain) { - QByteArray cmd = "tbreak "; - cmd += rp.toolChainAbi.os() == Abi::WindowsOS ? "qMain" : "main"; + QString cmd = "tbreak "; + cmd += QLatin1String(rp.toolChainAbi.os() == Abi::WindowsOS ? "qMain" : "main"); runCommand({cmd, NoFlags}); } @@ -4369,12 +4369,12 @@ void GdbEngine::finishInferiorSetup() void GdbEngine::handleDebugInfoLocation(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { - const QByteArray debugInfoLocation = runParameters().debugInfoLocation.toLocal8Bit(); - if (QFile::exists(QString::fromLocal8Bit(debugInfoLocation))) { - const QByteArray curDebugInfoLocations = response.consoleStreamOutput.split('"').value(1); - QByteArray cmd = "set debug-file-directory " + debugInfoLocation; + const QString debugInfoLocation = runParameters().debugInfoLocation; + if (QFile::exists(debugInfoLocation)) { + const QString curDebugInfoLocations = response.consoleStreamOutput.split('"').value(1); + QString cmd = "set debug-file-directory " + debugInfoLocation; if (!curDebugInfoLocations.isEmpty()) - cmd += HostOsInfo::pathListSeparator().toLatin1() + curDebugInfoLocations; + cmd += HostOsInfo::pathListSeparator() + curDebugInfoLocations; runCommand({cmd, NoFlags}); } } @@ -4382,19 +4382,19 @@ void GdbEngine::handleDebugInfoLocation(const DebuggerResponse &response) void GdbEngine::notifyInferiorSetupFailed(const QString &msg) { - showStatusMessage(tr("Failed to start application:") + QLatin1Char(' ') + msg); + showStatusMessage(tr("Failed to start application:") + ' ' + msg); if (state() == EngineSetupFailed) { - showMessage(_("INFERIOR START FAILED, BUT ADAPTER DIED ALREADY")); + showMessage("INFERIOR START FAILED, BUT ADAPTER DIED ALREADY"); return; // Adapter crashed meanwhile, so this notification is meaningless. } - showMessage(_("INFERIOR START FAILED")); + showMessage("INFERIOR START FAILED"); AsynchronousMessageBox::critical(tr("Failed to start application"), msg); DebuggerEngine::notifyInferiorSetupFailed(); } void GdbEngine::handleAdapterCrashed(const QString &msg) { - showMessage(_("ADAPTER CRASHED")); + showMessage("ADAPTER CRASHED"); // The adapter is expected to have cleaned up after itself when we get here, // so the effect is about the same as AdapterStartFailed => use it. @@ -4418,8 +4418,8 @@ void GdbEngine::createFullBacktrace() DebuggerCommand cmd("thread apply all bt full", NeedsStop | ConsoleCommand); cmd.callback = [this](const DebuggerResponse &response) { if (response.resultClass == ResultDone) { - Internal::openTextEditor(_("Backtrace $"), - _(response.consoleStreamOutput + response.logStreamOutput)); + Internal::openTextEditor("Backtrace $", + response.consoleStreamOutput + response.logStreamOutput); } }; runCommand(cmd); @@ -4452,14 +4452,14 @@ bool GdbEngine::usesTargetAsync() const return runParameters().useTargetAsync || boolSetting(TargetAsync); } -void GdbEngine::scheduleTestResponse(int testCase, const QByteArray &response) +void GdbEngine::scheduleTestResponse(int testCase, const QString &response) { if (!m_testCases.contains(testCase) && runParameters().testCase != testCase) return; int token = currentToken() + 1; - showMessage(_("SCHEDULING TEST RESPONSE (CASE: %1, TOKEN: %2, RESPONSE: %3)") - .arg(testCase).arg(token).arg(_(response))); + showMessage(QString("SCHEDULING TEST RESPONSE (CASE: %1, TOKEN: %2, RESPONSE: %3)") + .arg(testCase).arg(token).arg(response)); m_scheduledTestResponses[token] = response; } @@ -4543,26 +4543,18 @@ void GdbEngine::interruptLocalInferior(qint64 pid) { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state(); return); if (pid <= 0) { - showMessage(QLatin1String("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED"), LogError); + showMessage("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED", LogError); return; } QString errorMessage; if (interruptProcess(pid, GdbEngineType, &errorMessage)) { - showMessage(QLatin1String("Interrupted ") + QString::number(pid)); + showMessage("Interrupted " + QString::number(pid)); } else { showMessage(errorMessage, LogError); notifyInferiorStopFailed(); } } -QByteArray GdbEngine::dotEscape(QByteArray str) -{ - str.replace(' ', '.'); - str.replace('\\', '.'); - str.replace('/', '.'); - return str; -} - void GdbEngine::debugLastCommand() { runCommand(m_lastDebuggableCommand); @@ -4599,8 +4591,8 @@ void GdbEngine::doUpdateLocals(const UpdateParameters ¶ms) watchHandler()->appendFormatRequests(&cmd); watchHandler()->appendWatchersAndTooltipRequests(&cmd); - cmd.arg("stringcutoff", action(MaximalStringLength)->value().toByteArray()); - cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toByteArray()); + cmd.arg("stringcutoff", action(MaximalStringLength)->value().toString()); + cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toString()); const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty(); @@ -4628,13 +4620,12 @@ void GdbEngine::handleFetchVariables(const DebuggerResponse &response) m_inUpdateLocals = false; if (response.resultClass == ResultDone) { - QByteArray out = response.consoleStreamOutput; + QString out = response.consoleStreamOutput; while (out.endsWith(' ') || out.endsWith('\n')) out.chop(1); int pos = out.indexOf("data="); if (pos != 0) { - showMessage(_("DISCARDING JUNK AT BEGIN OF RESPONSE: " - + out.left(pos))); + showMessage("DISCARDING JUNK AT BEGIN OF RESPONSE: " + out.left(pos)); out = out.mid(pos); } GdbMi all; @@ -4643,7 +4634,7 @@ void GdbEngine::handleFetchVariables(const DebuggerResponse &response) updateLocalsView(all); } else { - showMessage(_("DUMPER FAILED: " + response.toString())); + showMessage("DUMPER FAILED: " + response.toString()); } watchHandler()->notifyUpdateFinished(); } diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 0db63af932..5d9642f579 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -128,9 +128,9 @@ private slots: void handleInterruptDeviceInferior(const QString &error); void handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus); void handleGdbError(QProcess::ProcessError error); - void readDebugeeOutput(const QByteArray &data); void readGdbStandardOutput(); void readGdbStandardError(); + void readDebuggeeOutput(const QByteArray &ba); private: QTextCodec *m_outputCodec; @@ -141,7 +141,7 @@ private: // Name of the convenience variable containing the last // known function return value. - QByteArray m_resultVarName; + QString m_resultVarName; private: ////////// Gdb Command Management ////////// @@ -176,15 +176,15 @@ private: void setTokenBarrier(); // Sets up an "unexpected result" for the following commeand. - void scheduleTestResponse(int testCase, const QByteArray &response); + void scheduleTestResponse(int testCase, const QString &response); QHash<int, DebuggerCommand> m_commandForToken; QHash<int, int> m_flagsForToken; int commandTimeoutTime() const; QTimer m_commandTimer; - QByteArray m_pendingConsoleStreamOutput; - QByteArray m_pendingLogStreamOutput; + QString m_pendingConsoleStreamOutput; + QString m_pendingLogStreamOutput; // This contains the first token number for the current round // of evaluation. Responses with older tokens are considers @@ -202,8 +202,8 @@ private: private: ////////// Gdb Output, State & Capability Handling ////////// protected: - void handleResponse(const QByteArray &buff); - void handleAsyncOutput(const QByteArray &asyncClass, const GdbMi &result); + void handleResponse(const QString &buff); + void handleAsyncOutput(const QString &asyncClass, const GdbMi &result); void handleStopResponse(const GdbMi &data); void handleResultRecord(DebuggerResponse *response); void handleStop1(const GdbMi &data); @@ -282,8 +282,8 @@ private: ////////// View & Data Stuff ////////// void handleCatchInsert(const DebuggerResponse &response, Breakpoint bp); void handleBkpt(const GdbMi &bkpt, Breakpoint bp); void updateResponse(BreakpointResponse &response, const GdbMi &bkpt); - QByteArray breakpointLocation(const BreakpointParameters &data); // For gdb/MI. - QByteArray breakpointLocation2(const BreakpointParameters &data); // For gdb/CLI fallback. + QString breakpointLocation(const BreakpointParameters &data); // For gdb/MI. + QString breakpointLocation2(const BreakpointParameters &data); // For gdb/CLI fallback. QString breakLocation(const QString &file) const; // @@ -312,7 +312,7 @@ private: ////////// View & Data Stuff ////////// // Register specific stuff // void reloadRegisters() override; - void setRegisterValue(const QByteArray &name, const QString &value) override; + void setRegisterValue(const QString &name, const QString &value) override; void handleRegisterListNames(const DebuggerResponse &response); void handleRegisterListing(const DebuggerResponse &response); void handleRegisterListValues(const DebuggerResponse &response); @@ -327,7 +327,7 @@ private: ////////// View & Data Stuff ////////// void fetchDisassemblerByCliPointMixed(const DisassemblerAgentCookie &ac); void fetchDisassemblerByCliRangeMixed(const DisassemblerAgentCookie &ac); void fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie &ac); - bool handleCliDisassemblerResult(const QByteArray &response, DisassemblerAgent *agent); + bool handleCliDisassemblerResult(const QString &response, DisassemblerAgent *agent); // // Source file specific stuff @@ -406,7 +406,7 @@ protected: QString errorMessage(QProcess::ProcessError error); void showExecutionError(const QString &message); - static QByteArray tooltipIName(const QString &exp); + static QString tooltipIName(const QString &exp); // For short-circuiting stack and thread list evaluation. bool m_stackNeeded; @@ -416,7 +416,7 @@ protected: bool m_inUpdateLocals; // HACK: - QByteArray m_currentThread; + QString m_currentThread; QString m_lastWinException; QString m_lastMissingDebugInfo; bool m_terminalTrap; @@ -424,7 +424,7 @@ protected: bool usesExecInterrupt() const; bool usesTargetAsync() const; - QHash<int, QByteArray> m_scheduledTestResponses; + QHash<int, QString> m_scheduledTestResponses; QSet<int> m_testCases; // Debug information @@ -444,7 +444,6 @@ protected: static QString msgInferiorSetupOk(); static QString msgInferiorRunOk(); static QString msgConnectRemoteServerFailed(const QString &why); - static QByteArray dotEscape(QByteArray str); void debugLastCommand() override; DebuggerCommand m_lastDebuggableCommand; diff --git a/src/plugins/debugger/gdb/gdbplainengine.cpp b/src/plugins/debugger/gdb/gdbplainengine.cpp index a04a17aa48..13709f7cec 100644 --- a/src/plugins/debugger/gdb/gdbplainengine.cpp +++ b/src/plugins/debugger/gdb/gdbplainengine.cpp @@ -29,7 +29,6 @@ #include <debugger/debuggercore.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <utils/hostosinfo.h> #include <utils/qtcassert.h> @@ -46,7 +45,7 @@ GdbPlainEngine::GdbPlainEngine(const DebuggerRunParameters &startParameters) { // Output connect(&m_outputCollector, &OutputCollector::byteDelivery, - this, &GdbEngine::readDebugeeOutput); + this, &GdbEngine::readDebuggeeOutput); } void GdbPlainEngine::setupInferior() @@ -55,9 +54,11 @@ void GdbPlainEngine::setupInferior() setEnvironmentVariables(); if (!runParameters().inferior.commandLineArguments.isEmpty()) { QString args = runParameters().inferior.commandLineArguments; - runCommand({"-exec-arguments " + toLocalEncoding(args), NoFlags}); + runCommand({"-exec-arguments " + args, NoFlags}); } - runCommand({"-file-exec-and-symbols \"" + execFilePath() + '"', NoFlags, + + QString executable = QFileInfo(runParameters().inferior.executable).absoluteFilePath(); + runCommand({"-file-exec-and-symbols \"" + executable + '"', NoFlags, CB(handleFileExecAndSymbols)}); } @@ -67,11 +68,10 @@ void GdbPlainEngine::handleFileExecAndSymbols(const DebuggerResponse &response) if (response.resultClass == ResultDone) { handleInferiorPrepared(); } else { - QByteArray ba = response.data["msg"].data(); - QString msg = fromLocalEncoding(ba); + QString msg = response.data["msg"].data(); // Extend the message a bit in unknown cases. - if (!ba.endsWith("File format not recognized")) - msg = tr("Starting executable failed:") + QLatin1Char('\n') + msg; + if (!msg.endsWith("File format not recognized")) + msg = tr("Starting executable failed:") + '\n' + msg; notifyInferiorSetupFailed(msg); } } @@ -83,19 +83,20 @@ void GdbPlainEngine::runEngine() else runCommand({"-exec-run", RunRequest, CB(handleExecRun)}); } + void GdbPlainEngine::handleExecRun(const DebuggerResponse &response) { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); if (response.resultClass == ResultRunning) { notifyEngineRunAndInferiorRunOk(); // For gdb < 7.0 //showStatusMessage(tr("Running...")); - showMessage(_("INFERIOR STARTED")); + showMessage("INFERIOR STARTED"); showMessage(msgInferiorSetupOk(), StatusBar); // FIXME: That's the wrong place for it. if (boolSetting(EnableReverseDebugging)) runCommand({"target record", NoFlags}); } else { - QString msg = fromLocalEncoding(response.data["msg"].data()); + QString msg = response.data["msg"].data(); //QTC_CHECK(status() == InferiorRunOk); //interruptInferior(); showMessage(msg); @@ -106,7 +107,7 @@ void GdbPlainEngine::handleExecRun(const DebuggerResponse &response) void GdbPlainEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); if (!prepareCommand()) return; @@ -118,7 +119,7 @@ void GdbPlainEngine::setupEngine() .arg(m_outputCollector.errorString())); return; } - gdbArgs.append(_("--tty=") + m_outputCollector.serverName()); + gdbArgs.append("--tty=" + m_outputCollector.serverName()); if (!runParameters().inferior.workingDirectory.isEmpty()) m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory); @@ -138,26 +139,10 @@ void GdbPlainEngine::interruptInferior2() void GdbPlainEngine::shutdownEngine() { - showMessage(_("PLAIN ADAPTER SHUTDOWN %1").arg(state())); + showMessage(QString("PLAIN ADAPTER SHUTDOWN %1").arg(state())); m_outputCollector.shutdown(); notifyAdapterShutdownOk(); } -QByteArray GdbPlainEngine::execFilePath() const -{ - return QFileInfo(runParameters().inferior.executable) - .absoluteFilePath().toLocal8Bit(); -} - -QByteArray GdbPlainEngine::toLocalEncoding(const QString &s) const -{ - return s.toLocal8Bit(); -} - -QString GdbPlainEngine::fromLocalEncoding(const QByteArray &b) const -{ - return QString::fromLocal8Bit(b); -} - } // namespace Debugger } // namespace Internal diff --git a/src/plugins/debugger/gdb/gdbplainengine.h b/src/plugins/debugger/gdb/gdbplainengine.h index ab1f809156..a4168ebf40 100644 --- a/src/plugins/debugger/gdb/gdbplainengine.h +++ b/src/plugins/debugger/gdb/gdbplainengine.h @@ -50,10 +50,6 @@ private: void interruptInferior2(); void shutdownEngine(); - QByteArray execFilePath() const; - QByteArray toLocalEncoding(const QString &s) const; - QString fromLocalEncoding(const QByteArray &b) const; - OutputCollector m_outputCollector; }; diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index 6c4e962172..5b1ce8cd3c 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -29,7 +29,6 @@ #include <debugger/debuggercore.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <debugger/procinterrupt.h> #include <coreplugin/messagebox.h> @@ -72,7 +71,7 @@ GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerRunParameters &runPar void GdbRemoteServerEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); QString serverStartScript = runParameters().serverStartScript; if (!serverStartScript.isEmpty()) { @@ -179,10 +178,10 @@ void GdbRemoteServerEngine::setupInferior() // postCommand("set architecture " + remoteArch); const QString solibSearchPath = rp.solibSearchPath.join(HostOsInfo::pathListSeparator()); if (!solibSearchPath.isEmpty()) - runCommand({"set solib-search-path " + solibSearchPath.toLocal8Bit(), NoFlags}); + runCommand({"set solib-search-path " + solibSearchPath, NoFlags}); if (!args.isEmpty()) - runCommand({"-exec-arguments " + args.toLocal8Bit(), NoFlags}); + runCommand({"-exec-arguments " + args, NoFlags}); setEnvironmentVariables(); @@ -215,7 +214,7 @@ void GdbRemoteServerEngine::setupInferior() } if (!symbolFile.isEmpty()) { - runCommand({"-file-exec-and-symbols \"" + symbolFile.toLocal8Bit() + '"', + runCommand({"-file-exec-and-symbols \"" + symbolFile + '"', NoFlags, CB(handleFileExecAndSymbols)}); } } @@ -233,12 +232,10 @@ void GdbRemoteServerEngine::handleFileExecAndSymbols(const DebuggerResponse &res if (response.resultClass == ResultDone) { callTargetRemote(); } else { - QByteArray reason = response.data["msg"].data(); - QString msg = tr("Reading debug information failed:"); - msg += QLatin1Char('\n'); - msg += QString::fromLocal8Bit(reason); + QString reason = response.data["msg"].data(); + QString msg = tr("Reading debug information failed:") + '\n' + reason; if (reason.endsWith("No such file or directory.")) { - showMessage(_("INFERIOR STARTUP: BINARY NOT FOUND")); + showMessage("INFERIOR STARTUP: BINARY NOT FOUND"); showMessage(msg, StatusBar); callTargetRemote(); // Proceed nevertheless. } else { @@ -249,8 +246,7 @@ void GdbRemoteServerEngine::handleFileExecAndSymbols(const DebuggerResponse &res void GdbRemoteServerEngine::callTargetRemote() { - QByteArray rawChannel = runParameters().remoteChannel.toLatin1(); - QByteArray channel = rawChannel; + QString channel = runParameters().remoteChannel; // Don't touch channels with explicitly set protocols. if (!channel.startsWith("tcp:") && !channel.startsWith("udp:") @@ -278,19 +274,17 @@ void GdbRemoteServerEngine::handleTargetRemote(const DebuggerResponse &response) QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == ResultDone) { // gdb server will stop the remote application itself. - showMessage(_("INFERIOR STARTED")); + showMessage("INFERIOR STARTED"); showMessage(msgAttachedToStoppedInferior(), StatusBar); QString postAttachCommands = stringSetting(GdbPostAttachCommands); if (!postAttachCommands.isEmpty()) { foreach (const QString &cmd, postAttachCommands.split(QLatin1Char('\n'))) - runCommand({cmd.toLatin1(), NoFlags}); + runCommand({cmd, NoFlags}); } handleInferiorPrepared(); } else { // 16^error,msg="hd:5555: Connection timed out." - QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data["msg"].data())); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(msgConnectRemoteServerFailed(response.data["msg"].data())); } } @@ -298,25 +292,23 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const DebuggerResponse &r { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == ResultDone) { - showMessage(_("ATTACHED TO GDB SERVER STARTED")); + showMessage("ATTACHED TO GDB SERVER STARTED"); showMessage(msgAttachedToStoppedInferior(), StatusBar); QString postAttachCommands = stringSetting(GdbPostAttachCommands); if (!postAttachCommands.isEmpty()) { foreach (const QString &cmd, postAttachCommands.split(QLatin1Char('\n'))) - runCommand({cmd.toLatin1(), NoFlags}); + runCommand({cmd, NoFlags}); } if (runParameters().attachPID > 0) { // attach to pid if valid // gdb server will stop the remote application itself. - runCommand({"attach " + QByteArray::number(runParameters().attachPID), + runCommand({"attach " + QString::number(runParameters().attachPID), NoFlags, CB(handleTargetExtendedAttach)}); } else { - runCommand({"-gdb-set remote exec-file " + runParameters().inferior.executable.toLatin1(), + runCommand({"-gdb-set remote exec-file " + runParameters().inferior.executable, NoFlags, CB(handleTargetExtendedAttach)}); } } else { - QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data["msg"].data())); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(msgConnectRemoteServerFailed(response.data["msg"].data())); } } @@ -327,9 +319,7 @@ void GdbRemoteServerEngine::handleTargetExtendedAttach(const DebuggerResponse &r // gdb server will stop the remote application itself. handleInferiorPrepared(); } else { - QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data["msg"].data())); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(msgConnectRemoteServerFailed(response.data["msg"].data())); } } @@ -339,23 +329,21 @@ void GdbRemoteServerEngine::handleTargetQnx(const DebuggerResponse &response) QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == ResultDone) { // gdb server will stop the remote application itself. - showMessage(_("INFERIOR STARTED")); + showMessage("INFERIOR STARTED"); showMessage(msgAttachedToStoppedInferior(), StatusBar); const DebuggerRunParameters &rp = isMasterEngine() ? runParameters() : masterEngine()->runParameters(); const qint64 pid = rp.attachPID; const QString remoteExecutable = rp.inferior.executable; if (pid > -1) - runCommand({"attach " + QByteArray::number(pid), NoFlags, CB(handleAttach)}); + runCommand({"attach " + QString::number(pid), NoFlags, CB(handleAttach)}); else if (!remoteExecutable.isEmpty()) - runCommand({"set nto-executable " + remoteExecutable.toLatin1(), NoFlags, CB(handleSetNtoExecutable)}); + runCommand({"set nto-executable " + remoteExecutable, NoFlags, CB(handleSetNtoExecutable)}); else handleInferiorPrepared(); } else { // 16^error,msg="hd:5555: Connection timed out." - QString msg = msgConnectRemoteServerFailed( - QString::fromLocal8Bit(response.data["msg"].data())); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(response.data["msg"].data()); } } @@ -365,7 +353,7 @@ void GdbRemoteServerEngine::handleAttach(const DebuggerResponse &response) switch (response.resultClass) { case ResultDone: case ResultRunning: { - showMessage(_("INFERIOR ATTACHED")); + showMessage("INFERIOR ATTACHED"); showMessage(msgAttachedToStoppedInferior(), StatusBar); handleInferiorPrepared(); break; @@ -377,8 +365,7 @@ void GdbRemoteServerEngine::handleAttach(const DebuggerResponse &response) } // if msg != "ptrace: ..." fall through default: - QString msg = QString::fromLocal8Bit(response.data["msg"].data()); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(response.data["msg"].data()); } } @@ -388,15 +375,14 @@ void GdbRemoteServerEngine::handleSetNtoExecutable(const DebuggerResponse &respo switch (response.resultClass) { case ResultDone: case ResultRunning: { - showMessage(_("EXECUTABLE SET")); + showMessage("EXECUTABLE SET"); showMessage(msgAttachedToStoppedInferior(), StatusBar); handleInferiorPrepared(); break; } case ResultError: default: - QString msg = QString::fromLocal8Bit(response.data["msg"].data()); - notifyInferiorSetupFailed(msg); + notifyInferiorSetupFailed(response.data["msg"].data()); } } @@ -417,11 +403,10 @@ void GdbRemoteServerEngine::handleExecRun(const DebuggerResponse &response) QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); if (response.resultClass == ResultRunning) { notifyEngineRunAndInferiorRunOk(); - showMessage(_("INFERIOR STARTED")); + showMessage("INFERIOR STARTED"); showMessage(msgInferiorSetupOk(), StatusBar); } else { - QString msg = QString::fromLocal8Bit(response.data["msg"].data()); - showMessage(msg); + showMessage(response.data["msg"].data()); notifyEngineRunFailed(); } } @@ -438,7 +423,7 @@ void GdbRemoteServerEngine::interruptInferior2() bool ok = interruptProcess(pid, GdbEngineType, &m_errorString); if (!ok) { // FIXME: Extra state needed? - showMessage(_("NOTE: INFERIOR STOP NOT POSSIBLE")); + showMessage("NOTE: INFERIOR STOP NOT POSSIBLE"); showStatusMessage(tr("Interrupting not possible")); notifyInferiorRunOk(); } @@ -469,7 +454,7 @@ void GdbRemoteServerEngine::notifyEngineRemoteServerRunning runParameters().attachPID = inferiorPid; runParameters().remoteChannel = QString::fromLatin1(serverChannel); runParameters().multiProcess = true; - showMessage(_("NOTE: REMOTE SERVER RUNNING IN MULTIMODE")); + showMessage("NOTE: REMOTE SERVER RUNNING IN MULTIMODE"); m_startAttempted = true; startGdb(); } diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index 60019e7efb..33f32b36b8 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -28,7 +28,6 @@ #include <debugger/debuggercore.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <debugger/shared/hostutils.h> #include <utils/hostosinfo.h> @@ -70,7 +69,7 @@ GdbTermEngine::~GdbTermEngine() void GdbTermEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); // Currently, adapters are not re-used // // We leave the console open, so recycle it now. @@ -119,8 +118,8 @@ void GdbTermEngine::setupInferior() const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID(); notifyInferiorPid(attachedPID); const QString msg = (attachedMainThreadID != -1) - ? QString::fromLatin1("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID) - : QString::fromLatin1("Going to attach to %1").arg(attachedPID); + ? QString("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID) + : QString("Going to attach to %1").arg(attachedPID); showMessage(msg, LogMisc); handleInferiorPrepared(); } @@ -129,7 +128,7 @@ void GdbTermEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); const qint64 attachedPID = m_stubProc.applicationPID(); - runCommand({"attach " + QByteArray::number(attachedPID), NoFlags, + runCommand({"attach " + QString::number(attachedPID), NoFlags, [this](const DebuggerResponse &r) { handleStubAttached(r); }}); } @@ -148,17 +147,17 @@ void GdbTermEngine::handleStubAttached(const DebuggerResponse &response) // Resume thread that was suspended by console stub process (see stub code). const qint64 mainThreadId = m_stubProc.applicationMainThreadID(); if (winResumeThread(mainThreadId, &errorMessage)) { - showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed"). + showMessage(QString("Inferior attached, thread %1 resumed"). arg(mainThreadId), LogMisc); } else { - showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2"). + showMessage(QString("Inferior attached, unable to resume thread %1: %2"). arg(mainThreadId).arg(errorMessage), LogWarning); } notifyEngineRunAndInferiorStopOk(); continueInferiorInternal(); } else { - showMessage(_("INFERIOR ATTACHED AND RUNNING")); + showMessage("INFERIOR ATTACHED AND RUNNING"); //notifyEngineRunAndInferiorRunOk(); // Wait for the upcoming *stopped and handle it there. } @@ -169,11 +168,11 @@ void GdbTermEngine::handleStubAttached(const DebuggerResponse &response) notifyEngineRunFailed(); break; } - showMessage(QString::fromLocal8Bit(response.data["msg"].data())); + showMessage(response.data["msg"].data()); notifyEngineIll(); break; default: - showMessage(QString::fromLatin1("Invalid response %1").arg(response.resultClass)); + showMessage(QString("Invalid response %1").arg(response.resultClass)); notifyEngineIll(); break; } @@ -192,10 +191,10 @@ void GdbTermEngine::stubError(const QString &msg) void GdbTermEngine::stubExited() { if (state() == EngineShutdownRequested || state() == DebuggerFinished) { - showMessage(_("STUB EXITED EXPECTEDLY")); + showMessage("STUB EXITED EXPECTEDLY"); return; } - showMessage(_("STUB EXITED")); + showMessage("STUB EXITED"); notifyEngineIll(); } diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 995879601c..7c3e8f54f0 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -32,7 +32,6 @@ #include <debugger/debuggermainwindow.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggertooltipmanager.h> #include <debugger/breakhandler.h> @@ -117,18 +116,18 @@ void LldbEngine::runCommand(const DebuggerCommand &cmd) if (m_lldbProc.state() != QProcess::Running) { // This can legally happen e.g. through a reloadModule() // triggered by changes in view visibility. - showMessage(_("NO LLDB PROCESS RUNNING, CMD IGNORED: %1 %2") - .arg(_(cmd.function)).arg(state())); + showMessage(QString("NO LLDB PROCESS RUNNING, CMD IGNORED: %1 %2") + .arg(cmd.function).arg(state())); return; } const int tok = ++currentToken(); DebuggerCommand command = cmd; command.arg("token", tok); QByteArray token = QByteArray::number(tok); - QByteArray function = command.function + "(" + command.argsToPython() + ")"; - showMessage(_(token + function + '\n'), LogInput); + QString function = command.function + "(" + command.argsToPython() + ")"; + showMessage(token + function + '\n', LogInput); m_commandForToken[currentToken()] = command; - m_lldbProc.write("script theDumper." + function + "\n"); + m_lldbProc.write("script theDumper." + function.toUtf8() + "\n"); } void LldbEngine::debugLastCommand() @@ -155,11 +154,11 @@ void LldbEngine::abortDebugger() { if (targetState() == DebuggerFinished) { // We already tried. Try harder. - showMessage(_("ABORTING DEBUGGER. SECOND TIME.")); + showMessage("ABORTING DEBUGGER. SECOND TIME."); m_lldbProc.kill(); } else { // Be friendly the first time. This will change targetState(). - showMessage(_("ABORTING DEBUGGER. FIRST TIME.")); + showMessage("ABORTING DEBUGGER. FIRST TIME."); quitDebugger(); } } @@ -206,7 +205,7 @@ void LldbEngine::setupEngine() #endif QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); // Currently, adapters are not re-used // // We leave the console open, so recycle it now. @@ -261,7 +260,7 @@ void LldbEngine::startLldb() connect(this, &LldbEngine::outputReady, this, &LldbEngine::handleResponse, Qt::QueuedConnection); - showMessage(_("STARTING LLDB: ") + m_lldbCmd); + showMessage("STARTING LLDB: " + m_lldbCmd); m_lldbProc.setEnvironment(runParameters().debuggerEnvironment); if (!runParameters().inferior.workingDirectory.isEmpty()) m_lldbProc.setWorkingDirectory(runParameters().inferior.workingDirectory); @@ -273,7 +272,7 @@ void LldbEngine::startLldb() const QString msg = tr("Unable to start LLDB \"%1\": %2") .arg(m_lldbCmd, m_lldbProc.errorString()); notifyEngineSetupFailed(); - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!msg.isEmpty()) ICore::showWarningWithOptions(tr("Adapter start failed."), msg); return; @@ -285,7 +284,7 @@ void LldbEngine::startLldb() // FIXME: splitting of startLldb() necessary to support LLDB <= 310 - revert asap void LldbEngine::startLldbStage2() { - showMessage(_("ADAPTER STARTED")); + showMessage("ADAPTER STARTED"); showStatusMessage(tr("Setting up inferior...")); const QByteArray dumperSourcePath = @@ -308,23 +307,23 @@ void LldbEngine::setupInferior() foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) { DebuggerCommand cmd("executeDebuggerCommand"); if (item.unset) - cmd.arg("command", "settings remove target.env-vars " + item.name.toUtf8()); + cmd.arg("command", "settings remove target.env-vars " + item.name); else - cmd.arg("command", "settings set target.env-vars '" + item.name.toUtf8() + '=' + item.value.toUtf8() + '\''); + cmd.arg("command", "settings set target.env-vars '" + item.name + '=' + item.value + '\''); runCommand(cmd); } const QString path = stringSetting(ExtraDumperFile); if (!path.isEmpty() && QFileInfo(path).isReadable()) { DebuggerCommand cmd("addDumperModule"); - cmd.arg("path", path.toUtf8()); + cmd.arg("path", path); runCommand(cmd); } const QString commands = stringSetting(ExtraDumperCommands); if (!commands.isEmpty()) { DebuggerCommand cmd("executeDebuggerCommand"); - cmd.arg("command", commands.toUtf8()); + cmd.arg("command", commands); runCommand(cmd); } @@ -348,9 +347,9 @@ void LldbEngine::setupInferior() cmd2.arg("startmode", rp.startMode); cmd2.arg("nativemixed", isNativeMixedActive()); - cmd2.arg("dyldimagesuffix", rp.inferior.environment.value(_("DYLD_IMAGE_SUFFIX"))); - cmd2.arg("dyldframeworkpath", rp.inferior.environment.value(_("DYLD_LIBRARY_PATH"))); - cmd2.arg("dyldlibrarypath", rp.inferior.environment.value(_("DYLD_FRAMEWORK_PATH"))); + cmd2.arg("dyldimagesuffix", rp.inferior.environment.value("DYLD_IMAGE_SUFFIX")); + cmd2.arg("dyldframeworkpath", rp.inferior.environment.value("DYLD_LIBRARY_PATH")); + cmd2.arg("dyldlibrarypath", rp.inferior.environment.value("DYLD_FRAMEWORK_PATH")); QJsonArray processArgs; foreach (const QString &arg, args.toUnixArgs()) @@ -394,7 +393,7 @@ void LldbEngine::setupInferior() bp.setEngine(this); insertBreakpoint(bp); } else { - showMessage(_("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE") + showMessage(QString("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE") .arg(bp.id().toString()).arg(bp.state())); } } @@ -464,21 +463,21 @@ void LldbEngine::continueInferior() runCommand(cmd); } -void LldbEngine::handleResponse(const QByteArray &response) +void LldbEngine::handleResponse(const QString &response) { GdbMi all; all.fromStringMultiple(response); foreach (const GdbMi &item, all.children()) { - const QByteArray name = item.name(); + const QString name = item.name(); if (name == "result") { - QString msg = item["status"].toUtf8(); + QString msg = item["status"].data(); if (msg.size()) msg[0] = msg.at(0).toUpper(); showStatusMessage(msg); int token = item["token"].toInt(); - showMessage(QString::fromLatin1("%1^").arg(token), LogOutput); + showMessage(QString("%1^").arg(token), LogOutput); if (m_commandForToken.contains(token)) { DebuggerCommand cmd = m_commandForToken.take(token); DebuggerResponse response; @@ -596,7 +595,7 @@ void LldbEngine::changeBreakpoint(Breakpoint bp) { const BreakpointResponse &response = bp.response(); DebuggerCommand cmd("changeBreakpoint"); - cmd.arg("lldbid", response.id.toByteArray()); + cmd.arg("lldbid", response.id.toString()); cmd.callback = [this, bp](const DebuggerResponse &response) { QTC_CHECK(!bp.isValid() || bp.state() == BreakpointChangeProceeding); updateBreakpointData(bp, response.data, false); @@ -611,7 +610,7 @@ void LldbEngine::removeBreakpoint(Breakpoint bp) const BreakpointResponse &response = bp.response(); if (response.id.isValid()) { DebuggerCommand cmd("removeBreakpoint"); - cmd.arg("lldbid", response.id.toByteArray()); + cmd.arg("lldbid", response.id.toString()); cmd.callback = [this, bp](const DebuggerResponse &) { QTC_CHECK(bp.state() == BreakpointRemoveProceeding); Breakpoint bp0 = bp; @@ -635,9 +634,9 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add response.address = 0; response.enabled = bkpt["enabled"].toInt(); response.ignoreCount = bkpt["ignorecount"].toInt(); - response.condition = QByteArray::fromHex(bkpt["condition"].data()); + response.condition = fromHex(bkpt["condition"].data()); response.hitCount = bkpt["hitcount"].toInt(); - response.fileName = bkpt["file"].toUtf8(); + response.fileName = bkpt["file"].data(); response.lineNumber = bkpt["line"].toInt(); GdbMi locations = bkpt["locations"]; @@ -649,8 +648,8 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add sub.id = BreakpointResponseId(rid.majorPart(), locid); sub.type = response.type; sub.address = location["addr"].toAddress(); - sub.functionName = location["func"].toUtf8(); - sub.fileName = location["file"].toUtf8(); + sub.functionName = location["func"].data(); + sub.fileName = location["file"].data(); sub.lineNumber = location["line"].toInt(); bp.insertSubBreakpoint(sub); } @@ -658,11 +657,11 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add } else if (numChild == 1) { const GdbMi location = locations.childAt(0); response.address = location["addr"].toAddress(); - response.functionName = location["func"].toUtf8(); + response.functionName = location["func"].data(); response.pending = false; } else { // This can happen for pending breakpoints. - showMessage(_("NO LOCATIONS (YET) FOR BP %1").arg(response.toString())); + showMessage(QString("NO LOCATIONS (YET) FOR BP %1").arg(response.toString())); } bp.setResponse(response); if (added) @@ -673,14 +672,14 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add void LldbEngine::handleOutputNotification(const GdbMi &output) { - QByteArray channel = output["channel"].data(); - QByteArray data = QByteArray::fromHex(output["data"].data()); + QString channel = output["channel"].data(); + QString data = fromHex(output["data"].data()); LogChannel ch = AppStuff; if (channel == "stdout") ch = AppOutput; else if (channel == "stderr") ch = AppError; - showMessage(QString::fromUtf8(data), ch); + showMessage(data, ch); } void LldbEngine::loadSymbols(const QString &moduleName) @@ -701,8 +700,8 @@ void LldbEngine::reloadModules() handler->beginUpdateAll(); foreach (const GdbMi &item, modules.children()) { Module module; - module.modulePath = item["file"].toUtf8(); - module.moduleName = item["name"].toUtf8(); + module.modulePath = item["file"].data(); + module.moduleName = item["name"].data(); module.symbolsRead = Module::UnknownReadState; module.startAddress = item["loaded_addr"].toAddress(); module.endAddress = 0; // FIXME: End address not easily available. @@ -719,15 +718,15 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName) cmd.arg("module", moduleName); cmd.callback = [this, moduleName](const DebuggerResponse &response) { const GdbMi &symbols = response.data["symbols"]; - QString moduleName = response.data["module"].toUtf8(); + QString moduleName = response.data["module"].data(); Symbols syms; foreach (const GdbMi &item, symbols.children()) { Symbol symbol; - symbol.address = item["address"].toUtf8(); - symbol.name = item["name"].toUtf8(); - symbol.state = item["state"].toUtf8(); - symbol.section = item["section"].toUtf8(); - symbol.demangled = item["demangled"].toUtf8(); + symbol.address = item["address"].data(); + symbol.name = item["name"].data(); + symbol.state = item["state"].data(); + symbol.section = item["section"].data(); + symbol.demangled = item["demangled"].data(); syms.append(symbol); } Internal::showModuleSymbols(moduleName, syms); @@ -789,8 +788,8 @@ void LldbEngine::assignValueInDebugger(WatchItem *, const QString &expression, const QVariant &value) { DebuggerCommand cmd("assignValue"); - cmd.arg("exp", expression.toLatin1().toHex()); - cmd.arg("value", value.toString().toLatin1().toHex()); + cmd.arg("exp", toHex(expression)); + cmd.arg("value", toHex(value.toString())); cmd.callback = [this](const DebuggerResponse &) { updateLocals(); }; runCommand(cmd); } @@ -830,7 +829,7 @@ void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms) void LldbEngine::handleLldbError(QProcess::ProcessError error) { - showMessage(_("LLDB PROCESS ERROR: %1").arg(error)); + showMessage(QString("LLDB PROCESS ERROR: %1").arg(error)); switch (error) { case QProcess::Crashed: break; // will get a processExited() as well @@ -869,7 +868,7 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const return tr("An error occurred when attempting to read from " "the Lldb process. For example, the process may not be running."); default: - return tr("An unknown error in the LLDB process occurred.") + QLatin1Char(' '); + return tr("An unknown error in the LLDB process occurred.") + ' '; } } @@ -880,22 +879,23 @@ void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatu void LldbEngine::readLldbStandardError() { - QByteArray err = m_lldbProc.readAllStandardError(); + QString err = QString::fromUtf8(m_lldbProc.readAllStandardError()); qDebug() << "\nLLDB STDERR UNEXPECTED: " << err; - showMessage(_("Lldb stderr: " + err), LogError); + showMessage("Lldb stderr: " + err, LogError); } void LldbEngine::readLldbStandardOutput() { - QByteArray out = m_lldbProc.readAllStandardOutput(); - out.replace("\r\n", "\n"); - showMessage(_(out), LogOutput); + QByteArray outba = m_lldbProc.readAllStandardOutput(); + outba.replace("\r\n", "\n"); + QString out = QString::fromUtf8(outba); + showMessage(out, LogOutput); m_inbuffer.append(out); while (true) { int pos = m_inbuffer.indexOf("@\n"); if (pos == -1) break; - QByteArray response = m_inbuffer.left(pos).trimmed(); + QString response = m_inbuffer.left(pos).trimmed(); m_inbuffer = m_inbuffer.mid(pos + 2); if (response == "lldbstartupok") startLldbStage2(); @@ -906,7 +906,7 @@ void LldbEngine::readLldbStandardOutput() void LldbEngine::handleStateNotification(const GdbMi &reportedState) { - QByteArray newState = reportedState.data(); + QString newState = reportedState.data(); if (newState == "running") notifyInferiorRunOk(); else if (newState == "inferiorrunfailed") @@ -956,8 +956,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState) void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation) { qulonglong address = reportedLocation["address"].toAddress(); - QString fileName = reportedLocation["file"].toUtf8(); - QByteArray function = reportedLocation["function"].data(); + QString fileName = reportedLocation["file"].data(); + QString function = reportedLocation["function"].data(); int lineNumber = reportedLocation["line"].toInt(); Location loc = Location(fileName, lineNumber); if (boolSetting(OperateByInstruction) || !QFileInfo::exists(fileName) || lineNumber <= 0) { @@ -985,7 +985,7 @@ void LldbEngine::reloadRegisters() foreach (const GdbMi &item, regs.children()) { Register reg; reg.name = item["name"].data(); - reg.value.fromByteArray(item["value"].data(), HexadecimalFormat); + reg.value.fromString(item["value"].data(), HexadecimalFormat); reg.size = item["size"].data().toInt(); reg.reportedType = item["type"].data(); if (reg.reportedType.startsWith("unsigned")) @@ -1023,20 +1023,20 @@ void LldbEngine::fetchDisassembler(DisassemblerAgent *agent) foreach (const GdbMi &line, response.data["lines"].children()) { DisassemblerLine dl; dl.address = line["address"].toAddress(); - //dl.data = line["data"].toUtf8(); + //dl.data = line["data"].data(); //dl.rawData = line["rawdata"].data(); - dl.data = line["rawdata"].toUtf8(); + dl.data = line["rawdata"].data(); if (!dl.data.isEmpty()) dl.data += QString(30 - dl.data.size(), QLatin1Char(' ')); - dl.data += line["data"].toUtf8(); + dl.data += line["data"].data(); dl.offset = line["offset"].toInt(); dl.lineNumber = line["line"].toInt(); - dl.fileName = line["file"].toUtf8(); - dl.function = line["function"].toUtf8(); + dl.fileName = line["file"].data(); + dl.function = line["function"].data(); dl.hunk = line["hunk"].toInt(); - QByteArray comment = QByteArray::fromHex(line["comment"].data()); + QString comment = fromHex(line["comment"].data()); if (!comment.isEmpty()) - dl.data += QString::fromUtf8(" # " + comment); + dl.data += " # " + comment; result.appendLine(dl); } agent->setContents(result); @@ -1049,8 +1049,7 @@ void LldbEngine::fetchFullBacktrace() { DebuggerCommand cmd("fetchFullBacktrace"); cmd.callback = [](const DebuggerResponse &response) { - Internal::openTextEditor(_("Backtrace $"), - QString::fromUtf8(QByteArray::fromHex(response.data.data()))); + Internal::openTextEditor("Backtrace $", fromHex(response.data.data())); }; runCommand(cmd); } @@ -1074,7 +1073,7 @@ void LldbEngine::fetchMemory(MemoryAgent *agent, QObject *editorToken, if (!agent.isNull()) { QPointer<QObject> token = m_memoryAgentTokens.value(id); QTC_ASSERT(!token.isNull(), return); - QByteArray ba = QByteArray::fromHex(response.data["contents"].data()); + QByteArray ba = QByteArray::fromHex(response.data["contents"].data().toUtf8()); agent->addLazyData(token.data(), addr, ba); } }; @@ -1092,12 +1091,12 @@ void LldbEngine::changeMemory(MemoryAgent *agent, QObject *editorToken, } DebuggerCommand cmd("writeMemory"); cmd.arg("address", addr); - cmd.arg("data", data.toHex()); + cmd.arg("data", QString::fromUtf8(data.toHex())); cmd.callback = [this, id](const DebuggerResponse &response) { Q_UNUSED(response); }; runCommand(cmd); } -void LldbEngine::setRegisterValue(const QByteArray &name, const QString &value) +void LldbEngine::setRegisterValue(const QString &name, const QString &value) { DebuggerCommand cmd("setRegister"); cmd.arg("name", name); @@ -1153,7 +1152,7 @@ void LldbEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result if (result.success) { startLldb(); } else { - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!result.reason.isEmpty()) { const QString title = tr("Adapter start failed"); ICore::showWarningWithOptions(title, result.reason); @@ -1176,10 +1175,10 @@ void LldbEngine::stubError(const QString &msg) void LldbEngine::stubExited() { if (state() == EngineShutdownRequested || state() == DebuggerFinished) { - showMessage(_("STUB EXITED EXPECTEDLY")); + showMessage("STUB EXITED EXPECTEDLY"); return; } - showMessage(_("STUB EXITED")); + showMessage("STUB EXITED"); notifyEngineIll(); } diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h index 17cae32246..692d2b2c8d 100644 --- a/src/plugins/debugger/lldb/lldbengine.h +++ b/src/plugins/debugger/lldb/lldbengine.h @@ -62,7 +62,7 @@ public: ~LldbEngine(); signals: - void outputReady(const QByteArray &data); + void outputReady(const QString &data); private: DebuggerEngine *cppEngine() override { return this; } @@ -116,7 +116,7 @@ private: void fetchDisassembler(Internal::DisassemblerAgent *) override; bool isSynchronous() const override { return true; } - void setRegisterValue(const QByteArray &name, const QString &value) override; + void setRegisterValue(const QString &name, const QString &value) override; void fetchMemory(Internal::MemoryAgent *, QObject *, quint64 addr, quint64 length) override; void changeMemory(Internal::MemoryAgent *, QObject *, quint64 addr, const QByteArray &data) override; @@ -133,7 +133,7 @@ private: void handleLocationNotification(const GdbMi &location); void handleOutputNotification(const GdbMi &output); - void handleResponse(const QByteArray &data); + void handleResponse(const QString &data); void updateAll() override; void doUpdateLocals(const UpdateParameters ¶ms) override; void updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool added); @@ -147,7 +147,7 @@ private: private: DebuggerCommand m_lastDebuggableCommand; - QByteArray m_inbuffer; + QString m_inbuffer; QString m_scriptFileName; Utils::QtcProcess m_lldbProc; QString m_lldbCmd; diff --git a/src/plugins/debugger/memoryagent.h b/src/plugins/debugger/memoryagent.h index b761eac4c8..e765f465ce 100644 --- a/src/plugins/debugger/memoryagent.h +++ b/src/plugins/debugger/memoryagent.h @@ -62,7 +62,7 @@ public: QWidget *parent; quint64 startAddress; - QByteArray registerName; + QString registerName; unsigned flags; QList<Internal::MemoryMarkup> markup; QPoint pos; diff --git a/src/plugins/debugger/memoryview.cpp b/src/plugins/debugger/memoryview.cpp index a451b7e243..31d2ac95ae 100644 --- a/src/plugins/debugger/memoryview.cpp +++ b/src/plugins/debugger/memoryview.cpp @@ -134,7 +134,7 @@ void MemoryView::setMarkup(const QList<MemoryMarkup> &m) */ RegisterMemoryView::RegisterMemoryView(QWidget *binEditor, quint64 addr, - const QByteArray ®Name, + const QString ®Name, RegisterHandler *handler, QWidget *parent) : MemoryView(binEditor, parent), m_registerName(regName), m_registerAddress(addr) @@ -144,16 +144,15 @@ RegisterMemoryView::RegisterMemoryView(QWidget *binEditor, quint64 addr, updateContents(); } -void RegisterMemoryView::onRegisterChanged(const QByteArray &name, quint64 value) +void RegisterMemoryView::onRegisterChanged(const QString &name, quint64 value) { if (name == m_registerName) setRegisterAddress(value); } -QString RegisterMemoryView::title(const QByteArray ®isterName, quint64 a) +QString RegisterMemoryView::title(const QString ®isterName, quint64 a) { - return tr("Memory at Register \"%1\" (0x%2)") - .arg(QString::fromUtf8(registerName)).arg(a, 0, 16); + return tr("Memory at Register \"%1\" (0x%2)").arg(registerName).arg(a, 0, 16); } void RegisterMemoryView::setRegisterAddress(quint64 v) @@ -169,12 +168,9 @@ void RegisterMemoryView::setRegisterAddress(quint64 v) setMarkup(registerMarkup(v, m_registerName)); } -QList<MemoryMarkup> RegisterMemoryView::registerMarkup(quint64 a, const QByteArray ®Name) +QList<MemoryMarkup> RegisterMemoryView::registerMarkup(quint64 a, const QString ®Name) { - QList<MemoryMarkup> result; - result.push_back(MemoryMarkup(a, 1, QColor(Qt::blue).lighter(), - tr("Register \"%1\"").arg(QString::fromUtf8(regName)))); - return result; + return { MemoryMarkup(a, 1, QColor(Qt::blue).lighter(), tr("Register \"%1\"").arg(regName)) }; } } // namespace Internal diff --git a/src/plugins/debugger/memoryview.h b/src/plugins/debugger/memoryview.h index 8a30f9025b..10cfb5013e 100644 --- a/src/plugins/debugger/memoryview.h +++ b/src/plugins/debugger/memoryview.h @@ -63,17 +63,17 @@ class RegisterMemoryView : public MemoryView { Q_OBJECT public: - explicit RegisterMemoryView(QWidget *binEditor, quint64 addr, const QByteArray ®Name, + explicit RegisterMemoryView(QWidget *binEditor, quint64 addr, const QString ®Name, RegisterHandler *rh, QWidget *parent = 0); - static QList<MemoryMarkup> registerMarkup(quint64 a, const QByteArray ®Name); - static QString title(const QByteArray ®isterName, quint64 a = 0); + static QList<MemoryMarkup> registerMarkup(quint64 a, const QString ®Name); + static QString title(const QString ®isterName, quint64 a = 0); private: - void onRegisterChanged(const QByteArray &name, quint64 value); + void onRegisterChanged(const QString &name, quint64 value); void setRegisterAddress(quint64 v); - QByteArray m_registerName; + QString m_registerName; quint64 m_registerAddress; }; diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 02cacdedf0..9aa864e588 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -31,7 +31,6 @@ #include <debugger/debuggerplugin.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggertooltipmanager.h> #include <debugger/threaddata.h> @@ -76,26 +75,26 @@ void PdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages return; QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); if (state() == DebuggerNotReady) { - showMessage(_("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command); + showMessage("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: " + command); return; } QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); - postDirectCommand(command.toLatin1()); + postDirectCommand(command); } -void PdbEngine::postDirectCommand(const QByteArray &command) +void PdbEngine::postDirectCommand(const QString &command) { QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); - showMessage(_(command), LogInput); - m_proc.write(command + '\n'); + showMessage(command, LogInput); + m_proc.write(command.toUtf8() + '\n'); } void PdbEngine::runCommand(const DebuggerCommand &cmd) { QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); - QByteArray command = "qdebug('" + cmd.function + "'," + cmd.argsToPython() + ")"; - showMessage(_(command), LogInput); - m_proc.write(command + '\n'); + QString command = "qdebug('" + cmd.function + "'," + cmd.argsToPython() + ")"; + showMessage(command, LogInput); + m_proc.write(command.toUtf8() + '\n'); } void PdbEngine::shutdownInferior() @@ -129,14 +128,14 @@ void PdbEngine::setupEngine() QFile scriptFile(runParameters().mainScript); if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) { AsynchronousMessageBox::critical(tr("Python Error"), - _("Cannot open script file %1:\n%2"). + QString("Cannot open script file %1:\n%2"). arg(scriptFile.fileName(), scriptFile.errorString())); notifyEngineSetupFailed(); } QStringList args = { bridge, scriptFile.fileName() }; args.append(Utils::QtcProcess::splitArgs(runParameters().inferior.workingDirectory)); - showMessage(_("STARTING ") + m_interpreter + QLatin1Char(' ') + args.join(QLatin1Char(' '))); + showMessage("STARTING " + m_interpreter + QLatin1Char(' ') + args.join(QLatin1Char(' '))); m_proc.setEnvironment(runParameters().debuggerEnvironment.toStringList()); m_proc.start(m_interpreter, args); @@ -144,7 +143,7 @@ void PdbEngine::setupEngine() const QString msg = tr("Unable to start pdb \"%1\": %2") .arg(m_interpreter, m_proc.errorString()); notifyEngineSetupFailed(); - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!msg.isEmpty()) ICore::showWarningWithOptions(tr("Adapter start failed"), msg); notifyEngineSetupFailed(); @@ -256,7 +255,7 @@ void PdbEngine::selectThread(ThreadId threadId) bool PdbEngine::acceptsBreakpoint(Breakpoint bp) const { const QString fileName = bp.fileName(); - return fileName.endsWith(QLatin1String(".py")); + return fileName.endsWith(".py"); } void PdbEngine::insertBreakpoint(Breakpoint bp) @@ -264,12 +263,11 @@ void PdbEngine::insertBreakpoint(Breakpoint bp) QTC_CHECK(bp.state() == BreakpointInsertRequested); bp.notifyBreakpointInsertProceeding(); - QByteArray loc; + QString loc; if (bp.type() == BreakpointByFunction) - loc = bp.functionName().toLatin1(); + loc = bp.functionName(); else - loc = bp.fileName().toLocal8Bit() + ':' - + QByteArray::number(bp.lineNumber()); + loc = bp.fileName() + ':' + QString::number(bp.lineNumber()); postDirectCommand("break " + loc); } @@ -279,8 +277,8 @@ void PdbEngine::removeBreakpoint(Breakpoint bp) QTC_CHECK(bp.state() == BreakpointRemoveRequested); bp.notifyBreakpointRemoveProceeding(); BreakpointResponse br = bp.response(); - showMessage(_("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName())); - postDirectCommand("clear " + br.id.toByteArray()); + showMessage(QString("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName())); + postDirectCommand("clear " + br.id.toString()); // Pretend it succeeds without waiting for response. bp.notifyBreakpointRemoveOk(); } @@ -305,16 +303,16 @@ void PdbEngine::refreshModules(const GdbMi &modules) handler->beginUpdateAll(); foreach (const GdbMi &item, modules.children()) { Module module; - module.moduleName = _(item["name"].data()); - QString path = _(item["value"].data()); - int pos = path.indexOf(_("' from '")); + module.moduleName = item["name"].data(); + QString path = item["value"].data(); + int pos = path.indexOf("' from '"); if (pos != -1) { path = path.mid(pos + 8); if (path.size() >= 2) path.chop(2); - } else if (path.startsWith(_("<module '")) - && path.endsWith(_("' (built-in)>"))) { - path = _("(builtin)"); + } else if (path.startsWith("<module '") + && path.endsWith("' (built-in)>")) { + path = "(builtin)"; } module.modulePath = path; handler->updateModule(module); @@ -331,7 +329,7 @@ void PdbEngine::requestModuleSymbols(const QString &moduleName) void PdbEngine::refreshState(const GdbMi &reportedState) { - QByteArray newState = reportedState.data(); + QString newState = reportedState.data(); if (newState == "stopped") { notifyInferiorSpontaneousStop(); updateAll(); @@ -343,11 +341,11 @@ void PdbEngine::refreshState(const GdbMi &reportedState) void PdbEngine::refreshLocation(const GdbMi &reportedLocation) { StackFrame frame; - frame.file = reportedLocation["file"].toUtf8(); + frame.file = reportedLocation["file"].data(); frame.line = reportedLocation["line"].toInt(); frame.usable = QFileInfo(frame.file).isReadable(); if (state() == InferiorRunOk) { - showMessage(QString::fromLatin1("STOPPED AT: %1:%2").arg(frame.file).arg(frame.line)); + showMessage(QString("STOPPED AT: %1:%2").arg(frame.file).arg(frame.line)); gotoLocation(frame); notifyInferiorSpontaneousStop(); updateAll(); @@ -356,11 +354,11 @@ void PdbEngine::refreshLocation(const GdbMi &reportedLocation) void PdbEngine::refreshSymbols(const GdbMi &symbols) { - QString moduleName = symbols["module"].toUtf8(); + QString moduleName = symbols["module"].data(); Symbols syms; foreach (const GdbMi &item, symbols["symbols"].children()) { Symbol symbol; - symbol.name = item["name"].toUtf8(); + symbol.name = item["name"].data(); syms.append(symbol); } Internal::showModuleSymbols(moduleName, syms); @@ -377,12 +375,11 @@ void PdbEngine::assignValueInDebugger(WatchItem *, const QString &expression, co //cmd.arg("expression", expression); //cmd.arg("value", value.toString()); //runCommand(cmd); - QByteArray exp = expression.toUtf8(); - postDirectCommand("global " + exp + ';' + exp + "=" + value.toString().toUtf8()); + postDirectCommand("global " + expression + ';' + expression + "=" + value.toString()); updateLocals(); } -void PdbEngine::updateItem(const QByteArray &iname) +void PdbEngine::updateItem(const QString &iname) { Q_UNUSED(iname); updateAll(); @@ -390,7 +387,7 @@ void PdbEngine::updateItem(const QByteArray &iname) void PdbEngine::handlePdbError(QProcess::ProcessError error) { - showMessage(_("HANDLE PDB ERROR")); + showMessage("HANDLE PDB ERROR"); switch (error) { case QProcess::Crashed: break; // will get a processExited() as well @@ -435,45 +432,45 @@ QString PdbEngine::errorMessage(QProcess::ProcessError error) const void PdbEngine::handlePdbFinished(int code, QProcess::ExitStatus type) { - showMessage(_("PDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code)); + showMessage(QString("PDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code)); notifyEngineSpontaneousShutdown(); } void PdbEngine::readPdbStandardError() { - QByteArray err = m_proc.readAllStandardError(); + QString err = QString::fromUtf8(m_proc.readAllStandardError()); //qWarning() << "Unexpected pdb stderr:" << err; - showMessage(_("Unexpected pdb stderr: " + err)); + showMessage("Unexpected pdb stderr: " + err); //handleOutput(err); } void PdbEngine::readPdbStandardOutput() { - QByteArray out = m_proc.readAllStandardOutput(); + QString out = QString::fromUtf8(m_proc.readAllStandardOutput()); handleOutput(out); } -void PdbEngine::handleOutput(const QByteArray &data) +void PdbEngine::handleOutput(const QString &data) { m_inbuffer.append(data); while (true) { int pos = m_inbuffer.indexOf('\n'); if (pos == -1) break; - QByteArray response = m_inbuffer.left(pos).trimmed(); + QString response = m_inbuffer.left(pos).trimmed(); m_inbuffer = m_inbuffer.mid(pos + 1); handleOutput2(response); } } -void PdbEngine::handleOutput2(const QByteArray &data) +void PdbEngine::handleOutput2(const QString &data) { - foreach (QByteArray line, data.split('\n')) { + foreach (QString line, data.split('\n')) { GdbMi item; item.fromString(line); - showMessage(_(line), LogOutput); + showMessage(line, LogOutput); if (line.startsWith("stack={")) { refreshStack(item); @@ -490,15 +487,13 @@ void PdbEngine::handleOutput2(const QByteArray &data) } else if (line.startsWith("Breakpoint")) { int pos1 = line.indexOf(" at "); QTC_ASSERT(pos1 != -1, continue); - QByteArray bpnr = line.mid(11, pos1 - 11); + QString bpnr = line.mid(11, pos1 - 11); int pos2 = line.lastIndexOf(':'); QTC_ASSERT(pos2 != -1, continue); - QByteArray fileName = line.mid(pos1 + 4, pos2 - pos1 - 4); - QByteArray lineNumber = line.mid(pos2 + 1); BreakpointResponse br; br.id = BreakpointResponseId(bpnr); - br.fileName = _(fileName); - br.lineNumber = lineNumber.toInt(); + br.fileName = line.mid(pos1 + 4, pos2 - pos1 - 4); + br.lineNumber = line.mid(pos2 + 1).toInt(); Breakpoint bp = breakHandler()->findBreakpointByFileAndLine(br.fileName, br.lineNumber, false); if (bp.isValid()) { bp.setResponse(br); @@ -526,9 +521,9 @@ void PdbEngine::refreshStack(const GdbMi &stack) foreach (const GdbMi &item, stack["frames"].children()) { StackFrame frame; frame.level = item["level"].data(); - frame.file = item["file"].toUtf8(); - frame.function = item["function"].toUtf8(); - frame.module = item["function"].toUtf8(); + frame.file = item["file"].data(); + frame.function = item["function"].data(); + frame.module = item["function"].data(); frame.line = item["line"].toInt(); frame.address = item["address"].toAddress(); GdbMi usable = item["usable"]; diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index f71f1911ba..a0a944c5d4 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -90,10 +90,10 @@ private: bool supportsThreads() const { return true; } bool isSynchronous() const override { return true; } - void updateItem(const QByteArray &iname) override; + void updateItem(const QString &iname) override; void runCommand(const DebuggerCommand &cmd) override; - void postDirectCommand(const QByteArray &command); + void postDirectCommand(const QString &command); void refreshLocation(const GdbMi &reportedLocation); void refreshStack(const GdbMi &stack); @@ -109,13 +109,13 @@ private: void handlePdbError(QProcess::ProcessError error); void readPdbStandardOutput(); void readPdbStandardError(); - void handleOutput2(const QByteArray &data); - void handleResponse(const QByteArray &ba); - void handleOutput(const QByteArray &data); + void handleOutput2(const QString &data); + void handleResponse(const QString &ba); + void handleOutput(const QString &data); void updateAll() override; void updateLocals() override; - QByteArray m_inbuffer; + QString m_inbuffer; QProcess m_proc; QString m_interpreter; }; diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index f9d52b1155..b9f616f703 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -102,7 +102,7 @@ bool QmlCppEngine::canHandleToolTip(const DebuggerToolTipContext &ctx) const return success; } -void QmlCppEngine::updateItem(const QByteArray &iname) +void QmlCppEngine::updateItem(const QString &iname) { if (iname.startsWith("inspect.")) m_qmlEngine->updateItem(iname); @@ -110,7 +110,7 @@ void QmlCppEngine::updateItem(const QByteArray &iname) m_activeEngine->updateItem(iname); } -void QmlCppEngine::expandItem(const QByteArray &iname) +void QmlCppEngine::expandItem(const QString &iname) { if (iname.startsWith("inspect.")) m_qmlEngine->expandItem(iname); @@ -118,7 +118,7 @@ void QmlCppEngine::expandItem(const QByteArray &iname) m_activeEngine->expandItem(iname); } -void QmlCppEngine::selectWatchData(const QByteArray &iname) +void QmlCppEngine::selectWatchData(const QString &iname) { if (iname.startsWith("inspect.")) m_qmlEngine->selectWatchData(iname); @@ -190,7 +190,7 @@ void QmlCppEngine::reloadFullStack() m_cppEngine->reloadFullStack(); } -void QmlCppEngine::setRegisterValue(const QByteArray &name, const QString &value) +void QmlCppEngine::setRegisterValue(const QString &name, const QString &value) { m_cppEngine->setRegisterValue(name, value); } @@ -219,7 +219,7 @@ bool QmlCppEngine::isSynchronous() const return m_activeEngine->isSynchronous(); } -QByteArray QmlCppEngine::qtNamespace() const +QString QmlCppEngine::qtNamespace() const { return m_cppEngine->qtNamespace(); } @@ -417,7 +417,7 @@ void QmlCppEngine::notifyInferiorSetupOk() DebuggerEngine::notifyInferiorSetupOk(); } -void QmlCppEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel, int pid) +void QmlCppEngine::notifyEngineRemoteServerRunning(const QString &serverChannel, int pid) { m_cppEngine->notifyEngineRemoteServerRunning(serverChannel, pid); } diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h index e549a26206..c9d592471b 100644 --- a/src/plugins/debugger/qml/qmlcppengine.h +++ b/src/plugins/debugger/qml/qmlcppengine.h @@ -42,9 +42,9 @@ public: bool canDisplayTooltip() const override; bool canHandleToolTip(const DebuggerToolTipContext &) const override; - void updateItem(const QByteArray &iname) override; - void expandItem(const QByteArray &iname) override; - void selectWatchData(const QByteArray &iname) override; + void updateItem(const QString &iname) override; + void expandItem(const QString &iname) override; + void selectWatchData(const QString &iname) override; void watchPoint(const QPoint &) override; void fetchMemory(MemoryAgent *, QObject *, quint64 addr, quint64 length) override; @@ -61,11 +61,11 @@ public: void reloadSourceFiles() override; void reloadFullStack() override; - void setRegisterValue(const QByteArray &name, const QString &value) override; + void setRegisterValue(const QString &name, const QString &value) override; bool hasCapability(unsigned cap) const override; bool isSynchronous() const override; - QByteArray qtNamespace() const override; + QString qtNamespace() const override; void createSnapshot() override; void updateAll() override; @@ -121,7 +121,7 @@ protected: void notifyInferiorShutdownOk() override; void notifyInferiorSetupOk() override; - void notifyEngineRemoteServerRunning(const QByteArray &, int pid) override; + void notifyEngineRemoteServerRunning(const QString &, int pid) override; private: void engineStateChanged(DebuggerState newState); diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 59f509bde1..b865945fab 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -35,7 +35,6 @@ #include <debugger/debuggercore.h> #include <debugger/debuggerinternalconstants.h> #include <debugger/debuggerruncontrol.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggertooltipmanager.h> #include <debugger/sourcefileshandler.h> #include <debugger/stackhandler.h> @@ -111,8 +110,8 @@ enum StepAction struct QmlV8ObjectData { int handle = -1; - QByteArray name; - QByteArray type; + QString name; + QString type; QVariant value; QVariantList properties; }; @@ -121,9 +120,9 @@ typedef std::function<void(const QVariantMap &)> QmlCallback; struct LookupData { - QByteArray iname; + QString iname; QString name; - QByteArray exp; + QString exp; }; typedef QHash<int, LookupData> LookupItems; // id -> (iname, exp) @@ -132,7 +131,7 @@ class QmlEnginePrivate : QmlDebugClient { public: QmlEnginePrivate(QmlEngine *engine_, QmlDebugConnection *connection_) - : QmlDebugClient(QLatin1String("V8Debugger"), connection_), + : QmlDebugClient("V8Debugger", connection_), engine(engine_), inspectorAgent(engine, connection_), connection(connection_) @@ -162,7 +161,7 @@ public: void handleBacktrace(const QVariantMap &response); void handleLookup(const QVariantMap &response); void handleExecuteDebuggerCommand(const QVariantMap &response); - void handleEvaluateExpression(const QVariantMap &response, const QByteArray &iname, const QString &expr); + void handleEvaluateExpression(const QVariantMap &response, const QString &iname, const QString &expr); void handleFrame(const QVariantMap &response); void handleScope(const QVariantMap &response); void handleVersion(const QVariantMap &response); @@ -172,7 +171,7 @@ public: void updateScriptSource(const QString &fileName, int lineOffset, int columnOffset, const QString &source); void runCommand(const DebuggerCommand &command, const QmlCallback &cb = QmlCallback()); - void runDirectCommand(const QByteArray &type, const QByteArray &msg = QByteArray()); + void runDirectCommand(const QString &type, const QByteArray &msg = QByteArray()); void clearRefs() { refVals.clear(); } void memorizeRefs(const QVariant &refs); @@ -240,7 +239,7 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin : DebuggerEngine(startParameters), d(new QmlEnginePrivate(this, new QmlDebugConnection(this))) { - setObjectName(QLatin1String("QmlEngine")); + setObjectName("QmlEngine"); if (masterEngine) setMasterEngine(masterEngine); @@ -351,7 +350,7 @@ void QmlEngine::connectionEstablished() void QmlEngine::tryToConnect(Utils::Port port) { - showMessage(QLatin1String("QML Debugger: No application output received in time, trying to connect ..."), LogStatus); + showMessage("QML Debugger: No application output received in time, trying to connect ...", LogStatus); d->retryOnConnectFail = true; if (state() == EngineRunRequested) { if (isSlaveEngine()) { @@ -380,7 +379,7 @@ void QmlEngine::beginConnection(Utils::Port port) QString host = runParameters().qmlServerAddress; // Use localhost as default if (host.isEmpty()) - host = QLatin1String("localhost"); + host = "localhost"; /* * Let plugin-specific code override the port printed by the application. This is necessary @@ -458,7 +457,7 @@ void QmlEngine::errorMessageBoxFinished(int result) break; } case QMessageBox::Help: { - HelpManager::handleHelpRequest(QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html")); + HelpManager::handleHelpRequest("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"); // fall through } default: @@ -544,9 +543,8 @@ void QmlEngine::startApplicationLauncher() StandardRunnable runnable = runParameters().inferior; appendMessage(tr("Starting %1 %2").arg( QDir::toNativeSeparators(runnable.executable), - runnable.commandLineArguments) - + QLatin1Char('\n') - , Utils::NormalMessageFormat); + runnable.commandLineArguments) + '\n', + Utils::NormalMessageFormat); d->applicationLauncher.start(runnable); } } @@ -584,14 +582,14 @@ void QmlEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) } } -void QmlEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel, int pid) +void QmlEngine::notifyEngineRemoteServerRunning(const QString &serverChannel, int pid) { bool ok = false; quint16 qmlPort = serverChannel.toUInt(&ok); if (ok) runParameters().qmlServerPort = Utils::Port(qmlPort); else - qWarning() << tr("QML debugging port not set: Unable to convert %1 to unsigned int.").arg(QString::fromLatin1(serverChannel)); + qWarning() << tr("QML debugging port not set: Unable to convert %1 to unsigned int.").arg(serverChannel); DebuggerEngine::notifyEngineRemoteServerRunning(serverChannel, pid); notifyEngineSetupOk(); @@ -661,7 +659,7 @@ void QmlEngine::continueInferior() void QmlEngine::interruptInferior() { - showMessage(_(INTERRUPT), LogInput); + showMessage(INTERRUPT, LogInput); d->runDirectCommand(INTERRUPT); notifyInferiorStopOk(); } @@ -707,7 +705,7 @@ void QmlEngine::executeRunToLine(const ContextData &data) { QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); showStatusMessage(tr("Run to line %1 (%2) requested...").arg(data.lineNumber).arg(data.fileName), 5000); - d->setBreakpoint(QString(_(SCRIPTREGEXP)), data.fileName, true, data.lineNumber); + d->setBreakpoint(SCRIPTREGEXP, data.fileName, true, data.lineNumber); clearExceptionSelection(); d->continueDebugging(Continue); @@ -758,12 +756,12 @@ void QmlEngine::insertBreakpoint(Breakpoint bp) d->setExceptionBreak(AllExceptions, params.enabled); } else if (params.type == BreakpointByFileAndLine) { - d->setBreakpoint(QString(_(SCRIPTREGEXP)), params.fileName, + d->setBreakpoint(SCRIPTREGEXP, params.fileName, params.enabled, params.lineNumber, 0, - QLatin1String(params.condition), params.ignoreCount); + params.condition, params.ignoreCount); } else if (params.type == BreakpointOnQmlSignalEmit) { - d->setBreakpoint(QString(_(EVENT)), params.functionName, params.enabled); + d->setBreakpoint(EVENT, params.functionName, params.enabled); BreakpointResponse br = bp.response(); br.pending = false; bp.setResponse(br); @@ -793,7 +791,7 @@ void QmlEngine::removeBreakpoint(Breakpoint bp) if (params.type == BreakpointAtJavaScriptThrow) d->setExceptionBreak(AllExceptions); else if (params.type == BreakpointOnQmlSignalEmit) - d->setBreakpoint(QString(_(EVENT)), params.functionName, false); + d->setBreakpoint(EVENT, params.functionName, false); else d->clearBreakpoint(breakpoint); @@ -815,7 +813,7 @@ void QmlEngine::changeBreakpoint(Breakpoint bp) br.enabled = params.enabled; bp.setResponse(br); } else if (params.type == BreakpointOnQmlSignalEmit) { - d->setBreakpoint(QString(_(EVENT)), params.functionName, params.enabled); + d->setBreakpoint(EVENT, params.functionName, params.enabled); br.enabled = params.enabled; bp.setResponse(br); } else { @@ -834,7 +832,7 @@ void QmlEngine::changeBreakpoint(Breakpoint bp) void QmlEngine::attemptBreakpointSynchronization() { if (!stateAcceptsBreakpointChanges()) { - showMessage(_("BREAKPOINT SYNCHRONIZATION NOT POSSIBLE IN CURRENT STATE")); + showMessage("BREAKPOINT SYNCHRONIZATION NOT POSSIBLE IN CURRENT STATE"); return; } @@ -934,18 +932,18 @@ void QmlEngine::assignValueInDebugger(WatchItem *item, d->inspectorAgent.assignValue(item, expression, value); } else { StackHandler *handler = stackHandler(); - QString exp = QString(_("%1 = %2;")).arg(expression).arg(value.toString()); + QString exp = QString("%1 = %2;").arg(expression).arg(value.toString()); if (handler->isContentsValid() && handler->currentFrame().isUsable()) { d->evaluate(exp, [this](const QVariantMap &) { d->updateLocals(); }); } else { - showMessage(QString(_("Cannot evaluate %1 in current stack frame")).arg( - expression), ConsoleOutput); + showMessage(QString("Cannot evaluate %1 in current stack frame") + .arg(expression), ConsoleOutput); } } } } -void QmlEngine::expandItem(const QByteArray &iname) +void QmlEngine::expandItem(const QString &iname) { const WatchItem *item = watchHandler()->findItem(iname); QTC_ASSERT(item, return); @@ -959,7 +957,7 @@ void QmlEngine::expandItem(const QByteArray &iname) } } -void QmlEngine::updateItem(const QByteArray &iname) +void QmlEngine::updateItem(const QString &iname) { const WatchItem *item = watchHandler()->findItem(iname); QTC_ASSERT(item, return); @@ -967,14 +965,14 @@ void QmlEngine::updateItem(const QByteArray &iname) if (state() == InferiorStopOk) { // The Qt side Q_ASSERTs otherwise. So postpone the evaluation, // it will be triggered from from upateLocals() later. - QString exp = QString::fromUtf8(item->exp); + QString exp = item->exp; d->evaluate(exp, [this, iname, exp](const QVariantMap &response) { d->handleEvaluateExpression(response, iname, exp); }); } } -void QmlEngine::selectWatchData(const QByteArray &iname) +void QmlEngine::selectWatchData(const QString &iname) { const WatchItem *item = watchHandler()->findItem(iname); if (item && item->isInspect()) @@ -1001,9 +999,9 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, ConsoleItem *item = 0; if (result.type() == QVariant::Map) { if (key.isEmpty()) - text = _("Object"); + text = "Object"; else - text = key + _(" : Object"); + text = key + " : Object"; QMap<QString, QVariant> resultMap = result.toMap(); QVarLengthArray<ConsoleItem *> children(resultMap.size()); @@ -1027,9 +1025,9 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, } else if (result.type() == QVariant::List) { if (key.isEmpty()) - text = _("List"); + text = "List"; else - text = QString(_("[%1] : List")).arg(key); + text = QString("[%1] : List").arg(key); QVariantList resultList = result.toList(); QVarLengthArray<ConsoleItem *> children(resultList.size()); @@ -1047,7 +1045,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, } else if (result.canConvert(QVariant::String)) { item = new ConsoleItem(ConsoleItem::DefaultType, result.toString()); } else { - item = new ConsoleItem(ConsoleItem::DefaultType, _("Unknown Value")); + item = new ConsoleItem(ConsoleItem::DefaultType, "Unknown Value"); } return item; @@ -1124,7 +1122,7 @@ void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages d->evaluate(command, CB(d->handleExecuteDebuggerCommand)); } else { // Paused but no stack? Something is wrong - d->engine->showMessage(_("Cannot evaluate %1. The stack trace is broken.").arg(command), + d->engine->showMessage(QString("Cannot evaluate %1. The stack trace is broken.").arg(command), ConsoleOutput); } } else if (d->unpausedEvaluate) { @@ -1136,8 +1134,8 @@ void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages if (queryId) { d->queryIds.append(queryId); } else { - d->engine->showMessage(_("The application has to be stopped in a breakpoint in order to" - " evaluate expressions"), ConsoleOutput); + d->engine->showMessage("The application has to be stopped in a breakpoint in order to" + " evaluate expressions", ConsoleOutput); } } } @@ -1165,13 +1163,13 @@ void QmlEnginePrivate::updateScriptSource(const QString &fileName, int lineOffse for (int i = 0; i < columnOffset; ++i) { if (!cursor.movePosition(QTextCursor::NextCharacter)) - cursor.insertText(QLatin1String(" ")); + cursor.insertText(" "); } QTC_CHECK(cursor.positionInBlock() == columnOffset); - QStringList lines = source.split(QLatin1Char('\n')); + QStringList lines = source.split('\n'); foreach (QString line, lines) { - if (line.endsWith(QLatin1Char('\r'))) + if (line.endsWith('\r')) line.remove(line.size() -1, 1); // line already there? @@ -1239,27 +1237,27 @@ bool QmlEngine::isConnected() const void QmlEngine::showConnectionStateMessage(const QString &message) { - showMessage(_("QML Debugger: ") + message, LogStatus); + showMessage("QML Debugger: " + message, LogStatus); } void QmlEngine::logServiceStateChange(const QString &service, float version, - QmlDebugClient::State newState) + QmlDebugClient::State newState) { switch (newState) { case QmlDebugClient::Unavailable: { - showConnectionStateMessage(_("Status of \"%1\" Version: %2 changed to 'unavailable'."). - arg(service).arg(QString::number(version))); + showConnectionStateMessage(QString("Status of \"%1\" Version: %2 changed to 'unavailable'."). + arg(service).arg(version)); break; } case QmlDebugClient::Enabled: { - showConnectionStateMessage(_("Status of \"%1\" Version: %2 changed to 'enabled'."). - arg(service).arg(QString::number(version))); + showConnectionStateMessage(QString("Status of \"%1\" Version: %2 changed to 'enabled'."). + arg(service).arg(version)); break; } case QmlDebugClient::NotConnected: { - showConnectionStateMessage(_("Status of \"%1\" Version: %2 changed to 'not connected'."). - arg(service).arg(QString::number(version))); + showConnectionStateMessage(QString("Status of \"%1\" Version: %2 changed to 'not connected'."). + arg(service).arg(version)); break; } } @@ -1267,7 +1265,7 @@ void QmlEngine::logServiceStateChange(const QString &service, float version, void QmlEngine::logServiceActivity(const QString &service, const QString &logMessage) { - showMessage(service + QLatin1Char(' ') + logMessage, LogDebug); + showMessage(service + ' ' + logMessage, LogDebug); } void QmlEnginePrivate::continueDebugging(StepAction action) @@ -1326,7 +1324,7 @@ void QmlEnginePrivate::evaluate(const QString expr, const QmlCallback &cb) } void QmlEnginePrivate::handleEvaluateExpression(const QVariantMap &response, - const QByteArray &iname, + const QString &iname, const QString &exp) { // { "seq" : <number>, @@ -1338,16 +1336,16 @@ void QmlEnginePrivate::handleEvaluateExpression(const QVariantMap &response, // "success" : true // } - QVariant bodyVal = response.value(_(BODY)).toMap(); + QVariant bodyVal = response.value(BODY).toMap(); QmlV8ObjectData body = extractData(bodyVal); WatchHandler *watchHandler = engine->watchHandler(); auto item = new WatchItem; item->iname = iname; item->name = exp; - item->exp = exp.toLatin1(); + item->exp = exp; item->id = body.handle; - bool success = response.value(_("success")).toBool(); + bool success = response.value("success").toBool(); if (success) { item->type = body.type; item->value = body.value.toString(); @@ -1491,10 +1489,11 @@ void QmlEnginePrivate::setBreakpoint(const QString type, const QString target, // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0> // } // } - if (type == _(EVENT)) { + if (type == EVENT) { QPacket rs(connection->currentDataStreamVersion()); rs << target.toUtf8() << enabled; - engine->showMessage(QString(_("%1 %2 %3")).arg(_(BREAKONSIGNAL), target, enabled ? _("enabled") : _("disabled")), LogInput); + engine->showMessage(QString("%1 %2 %3") + .arg(BREAKONSIGNAL, target, QLatin1String(enabled ? "enabled" : "disabled")), LogInput); runDirectCommand(BREAKONSIGNAL, rs.data()); } else { @@ -1502,7 +1501,7 @@ void QmlEnginePrivate::setBreakpoint(const QString type, const QString target, cmd.arg(TYPE, type); cmd.arg(ENABLED, enabled); - if (type == _(SCRIPTREGEXP)) + if (type == SCRIPTREGEXP) cmd.arg(TARGET, Utils::FileName::fromString(target).fileName()); else cmd.arg(TARGET, target); @@ -1614,10 +1613,10 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const QmlV8ObjectData objectData; const QVariantMap dataMap = data.toMap(); - objectData.name = dataMap.value(_(NAME)).toByteArray(); + objectData.name = dataMap.value(NAME).toString(); - if (dataMap.contains(_(REF))) { - objectData.handle = dataMap.value(_(REF)).toInt(); + if (dataMap.contains(REF)) { + objectData.handle = dataMap.value(REF).toInt(); if (refVals.contains(objectData.handle)) { QmlV8ObjectData data = refVals.value(objectData.handle); objectData.type = data.type; @@ -1625,46 +1624,46 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const objectData.properties = data.properties; } } else { - objectData.handle = dataMap.value(_(HANDLE)).toInt(); - QString type = dataMap.value(_(TYPE)).toString(); + objectData.handle = dataMap.value(HANDLE).toInt(); + QString type = dataMap.value(TYPE).toString(); - if (type == _("undefined")) { - objectData.type = QByteArray("undefined"); - objectData.value = QVariant(_("undefined")); + if (type == "undefined") { + objectData.type = "undefined"; + objectData.value = "undefined"; - } else if (type == _("null")) { // Deprecated. typeof(null) == "object" in JavaScript - objectData.type = QByteArray("object"); - objectData.value= QVariant(_("null")); + } else if (type == "null") { // Deprecated. typeof(null) == "object" in JavaScript + objectData.type = "object"; + objectData.value = "null"; - } else if (type == _("boolean")) { - objectData.type = QByteArray("boolean"); - objectData.value = dataMap.value(_(VALUE)); + } else if (type == "boolean") { + objectData.type = "boolean"; + objectData.value = dataMap.value(VALUE); - } else if (type == _("number")) { - objectData.type = QByteArray("number"); - objectData.value = dataMap.value(_(VALUE)); + } else if (type == "number") { + objectData.type = "number"; + objectData.value = dataMap.value(VALUE); - } else if (type == _("string")) { + } else if (type == "string") { QLatin1Char quote('"'); - objectData.type = QByteArray("string"); - objectData.value = QString(quote + dataMap.value(_(VALUE)).toString() + quote); + objectData.type = "string"; + objectData.value = QString(quote + dataMap.value(VALUE).toString() + quote); - } else if (type == _("object")) { - objectData.type = QByteArray("object"); + } else if (type == "object") { + objectData.type = "object"; // ignore "className": it doesn't make any sense. - if (dataMap.contains(_("properties"))) - objectData.properties = dataMap.value(_("properties")).toList(); - else if (dataMap.value(_("value")).isNull()) - objectData.value = QVariant(_("null")); // Yes, null is an object. - } else if (type == _("function")) { - objectData.type = QByteArray("function"); - objectData.value = dataMap.value(_(NAME)); - objectData.properties = dataMap.value(_("properties")).toList(); - - } else if (type == _("script")) { - objectData.type = QByteArray("script"); - objectData.value = dataMap.value(_(NAME)); + if (dataMap.contains("properties")) + objectData.properties = dataMap.value("properties").toList(); + else if (dataMap.value("value").isNull()) + objectData.value = "null"; // Yes, null is an object. + } else if (type == "function") { + objectData.type = "function"; + objectData.value = dataMap.value(NAME); + objectData.properties = dataMap.value("properties").toList(); + + } else if (type == "script") { + objectData.type = "script"; + objectData.value = dataMap.value(NAME); } } @@ -1674,25 +1673,25 @@ QmlV8ObjectData QmlEnginePrivate::extractData(const QVariant &data) const void QmlEnginePrivate::runCommand(const DebuggerCommand &command, const QmlCallback &cb) { QJsonObject object; - object.insert(QStringLiteral("seq"), ++sequence); - object.insert(QStringLiteral("type"), QStringLiteral("request")); - object.insert(QStringLiteral("command"), QLatin1String(command.function)); - object.insert(QStringLiteral("arguments"), command.args); + object.insert("seq", ++sequence); + object.insert("type", "request"); + object.insert("command", command.function); + object.insert("arguments", command.args); if (cb) callbackForToken[sequence] = cb; runDirectCommand(V8REQUEST, QJsonDocument(object).toJson(QJsonDocument::Compact)); } -void QmlEnginePrivate::runDirectCommand(const QByteArray &type, const QByteArray &msg) +void QmlEnginePrivate::runDirectCommand(const QString &type, const QByteArray &msg) { // Leave item as variable, serialization depends on it. QByteArray cmd = V8DEBUG; - engine->showMessage(QString::fromLatin1("%1 %2").arg(_(type), _(msg)), LogInput); + engine->showMessage(QString("%1 %2").arg(type, QString::fromLatin1(msg)), LogInput); QPacket rs(connection->currentDataStreamVersion()); - rs << cmd << type << msg; + rs << cmd << type.toLatin1() << msg; if (state() == Enabled) sendMessage(rs.data()); @@ -1705,7 +1704,7 @@ void QmlEnginePrivate::memorizeRefs(const QVariant &refs) if (refs.isValid()) { foreach (const QVariant &ref, refs.toList()) { const QVariantMap refData = ref.toMap(); - int handle = refData.value(_(HANDLE)).toInt(); + int handle = refData.value(HANDLE).toInt(); refVals[handle] = extractData(refData); } } @@ -1733,37 +1732,35 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) //break on signal handler requested } else if (type == V8MESSAGE) { - const QString responseString = QLatin1String(response); - SDEBUG(responseString); - engine->showMessage(QLatin1String(V8MESSAGE) + QLatin1Char(' ') + responseString, LogOutput); + SDEBUG(response); + engine->showMessage(QString(V8MESSAGE) + ' ' + QString::fromLatin1(response), LogOutput); - const QVariantMap resp = - QJsonDocument::fromJson(responseString.toUtf8()).toVariant().toMap(); + const QVariantMap resp = QJsonDocument::fromJson(response).toVariant().toMap(); - const QString type(resp.value(_(TYPE)).toString()); + const QString type = resp.value(TYPE).toString(); - if (type == _("response")) { + if (type == "response") { - const QString debugCommand(resp.value(_(COMMAND)).toString()); + const QString debugCommand(resp.value(COMMAND).toString()); - memorizeRefs(resp.value(_(REFS))); + memorizeRefs(resp.value(REFS)); - bool success = resp.value(_("success")).toBool(); + bool success = resp.value("success").toBool(); if (!success) { SDEBUG("Request was unsuccessful"); } - int requestSeq = resp.value(_("request_seq")).toInt(); + int requestSeq = resp.value("request_seq").toInt(); if (callbackForToken.contains(requestSeq)) { callbackForToken[requestSeq](resp); - } else if (debugCommand == _(DISCONNECT)) { + } else if (debugCommand == DISCONNECT) { //debugging session ended - } else if (debugCommand == _(CONTINEDEBUGGING)) { + } else if (debugCommand == CONTINEDEBUGGING) { //do nothing, wait for next break - } else if (debugCommand == _(SETBREAKPOINT)) { + } else if (debugCommand == SETBREAKPOINT) { // { "seq" : <number>, // "type" : "response", // "request_seq" : <number>, @@ -1775,9 +1772,9 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) // "success" : true // } - int seq = resp.value(_("request_seq")).toInt(); - const QVariantMap breakpointData = resp.value(_(BODY)).toMap(); - int index = breakpointData.value(_("breakpoint")).toInt(); + int seq = resp.value("request_seq").toInt(); + const QVariantMap breakpointData = resp.value(BODY).toMap(); + int index = breakpointData.value("breakpoint").toInt(); if (breakpointsSync.contains(seq)) { BreakpointModelId id = breakpointsSync.take(seq); @@ -1786,7 +1783,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) //Is actual position info present? Then breakpoint was //accepted const QVariantList actualLocations = - breakpointData.value(_("actual_locations")).toList(); + breakpointData.value("actual_locations").toList(); if (actualLocations.count()) { //The breakpoint requested line should be same as //actual line @@ -1794,7 +1791,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) Breakpoint bp = handler->breakpointById(id); if (bp.state() != BreakpointInserted) { BreakpointResponse br = bp.response(); - br.lineNumber = breakpointData.value(_("line")).toInt() + 1; + br.lineNumber = breakpointData.value("line").toInt() + 1; br.pending = false; bp.setResponse(br); bp.notifyBreakpointInsertOk(); @@ -1807,10 +1804,10 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) } - } else if (debugCommand == _(CLEARBREAKPOINT)) { + } else if (debugCommand == CLEARBREAKPOINT) { // DO NOTHING - } else if (debugCommand == _(SETEXCEPTIONBREAK)) { + } else if (debugCommand == SETEXCEPTIONBREAK) { // { "seq" : <number>, // "type" : "response", // "request_seq" : <number>, @@ -1823,7 +1820,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) // } - } else if (debugCommand == _(SCRIPTS)) { + } else if (debugCommand == SCRIPTS) { // { "seq" : <number>, // "type" : "response", // "request_seq" : <number>, @@ -1851,15 +1848,15 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) // } if (success) { - const QVariantList body = resp.value(_(BODY)).toList(); + const QVariantList body = resp.value(BODY).toList(); QStringList sourceFiles; for (int i = 0; i < body.size(); ++i) { const QVariantMap entryMap = body.at(i).toMap(); - const int lineOffset = entryMap.value(QLatin1String("lineOffset")).toInt(); - const int columnOffset = entryMap.value(QLatin1String("columnOffset")).toInt(); - const QString name = entryMap.value(QLatin1String("name")).toString(); - const QString source = entryMap.value(QLatin1String("source")).toString(); + const int lineOffset = entryMap.value("lineOffset").toInt(); + const int columnOffset = entryMap.value("columnOffset").toInt(); + const QString name = entryMap.value("name").toString(); + const QString source = entryMap.value("source").toString(); if (name.isEmpty()) continue; @@ -1884,34 +1881,34 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) // DO NOTHING } - } else if (type == _(EVENT)) { - const QString eventType(resp.value(_(EVENT)).toString()); + } else if (type == EVENT) { + const QString eventType(resp.value(EVENT).toString()); - if (eventType == _("break")) { + if (eventType == "break") { clearRefs(); - const QVariantMap breakData = resp.value(_(BODY)).toMap(); - const QString invocationText = breakData.value(_("invocationText")).toString(); - const QString scriptUrl = breakData.value(_("script")).toMap().value(_("name")).toString(); - const QString sourceLineText = breakData.value(_("sourceLineText")).toString(); + const QVariantMap breakData = resp.value(BODY).toMap(); + const QString invocationText = breakData.value("invocationText").toString(); + const QString scriptUrl = breakData.value("script").toMap().value("name").toString(); + const QString sourceLineText = breakData.value("sourceLineText").toString(); bool inferiorStop = true; QList<int> v8BreakpointIds; { - const QVariantList v8BreakpointIdList = breakData.value(_("breakpoints")).toList(); + const QVariantList v8BreakpointIdList = breakData.value("breakpoints").toList(); foreach (const QVariant &breakpointId, v8BreakpointIdList) v8BreakpointIds << breakpointId.toInt(); } - if (!v8BreakpointIds.isEmpty() && invocationText.startsWith(_("[anonymous]()")) - && scriptUrl.endsWith(_(".qml")) - && sourceLineText.trimmed().startsWith(QLatin1Char('('))) { + if (!v8BreakpointIds.isEmpty() && invocationText.startsWith("[anonymous]()") + && scriptUrl.endsWith(".qml") + && sourceLineText.trimmed().startsWith('(')) { // we hit most likely the anonymous wrapper function automatically generated for bindings // -> relocate the breakpoint to column: 1 and continue - int newColumn = sourceLineText.indexOf(QLatin1Char('(')) + 1; + int newColumn = sourceLineText.indexOf('(') + 1; BreakHandler *handler = engine->breakHandler(); foreach (int v8Id, v8BreakpointIds) { @@ -1921,13 +1918,13 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) const BreakpointParameters ¶ms = bp.parameters(); clearBreakpoint(v8Id); - setBreakpoint(QString(_(SCRIPTREGEXP)), - params.fileName, - params.enabled, - params.lineNumber, - newColumn, - QString(QString::fromLatin1(params.condition)), - params.ignoreCount); + setBreakpoint(SCRIPTREGEXP, + params.fileName, + params.enabled, + params.lineNumber, + newColumn, + params.condition, + params.ignoreCount); breakpointsSync.insert(sequence, id); } } @@ -1936,7 +1933,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) } //Skip debug break if this is an internal function - if (sourceLineText == _(INTERNAL_FUNCTION)) { + if (sourceLineText == INTERNAL_FUNCTION) { continueDebugging(previousStepAction); inferiorStop = false; } @@ -1954,8 +1951,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) bp.setResponse(br); } if (bp.state() != BreakpointInserted) { - br.lineNumber = breakData.value( - _("sourceLine")).toInt() + 1; + br.lineNumber = breakData.value("sourceLine").toInt() + 1; br.pending = false; bp.setResponse(br); bp.notifyBreakpointInsertOk(); @@ -1975,16 +1971,16 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) } } - } else if (eventType == _("exception")) { - const QVariantMap body = resp.value(_(BODY)).toMap(); - int lineNumber = body.value(_("sourceLine")).toInt() + 1; + } else if (eventType == "exception") { + const QVariantMap body = resp.value(BODY).toMap(); + int lineNumber = body.value("sourceLine").toInt() + 1; - const QVariantMap script = body.value(_("script")).toMap(); - QUrl fileUrl(script.value(_(NAME)).toString()); + const QVariantMap script = body.value("script").toMap(); + QUrl fileUrl(script.value(NAME).toString()); QString filePath = engine->toFileInProject(fileUrl); - const QVariantMap exception = body.value(_("exception")).toMap(); - QString errorMessage = exception.value(_("text")).toString(); + const QVariantMap exception = body.value("exception").toMap(); + QString errorMessage = exception.value("text").toString(); QStringList messages = highlightExceptionCode(lineNumber, filePath, errorMessage); foreach (const QString msg, messages) @@ -1998,7 +1994,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) if (engine->state() == InferiorStopOk) backtrace(); - } else if (eventType == _("afterCompile")) { + } else if (eventType == "afterCompile") { //Currently break point relocation is disabled. //Uncomment the line below when it will be enabled. // listBreakpoints(); @@ -2010,7 +2006,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data) if (eventType.isEmpty()) { debuggerConsole()->printItem(new ConsoleItem( ConsoleItem::ErrorType, - resp.value(_(MESSAGE)).toString())); + resp.value(MESSAGE).toString())); } } //EVENT @@ -2036,10 +2032,10 @@ void QmlEnginePrivate::handleBacktrace(const QVariantMap &response) // "success" : true // } - const QVariantMap body = response.value(_(BODY)).toMap(); - const QVariantList frames = body.value(_("frames")).toList(); + const QVariantMap body = response.value(BODY).toMap(); + const QVariantList frames = body.value("frames").toList(); - int fromFrameIndex = body.value(_("fromFrame")).toInt(); + int fromFrameIndex = body.value("fromFrame").toInt(); QTC_ASSERT(0 == fromFrameIndex, return); @@ -2097,27 +2093,27 @@ StackFrame QmlEnginePrivate::extractStackFrame(const QVariant &bodyVal) const QVariantMap body = bodyVal.toMap(); StackFrame stackFrame; - stackFrame.level = body.value(_("index")).toByteArray(); + stackFrame.level = body.value("index").toString(); //Do not insert the frame corresponding to the internal function - if (body.value(QLatin1String("sourceLineText")) == QLatin1String(INTERNAL_FUNCTION)) { + if (body.value("sourceLineText") == INTERNAL_FUNCTION) { stackFrame.level.clear(); return stackFrame; } - QmlV8ObjectData objectData = extractData(body.value(_("func"))); + QmlV8ObjectData objectData = extractData(body.value("func")); QString functionName = objectData.value.toString(); if (functionName.isEmpty()) functionName = QCoreApplication::translate("QmlEngine", "Anonymous Function"); stackFrame.function = functionName; - objectData = extractData(body.value(_("script"))); + objectData = extractData(body.value("script")); stackFrame.file = engine->toFileInProject(objectData.value.toString()); stackFrame.usable = QFileInfo(stackFrame.file).isReadable(); - objectData = extractData(body.value(_("receiver"))); + objectData = extractData(body.value("receiver")); stackFrame.receiver = objectData.value.toString(); - stackFrame.line = body.value(_("line")).toInt() + 1; + stackFrame.line = body.value("line").toInt() + 1; return stackFrame; } @@ -2154,7 +2150,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) // "running" : <is the VM running after sending this response> // "success" : true // } - QVariantMap body = response.value(_(BODY)).toMap(); + QVariantMap body = response.value(BODY).toMap(); StackHandler *stackHandler = engine->stackHandler(); WatchHandler * watchHandler = engine->watchHandler(); @@ -2169,9 +2165,9 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) // Always add a "this" variable { - QByteArray iname = "local.this"; - QString exp = QLatin1String("this"); - QmlV8ObjectData objectData = extractData(body.value(_("receiver"))); + QString iname = "local.this"; + QString exp = "this"; + QmlV8ObjectData objectData = extractData(body.value("receiver")); auto item = new WatchItem; item->iname = iname; @@ -2182,7 +2178,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) item->setHasChildren(objectData.properties.count()); // In case of global object, we do not get children // Set children nevertheless and query later. - if (item->value == QLatin1String("global")) { + if (item->value == "global") { item->setHasChildren(true); item->id = 0; } @@ -2193,13 +2189,13 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) } currentFrameScopes.clear(); - const QVariantList scopes = body.value(_("scopes")).toList(); + const QVariantList scopes = body.value("scopes").toList(); foreach (const QVariant &scope, scopes) { //Do not query for global types (0) //Showing global properties increases clutter. - if (scope.toMap().value(_("type")).toInt() == 0) + if (scope.toMap().value("type").toInt() == 0) continue; - int scopeIndex = scope.toMap().value(_("index")).toInt(); + int scopeIndex = scope.toMap().value("index").toInt(); currentFrameScopes.append(scopeIndex); this->scope(scopeIndex); } @@ -2209,7 +2205,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) if (stackHandler->isContentsValid() && stackHandler->currentFrame().isUsable()) { QStringList watchers = watchHandler->watchedExpressions(); foreach (const QString &exp, watchers) { - const QByteArray iname = watchHandler->watcherName(exp.toLatin1()); + const QString iname = watchHandler->watcherName(exp); evaluate(exp, [this, iname, exp](const QVariantMap &response) { handleEvaluateExpression(response, iname, exp); }); @@ -2219,7 +2215,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) // Expand locals that were previously expanded. local.this and watch.* // trigger updates in there handleEvaluatedExpression handlers. LookupItems itemsToLookup; - foreach (const QByteArray &iname, watchHandler->expandedINames()) { + foreach (const QString &iname, watchHandler->expandedINames()) { if (iname != "local.this") { const WatchItem *item = watchHandler->findItem(iname); if (item && item->isLocal()) @@ -2252,14 +2248,14 @@ void QmlEnginePrivate::handleScope(const QVariantMap &response) // "running" : <is the VM running after sending this response> // "success" : true // } - QVariantMap bodyMap = response.value(_(BODY)).toMap(); + QVariantMap bodyMap = response.value(BODY).toMap(); //Check if the frameIndex is same as current Stack Index StackHandler *stackHandler = engine->stackHandler(); - if (bodyMap.value(_("frameIndex")).toInt() != stackHandler->currentIndex()) + if (bodyMap.value("frameIndex").toInt() != stackHandler->currentIndex()) return; - QmlV8ObjectData objectData = extractData(bodyMap.value(_("object"))); + QmlV8ObjectData objectData = extractData(bodyMap.value("object")); LookupItems itemsToLookup; foreach (const QVariant &property, objectData.properties) { @@ -2270,8 +2266,8 @@ void QmlEnginePrivate::handleScope(const QVariantMap &response) if (item->exp.startsWith('.') || item->exp.isEmpty()) continue; - item->name = QLatin1String(item->exp); - item->iname = QByteArray("local.") + item->exp; + item->name = item->exp; + item->iname = "local." + item->exp; item->id = localData.handle; if (localData.value.isValid()) { @@ -2323,17 +2319,17 @@ ConsoleItem *QmlEnginePrivate::constructLogItemTree(const QmlV8ObjectData &objec if (objectData.value.isValid()) { text = objectData.value.toString(); } else if (!objectData.type.isEmpty()) { - text = QString::fromLatin1(objectData.type); + text = objectData.type; } else { int handle = objectData.handle; ConsoleItem *item = new ConsoleItem(ConsoleItem::DefaultType, - QString::fromLatin1(objectData.name), + objectData.name, [this, handle](ConsoleItem *item) { DebuggerCommand cmd(LOOKUP); cmd.arg(HANDLES, QList<int>() << handle); runCommand(cmd, [this, item, handle](const QVariantMap &response) { - const QVariantMap body = response.value(_(BODY)).toMap(); + const QVariantMap body = response.value(BODY).toMap(); QStringList handlesList = body.keys(); foreach (const QString &handleString, handlesList) { if (handle != handleString.toInt()) @@ -2344,15 +2340,15 @@ ConsoleItem *QmlEnginePrivate::constructLogItemTree(const QmlV8ObjectData &objec // keep original name, if possible QString name = item->expression(); if (name.isEmpty()) - name = QString::fromLatin1(objectData.name); + name = objectData.name; QString value = objectData.value.isValid() ? - objectData.value.toString() : QString::fromLatin1(objectData.type); + objectData.value.toString() : objectData.type; // We can do setData() and cause dataChanged() here, but only because this // callback is executed after fetchMore() has returned. item->model()->setData(item->index(), - QString::fromLatin1("%1: %2").arg(name).arg(value), + QString("%1: %2").arg(name, value), ConsoleItem::ExpressionRole); QList<int> newHandles; @@ -2366,7 +2362,7 @@ ConsoleItem *QmlEnginePrivate::constructLogItemTree(const QmlV8ObjectData &objec } if (!objectData.name.isEmpty()) - text = QString(_("%1: %2")).arg(QString::fromLatin1(objectData.name)).arg(text); + text = QString("%1: %2").arg(objectData.name, text); if (objectData.properties.isEmpty()) return new ConsoleItem(ConsoleItem::DefaultType, text); @@ -2397,21 +2393,21 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro foreach (const QVariant &property, properties) { QmlV8ObjectData propertyData = extractData(property); auto item = new WatchItem; - item->name = QString::fromUtf8(propertyData.name); + item->name = propertyData.name; // Check for v8 specific local data - if (item->name.startsWith(QLatin1Char('.')) || item->name.isEmpty()) + if (item->name.startsWith('.') || item->name.isEmpty()) continue; if (parent->type == "object") { - if (parent->value == _("Array")) - item->exp = parent->exp + '[' + item->name.toLatin1() + ']'; - else if (parent->value == _("Object")) - item->exp = parent->exp + '.' + item->name.toLatin1(); + if (parent->value == "Array") + item->exp = parent->exp + '[' + item->name + ']'; + else if (parent->value == "Object") + item->exp = parent->exp + '.' + item->name; } else { - item->exp = item->name.toLatin1(); + item->exp = item->name; } - item->iname = parent->iname + '.' + item->name.toLatin1(); + item->iname = parent->iname + '.' + item->name; item->id = propertyData.handle; item->type = propertyData.type; item->value = propertyData.value.toString(); @@ -2433,16 +2429,16 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro void QmlEnginePrivate::handleExecuteDebuggerCommand(const QVariantMap &response) { - auto it = response.constFind(_(SUCCESS)); + auto it = response.constFind(SUCCESS); if (it != response.constEnd() && it.value().toBool()) { - debuggerConsole()->printItem(constructLogItemTree(extractData(response.value(_(BODY))))); + debuggerConsole()->printItem(constructLogItemTree(extractData(response.value(BODY)))); // Update the locals foreach (int index, currentFrameScopes) scope(index); } else { debuggerConsole()->printItem(new ConsoleItem(ConsoleItem::ErrorType, - response.value(_(MESSAGE)).toString())); + response.value(MESSAGE).toString())); } } @@ -2456,7 +2452,7 @@ void QmlEnginePrivate::handleLookup(const QVariantMap &response) // "running" : <is the VM running after sending this response> // "success" : true // } - const QVariantMap body = response.value(_(BODY)).toMap(); + const QVariantMap body = response.value(BODY).toMap(); QStringList handlesList = body.keys(); foreach (const QString &handleString, handlesList) { @@ -2497,7 +2493,7 @@ void QmlEnginePrivate::stateChanged(State state) void QmlEnginePrivate::handleVersion(const QVariantMap &response) { - unpausedEvaluate = response.value(_(BODY)).toMap().value(_("UnpausedEvaluate"), false).toBool(); + unpausedEvaluate = response.value(BODY).toMap().value("UnpausedEvaluate", false).toBool(); } void QmlEnginePrivate::flushSendBuffer() diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index 5e534ab08e..6c6dcacd0c 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -68,7 +68,7 @@ private slots: void appendMessage(const QString &msg, Utils::OutputFormat); private: - void notifyEngineRemoteServerRunning(const QByteArray &, int pid) override; + void notifyEngineRemoteServerRunning(const QString &, int pid) override; void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) override; void showMessage(const QString &msg, int channel = LogDebug, @@ -122,9 +122,9 @@ private: void reloadFullStack() override {} void updateAll() override; - void updateItem(const QByteArray &iname) override; - void expandItem(const QByteArray &iname) override; - void selectWatchData(const QByteArray &iname) override; + void updateItem(const QString &iname) override; + void expandItem(const QString &iname) override; + void selectWatchData(const QString &iname) override; void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) override; bool hasCapability(unsigned) const override; diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 11215be9e9..f8ef4896fe 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -29,7 +29,6 @@ #include <debugger/debuggeractions.h> #include <debugger/debuggercore.h> #include <debugger/debuggerengine.h> -#include <debugger/debuggerstringutils.h> #include <debugger/watchhandler.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -82,7 +81,7 @@ QmlInspectorAgent::QmlInspectorAgent(QmlEngine *engine, QmlDebugConnection *conn , m_showAppOnTopAction(action(ShowAppOnTop)) , m_engineClientConnected(false) { - m_debugIdToIname.insert(WatchItem::InvalidId, QByteArray("inspect")); + m_debugIdToIname.insert(WatchItem::InvalidId, "inspect"); connect(action(ShowQmlObjectTree), &Utils::SavedAction::valueChanged, this, &QmlInspectorAgent::updateState); m_delayQueryTimer.setSingleShot(true); @@ -180,12 +179,12 @@ void QmlInspectorAgent::assignValue(const WatchItem *data, val = val.replace(QLatin1Char('\"'), QLatin1String("\\\"")); val = QLatin1Char('\"') + val + QLatin1Char('\"'); } - QString expression = QString(_("%1 = %2;")).arg(expr).arg(val); + QString expression = QString("%1 = %2;").arg(expr).arg(val); queryExpressionResult(data->id, expression); } } -static int parentIdForIname(const QByteArray &iname) +static int parentIdForIname(const QString &iname) { // Extract the parent id int lastIndex = iname.lastIndexOf('.'); @@ -226,7 +225,7 @@ bool QmlInspectorAgent::selectObjectInTree(int debugId) << m_debugIdToIname.contains(debugId); if (m_debugIdToIname.contains(debugId)) { - QByteArray iname = m_debugIdToIname.value(debugId); + QString iname = m_debugIdToIname.value(debugId); QTC_ASSERT(iname.startsWith("inspect."), qDebug() << iname); qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree"; m_qmlEngine->watchHandler()->setCurrentItem(iname); @@ -238,7 +237,7 @@ bool QmlInspectorAgent::selectObjectInTree(int debugId) using namespace QmlDebug::Constants; if (m_engineClient->objectName() == QLatin1String(QDECLARATIVE_ENGINE)) { // reset current Selection - QByteArray root = m_qmlEngine->watchHandler()->watchItem(QModelIndex())->iname; + QString root = m_qmlEngine->watchHandler()->watchItem(QModelIndex())->iname; m_qmlEngine->watchHandler()->setCurrentItem(root); } else { fetchObject(debugId); @@ -329,7 +328,7 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, qCDebug(qmlInspectorLog) << __FUNCTION__ << "() ..."; if (type == "FETCH_OBJECT_R") { - log(LogReceive, _("FETCH_OBJECT_R %1").arg( + log(LogReceive, QString("FETCH_OBJECT_R %1").arg( qvariant_cast<ObjectReference>(value).idString())); } else if (type == "SET_BINDING_R" || type == "RESET_BINDING_R" @@ -391,7 +390,7 @@ void QmlInspectorAgent::newObject(int engineId, int /*objectId*/, int /*parentId void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value) { - const QByteArray iname = m_debugIdToIname.value(debugId) + + const QString iname = m_debugIdToIname.value(debugId) + ".[properties]." + propertyName; WatchHandler *watchHandler = m_qmlEngine->watchHandler(); qCDebug(qmlInspectorLog) @@ -410,7 +409,7 @@ void QmlInspectorAgent::reloadEngines() if (!isConnected()) return; - log(LogSend, _("LIST_ENGINES")); + log(LogSend, "LIST_ENGINES"); m_engineQueryId = m_engineClient->queryAvailableEngines(); } @@ -474,7 +473,7 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec const int parentId = object.parentId(); const int objectDebugId = object.debugId(); if (m_debugIdToIname.contains(parentId)) { - QByteArray parentIname = m_debugIdToIname.value(parentId); + QString parentIname = m_debugIdToIname.value(parentId); if (parentId != WatchItem::InvalidId && !handler->isExpandedIName(parentIname)) { m_objectStack.push(object); handler->fetchMore(parentIname); @@ -492,7 +491,7 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec // We want to expand only a particular branch and not the whole tree. Hence, we do not // expand siblings. if (object.children().contains(top)) { - QByteArray objectIname = m_debugIdToIname.value(objectDebugId); + QString objectIname = m_debugIdToIname.value(objectDebugId); if (!handler->isExpandedIName(objectIname)) { handler->fetchMore(objectIname); } else { @@ -536,7 +535,7 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) if (m_debugIdToIname.contains(m_objectToSelect)) { // select item in view - QByteArray iname = m_debugIdToIname.value(m_objectToSelect); + QString iname = m_debugIdToIname.value(m_objectToSelect); qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree"; m_qmlEngine->watchHandler()->setCurrentItem(iname); m_objectToSelect = WatchItem::InvalidId; @@ -577,27 +576,27 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref) buildDebugIdHashRecursive(it); } -static QByteArray buildIName(const QByteArray &parentIname, int debugId) +static QString buildIName(const QString &parentIname, int debugId) { if (parentIname.isEmpty()) - return "inspect." + QByteArray::number(debugId); - return parentIname + "." + QByteArray::number(debugId); + return "inspect." + QString::number(debugId); + return parentIname + "." + QString::number(debugId); } -static QByteArray buildIName(const QByteArray &parentIname, const QString &name) +static QString buildIName(const QString &parentIname, const QString &name) { - return parentIname + "." + name.toLatin1(); + return parentIname + "." + name; } void QmlInspectorAgent::addWatchData(const ObjectReference &obj, - const QByteArray &parentIname, + const QString &parentIname, bool append) { qCDebug(qmlInspectorLog) << '(' << obj << parentIname << ')'; QTC_ASSERT(m_qmlEngine, return); int objDebugId = obj.debugId(); - QByteArray objIname = buildIName(parentIname, objDebugId); + QString objIname = buildIName(parentIname, objDebugId); if (append) { QString name = obj.idString(); @@ -612,9 +611,9 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj, objWatch->iname = objIname; objWatch->name = name; objWatch->id = objDebugId; - objWatch->exp = name.toLatin1(); - objWatch->type = obj.className().toLatin1(); - objWatch->value = _("object"); + objWatch->exp = name; + objWatch->type = obj.className(); + objWatch->value = "object"; objWatch->wantsChildren = true; objWatch->setAllUnneeded(); @@ -623,7 +622,7 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj, if (m_debugIdToIname.contains(objDebugId)) { // The data needs to be removed since we now know the parent and // hence we can insert the data in the correct position - const QByteArray oldIname = m_debugIdToIname.value(objDebugId); + const QString oldIname = m_debugIdToIname.value(objDebugId); if (oldIname != objIname) m_qmlEngine->watchHandler()->removeItemByIName(oldIname); } @@ -639,12 +638,12 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj, // properties if (append && obj.properties().count()) { - QByteArray iname = objIname + ".[properties]"; + QString iname = objIname + ".[properties]"; auto propertiesWatch = new WatchItem; propertiesWatch->iname = iname; propertiesWatch->name = tr("Properties"); propertiesWatch->id = objDebugId; - propertiesWatch->value = _("list"); + propertiesWatch->value = "list"; propertiesWatch->wantsChildren = true; propertiesWatch->setAllUnneeded(); @@ -656,8 +655,8 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj, propertyWatch->iname = buildIName(iname, propertyName); propertyWatch->name = propertyName; propertyWatch->id = objDebugId; - propertyWatch->exp = propertyName.toLatin1(); - propertyWatch->type = property.valueTypeName().toLatin1(); + propertyWatch->exp = propertyName; + propertyWatch->type = property.valueTypeName(); propertyWatch->value = property.value().toString(); propertyWatch->wantsChildren = false; propertyWatch->setAllUnneeded(); @@ -675,11 +674,11 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj, void QmlInspectorAgent::log(QmlInspectorAgent::LogDirection direction, const QString &message) { - QString msg = _("Inspector"); + QString msg = "Inspector"; if (direction == LogSend) - msg += _(" sending "); + msg += " sending "; else - msg += _(" receiving "); + msg += " receiving "; msg += message; if (m_qmlEngine) @@ -701,7 +700,7 @@ void QmlInspectorAgent::clearObjectTree() m_debugIdHash.clear(); m_debugIdHash.reserve(old_count + 1); m_debugIdToIname.clear(); - m_debugIdToIname.insert(WatchItem::InvalidId, QByteArray("inspect")); + m_debugIdToIname.insert(WatchItem::InvalidId, "inspect"); m_objectStack.clear(); m_objectWatches.clear(); } diff --git a/src/plugins/debugger/qml/qmlinspectoragent.h b/src/plugins/debugger/qml/qmlinspectoragent.h index f8ed4e131e..626ab4c723 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.h +++ b/src/plugins/debugger/qml/qmlinspectoragent.h @@ -86,7 +86,7 @@ private: void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref); void addWatchData(const QmlDebug::ObjectReference &obj, - const QByteArray &parentIname, bool append); + const QString &parentIname, bool append); enum LogDirection { LogSend, @@ -130,7 +130,7 @@ private: QList<quint32> m_objectTreeQueryIds; QStack<QmlDebug::ObjectReference> m_objectStack; QmlDebug::EngineReference m_engine; - QHash<int, QByteArray> m_debugIdToIname; + QHash<int, QString> m_debugIdToIname; QHash<int, QmlDebug::FileReference> m_debugIdLocations; DebugIdHash m_debugIdHash; diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index e2b3402243..921da6304f 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -97,22 +97,22 @@ static uint decodeHexChar(unsigned char c) return uint(-1); } -void RegisterValue::fromByteArray(const QByteArray &ba, RegisterFormat format) +void RegisterValue::fromString(const QString &str, RegisterFormat format) { - known = !ba.isEmpty(); + known = !str.isEmpty(); v.u64[1] = v.u64[0] = 0; - const int n = ba.size(); + const int n = str.size(); int pos = 0; - if (ba.startsWith("0x")) + if (str.startsWith("0x")) pos += 2; - bool negative = pos < n && ba.at(pos) == '-'; + bool negative = pos < n && str.at(pos) == '-'; if (negative) ++pos; while (pos < n) { - uint c = ba.at(pos); + uint c = str.at(pos).unicode(); if (format != CharacterFormat) { c = decodeHexChar(c); if (c == uint(-1)) @@ -136,15 +136,15 @@ bool RegisterValue::operator==(const RegisterValue &other) return v.u64[0] == other.v.u64[0] && v.u64[1] == other.v.u64[1]; } -static QByteArray formatRegister(quint64 v, int size, RegisterFormat format, bool forEdit) +static QString formatRegister(quint64 v, int size, RegisterFormat format, bool forEdit) { - QByteArray result; + QString result; if (format == HexadecimalFormat) { - result = QByteArray::number(v, 16); - result.prepend(QByteArray(2*size - result.size(), '0')); + result = QString::number(v, 16); + result.prepend(QString(2*size - result.size(), '0')); } else if (format == DecimalFormat) { - result = QByteArray::number(v, 10); - result.prepend(QByteArray(2*size - result.size(), ' ')); + result = QString::number(v, 10); + result.prepend(QString(2*size - result.size(), ' ')); } else if (format == SignedDecimalFormat) { qint64 sv; if (size >= 8) @@ -155,8 +155,8 @@ static QByteArray formatRegister(quint64 v, int size, RegisterFormat format, boo sv = qint16(v); else sv = qint8(v); - result = QByteArray::number(sv, 10); - result.prepend(QByteArray(2*size - result.size(), ' ')); + result = QString::number(sv, 10); + result.prepend(QString(2*size - result.size(), ' ')); } else if (format == CharacterFormat) { bool spacesOnly = true; if (v >= 32 && v < 127) { @@ -172,23 +172,23 @@ static QByteArray formatRegister(quint64 v, int size, RegisterFormat format, boo if (spacesOnly && forEdit) result.clear(); else - result.prepend(QByteArray(2*size - result.size(), ' ')); + result.prepend(QString(2*size - result.size(), ' ')); } return result; } -QByteArray RegisterValue::toByteArray(RegisterKind kind, int size, RegisterFormat format, bool forEdit) const +QString RegisterValue::toString(RegisterKind kind, int size, RegisterFormat format, bool forEdit) const { if (!known) - return "[inaccessible]"; + return QLatin1String("[inaccessible]"); if (kind == FloatRegister) { if (size == 4) - return QByteArray::number(v.f[0]); + return QString::number(v.f[0]); if (size == 8) - return QByteArray::number(v.d[0]); + return QString::number(v.d[0]); } - QByteArray result; + QString result; if (size > 8) { result += formatRegister(v.u64[1], size - 8, format, forEdit); size = 8; @@ -391,9 +391,9 @@ quint64 RegisterItem::addressValue() const void RegisterItem::triggerChange() { - QByteArray ba = "0x" + m_reg.value.toByteArray(m_reg.kind, m_reg.size, HexadecimalFormat); + QString value = "0x" + m_reg.value.toString(m_reg.kind, m_reg.size, HexadecimalFormat); DebuggerEngine *engine = static_cast<RegisterHandler *>(model())->engine(); - engine->setRegisterValue(m_reg.name, QString::fromLatin1(ba)); + engine->setRegisterValue(m_reg.name, value); } QVariant RegisterItem::data(int column, int role) const @@ -417,23 +417,23 @@ QVariant RegisterItem::data(int column, int role) const case Qt::DisplayRole: switch (column) { case RegisterNameColumn: { - QByteArray res = m_reg.name; + QString res = m_reg.name; if (!m_reg.description.isEmpty()) res += " (" + m_reg.description + ')'; return res; } case RegisterValueColumn: { - return m_reg.value.toByteArray(m_reg.kind, m_reg.size, m_format); + return m_reg.value.toString(m_reg.kind, m_reg.size, m_format); } } case Qt::ToolTipRole: - return QString::fromLatin1("Current Value: %1\nPreviousValue: %2") - .arg(QString::fromLatin1(m_reg.value.toByteArray(m_reg.kind, m_reg.size, m_format))) - .arg(QString::fromLatin1(m_reg.previousValue.toByteArray(m_reg.kind, m_reg.size, m_format))); + return QString("Current Value: %1\nPreviousValue: %2") + .arg(m_reg.value.toString(m_reg.kind, m_reg.size, m_format)) + .arg(m_reg.previousValue.toString(m_reg.kind, m_reg.size, m_format)); case Qt::EditRole: // Edit: Unpadded for editing - return QString::fromLatin1(m_reg.value.toByteArray(m_reg.kind, m_reg.size, m_format)); + return m_reg.value.toString(m_reg.kind, m_reg.size, m_format); case Qt::TextAlignmentRole: return column == RegisterValueColumn ? QVariant(Qt::AlignRight) : QVariant(); @@ -447,7 +447,7 @@ QVariant RegisterItem::data(int column, int role) const bool RegisterItem::setData(int column, const QVariant &value, int role) { if (column == RegisterValueColumn && role == Qt::EditRole) { - m_reg.value.fromByteArray(value.toString().toLatin1(), m_format); + m_reg.value.fromString(value.toString(), m_format); triggerChange(); return true; } @@ -476,11 +476,11 @@ QVariant RegisterSubItem::data(int column, int role) const QTC_ASSERT(parent(), return QVariant()); RegisterItem *registerItem = static_cast<RegisterItem *>(parent()); RegisterValue value = registerItem->m_reg.value; - QByteArray ba; + QString ba; for (int i = 0; i != m_count; ++i) { int tab = 5 * (i + 1) * m_subSize; - QByteArray b = value.subValue(m_subSize, i).toByteArray(m_subKind, m_subSize, m_subFormat); - ba += QByteArray(tab - ba.size() - b.size(), ' '); + QString b = value.subValue(m_subSize, i).toString(m_subKind, m_subSize, m_subFormat); + ba += QString(tab - ba.size() - b.size(), ' '); ba += b; } return ba; @@ -550,7 +550,7 @@ void RegisterHandler::updateRegister(const Register &r) } } -void RegisterHandler::setNumberFormat(const QByteArray &name, RegisterFormat format) +void RegisterHandler::setNumberFormat(const QString &name, RegisterFormat format) { RegisterItem *reg = m_registerByName.value(name, 0); QTC_ASSERT(reg, return); @@ -579,20 +579,19 @@ QVariant RegisterEditItem::data(int column, int role) const case Qt::EditRole: switch (column) { case RegisterNameColumn: { - return QString::fromLatin1("[%1]").arg(m_index); + return QString("[%1]").arg(m_index); } case RegisterValueColumn: { RegisterItem *registerItem = static_cast<RegisterItem *>(parent()->parent()); RegisterValue value = registerItem->m_reg.value; return value.subValue(m_subSize, m_index) - .toByteArray(m_subKind, m_subSize, m_subFormat, role == Qt::EditRole); + .toString(m_subKind, m_subSize, m_subFormat, role == Qt::EditRole); } } case Qt::ToolTipRole: { RegisterItem *registerItem = static_cast<RegisterItem *>(parent()->parent()); return RegisterHandler::tr("Edit bits %1...%2 of register %3") - .arg(m_index * 8).arg(m_index * 8 + 7) - .arg(QString::fromLatin1(registerItem->m_reg.name)); + .arg(m_index * 8).arg(m_index * 8 + 7).arg(registerItem->m_reg.name); } default: break; @@ -608,7 +607,7 @@ bool RegisterEditItem::setData(int column, const QVariant &value, int role) RegisterItem *registerItem = static_cast<RegisterItem *>(parent()->parent()); Register ® = registerItem->m_reg; RegisterValue vv; - vv.fromByteArray(value.toString().toLatin1(), m_subFormat); + vv.fromString(value.toString(), m_subFormat); reg.value.setSubValue(m_subSize, m_index, vv); registerItem->triggerChange(); return true; diff --git a/src/plugins/debugger/registerhandler.h b/src/plugins/debugger/registerhandler.h index f8bf2ca3fe..96293cfa1e 100644 --- a/src/plugins/debugger/registerhandler.h +++ b/src/plugins/debugger/registerhandler.h @@ -79,9 +79,9 @@ public: bool operator==(const RegisterValue &other); bool operator!=(const RegisterValue &other) { return !operator==(other); } - void fromByteArray(const QByteArray &ba, RegisterFormat format); - QByteArray toByteArray(RegisterKind kind, int size, RegisterFormat format, - bool forEdit = false) const; + void fromString(const QString &str, RegisterFormat format); + QString toString(RegisterKind kind, int size, RegisterFormat format, + bool forEdit = false) const; RegisterValue subValue(int size, int index) const; void setSubValue(int size, int index, RegisterValue subValue); @@ -105,17 +105,17 @@ public: Register() { size = 0; kind = UnknownRegister; } void guessMissingData(); - QByteArray name; - QByteArray reportedType; + QString name; + QString reportedType; RegisterValue value; RegisterValue previousValue; - QByteArray description; + QString description; int size; RegisterKind kind; }; class RegisterItem; -typedef QMap<quint64, QByteArray> RegisterMap; +typedef QMap<quint64, QString> RegisterMap; class RegisterHandler : public Utils::TreeModel { @@ -129,15 +129,15 @@ public: void updateRegister(const Register ®); - void setNumberFormat(const QByteArray &name, RegisterFormat format); + void setNumberFormat(const QString &name, RegisterFormat format); void commitUpdates() { emit layoutChanged(); } RegisterMap registerMap() const; signals: - void registerChanged(const QByteArray &name, quint64 value); // For memory views + void registerChanged(const QString &name, quint64 value); // For memory views private: - QHash<QByteArray, RegisterItem *> m_registerByName; + QHash<QString, RegisterItem *> m_registerByName; DebuggerEngine * const m_engine; }; diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 5d77b91141..0a5e2adc4a 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -173,14 +173,13 @@ void RegisterTreeView::contextMenuEvent(QContextMenuEvent *ev) QAction *actShowDisassembler = menu.addAction(tr("Open Disassembler...")); actShowDisassembler->setEnabled(engine->hasCapability(DisassemblerCapability)); - const QByteArray registerName = idx.data(RegisterNameRole).toByteArray(); - const QString registerNameStr = QString::fromUtf8(registerName); + const QString registerName = idx.data(RegisterNameRole).toString(); if (address) { const bool canShow = actionsEnabled && engine->hasCapability(ShowMemoryCapability); actEditMemory->setText(tr("Open Memory Editor at 0x%1").arg(address, 0, 16)); actEditMemory->setEnabled(canShow); actViewMemory->setText(tr("Open Memory View at Value of Register %1 0x%2") - .arg(registerNameStr).arg(address, 0, 16)); + .arg(registerName).arg(address, 0, 16)); actShowDisassemblerAt->setText(tr("Open Disassembler at 0x%1") .arg(address, 0, 16)); actShowDisassemblerAt->setEnabled(engine->hasCapability(DisassemblerCapability)); diff --git a/src/plugins/debugger/stackframe.cpp b/src/plugins/debugger/stackframe.cpp index 6e755d8837..a92ea661d4 100644 --- a/src/plugins/debugger/stackframe.cpp +++ b/src/plugins/debugger/stackframe.cpp @@ -93,9 +93,9 @@ StackFrame StackFrame::parseFrame(const GdbMi &frameMi, const DebuggerRunParamet { StackFrame frame; frame.level = frameMi["level"].data(); - frame.function = frameMi["function"].toUtf8(); - frame.module = frameMi["module"].toUtf8(); - frame.file = QFile::decodeName(frameMi["file"].data()); + frame.function = frameMi["function"].data(); + frame.module = frameMi["module"].data(); + frame.file = frameMi["file"].data(); frame.line = frameMi["line"].toInt(); frame.address = frameMi["address"].toAddress(); frame.context = frameMi["context"].data(); diff --git a/src/plugins/debugger/stackframe.h b/src/plugins/debugger/stackframe.h index 5d7674e642..916d578b52 100644 --- a/src/plugins/debugger/stackframe.h +++ b/src/plugins/debugger/stackframe.h @@ -54,7 +54,7 @@ public: public: DebuggerLanguage language; - QByteArray level; + QString level; QString function; QString file; // We try to put an absolute file name in there. QString module; // Sometimes something like "/usr/lib/libstdc++.so.6" @@ -62,7 +62,7 @@ public: qint32 line; quint64 address; bool usable; - QByteArray context; // Opaque value produced and consumed by the native backends. + QString context; // Opaque value produced and consumed by the native backends. Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::StackHandler) }; diff --git a/src/plugins/debugger/threaddata.h b/src/plugins/debugger/threaddata.h index 23f280c105..a011d88b81 100644 --- a/src/plugins/debugger/threaddata.h +++ b/src/plugins/debugger/threaddata.h @@ -89,7 +89,7 @@ struct ThreadData // Permanent data. ThreadId id; - QByteArray groupId; + QString groupId; QString targetId; QString core; bool stopped; diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index e9ba1f8767..306cd6146b 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -310,12 +310,12 @@ void ThreadsHandler::setCurrentThread(ThreadId id) updateThreadBox(); } -QByteArray ThreadsHandler::pidForGroupId(const QByteArray &groupId) const +QString ThreadsHandler::pidForGroupId(const QString &groupId) const { return m_pidForGroupId[groupId]; } -void ThreadsHandler::notifyGroupCreated(const QByteArray &groupId, const QByteArray &pid) +void ThreadsHandler::notifyGroupCreated(const QString &groupId, const QString &pid) { m_pidForGroupId[groupId] = pid; } @@ -366,7 +366,7 @@ void ThreadsHandler::removeAll() rootItem()->removeChildren(); } -bool ThreadsHandler::notifyGroupExited(const QByteArray &groupId) +bool ThreadsHandler::notifyGroupExited(const QString &groupId) { QList<ThreadItem *> list; forFirstLevelItems([&list, groupId](ThreadItem *item) { @@ -380,7 +380,7 @@ bool ThreadsHandler::notifyGroupExited(const QByteArray &groupId) return m_pidForGroupId.isEmpty(); } -void ThreadsHandler::notifyRunning(const QByteArray &data) +void ThreadsHandler::notifyRunning(const QString &data) { if (data.isEmpty() || data == "all") { notifyAllRunning(); @@ -405,7 +405,7 @@ void ThreadsHandler::notifyRunning(ThreadId threadId) item->notifyRunning(); } -void ThreadsHandler::notifyStopped(const QByteArray &data) +void ThreadsHandler::notifyStopped(const QString &data) { if (data.isEmpty() || data == "all") { notifyAllStopped(); @@ -444,17 +444,17 @@ void ThreadsHandler::updateThreads(const GdbMi &data) const GdbMi frame = item["frame"]; ThreadData thread; thread.id = ThreadId(item["id"].toInt()); - thread.targetId = item["target-id"].toLatin1(); - thread.details = item["details"].toLatin1(); - thread.core = item["core"].toLatin1(); - thread.state = item["state"].toLatin1(); + thread.targetId = item["target-id"].data(); + thread.details = item["details"].data(); + thread.core = item["core"].data(); + thread.state = item["state"].data(); thread.address = frame["addr"].toAddress(); - thread.function = frame["func"].toLatin1(); - thread.fileName = frame["fullname"].toLatin1(); + thread.function = frame["func"].data(); + thread.fileName = frame["fullname"].data(); thread.lineNumber = frame["line"].toInt(); - thread.module = QString::fromLocal8Bit(frame["from"].data()); - thread.name = item["name"].toLatin1(); - thread.stopped = thread.state != QLatin1String("running"); + thread.module = frame["from"].data(); + thread.name = item["name"].data(); + thread.stopped = thread.state != "running"; updateThread(thread); } diff --git a/src/plugins/debugger/threadshandler.h b/src/plugins/debugger/threadshandler.h index 9ef6f14cc7..83f20ccd9d 100644 --- a/src/plugins/debugger/threadshandler.h +++ b/src/plugins/debugger/threadshandler.h @@ -52,7 +52,7 @@ public: ThreadId currentThread() const; ThreadId threadAt(int index) const; void setCurrentThread(ThreadId id); - QByteArray pidForGroupId(const QByteArray &groupId) const; + QString pidForGroupId(const QString &groupId) const; void updateThread(const ThreadData &threadData); void updateThreads(const GdbMi &data); @@ -63,15 +63,15 @@ public: ThreadData thread(ThreadId id) const; QAbstractItemModel *model(); - void notifyGroupCreated(const QByteArray &groupId, const QByteArray &pid); - bool notifyGroupExited(const QByteArray &groupId); // Returns true when empty. + void notifyGroupCreated(const QString &groupId, const QString &pid); + bool notifyGroupExited(const QString &groupId); // Returns true when empty. // Clear out all frame information - void notifyRunning(const QByteArray &data); + void notifyRunning(const QString &data); void notifyRunning(ThreadId threadId); void notifyAllRunning(); - void notifyStopped(const QByteArray &data); + void notifyStopped(const QString &data); void notifyStopped(ThreadId threadId); void notifyAllStopped(); @@ -85,7 +85,7 @@ private: ThreadId m_currentId; bool m_resetLocationScheduled; - QHash<QByteArray, QByteArray> m_pidForGroupId; + QHash<QString, QString> m_pidForGroupId; }; } // namespace Internal diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index badcf601c3..c3506a0561 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -35,21 +35,21 @@ namespace Debugger { namespace Internal { -bool isPointerType(const QByteArray &type) +bool isPointerType(const QString &type) { return type.endsWith('*') || type.endsWith("* const"); } -bool isCharPointerType(const QByteArray &type) +bool isCharPointerType(const QString &type) { return type == "char *" || type == "const char *" || type == "char const *"; } -bool isIntType(const QByteArray &type) +bool isIntType(const QString &type) { if (type.isEmpty()) return false; - switch (type.at(0)) { + switch (type.at(0).unicode()) { case 'b': return type == "bool"; case 'c': @@ -97,12 +97,12 @@ bool isIntType(const QByteArray &type) } } -bool isFloatType(const QByteArray &type) +bool isFloatType(const QString &type) { return type == "float" || type == "double" || type == "qreal"; } -bool isIntOrFloatType(const QByteArray &type) +bool isIntOrFloatType(const QString &type) { return isIntType(type) || isFloatType(type); } @@ -176,7 +176,7 @@ void WatchItem::setValue(const QString &value0) // pointer type information is available in the 'type' // column. No need to duplicate it here. - if (value.startsWith(QLatin1Char('(') + QLatin1String(type) + QLatin1String(") 0x"))) + if (value.startsWith('(' + type + ") 0x")) value = value.section(QLatin1Char(' '), -1, -1); setValueUnneeded(); @@ -184,7 +184,7 @@ void WatchItem::setValue(const QString &value0) enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren }; -static GuessChildrenResult guessChildren(const QByteArray &type) +static GuessChildrenResult guessChildren(const QString &type) { if (isIntOrFloatType(type)) return HasNoChildren; @@ -197,7 +197,7 @@ static GuessChildrenResult guessChildren(const QByteArray &type) return HasPossiblyChildren; } -void WatchItem::setType(const QByteArray &str, bool guessChildrenFromType) +void WatchItem::setType(const QString &str, bool guessChildrenFromType) { type = str.trimmed(); bool changed = true; @@ -242,7 +242,7 @@ QString WatchItem::toString() const str << QLatin1Char('{'); if (!iname.isEmpty()) str << "iname=\"" << iname << doubleQuoteComma; - if (!name.isEmpty() && name != QLatin1String(iname)) + if (!name.isEmpty() && name != iname) str << "name=\"" << name << doubleQuoteComma; if (address) { str.setIntegerBase(16); @@ -306,11 +306,11 @@ QString WatchItem::shadowedName(const QString &name, int seen) return shadowedNameFormat().arg(name).arg(seen); } -QByteArray WatchItem::hexAddress() const +QString WatchItem::hexAddress() const { if (address) - return QByteArray("0x") + QByteArray::number(address, 16); - return QByteArray(); + return "0x" + QString::number(address, 16); + return QString(); } template <class T> @@ -325,9 +325,9 @@ QString decodeItemHelper(const double &t) } template <class T> -void decodeArrayHelper(WatchItem *item, const QByteArray &rawData, int size, const QByteArray &childType) +void decodeArrayHelper(WatchItem *item, const QString &rawData, int size, const QString &childType) { - const QByteArray ba = QByteArray::fromHex(rawData); + const QByteArray ba = QByteArray::fromHex(rawData.toUtf8()); const T *p = (const T *) ba.data(); for (int i = 0, n = ba.size() / sizeof(T); i < n; ++i) { WatchItem *child = new WatchItem; @@ -340,8 +340,8 @@ void decodeArrayHelper(WatchItem *item, const QByteArray &rawData, int size, con } } -static void decodeArrayData(WatchItem *item, const QByteArray &rawData, - const DebuggerEncoding &encoding, const QByteArray &childType) +static void decodeArrayData(WatchItem *item, const QString &rawData, + const DebuggerEncoding &encoding, const QString &childType) { switch (encoding.type) { case DebuggerEncoding::HexEncodedSignedInteger: @@ -426,14 +426,14 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort) if (iname.startsWith("local.") && iname.count('.') == 1) // Solve one common case of adding 'class' in // *(class X*)0xdeadbeef for gdb. - exp = name.toLatin1(); + exp = name; else exp = "*(" + gdbQuoteTypes(type) + "*)" + hexAddress(); } } mi = input["value"]; - QByteArray enc = input["valueencoded"].data(); + QString enc = input["valueencoded"].data(); if (mi.isValid() || !enc.isEmpty()) { setValue(decodeData(mi.data(), enc)); } else { @@ -474,7 +474,7 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort) mi = input["arraydata"]; if (mi.isValid()) { DebuggerEncoding encoding(input["arrayencoding"].data()); - QByteArray childType = input["childtype"].data(); + QString childType = input["childtype"].data(); decodeArrayData(this, mi.data(), encoding, childType); } else { const GdbMi children = input["children"]; @@ -495,13 +495,13 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort) if (childNumChild.isValid()) child->setHasChildren(childNumChild.toInt() > 0); GdbMi name = subinput["name"]; - QByteArray nn; + QString nn; if (name.isValid()) { nn = name.data(); - child->name = QString::fromLatin1(nn); + child->name = nn; } else { nn.setNum(i); - child->name = QString::fromLatin1("[%1]").arg(i); + child->name = QString("[%1]").arg(i); } GdbMi iname = subinput["iname"]; if (iname.isValid()) @@ -512,7 +512,7 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort) child->address = addressBase + i * addressStep; child->exp = "*(" + gdbQuoteTypes(child->type) + "*)" + child->hexAddress(); } - QByteArray key = subinput["key"].data(); + QString key = subinput["key"].data(); if (!key.isEmpty()) child->name = decodeData(key, subinput["keyencoded"].data()); child->parseHelper(subinput, maySort); @@ -531,14 +531,14 @@ void WatchItem::parse(const GdbMi &data, bool maySort) GdbMi wname = data["wname"]; if (wname.isValid()) // Happens (only) for watched expressions. - name = QString::fromUtf8(QByteArray::fromHex(wname.data())); + name = fromHex(wname.data()); else - name = QString::fromLatin1(data["name"].data()); + name = data["name"].data(); parseHelper(data, maySort); if (wname.isValid()) - exp = name.toUtf8(); + exp = name; } WatchItem *WatchItem::parentItem() const @@ -564,14 +564,14 @@ QString WatchItem::toToolTip() const str << "<html><body><table>"; formatToolTipRow(str, tr("Name"), name); formatToolTipRow(str, tr("Expression"), expression()); - formatToolTipRow(str, tr("Internal Type"), QLatin1String(type)); + formatToolTipRow(str, tr("Internal Type"), type); bool ok; const quint64 intValue = value.toULongLong(&ok); if (ok && intValue) { - formatToolTipRow(str, tr("Value"), QLatin1String("(dec) ") + value); - formatToolTipRow(str, QString(), QLatin1String("(hex) ") + QString::number(intValue, 16)); - formatToolTipRow(str, QString(), QLatin1String("(oct) ") + QString::number(intValue, 8)); - formatToolTipRow(str, QString(), QLatin1String("(bin) ") + QString::number(intValue, 2)); + formatToolTipRow(str, tr("Value"), "(dec) " + value); + formatToolTipRow(str, QString(), "(hex) " + QString::number(intValue, 16)); + formatToolTipRow(str, QString(), "(oct) " + QString::number(intValue, 8)); + formatToolTipRow(str, QString(), "(bin) " + QString::number(intValue, 2)); } else { QString val = value; if (val.size() > 1000) { @@ -589,7 +589,7 @@ QString WatchItem::toToolTip() const formatToolTipRow(str, tr("Array Index"), QString::number(arrayIndex)); if (size) formatToolTipRow(str, tr("Static Object Size"), tr("%n bytes", 0, size)); - formatToolTipRow(str, tr("Internal ID"), QLatin1String(internalName())); + formatToolTipRow(str, tr("Internal ID"), internalName()); str << "</table></body></html>"; return res; } @@ -627,7 +627,7 @@ quint64 WatchItem::realAddress() const return address; } -QByteArray WatchItem::internalName() const +QString WatchItem::internalName() const { if (arrayIndex >= 0) { if (const WatchItem *p = parentItem()) @@ -646,14 +646,14 @@ QString WatchItem::realName() const QString WatchItem::expression() const { if (!exp.isEmpty()) - return QString::fromLatin1(exp); + return exp; if (quint64 addr = realAddress()) { if (!type.isEmpty()) - return QString::fromLatin1("*(%1*)0x%2").arg(QLatin1String(type)).arg(addr, 0, 16); + return QString("*(%1*)0x%2").arg(type).arg(addr, 0, 16); } const WatchItem *p = parentItem(); if (p && !p->exp.isEmpty()) - return QString::fromLatin1("(%1).%2").arg(QString::fromLatin1(p->exp), name); + return QString("(%1).%2").arg(p->exp, name); return name; } diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index 17d23dadf4..512cee3770 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -53,7 +53,7 @@ public: QString expression() const; QString realName() const; quint64 realAddress() const; - QByteArray internalName() const; + QString internalName() const; QString toToolTip() const; QVariant editValue() const; @@ -87,28 +87,28 @@ public: void setError(const QString &); void setValue(const QString &); - void setType(const QByteArray &, bool guessChildrenFromType = true); + void setType(const QString &, bool guessChildrenFromType = true); - QString toString() const; + QString toString() const; static QString msgNotInScope(); static QString shadowedName(const QString &name, int seen); static const QString &shadowedNameFormat(); - QByteArray hexAddress() const; - QByteArray key() const { return address ? hexAddress() : iname; } + QString hexAddress() const; + QString key() const { return address ? hexAddress() : iname; } public: qint64 id; // Token for the engine for internal mapping qint32 state; // 'needed' flags; - QByteArray iname; // Internal name sth like 'local.baz.public.a' - QByteArray exp; // The expression + QString iname; // Internal name sth like 'local.baz.public.a' + QString exp; // The expression QString name; // Displayed name QString value; // Displayed value - QByteArray editvalue; // Displayed value - QByteArray editformat; // Format of displayed value + QString editvalue; // Displayed value + QString editformat; // Format of displayed value DebuggerEncoding editencoding; // Encoding of displayed value - QByteArray type; // Type for further processing + QString type; // Type for further processing quint64 address; // Displayed address of the actual object quint64 origaddr; // Address of the pointer referencing this item (gdb auto-deref) uint size; // Size diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index a1f3b8eb15..1b35ad2eed 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -71,10 +71,10 @@ enum { debugModel = 0 }; #define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0) -static QHash<QByteArray, int> theWatcherNames; +static QHash<QString, int> theWatcherNames; static int theWatcherCount = 0; -static QHash<QByteArray, int> theTypeFormats; -static QHash<QByteArray, int> theIndividualFormats; +static QHash<QString, int> theTypeFormats; +static QHash<QString, int> theIndividualFormats; static int theUnprintableBase = -1; const char INameProperty[] = "INameProperty"; @@ -151,13 +151,13 @@ static void readNumericVector(std::vector<double> *v, const QByteArray &rawData, qDebug() << "ENCODING ERROR: " << encoding.toString(); } -static QByteArray stripForFormat(const QByteArray &ba) +static QString stripForFormat(const QString &ba) { - QByteArray res; + QString res; res.reserve(ba.size()); int inArray = 0; for (int i = 0; i != ba.size(); ++i) { - const char c = ba.at(i); + const QChar c = ba.at(i); if (c == '<') break; if (c == '[') @@ -187,7 +187,7 @@ static void loadFormats() while (it.hasNext()) { it.next(); if (!it.key().isEmpty()) - theTypeFormats.insert(it.key().toUtf8(), it.value().toInt()); + theTypeFormats.insert(it.key(), it.value().toInt()); } value = sessionValue("IndividualFormats"); @@ -195,33 +195,33 @@ static void loadFormats() while (it.hasNext()) { it.next(); if (!it.key().isEmpty()) - theIndividualFormats.insert(it.key().toUtf8(), it.value().toInt()); + theIndividualFormats.insert(it.key(), it.value().toInt()); } } static void saveFormats() { QMap<QString, QVariant> formats; - QHashIterator<QByteArray, int> it(theTypeFormats); + QHashIterator<QString, int> it(theTypeFormats); while (it.hasNext()) { it.next(); const int format = it.value(); if (format != AutomaticFormat) { - const QByteArray key = it.key().trimmed(); + const QString key = it.key().trimmed(); if (!key.isEmpty()) - formats.insert(QString::fromLatin1(key), format); + formats.insert(key, format); } } setSessionValue("DefaultFormats", formats); formats.clear(); - it = QHashIterator<QByteArray, int>(theIndividualFormats); + it = QHashIterator<QString, int>(theIndividualFormats); while (it.hasNext()) { it.next(); const int format = it.value(); - const QByteArray key = it.key().trimmed(); + const QString key = it.key().trimmed(); if (!key.isEmpty()) - formats.insert(QString::fromLatin1(key), format); + formats.insert(key, format); } setSessionValue("IndividualFormats", formats); } @@ -263,7 +263,7 @@ public: saveGeometry(); } - void removeObject(const QByteArray &key) + void removeObject(const QString &key) { saveGeometry(); if (QWidget *w = findWidget(key)) { @@ -276,7 +276,7 @@ public: { saveGeometry(); if (QObject *o = widget(index)) { - QByteArray iname = o->property(INameProperty).toByteArray(); + QString iname = o->property(INameProperty).toString(); theIndividualFormats.remove(iname); saveFormats(); } @@ -290,11 +290,11 @@ public: hide(); } - QWidget *findWidget(const QByteArray &needle) + QWidget *findWidget(const QString &needle) { for (int i = count(); --i >= 0; ) { QWidget *w = widget(i); - QByteArray key = w->property(KeyProperty).toByteArray(); + QString key = w->property(KeyProperty).toString(); if (key == needle) return w; } @@ -303,7 +303,7 @@ public: template <class T> T *prepareObject(const WatchItem *item) { - const QByteArray key = item->key(); + const QString key = item->key(); T *t = 0; if (QWidget *w = findWidget(key)) { t = qobject_cast<T *>(w); @@ -350,13 +350,13 @@ public: QString displayForAutoTest(const QByteArray &iname) const; void reinitialize(bool includeInspectData = false); - WatchItem *findItem(const QByteArray &iname) const; + WatchItem *findItem(const QString &iname) const; void reexpandItems(); void showEditValue(const WatchItem *item); - void setTypeFormat(const QByteArray &type, int format); - void setIndividualFormat(const QByteArray &iname, int format); + void setTypeFormat(const QString &type, int format); + void setIndividualFormat(const QString &iname, int format); QString removeNamespaces(QString str) const; @@ -375,18 +375,18 @@ public: SeparatedView *m_separatedView; // Not owned. - QSet<QByteArray> m_expandedINames; + QSet<QString> m_expandedINames; QTimer m_requestUpdateTimer; - QHash<QByteArray, TypeInfo> m_reportedTypeInfo; + QHash<QString, TypeInfo> m_reportedTypeInfo; QHash<QString, DisplayFormats> m_reportedTypeFormats; // Type name -> Dumper Formats - QHash<QByteArray, QString> m_valueCache; + QHash<QString, QString> m_valueCache; }; WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine) : m_handler(handler), m_engine(engine), m_separatedView(new SeparatedView) { - setObjectName(QLatin1String("WatchModel")); + setObjectName("WatchModel"); m_contentsValid = false; m_contentsValid = true; // FIXME @@ -440,25 +440,25 @@ void WatchModel::reinitialize(bool includeInspectData) m_inspectorRoot->removeChildren(); } -WatchItem *WatchModel::findItem(const QByteArray &iname) const +WatchItem *WatchModel::findItem(const QString &iname) const { return findNonRooItem([iname](WatchItem *item) { return item->iname == iname; }); } -static QByteArray parentName(const QByteArray &iname) +static QString parentName(const QString &iname) { const int pos = iname.lastIndexOf('.'); - return pos == -1 ? QByteArray() : iname.left(pos); + return pos == -1 ? QString() : iname.left(pos); } -static QString niceTypeHelper(const QByteArray &typeIn) +static QString niceTypeHelper(const QString &typeIn) { - typedef QMap<QByteArray, QString> Cache; + typedef QMap<QString, QString> Cache; static Cache cache; const Cache::const_iterator it = cache.constFind(typeIn); if (it != cache.constEnd()) return it.value(); - const QString simplified = simplifyType(QLatin1String(typeIn)); + const QString simplified = simplifyType(typeIn); cache.insert(typeIn, simplified); // For simplicity, also cache unmodified types return simplified; } @@ -466,9 +466,9 @@ static QString niceTypeHelper(const QByteArray &typeIn) QString WatchModel::removeNamespaces(QString str) const { if (!boolSetting(ShowStdNamespace)) - str.remove(QLatin1String("std::")); + str.remove("std::"); if (!boolSetting(ShowQtNamespace)) { - const QString qtNamespace = QString::fromLatin1(m_engine->qtNamespace()); + const QString qtNamespace = m_engine->qtNamespace(); if (!qtNamespace.isEmpty()) str.remove(qtNamespace); } @@ -492,11 +492,11 @@ template <class IntType> QString reformatInteger(IntType value, int format) { switch (format) { case HexadecimalIntegerFormat: - return QLatin1String("(hex) ") + QString::number(value, 16); + return "(hex) " + QString::number(value, 16); case BinaryIntegerFormat: - return QLatin1String("(bin) ") + QString::number(value, 2); + return "(bin) " + QString::number(value, 2); case OctalIntegerFormat: - return QLatin1String("(oct) ") + QString::number(value, 8); + return "(oct) " + QString::number(value, 8); } return QString::number(value, 10); // not reached } @@ -536,19 +536,19 @@ static QString reformatCharacter(int code, int size, bool isSigned) const QChar c = QChar(uint(code)); QString out; if (c.isPrint()) - out = QString::fromLatin1("'") + c + QLatin1String("' "); + out = QString("'") + c + "' "; else if (code == 0) - out = QLatin1String("'\\0'"); + out = "'\\0'"; else if (code == '\r') - out = QLatin1String("'\\r'"); + out = "'\\r'"; else if (code == '\n') - out = QLatin1String("'\\n'"); + out = "'\\n'"; else if (code == '\t') - out = QLatin1String("'\\t'"); + out = "'\\t'"; else - out = QLatin1String(" "); + out = " "; - out += QLatin1Char('\t'); + out += '\t'; if (isSigned) { out += QString::number(code); @@ -560,7 +560,7 @@ static QString reformatCharacter(int code, int size, bool isSigned) out += QString::number(unsigned(code)); } - out += QLatin1Char('\t'); + out += '\t'; out += QString::fromLatin1("0x%1").arg(uint(code & ((1ULL << (8*size)) - 1)), 2 * size, 16, QLatin1Char('0')); @@ -579,11 +579,11 @@ static QString quoteUnprintable(const QString &str) if (c.isPrint()) encoded += c; else if (u == '\r') - encoded += QLatin1String("\\r"); + encoded += "\\r"; else if (u == '\t') - encoded += QLatin1String("\\t"); + encoded += "\\t"; else if (u == '\n') - encoded += QLatin1String("\\n"); + encoded += "\\n"; else encoded += QString::fromLatin1("\\%1") .arg(c.unicode(), 3, 8, QLatin1Char('0')); @@ -616,9 +616,9 @@ static int itemFormat(const WatchItem *item) static QString formattedValue(const WatchItem *item) { if (item->type == "bool") { - if (item->value == QLatin1String("0")) + if (item->value == "0") return QLatin1String("false"); - if (item->value == QLatin1String("1")) + if (item->value == "1") return QLatin1String("true"); return item->value; } @@ -649,7 +649,7 @@ static QString formattedValue(const WatchItem *item) || format == DecimalIntegerFormat || format == OctalIntegerFormat || format == BinaryIntegerFormat) { - bool isSigned = item->value.startsWith(QLatin1Char('-')); + bool isSigned = item->value.startsWith('-'); quint64 raw = isSigned ? quint64(item->value.toLongLong()) : item->value.toULongLong(); return reformatInteger(raw, format, item->size, isSigned); } @@ -679,8 +679,8 @@ static QString formattedValue(const WatchItem *item) if (item->elided) { QString v = item->value; v.chop(1); - QString len = item->elided > 0 ? QString::number(item->elided) : QLatin1String("unknown length"); - return quoteUnprintable(v) + QLatin1String("\"... (") + len + QLatin1Char(')'); + QString len = item->elided > 0 ? QString::number(item->elided) : "unknown length"; + return quoteUnprintable(v) + "\"... (" + len + ')'; } return quoteUnprintable(item->value); @@ -691,10 +691,10 @@ static QString formattedValue(const WatchItem *item) // "0x00000000`000003fd "Hallo"", or check gdb formatting of characters. static inline quint64 pointerValue(QString data) { - const int blankPos = data.indexOf(QLatin1Char(' ')); + const int blankPos = data.indexOf(' '); if (blankPos != -1) data.truncate(blankPos); - data.remove(QLatin1Char('`')); + data.remove('`'); return data.toULongLong(0, 0); } @@ -708,7 +708,7 @@ int WatchItem::editType() const if (isFloatType(type)) return QVariant::Double; // Check for pointers using hex values (0xAD00 "Hallo") - if (isPointerType(type) && value.startsWith(QLatin1String("0x"))) + if (isPointerType(type) && value.startsWith("0x")) return QVariant::ULongLong; return QVariant::String; } @@ -718,7 +718,7 @@ QVariant WatchItem::editValue() const { switch (editType()) { case QVariant::Bool: - return value != QLatin1String("0") && value != QLatin1String("false"); + return value != "0" && value != "false"; case QVariant::ULongLong: if (isPointerType(type)) // Fix pointer values (0xAD00 "Hallo" -> 0xAD00) return QVariant(pointerValue(value)); @@ -733,12 +733,12 @@ QVariant WatchItem::editValue() const // Some string value: '0x434 "Hallo"': // Remove quotes and replace newlines, which will cause line edit troubles. QString stringValue = value; - if (stringValue.endsWith(QLatin1Char('"'))) { - const int leadingDoubleQuote = stringValue.indexOf(QLatin1Char('"')); + if (stringValue.endsWith('"')) { + const int leadingDoubleQuote = stringValue.indexOf('"'); if (leadingDoubleQuote != stringValue.size() - 1) { stringValue.truncate(stringValue.size() - 1); stringValue.remove(0, leadingDoubleQuote + 1); - stringValue.replace(QLatin1String("\n"), QLatin1String("\\n")); + stringValue.replace("\n", "\\n"); } } return QVariant(quoteUnprintable(stringValue)); @@ -750,9 +750,9 @@ static QString truncateValue(QString v) enum { maxLength = 512 }; if (v.size() < maxLength) return v; - const bool isQuoted = v.endsWith(QLatin1Char('"')); // check for 'char* "Hallo"' + const bool isQuoted = v.endsWith('"'); // check for 'char* "Hallo"' v.truncate(maxLength); - v += isQuoted ? QLatin1String("...\"") : QLatin1String("..."); + v += QLatin1String(isQuoted ? "...\"" : "..."); return v; } @@ -767,18 +767,18 @@ static QString displayName(const WatchItem *item) result = QString::fromLatin1("[%1]").arg(item->arrayIndex); return result; } - if (item->iname.startsWith("return") && item->name.startsWith(QLatin1Char('$'))) + if (item->iname.startsWith("return") && item->name.startsWith('$')) result = WatchModel::tr("returned value"); - else if (item->name == QLatin1String("*")) - result = QLatin1Char('*') + p->name; + else if (item->name == "*") + result = '*' + p->name; else result = watchModel(item)->removeNamespaces(item->name); // Simplify names that refer to base classes. - if (result.startsWith(QLatin1Char('['))) { + if (result.startsWith('[')) { result = simplifyType(result); if (result.size() > 30) - result = result.left(27) + QLatin1String("...]"); + result = result.left(27) + "...]"; } return result; @@ -799,7 +799,7 @@ static QString displayType(const WatchItem *item) QString result = niceTypeHelper(item->type); if (item->bitsize) result += QString::fromLatin1(":%1").arg(item->bitsize); - result.remove(QLatin1Char('\'')); + result.remove('\''); result = watchModel(item)->removeNamespaces(result); return result; } @@ -830,17 +830,17 @@ static DisplayFormats typeFormatList(const WatchItem *item) // Types supported by dumpers: // Hack: Compensate for namespaces. - QString t = QLatin1String(stripForFormat(item->type)); - int pos = t.indexOf(QLatin1String("::Q")); - if (pos >= 0 && t.count(QLatin1Char(':')) == 2) + QString t = stripForFormat(item->type); + int pos = t.indexOf("::Q"); + if (pos >= 0 && t.count(':') == 2) t.remove(0, pos + 2); - pos = t.indexOf(QLatin1Char('<')); + pos = t.indexOf('<'); if (pos >= 0) t.truncate(pos); - t.replace(QLatin1Char(':'), QLatin1Char('_')); + t.replace(':', '_'); formats << watchModel(item)->m_reportedTypeFormats.value(t); - if (t.contains(QLatin1Char(']'))) + if (t.contains(']')) formats.append(ArrayPlotFormat); // Fixed artificial string and pointer types. @@ -878,7 +878,7 @@ static DisplayFormats typeFormatList(const WatchItem *item) // Fixed artificial integral types. QString v = item->value; - if (v.startsWith(QLatin1Char('-'))) + if (v.startsWith('-')) v = v.mid(1); v.toULongLong(&ok, 10); if (!ok) @@ -929,7 +929,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const case 1: return item->editValue(); case 2: - return QString::fromUtf8(item->type); + return item->type; } } @@ -970,7 +970,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const return removeNamespaces(displayType(item)); case LocalsRawTypeRole: - return QString::fromLatin1(item->type); + return item->type; case LocalsTypeFormatRole: return theTypeFormats.value(stripForFormat(item->type), AutomaticFormat); @@ -1022,7 +1022,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role case Qt::EditRole: switch (idx.column()) { case 0: { - m_handler->updateWatchExpression(item, value.toString().trimmed().toUtf8()); + m_handler->updateWatchExpression(item, value.toString().trimmed()); break; } case 1: // Change value @@ -1245,7 +1245,7 @@ WatchHandler::~WatchHandler() void WatchHandler::cleanup() { m_model->m_expandedINames.clear(); - theWatcherNames.remove(QByteArray()); + theWatcherNames.remove(QString()); saveWatchers(); m_model->reinitialize(); emit m_model->updateFinished(); @@ -1310,7 +1310,7 @@ bool WatchHandler::insertItem(WatchItem *item) void WatchModel::reexpandItems() { - foreach (const QByteArray &iname, m_expandedINames) { + foreach (const QString &iname, m_expandedINames) { if (WatchItem *item = findItem(iname)) { emit itemIsExpanded(indexForItem(item)); emit inameIsExpanded(iname); @@ -1347,7 +1347,7 @@ void WatchHandler::resetWatchers() loadSessionData(); } -void WatchHandler::notifyUpdateStarted(const QList<QByteArray> &inames) +void WatchHandler::notifyUpdateStarted(const QStringList &inames) { auto marker = [](TreeItem *it) { static_cast<WatchItem *>(it)->outdated = true; }; @@ -1393,7 +1393,7 @@ void WatchHandler::reexpandItems() m_model->reexpandItems(); } -void WatchHandler::removeItemByIName(const QByteArray &iname) +void WatchHandler::removeItemByIName(const QString &iname) { WatchItem *item = m_model->findItem(iname); if (!item) @@ -1406,15 +1406,14 @@ void WatchHandler::removeItemByIName(const QByteArray &iname) updateWatchersWindow(); } -QByteArray WatchHandler::watcherName(const QByteArray &exp) +QString WatchHandler::watcherName(const QString &exp) { - return "watch." + QByteArray::number(theWatcherNames[exp]); + return "watch." + QString::number(theWatcherNames[exp]); } -void WatchHandler::watchExpression(const QString &exp0, const QString &name) +void WatchHandler::watchExpression(const QString &exp, const QString &name) { // Do not insert the same entry more then once. - QByteArray exp = exp0.toLatin1(); if (exp.isEmpty() || theWatcherNames.contains(exp)) return; @@ -1422,7 +1421,7 @@ void WatchHandler::watchExpression(const QString &exp0, const QString &name) auto item = new WatchItem; item->exp = exp; - item->name = name.isEmpty() ? exp0 : name; + item->name = name.isEmpty() ? exp : name; item->iname = watcherName(exp); insertItem(item); saveWatchers(); @@ -1437,7 +1436,7 @@ void WatchHandler::watchExpression(const QString &exp0, const QString &name) updateWatchersWindow(); } -void WatchHandler::updateWatchExpression(WatchItem *item, const QByteArray &newExp) +void WatchHandler::updateWatchExpression(WatchItem *item, const QString &newExp) { if (newExp.isEmpty()) return; @@ -1446,7 +1445,7 @@ void WatchHandler::updateWatchExpression(WatchItem *item, const QByteArray &newE theWatcherNames.insert(newExp, theWatcherNames.value(item->exp)); theWatcherNames.remove(item->exp); item->exp = newExp; - item->name = QString::fromUtf8(item->exp); + item->name = newExp; } saveWatchers(); @@ -1466,7 +1465,7 @@ void WatchHandler::updateWatchExpression(WatchItem *item, const QByteArray &newE void WatchHandler::watchVariable(const QString &exp) { if (const WatchItem *localVariable = findCppLocalVariable(exp)) - watchExpression(QLatin1String(localVariable->exp), exp); + watchExpression(localVariable->exp, exp); else watchExpression(exp); } @@ -1486,7 +1485,7 @@ static void swapEndian(char *d, int nchar) void WatchModel::showEditValue(const WatchItem *item) { - const QByteArray &format = item->editformat; + const QString &format = item->editformat; if (format.isEmpty()) { // Nothing m_separatedView->removeObject(item->key()); @@ -1496,7 +1495,7 @@ void WatchModel::showEditValue(const WatchItem *item) QByteArray ba; uchar *bits = 0; if (format == DisplayImageData) { - ba = QByteArray::fromHex(item->editvalue); + ba = QByteArray::fromHex(item->editvalue.toUtf8()); QTC_ASSERT(ba.size() > 16, return); const int *header = (int *)(ba.data()); if (!ba.at(0) && !ba.at(1)) // Check on 'width' for Python dumpers returning 4-byte swapped-data. @@ -1507,7 +1506,7 @@ void WatchModel::showEditValue(const WatchItem *item) nbytes = header[2]; imformat = header[3]; } else if (format == DisplayImageFile) { - QTextStream ts(item->editvalue); + QTextStream ts(item->editvalue.toUtf8()); QString fileName; ts >> width >> height >> nbytes >> imformat >> fileName; QFile f(fileName); @@ -1524,10 +1523,8 @@ void WatchModel::showEditValue(const WatchItem *item) std::memcpy(im.bits(), bits, nbytes); ImageViewer *v = m_separatedView->prepareObject<ImageViewer>(item); v->setInfo(item->address ? - tr("%1 Object at %2").arg(QLatin1String(item->type), - QLatin1String(item->hexAddress())) : - tr("%1 Object at Unknown Address").arg(QLatin1String(item->type)) - + QLatin1String(" ") + + tr("%1 Object at %2").arg(item->type, item->hexAddress()) : + tr("%1 Object at Unknown Address").arg(item->type) + " " + ImageViewer::tr("Size: %1x%2, %3 byte, format: %4, depth: %5") .arg(width).arg(height).arg(nbytes).arg(im.format()).arg(im.depth()) ); @@ -1537,7 +1534,7 @@ void WatchModel::showEditValue(const WatchItem *item) || format == DisplayUtf16String || format == DisplayUcs4String) { // String data. - QByteArray ba = QByteArray::fromHex(item->editvalue); + QByteArray ba = QByteArray::fromHex(item->editvalue.toUtf8()); QString str; if (format == DisplayLatin1String) str = QString::fromLatin1(ba.constData(), ba.size()); @@ -1551,7 +1548,7 @@ void WatchModel::showEditValue(const WatchItem *item) } else if (format == DisplayPlotData) { // Plots std::vector<double> data; - readNumericVector(&data, QByteArray::fromHex(item->editvalue), item->editencoding); + readNumericVector(&data, QByteArray::fromHex(item->editvalue.toUtf8()), item->editencoding); m_separatedView->prepareObject<PlotViewer>(item)->setData(data); } else { QTC_ASSERT(false, qDebug() << "Display format: " << format); @@ -1566,7 +1563,7 @@ void WatchHandler::clearWatches() const QDialogButtonBox::StandardButton ret = CheckableMessageBox::doNotAskAgainQuestion( Core::ICore::mainWindow(), tr("Remove All Expression Evaluators"), tr("Are you sure you want to remove all expression evaluators?"), - Core::ICore::settings(), QLatin1String("RemoveAllWatchers")); + Core::ICore::settings(), "RemoveAllWatchers"); if (ret != QDialogButtonBox::Yes) return; @@ -1591,12 +1588,12 @@ QStringList WatchHandler::watchedExpressions() { // Filter out invalid watchers. QStringList watcherNames; - QHashIterator<QByteArray, int> it(theWatcherNames); + QHashIterator<QString, int> it(theWatcherNames); while (it.hasNext()) { it.next(); - const QByteArray &watcherName = it.key(); + const QString &watcherName = it.key(); if (!watcherName.isEmpty()) - watcherNames.push_back(QLatin1String(watcherName)); + watcherNames.push_back(watcherName); } return watcherNames; } @@ -1628,7 +1625,7 @@ const WatchItem *WatchHandler::watchItem(const QModelIndex &idx) const return static_cast<WatchItem *>(m_model->itemForIndex(idx)); } -void WatchHandler::fetchMore(const QByteArray &iname) const +void WatchHandler::fetchMore(const QString &iname) const { if (WatchItem *item = m_model->findItem(iname)) { m_model->m_expandedINames.insert(iname); @@ -1639,7 +1636,7 @@ void WatchHandler::fetchMore(const QByteArray &iname) const } } -WatchItem *WatchHandler::findItem(const QByteArray &iname) const +WatchItem *WatchHandler::findItem(const QString &iname) const { return m_model->findItem(iname); } @@ -1647,8 +1644,8 @@ WatchItem *WatchHandler::findItem(const QByteArray &iname) const const WatchItem *WatchHandler::findCppLocalVariable(const QString &name) const { // Can this be found as a local variable? - const QByteArray localsPrefix("local."); - QByteArray iname = localsPrefix + name.toLatin1(); + const QString localsPrefix("local."); + QString iname = localsPrefix + name; if (const WatchItem *item = findItem(iname)) return item; // // Nope, try a 'local.this.m_foo'. @@ -1658,9 +1655,9 @@ const WatchItem *WatchHandler::findCppLocalVariable(const QString &name) const return 0; } -void WatchModel::setTypeFormat(const QByteArray &type0, int format) +void WatchModel::setTypeFormat(const QString &type0, int format) { - const QByteArray type = stripForFormat(type0); + const QString type = stripForFormat(type0); if (format == AutomaticFormat) theTypeFormats.remove(type); else @@ -1669,7 +1666,7 @@ void WatchModel::setTypeFormat(const QByteArray &type0, int format) m_engine->updateAll(); } -void WatchModel::setIndividualFormat(const QByteArray &iname, int format) +void WatchModel::setIndividualFormat(const QString &iname, int format) { if (format == AutomaticFormat) theIndividualFormats.remove(iname); @@ -1678,7 +1675,7 @@ void WatchModel::setIndividualFormat(const QByteArray &iname, int format) saveFormats(); } -int WatchHandler::format(const QByteArray &iname) const +int WatchHandler::format(const QString &iname) const { int result = AutomaticFormat; if (const WatchItem *item = m_model->findItem(iname)) { @@ -1694,34 +1691,34 @@ QString WatchHandler::nameForFormat(int format) return WatchModel::nameForFormat(format); } -static const char *formatStringFromFormatCode(int code) +static QString formatStringFromFormatCode(int code) { switch (code) { // Taken from debuggerprotocol.h, DisplayFormat. case Latin1StringFormat: - return "latin"; + return QLatin1String("latin"); case SeparateLatin1StringFormat: - return "latin:separate"; + return QLatin1String("latin:separate"); case Utf8StringFormat: - return "utf8"; + return QLatin1String("utf8"); case SeparateUtf8StringFormat: - return "utf8:separate"; + return QLatin1String("utf8:separate"); case Utf16StringFormat: - return "utf16"; + return QLatin1String("utf16"); } - return ""; + return QString(); } -QByteArray WatchHandler::typeFormatRequests() const +QString WatchHandler::typeFormatRequests() const { - QByteArray ba; + QString ba; if (!theTypeFormats.isEmpty()) { - QHashIterator<QByteArray, int> it(theTypeFormats); + QHashIterator<QString, int> it(theTypeFormats); while (it.hasNext()) { it.next(); const int format = it.value(); if (format != AutomaticFormat) { - ba.append(it.key().toHex()); + ba.append(toHex(it.key())); ba.append('='); ba.append(formatStringFromFormatCode(format)); ba.append(','); @@ -1732,61 +1729,61 @@ QByteArray WatchHandler::typeFormatRequests() const return ba; } -QByteArray WatchHandler::individualFormatRequests() const +QString WatchHandler::individualFormatRequests() const { - QByteArray ba; + QString res; if (!theIndividualFormats.isEmpty()) { - QHashIterator<QByteArray, int> it(theIndividualFormats); + QHashIterator<QString, int> it(theIndividualFormats); while (it.hasNext()) { it.next(); const int format = it.value(); if (format != AutomaticFormat) { - ba.append(it.key()); - ba.append('='); - ba.append(formatStringFromFormatCode(it.value())); - ba.append(','); + res.append(it.key()); + res.append('='); + res.append(formatStringFromFormatCode(it.value())); + res.append(','); } } - ba.chop(1); + res.chop(1); } - return ba; + return res; } void WatchHandler::appendFormatRequests(DebuggerCommand *cmd) { QJsonArray expanded; - QSetIterator<QByteArray> jt(m_model->m_expandedINames); + QSetIterator<QString> jt(m_model->m_expandedINames); while (jt.hasNext()) - expanded.append(QLatin1String(jt.next())); + expanded.append(jt.next()); cmd->arg("expanded", expanded); QJsonObject typeformats; - QHashIterator<QByteArray, int> it(theTypeFormats); + QHashIterator<QString, int> it(theTypeFormats); while (it.hasNext()) { it.next(); const int format = it.value(); if (format != AutomaticFormat) - typeformats.insert(QLatin1String(it.key()), format); + typeformats.insert(it.key(), format); } cmd->arg("typeformats", typeformats); QJsonObject formats; - QHashIterator<QByteArray, int> it2(theIndividualFormats); + QHashIterator<QString, int> it2(theIndividualFormats); while (it2.hasNext()) { it2.next(); const int format = it2.value(); if (format != AutomaticFormat) - formats.insert(QLatin1String(it2.key()), format); + formats.insert(it2.key(), format); } cmd->arg("formats", formats); } -static inline QJsonObject watcher(const QByteArray &iname, const QByteArray &exp) +static inline QJsonObject watcher(const QString &iname, const QString &exp) { QJsonObject watcher; - watcher.insert(QStringLiteral("iname"), QLatin1String(iname)); - watcher.insert(QStringLiteral("exp"), QLatin1String(exp.toHex())); + watcher.insert("iname", iname); + watcher.insert("exp", toHex(exp)); return watcher; } @@ -1795,12 +1792,12 @@ void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd) QJsonArray watchers; DebuggerToolTipContexts toolTips = DebuggerToolTipManager::pendingTooltips(m_model->m_engine); foreach (const DebuggerToolTipContext &p, toolTips) - watchers.append(watcher(p.iname, p.expression.toLatin1())); + watchers.append(watcher(p.iname, p.expression)); - QHashIterator<QByteArray, int> it(WatchHandler::watcherNames()); + QHashIterator<QString, int> it(WatchHandler::watcherNames()); while (it.hasNext()) { it.next(); - watchers.append(watcher("watch." + QByteArray::number(it.value()), it.key())); + watchers.append(watcher("watch." + QString::number(it.value()), it.key())); } cmd->arg("watchers", watchers); } @@ -1810,8 +1807,8 @@ void WatchHandler::addDumpers(const GdbMi &dumpers) foreach (const GdbMi &dumper, dumpers.children()) { DisplayFormats formats; formats.append(RawFormat); - QByteArray reportedFormats = dumper["formats"].data(); - foreach (const QByteArray &format, reportedFormats.split(',')) { + QString reportedFormats = dumper["formats"].data(); + foreach (const QString &format, reportedFormats.split(',')) { if (int f = format.toInt()) formats.append(DisplayFormat(f)); } @@ -1819,9 +1816,9 @@ void WatchHandler::addDumpers(const GdbMi &dumpers) } } -void WatchHandler::addTypeFormats(const QByteArray &type, const DisplayFormats &formats) +void WatchHandler::addTypeFormats(const QString &type, const DisplayFormats &formats) { - m_model->m_reportedTypeFormats.insert(QLatin1String(stripForFormat(type)), formats); + m_model->m_reportedTypeFormats.insert(stripForFormat(type), formats); } QString WatchHandler::editorContents(const QModelIndexList &list) @@ -1831,7 +1828,7 @@ QString WatchHandler::editorContents(const QModelIndexList &list) m_model->forAllItems([&ts, this, list](WatchItem *item) { if (list.isEmpty() || list.contains(m_model->indexForItem(item))) { const QChar tab = QLatin1Char('\t'); - const QChar nl = QLatin1Char('\n'); + const QChar nl = '\n'; ts << QString(item->level(), tab) << item->name << tab << displayValue(item) << tab << item->type << nl; } @@ -1850,7 +1847,7 @@ void WatchHandler::resetLocation() m_model->m_resetLocationScheduled = false; } -void WatchHandler::setCurrentItem(const QByteArray &iname) +void WatchHandler::setCurrentItem(const QString &iname) { if (WatchItem *item = m_model->findItem(iname)) { QModelIndex idx = m_model->indexForItem(item); @@ -1858,7 +1855,7 @@ void WatchHandler::setCurrentItem(const QByteArray &iname) } } -QHash<QByteArray, int> WatchHandler::watcherNames() +QHash<QString, int> WatchHandler::watcherNames() { return theWatcherNames; } @@ -1874,12 +1871,12 @@ int WatchHandler::unprintableBase() return theUnprintableBase; } -bool WatchHandler::isExpandedIName(const QByteArray &iname) const +bool WatchHandler::isExpandedIName(const QString &iname) const { return m_model->m_expandedINames.contains(iname); } -QSet<QByteArray> WatchHandler::expandedINames() const +QSet<QString> WatchHandler::expandedINames() const { return m_model->m_expandedINames; } @@ -1888,7 +1885,7 @@ void WatchHandler::recordTypeInfo(const GdbMi &typeInfo) { if (typeInfo.type() == GdbMi::List) { foreach (const GdbMi &s, typeInfo.children()) { - QByteArray typeName = QByteArray::fromHex(s["name"].data()); + QString typeName = fromHex(s["name"].data()); TypeInfo ti(s["size"].data().toUInt()); m_model->m_reportedTypeInfo.insert(typeName, ti); } diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 6fd7e515f0..c0bc284a7a 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -48,7 +48,7 @@ public: signals: void currentIndexRequested(const QModelIndex &idx); void itemIsExpanded(const QModelIndex &idx); - void inameIsExpanded(const QByteArray &iname); + void inameIsExpanded(const QString &iname); void columnAdjustmentRequested(); void updateStarted(); void updateFinished(); @@ -66,57 +66,57 @@ public: void cleanup(); void watchExpression(const QString &exp, const QString &name = QString()); - void updateWatchExpression(WatchItem *item, const QByteArray &newExp); + void updateWatchExpression(WatchItem *item, const QString &newExp); void watchVariable(const QString &exp); void clearWatches(); const WatchItem *watchItem(const QModelIndex &) const; - void fetchMore(const QByteArray &iname) const; - WatchItem *findItem(const QByteArray &iname) const; + void fetchMore(const QString &iname) const; + WatchItem *findItem(const QString &iname) const; const WatchItem *findCppLocalVariable(const QString &name) const; void loadSessionData(); void saveSessionData(); - bool isExpandedIName(const QByteArray &iname) const; - QSet<QByteArray> expandedINames() const; + bool isExpandedIName(const QString &iname) const; + QSet<QString> expandedINames() const; static QStringList watchedExpressions(); - static QHash<QByteArray, int> watcherNames(); + static QHash<QString, int> watcherNames(); void appendFormatRequests(DebuggerCommand *cmd); void appendWatchersAndTooltipRequests(DebuggerCommand *cmd); - QByteArray typeFormatRequests() const; - QByteArray individualFormatRequests() const; + QString typeFormatRequests() const; + QString individualFormatRequests() const; - int format(const QByteArray &iname) const; + int format(const QString &iname) const; static QString nameForFormat(int format); void addDumpers(const GdbMi &dumpers); - void addTypeFormats(const QByteArray &type, const DisplayFormats &formats); + void addTypeFormats(const QString &type, const DisplayFormats &formats); void setUnprintableBase(int base); static int unprintableBase(); - QByteArray watcherName(const QByteArray &exp); + QString watcherName(const QString &exp); QString editorContents(const QModelIndexList &list = QModelIndexList()); void scheduleResetLocation(); void resetLocation(); - void setCurrentItem(const QByteArray &iname); + void setCurrentItem(const QString &iname); void updateWatchersWindow(); bool insertItem(WatchItem *item); // Takes ownership, returns whether item was added, not overwritten. void insertItems(const GdbMi &data); - void removeItemByIName(const QByteArray &iname); + void removeItemByIName(const QString &iname); void removeAllData(bool includeInspectData = false); void resetValueCache(); void resetWatchers(); - void notifyUpdateStarted(const QList<QByteArray> &inames = {}); + void notifyUpdateStarted(const QStringList &inames = {}); void notifyUpdateFinished(); void reexpandItems(); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index a69f936c71..4dd6d69161 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -140,7 +140,7 @@ bool isLeavableFunction(const QString &funcName, const QString &fileName) return false; } -bool isLetterOrNumber(char c) +bool isLetterOrNumber(int c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') @@ -225,7 +225,7 @@ bool startsWithDigit(const QString &str) return !str.isEmpty() && str.at(0).isDigit(); } -QByteArray stripPointerType(QByteArray type) +QString stripPointerType(QString type) { if (type.endsWith('*')) type.chop(1); @@ -256,7 +256,7 @@ QString formatToolTipAddress(quint64 a) return "0x" + rc; } -QByteArray gdbQuoteTypes(const QByteArray &type) +QString gdbQuoteTypes(const QString &type) { // gdb does not understand sizeof(Core::IDocument*). // "sizeof('Core::IDocument*')" is also not acceptable, @@ -274,8 +274,8 @@ QByteArray gdbQuoteTypes(const QByteArray &type) if (isPointerType(type)) return gdbQuoteTypes(stripPointerType(type)) + '*'; - QByteArray accu; - QByteArray result; + QString accu; + QString result; int templateLevel = 0; const char colon = ':'; @@ -283,8 +283,8 @@ QByteArray gdbQuoteTypes(const QByteArray &type) const char lessThan = '<'; const char greaterThan = '>'; for (int i = 0; i != type.size(); ++i) { - const char c = type.at(i); - if (isLetterOrNumber(c) || c == '_' || c == colon || c == ' ') { + const QChar c = type.at(i); + if (isLetterOrNumber(c.unicode()) || c == '_' || c == colon || c == ' ') { accu += c; } else if (c == lessThan) { ++templateLevel; diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index 7f77ba4dd5..a5539d5cec 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -39,14 +39,14 @@ bool isLeavableFunction(const QString &funcName, const QString &fileName); bool hasLetterOrNumber(const QString &exp); bool hasSideEffects(const QString &exp); bool isKeyWord(const QString &exp); -bool isPointerType(const QByteArray &type); -bool isCharPointerType(const QByteArray &type); +bool isPointerType(const QString &type); +bool isCharPointerType(const QString &type); bool startsWithDigit(const QString &str); -QByteArray stripPointerType(QByteArray type); -QByteArray gdbQuoteTypes(const QByteArray &type); -bool isFloatType(const QByteArray &type); -bool isIntOrFloatType(const QByteArray &type); -bool isIntType(const QByteArray &type); +QString stripPointerType(QString type); +QString gdbQuoteTypes(const QString &type); +bool isFloatType(const QString &type); +bool isIntOrFloatType(const QString &type); +bool isIntType(const QString &type); QString formatToolTipAddress(quint64 a); QString removeObviousSideEffects(const QString &exp); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index dd86e84230..fd14bef0ac 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -270,7 +270,7 @@ static MemoryMarkupList const quint64 offset = it.key() - address; if (offset < size) { ranges[offset] = ColorNumberToolTip(registerColorNumber, - WatchTreeView::tr("Register <i>%1</i>").arg(QString::fromUtf8(it.value()))); + WatchTreeView::tr("Register <i>%1</i>").arg(it.value())); } else { break; // Sorted. } @@ -455,7 +455,7 @@ void WatchTreeView::keyPressEvent(QKeyEvent *ev) if (ev->key() == Qt::Key_Delete && m_type == WatchersType) { WatchHandler *handler = currentEngine()->watchHandler(); foreach (const QModelIndex &idx, activeRows()) - handler->removeItemByIName(idx.data(LocalsINameRole).toByteArray()); + handler->removeItemByIName(idx.data(LocalsINameRole).toString()); } else if (ev->key() == Qt::Key_Return && ev->modifiers() == Qt::ControlModifier && m_type == LocalsType) { @@ -888,7 +888,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) } else if (act == &actWatchExpression) { watchExpression(exp, name); } else if (act == &actRemoveWatchExpression) { - handler->removeItemByIName(p.data(LocalsINameRole).toByteArray()); + handler->removeItemByIName(p.data(LocalsINameRole).toString()); } else if (act == &actRemoveAllWatchExpression) { handler->clearWatches(); } else if (act == &actCopy) { @@ -958,7 +958,7 @@ void WatchTreeView::setModel(QAbstractItemModel *model) void WatchTreeView::rowActivated(const QModelIndex &index) { - currentEngine()->selectWatchData(index.data(LocalsINameRole).toByteArray()); + currentEngine()->selectWatchData(index.data(LocalsINameRole).toString()); } void WatchTreeView::handleItemIsExpanded(const QModelIndex &idx) diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 7826eadc84..cf47e22870 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -227,82 +227,55 @@ struct BoostVersion : VersionBase {} }; -static QByteArray noValue = "\001"; - -static QString toHex(const QString &str) -{ - QString encoded; - foreach (const QChar c, str) { - encoded += QString::fromLatin1("%1") - .arg(c.unicode(), 2, 16, QLatin1Char('0')); - } - return encoded; -} +static QString noValue = "\001"; struct Context { - Context() : qtVersion(0), gccVersion(0), clangVersion(0), boostVersion(0) {} - - QByteArray nameSpace; - int qtVersion; - int gccVersion; - int clangVersion; - int boostVersion; + QString nameSpace; + int qtVersion = 0; + int gccVersion = 0; + int clangVersion = 0; + int boostVersion = 0; }; struct Name { Name() : name(noValue) {} - Name(const char *str) : name(str) {} - Name(const QByteArray &ba) : name(ba) {} + Name(const char *str) : name(QString::fromUtf8(str)) {} + Name(const QString &ba) : name(ba) {} - bool matches(const QByteArray &actualName0, const Context &context) const + bool matches(const QString &actualName0, const Context &context) const { - QByteArray actualName = actualName0; - QByteArray expectedName = name; + QString actualName = actualName0; + QString expectedName = name; expectedName.replace("@Q", context.nameSpace + 'Q'); return actualName == expectedName; } - QByteArray name; + QString name; }; -static Name nameFromIName(const QByteArray &iname) +static Name nameFromIName(const QString &iname) { int pos = iname.lastIndexOf('.'); return Name(pos == -1 ? iname : iname.mid(pos + 1)); } -static QByteArray parentIName(const QByteArray &iname) +static QString parentIName(const QString &iname) { int pos = iname.lastIndexOf('.'); - return pos == -1 ? QByteArray() : iname.left(pos); + return pos == -1 ? QString() : iname.left(pos); } -struct ValueBase +struct Value { - ValueBase() - : hasPtrSuffix(false), isFloatValue(false), substituteNamespace(true), - qtVersion(0), minimalGccVersion(0) - {} - - bool hasPtrSuffix; - bool isFloatValue; - bool substituteNamespace; - int qtVersion; - int minimalGccVersion; -}; - -struct Value : public ValueBase -{ - Value() : value(QString::fromLatin1(noValue)) {} + Value() : value(noValue) {} Value(const char *str) : value(QLatin1String(str)) {} - Value(const QByteArray &ba) : value(QString::fromLatin1(ba.data(), ba.size())) {} Value(const QString &str) : value(str) {} bool matches(const QString &actualValue0, const Context &context) const { - if (value == QString::fromLatin1(noValue)) + if (value == noValue) return true; if (context.qtVersion) { @@ -325,15 +298,15 @@ struct Value : public ValueBase } } QString actualValue = actualValue0; - if (actualValue == QLatin1String(" ")) + if (actualValue == " ") actualValue.clear(); // FIXME: Remove later. QString expectedValue = value; if (substituteNamespace) - expectedValue.replace(QLatin1Char('@'), QString::fromLatin1(context.nameSpace)); + expectedValue.replace('@', context.nameSpace); if (hasPtrSuffix) - return actualValue.startsWith(expectedValue + QLatin1String(" @0x")) - || actualValue.startsWith(expectedValue + QLatin1String("@0x")); + return actualValue.startsWith(expectedValue + " @0x") + || actualValue.startsWith(expectedValue + "@0x"); if (isFloatValue) { double f1 = fabs(expectedValue.toDouble()); @@ -352,33 +325,38 @@ struct Value : public ValueBase void setMinimalGccVersion(int version) { minimalGccVersion = version; } QString value; + bool hasPtrSuffix = false; + bool isFloatValue = false; + bool substituteNamespace = true; + int qtVersion = 0; + int minimalGccVersion = 0; }; struct Pointer : Value { Pointer() { hasPtrSuffix = true; } - Pointer(const QByteArray &value) : Value(value) { hasPtrSuffix = true; } + Pointer(const QString &value) : Value(value) { hasPtrSuffix = true; } }; struct FloatValue : Value { FloatValue() { isFloatValue = true; } - FloatValue(const QByteArray &value) : Value(value) { isFloatValue = true; } + FloatValue(const QString &value) : Value(value) { isFloatValue = true; } }; struct Value4 : Value { - Value4(const QByteArray &value) : Value(value) { qtVersion = 4; } + Value4(const QString &value) : Value(value) { qtVersion = 4; } }; struct Value5 : Value { - Value5(const QByteArray &value) : Value(value) { qtVersion = 5; } + Value5(const QString &value) : Value(value) { qtVersion = 5; } }; struct UnsubstitutedValue : Value { - UnsubstitutedValue(const QByteArray &value) : Value(value) { substituteNamespace = false; } + UnsubstitutedValue(const QString &value) : Value(value) { substituteNamespace = false; } }; struct Optional {}; @@ -386,10 +364,11 @@ struct Optional {}; struct Type { Type() : qtVersion(0), isPattern(false) {} - Type(const char *str) : type(str), qtVersion(0), isPattern(false) {} - Type(const QByteArray &ba) : type(ba), qtVersion(0), isPattern(false) {} + Type(const char *str) : type(QString::fromUtf8(str)), qtVersion(0), isPattern(false) {} + Type(const QString &ba) : type(ba), qtVersion(0), isPattern(false) {} - bool matches(const QByteArray &actualType0, const Context &context, bool fullNamespaceMatch = true) const + bool matches(const QString &actualType0, const Context &context, + bool fullNamespaceMatch = true) const { if (context.qtVersion) { if (qtVersion == 4) { @@ -404,20 +383,16 @@ struct Type } } } - QByteArray actualType = - simplifyType(QString::fromLatin1(actualType0)).toLatin1(); + QString actualType = simplifyType(actualType0); actualType.replace(' ', ""); actualType.replace("const", ""); - QByteArray expectedType = type; + QString expectedType = type; expectedType.replace(' ', ""); expectedType.replace("const", ""); expectedType.replace('@', context.nameSpace); - if (isPattern) { - QString actual = QString::fromLatin1(actualType); - QString expected = QString::fromLatin1(expectedType); - return QRegExp(expected).exactMatch(actual); - } + if (isPattern) + return QRegExp(expectedType).exactMatch(actualType); if (fullNamespaceMatch) expectedType.replace('?', context.nameSpace); @@ -437,24 +412,24 @@ struct Type return false; } - QByteArray type; + QString type; int qtVersion; bool isPattern; }; struct Type4 : Type { - Type4(const QByteArray &ba) : Type(ba) { qtVersion = 4; } + Type4(const QString &ba) : Type(ba) { qtVersion = 4; } }; struct Type5 : Type { - Type5(const QByteArray &ba) : Type(ba) { qtVersion = 5; } + Type5(const QString &ba) : Type(ba) { qtVersion = 5; } }; struct Pattern : Type { - Pattern(const QByteArray &ba) : Type(ba) { isPattern = true; } + Pattern(const QString &ba) : Type(ba) { isPattern = true; } }; enum DebuggerEngine @@ -470,28 +445,16 @@ enum DebuggerEngine NoGdbEngine = AllEngines & (~GdbEngine) }; -struct CheckBase -{ - CheckBase() : enginesForCheck(AllEngines), optionallyPresent(false) {} - mutable int enginesForCheck; - mutable VersionBase debuggerVersionForCheck; - mutable VersionBase gccVersionForCheck; - mutable VersionBase clangVersionForCheck; - mutable QtVersion qtVersionForCheck; - mutable BoostVersion boostVersionForCheck; - mutable bool optionallyPresent; -}; - -struct Check : CheckBase +struct Check { Check() {} - Check(const QByteArray &iname, const Value &value, const Type &type) + Check(const QString &iname, const Value &value, const Type &type) : iname(iname), expectedName(nameFromIName(iname)), expectedValue(value), expectedType(type) {} - Check(const QByteArray &iname, const Name &name, + Check(const QString &iname, const Name &name, const Value &value, const Type &type) : iname(iname), expectedName(name), expectedValue(value), expectedType(type) @@ -552,10 +515,18 @@ struct Check : CheckBase return *this; } - QByteArray iname; + QString iname; Name expectedName; Value expectedValue; Type expectedType; + + mutable int enginesForCheck = AllEngines; + mutable VersionBase debuggerVersionForCheck; + mutable VersionBase gccVersionForCheck; + mutable VersionBase clangVersionForCheck; + mutable QtVersion qtVersionForCheck; + mutable BoostVersion boostVersionForCheck; + mutable bool optionallyPresent = false; }; struct CheckType : public Check @@ -680,9 +651,9 @@ class Data : public DataBase { public: Data() {} - Data(const QByteArray &code) : code(code) {} + Data(const QString &code) : code(code) {} - Data(const QByteArray &includes, const QByteArray &code) + Data(const QString &includes, const QString &code) : includes(includes), code(code) {} @@ -829,9 +800,9 @@ public: } public: - mutable QByteArray profileExtra; - mutable QByteArray includes; - mutable QByteArray code; + mutable QString profileExtra; + mutable QString includes; + mutable QString code; mutable QList<Check> checks; }; @@ -846,7 +817,7 @@ struct TempStuff QVERIFY(!buildPath.isEmpty()); } - QByteArray input; + QString input; QTemporaryDir buildTemp; QString buildPath; }; @@ -883,8 +854,8 @@ private: void disarm() { t->buildTemp.setAutoRemove(!keepTemp()); } bool keepTemp() const { return m_keepTemp || m_forceKeepTemp; } TempStuff *t; - QByteArray m_debuggerBinary; - QByteArray m_qmakeBinary; + QString m_debuggerBinary; + QString m_qmakeBinary; QProcessEnvironment m_env; DebuggerEngine m_debuggerEngine; QString m_makeBinary; @@ -901,7 +872,7 @@ private: void tst_Dumpers::initTestCase() { - m_debuggerBinary = qgetenv("QTC_DEBUGGER_PATH_FOR_TEST"); + m_debuggerBinary = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_PATH_FOR_TEST")); if (m_debuggerBinary.isEmpty()) { #ifdef Q_OS_MAC m_debuggerBinary = "/Applications/Xcode.app/Contents/Developer/usr/bin/lldb"; @@ -909,20 +880,20 @@ void tst_Dumpers::initTestCase() m_debuggerBinary = "gdb"; #endif } - qDebug() << "Debugger : " << m_debuggerBinary.constData(); + qDebug() << "Debugger : " << m_debuggerBinary; m_debuggerEngine = GdbEngine; if (m_debuggerBinary.endsWith("cdb.exe")) m_debuggerEngine = CdbEngine; - QString base = QFileInfo(QString::fromLatin1(m_debuggerBinary)).baseName(); - if (base.startsWith(QLatin1String("lldb"))) + QString base = QFileInfo(m_debuggerBinary).baseName(); + if (base.startsWith("lldb")) m_debuggerEngine = LldbEngine; - m_qmakeBinary = qgetenv("QTC_QMAKE_PATH_FOR_TEST"); + m_qmakeBinary = QString::fromLocal8Bit(qgetenv("QTC_QMAKE_PATH_FOR_TEST")); if (m_qmakeBinary.isEmpty()) m_qmakeBinary = "qmake"; - qDebug() << "QMake : " << m_qmakeBinary.constData(); + qDebug() << "QMake : " << m_qmakeBinary; m_useGLibCxxDebug = qgetenv("QTC_USE_GLIBCXXDEBUG_FOR_TEST").toInt(); qDebug() << "Use _GLIBCXX_DEBUG : " << m_useGLibCxxDebug; @@ -932,8 +903,7 @@ void tst_Dumpers::initTestCase() if (m_debuggerEngine == GdbEngine) { QProcess debugger; - debugger.start(QString::fromLatin1(m_debuggerBinary) - + QLatin1String(" -i mi -quiet -nx")); + debugger.start(m_debuggerBinary + " -i mi -quiet -nx"); bool ok = debugger.waitForStarted(); debugger.write("set confirm off\npython print 43\nshow version\nquit\n"); ok = debugger.waitForFinished(); @@ -946,10 +916,10 @@ void tst_Dumpers::initTestCase() QVERIFY(usePython); QString version = QString::fromLocal8Bit(output); - int pos1 = version.indexOf(QLatin1String("&\"show version\\n")); + int pos1 = version.indexOf("&\"show version\\n"); QVERIFY(pos1 != -1); pos1 += 20; - int pos2 = version.indexOf(QLatin1String("~\"Copyright (C) "), pos1); + int pos2 = version.indexOf("~\"Copyright (C) ", pos1); QVERIFY(pos2 != -1); pos2 -= 4; version = version.mid(pos1, pos2 - pos1); @@ -959,16 +929,16 @@ void tst_Dumpers::initTestCase() m_makeBinary = QString::fromLocal8Bit(qgetenv("QTC_MAKE_PATH_FOR_TEST")); #ifdef Q_OS_WIN if (m_makeBinary.isEmpty()) - m_makeBinary = QLatin1String("mingw32-make"); + m_makeBinary = "mingw32-make"; // if qmake is not in PATH make sure the correct libs for inferior are prepended to PATH if (m_qmakeBinary != "qmake") { Utils::Environment env = Utils::Environment::systemEnvironment(); - env.prependOrSetPath(QDir::toNativeSeparators(QFileInfo(QLatin1String(m_qmakeBinary)).absolutePath())); + env.prependOrSetPath(QDir::toNativeSeparators(QFileInfo(m_qmakeBinary).absolutePath())); m_env = env.toProcessEnvironment(); } #else if (m_makeBinary.isEmpty()) - m_makeBinary = QLatin1String("make"); + m_makeBinary = "make"; #endif qDebug() << "Make path : " << m_makeBinary; qDebug() << "Gdb version : " << m_debuggerVersion; @@ -977,7 +947,7 @@ void tst_Dumpers::initTestCase() } else if (m_debuggerEngine == LldbEngine) { qDebug() << "Dumper dir : " << DUMPERDIR; QProcess debugger; - QString cmd = QString::fromUtf8(m_debuggerBinary + " -v"); + QString cmd = m_debuggerBinary + " -v"; debugger.start(cmd); bool ok = debugger.waitForFinished(2000); QVERIFY(ok); @@ -1005,7 +975,7 @@ void tst_Dumpers::initTestCase() QVERIFY(m_debuggerVersion); m_env = QProcessEnvironment::systemEnvironment(); - m_makeBinary = QLatin1String("make"); + m_makeBinary = "make"; } } @@ -1019,7 +989,7 @@ void tst_Dumpers::cleanup() if (!t->buildTemp.autoRemove()) { QFile logger(t->buildPath + QLatin1String("/input.txt")); logger.open(QIODevice::ReadWrite); - logger.write(t->input); + logger.write(t->input.toUtf8()); } delete t; } @@ -1056,7 +1026,7 @@ void tst_Dumpers::dumper() if (data.neededQtVersion.isRestricted) { QProcess qmake; qmake.setWorkingDirectory(t->buildPath); - cmd = QString::fromLatin1(m_qmakeBinary); + cmd = m_qmakeBinary; qmake.start(cmd, QStringList(QLatin1String("--version"))); QVERIFY(qmake.waitForFinished()); output = qmake.readAllStandardOutput(); @@ -1139,12 +1109,12 @@ void tst_Dumpers::dumper() proFile.write("DEFINES += _GLIBCXX_DEBUG\n"); if (m_debuggerEngine == GdbEngine && m_debuggerVersion < 70500) proFile.write("QMAKE_CXXFLAGS += -gdwarf-3\n"); - proFile.write(data.profileExtra); + proFile.write(data.profileExtra.toUtf8()); proFile.close(); QFile source(t->buildPath + QLatin1Char('/') + QLatin1String(mainFile)); QVERIFY(source.open(QIODevice::ReadWrite)); - QByteArray fullCode = QByteArray() + + QString fullCode = QString() + "\n\n#if defined(_MSC_VER)" + (data.useQt ? "\n#include <qt_windows.h>" : "\n#include <Windows.h>") + @@ -1205,17 +1175,17 @@ void tst_Dumpers::dumper() "\n BREAK;" "\n return 0;" "\n}\n"; - source.write(fullCode); + source.write(fullCode.toUtf8()); source.close(); QProcess qmake; qmake.setWorkingDirectory(t->buildPath); - cmd = QString::fromLatin1(m_qmakeBinary); + cmd = m_qmakeBinary; //qDebug() << "Starting qmake: " << cmd; QStringList options; #ifdef Q_OS_MAC if (m_qtVersion && m_qtVersion < 0x050000) - options << QLatin1String("-spec") << QLatin1String("unsupported/macx-clang"); + options << "-spec" << "unsupported/macx-clang"; #endif qmake.start(cmd, options); QVERIFY(qmake.waitForFinished()); @@ -1243,10 +1213,10 @@ void tst_Dumpers::dumper() QByteArray dumperDir = DUMPERDIR; - QSet<QByteArray> expandedINames; + QSet<QString> expandedINames; expandedINames.insert("local"); foreach (const Check &check, data.checks) { - QByteArray parent = check.iname; + QString parent = check.iname; while (true) { parent = parentIName(parent); if (parent.isEmpty()) @@ -1255,9 +1225,9 @@ void tst_Dumpers::dumper() } } - QByteArray expanded; - QByteArray expandedq; - foreach (const QByteArray &iname, expandedINames) { + QString expanded; + QString expandedq; + foreach (const QString &iname, expandedINames) { if (!expanded.isEmpty()) { expanded.append(','); expandedq.append(','); @@ -1266,19 +1236,16 @@ void tst_Dumpers::dumper() expandedq += '\'' + iname + '\''; } - QByteArray exe = m_debuggerBinary; + QString exe = m_debuggerBinary; QStringList args; - QByteArray cmds; + QString cmds; if (m_debuggerEngine == GdbEngine) { - const QFileInfo gdbBinaryFile(QString::fromLatin1(exe)); - const QByteArray uninstalledData = gdbBinaryFile.absolutePath().toLocal8Bit() + const QFileInfo gdbBinaryFile(exe); + const QString uninstalledData = gdbBinaryFile.absolutePath() + "/data-directory/python"; - args << QLatin1String("-i") - << QLatin1String("mi") - << QLatin1String("-quiet") - << QLatin1String("-nx"); + args << "-i" << "mi" << "-quiet" << "-nx"; QByteArray nograb = "-nograb"; cmds = "set confirm off\n" @@ -1322,7 +1289,7 @@ void tst_Dumpers::dumper() QFile fullLldb(t->buildPath + QLatin1String("/lldbcommand.txt")); fullLldb.setPermissions(QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|QFile::ReadGroup|QFile::ReadOther); fullLldb.open(QIODevice::WriteOnly); - fullLldb.write(exe + ' ' + args.join(QLatin1String(" ")).toUtf8() + '\n'); + fullLldb.write((exe + ' ' + args.join(' ') + '\n').toUtf8()); cmds = "sc import sys\n" "sc sys.path.insert(1, '" + dumperDir + "')\n" @@ -1334,7 +1301,7 @@ void tst_Dumpers::dumper() "'expanded':[" + expandedq + "]})\n" "quit\n"; - fullLldb.write(cmds); + fullLldb.write(cmds.toUtf8()); fullLldb.close(); } @@ -1342,16 +1309,16 @@ void tst_Dumpers::dumper() QProcessEnvironment env = m_env; if (data.useDebugImage) - env.insert(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug")); + env.insert("DYLD_IMAGE_SUFFIX", "_debug"); QProcess debugger; debugger.setProcessEnvironment(env); debugger.setWorkingDirectory(t->buildPath); - debugger.start(QString::fromLatin1(exe), args); + debugger.start(exe, args); QVERIFY(debugger.waitForStarted()); // FIXME: next line is necessary for LLDB <= 310 - remove asap debugger.waitForReadyRead(1000); - debugger.write(cmds); + debugger.write(cmds.toLocal8Bit()); QVERIFY(debugger.waitForFinished()); output = debugger.readAllStandardOutput(); QByteArray fullOutput = output; @@ -1424,7 +1391,7 @@ void tst_Dumpers::dumper() local.iname = "local"; foreach (const GdbMi &child, actual.children()) { - const QByteArray iname = child["iname"].data(); + const QString iname = child["iname"].data(); if (iname == "local.qtversion") context.qtVersion = child["value"].toInt(); else if (iname == "local.gccversion") @@ -1441,15 +1408,15 @@ void tst_Dumpers::dumper() } //qDebug() << "QT VERSION " << QByteArray::number(context.qtVersion, 16); - QSet<QByteArray> seenINames; + QSet<QString> seenINames; bool ok = true; for (int i = data.checks.size(); --i >= 0; ) { //qDebug() << "NUM CHECKS" << data.checks.size(); Check check = data.checks.at(i); - QByteArray iname = "local." + check.iname; + QString iname = "local." + check.iname; WatchItem *item = local.findAnyChild<WatchItem *>([iname](WatchItem *item) { - return item->iname == iname; + return item->internalName() == iname; }); if (item) { seenINames.insert(iname); @@ -1457,8 +1424,8 @@ void tst_Dumpers::dumper() data.checks.removeAt(i); if (check.matches(m_debuggerEngine, m_debuggerVersion, context)) { //qDebug() << "USING MATCHING TEST FOR " << iname; - QByteArray name = item->realName().toLatin1(); - QByteArray type = item->type; + QString name = item->realName(); + QString type = item->type; if (!check.expectedName.matches(name, context)) { qDebug() << "INAME : " << iname; qDebug() << "NAME ACTUAL : " << name; @@ -1524,7 +1491,7 @@ void tst_Dumpers::dumper_data() { QTest::addColumn<Data>("data"); - QByteArray fooData = + QString fooData = "#include <QHash>\n" "#include <QMap>\n" "#include <QObject>\n" @@ -1558,7 +1525,7 @@ void tst_Dumpers::dumper_data() " QHash<QObject *, Map::iterator> h;\n" "};\n"; - QByteArray nsData = + QString nsData = "namespace nsA {\n" "namespace nsB {\n" " struct SomeType\n" @@ -1628,21 +1595,25 @@ void tst_Dumpers::dumper_data() + CoreProfile() + Check("ba0", "ba0", "\"\"", "@QByteArray") - + Check("ba1", QByteArray("\"Hello\"World") - + char(0) + char(1) + char(2) + '"', "@QByteArray") + + Check("ba1", Value(QString("\"Hello\"World") + + QChar(0) + QChar(1) + QChar(2) + '"'), "@QByteArray") + Check("ba1.0", "[0]", "72", "char") + Check("ba1.11", "[11]", "0", "char") + Check("ba1.12", "[12]", "1", "char") + Check("ba1.13", "[13]", "2", "char") + CheckType("ba2", "@QByteArray") - + Check("s", '"' + QByteArray(100, 'x') + '"', "@QString") % NoCdbEngine - + Check("s", '"' + QByteArray(100, 'x') + "..." + '"', "@QString") % CdbEngine - + Check("ss", '"' + QByteArray(100, 'c') + '"', "std::string") % NoCdbEngine - + Check("ss", '"' + QByteArray(100, 'c') + "..." + '"', "std::string") % CdbEngine - - + Check("buf1", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray") - + Check("buf2", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray") + + Check("s", Value('"' + QString(100, QChar('x')) + '"'), + "@QString") % NoCdbEngine + + Check("s", Value('"' + QString(100, QChar('x')) + "..." + '"'), + "@QString") % CdbEngine + + Check("ss", Value('"' + QString(100, QChar('c')) + '"'), + "std::string") % NoCdbEngine + + Check("ss", Value('"' + QString(100, QChar('c')) + "..." + '"'), + "std::string") % CdbEngine + + + Check("buf1", Value("\"" + QString(1, QChar(0xee)) + "\""), "@QByteArray") + + Check("buf2", Value("\"" + QString(1, QChar(0xee)) + "\""), "@QByteArray") + Check("buf3", "\"\\ee\"", "@QByteArray") + CheckType("str1", "char *") @@ -1711,9 +1682,9 @@ void tst_Dumpers::dumper_data() Value5("Tue Jan 1 13:15:32 1980 GMT"), "@QDateTime") % NoCdbEngine % Optional(); #ifdef Q_OS_WIN - QByteArray tempDir = "\"C:/Program Files\""; + QString tempDir = "\"C:/Program Files\""; #else - QByteArray tempDir = "\"/tmp\""; + QString tempDir = "\"/tmp\""; #endif QTest::newRow("QDir") << Data("#include <QDir>\n", @@ -2506,7 +2477,7 @@ void tst_Dumpers::dumper_data() + Check("ob2", "\"A Subobject\"", "@QObject"); - QByteArray senderData = + QString senderData = " class Sender : public QObject\n" " {\n" " Q_OBJECT\n" @@ -2773,7 +2744,7 @@ void tst_Dumpers::dumper_data() + Check("s3.0", "[0]", "", "@QPointer<@QObject>") % NoCdbEngine + Check("s3.0", "[0]", "class QPointer<>", "@QPointer<@QObject>") % CdbEngine; - QByteArray sharedData = + QString sharedData = " class EmployeeData : public QSharedData\n" " {\n" " public:\n" @@ -3026,12 +2997,12 @@ void tst_Dumpers::dumper_data() + Check("uuid2", "{fffffffe-fffd-fffc-fbfa-f9f8f7f6f5f4}", "@QUuid"); - QByteArray expected1 = "\"AAA"; - expected1.append(char('\t')); - expected1.append(char('\r')); - expected1.append(char('\n')); - expected1.append(char(0)); - expected1.append(char(1)); + QString expected1 = "\"AAA"; + expected1.append(QChar('\t')); + expected1.append(QChar('\r')); + expected1.append(QChar('\n')); + expected1.append(QChar(0)); + expected1.append(QChar(1)); expected1.append("BBB\""); QChar oUmlaut = QLatin1Char((char)0xf6); @@ -4593,8 +4564,6 @@ void tst_Dumpers::dumper_data() + Check("set1.2", "[2]", "11", "int"); -//namespace noargs { - // class Goo // { // public: @@ -4872,7 +4841,7 @@ void tst_Dumpers::dumper_data() + Check("a1.0.2", "[2]", "2", "double") + Check("a1.2", "[2]", Pointer(), "double [3]") - + Check("a2", "\"abcd" + QByteArray(16, 0) + '"', "char [20]") + + Check("a2", Value("\"abcd" + QString(16, 0) + '"'), "char [20]") + Check("a2.0", "[0]", "97", "char") + Check("a2.3", "[3]", "100", "char"); @@ -5809,7 +5778,7 @@ void tst_Dumpers::dumper_data() + Check("f", "2", "double"); - QByteArray inheritanceData = + QString inheritanceData = "struct Empty {};\n" "struct Data { Data() : a(42) {} int a; };\n" "struct VEmpty {};\n" |