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>
This commit is contained in:
hjk
2016-06-07 17:04:53 +02:00
parent 3333352e3b
commit 726b907cc3
67 changed files with 1993 additions and 2168 deletions

View File

@@ -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):

View File

@@ -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;

View File

@@ -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 &params) cons
void BreakHandler::saveBreakpoints()
{
const QString one = _("1");
QList<QVariant> list;
foreach (TreeItem *n, rootItem()->children()) {
BreakpointItem *b = static_cast<BreakpointItem *>(n);
const BreakpointParameters &params = 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());

View File

@@ -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;

View File

@@ -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;

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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;

View File

@@ -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,
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, &currentFunction, &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

View File

@@ -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,
QString cdbAddBreakpointCommand(const BreakpointParameters &d,
const QList<QPair<QString, QString> > &sourcePathMapping,
BreakpointModelId id = BreakpointModelId(quint16(-1)), bool oneshot = false);
QByteArray cdbClearBreakpointCommand(const BreakpointModelId &id);
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);

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -32,7 +32,6 @@ HEADERS += \
debuggerrunconfigurationaspect.h \
debuggerruncontrol.h \
debuggerstartparameters.h \
debuggerstringutils.h \
debuggerkitconfigwidget.h \
debuggerkitinformation.h \
disassembleragent.h \

View File

@@ -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",

View File

@@ -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();

View File

@@ -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();
}
///////////////////////////////////////////////////////////////////////

View File

@@ -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);

View File

@@ -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:

View File

@@ -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);

View File

@@ -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

View File

@@ -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);
void fromString(const QString &str);
void fromStringMultiple(const QString &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);
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);
QString toString() const;
static QString stringFromResultClass(ResultClass resultClass);
int token;
ResultClass resultClass;
GdbMi data;
QByteArray logStreamOutput;
QByteArray consoleStreamOutput;
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,

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
};

View File

@@ -64,7 +64,7 @@ public:
QPoint mousePosition;
QString expression;
QByteArray iname;
QString iname;
bool isCppEditor;
};

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();
}
}

View File

@@ -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,9 +221,9 @@ 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 "
+ ' ' + tr("This can be caused by a path length limitation "
"in the core file.")
+ _(" ") + tr("Try to specify the binary using the "
+ ' ' + 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));

File diff suppressed because it is too large Load Diff

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
};

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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 &params)
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();
}

View File

@@ -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 &params) 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;

View File

@@ -62,7 +62,7 @@ public:
QWidget *parent;
quint64 startAddress;
QByteArray registerName;
QString registerName;
unsigned flags;
QList<Internal::MemoryMarkup> markup;
QPoint pos;

View File

@@ -134,7 +134,7 @@ void MemoryView::setMarkup(const QList<MemoryMarkup> &m)
*/
RegisterMemoryView::RegisterMemoryView(QWidget *binEditor, quint64 addr,
const QByteArray &regName,
const QString &regName,
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 &registerName, quint64 a)
QString RegisterMemoryView::title(const QString &registerName, 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 &regName)
QList<MemoryMarkup> RegisterMemoryView::registerMarkup(quint64 a, const QString &regName)
{
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

View File

@@ -63,17 +63,17 @@ class RegisterMemoryView : public MemoryView
{
Q_OBJECT
public:
explicit RegisterMemoryView(QWidget *binEditor, quint64 addr, const QByteArray &regName,
explicit RegisterMemoryView(QWidget *binEditor, quint64 addr, const QString &regName,
RegisterHandler *rh, QWidget *parent = 0);
static QList<MemoryMarkup> registerMarkup(quint64 a, const QByteArray &regName);
static QString title(const QByteArray &registerName, quint64 a = 0);
static QList<MemoryMarkup> registerMarkup(quint64 a, const QString &regName);
static QString title(const QString &registerName, 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;
};

View File

@@ -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"];

View File

@@ -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;
};

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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,7 +1237,7 @@ 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,
@@ -1247,19 +1245,19 @@ void QmlEngine::logServiceStateChange(const QString &service, float version,
{
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();
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 = QByteArray("script");
objectData.value = dataMap.value(_(NAME));
} 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,12 +1918,12 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
const BreakpointParameters &params = bp.parameters();
clearBreakpoint(v8Id);
setBreakpoint(QString(_(SCRIPTREGEXP)),
setBreakpoint(SCRIPTREGEXP,
params.fileName,
params.enabled,
params.lineNumber,
newColumn,
QString(QString::fromLatin1(params.condition)),
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()

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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 &reg = 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;

View File

@@ -79,8 +79,8 @@ 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,
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;
@@ -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 &reg);
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;
};

View File

@@ -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));

View File

@@ -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();

View File

@@ -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)
};

View File

@@ -89,7 +89,7 @@ struct ThreadData
// Permanent data.
ThreadId id;
QByteArray groupId;
QString groupId;
QString targetId;
QString core;
bool stopped;

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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,7 +87,7 @@ 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;
@@ -95,20 +95,20 @@ public:
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

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)

View File

@@ -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("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", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
+ Check("buf2", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
+ 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"