forked from qt-creator/qt-creator
Debugger: Fix build with Qt6
QStringRef gone. ViewOptions changed. MetaType register stream operators automatically. Task-number: QTCREATORBUG-24098 Change-Id: Ibf98561af951aa5fc4ec483d18dafeaad02e07c3 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -137,7 +137,7 @@ void BreakpointParameters::updateLocation(const QString &location)
|
||||
{
|
||||
if (!location.isEmpty()) {
|
||||
int pos = location.indexOf(':');
|
||||
lineNumber = location.midRef(pos + 1).toInt();
|
||||
lineNumber = location.mid(pos + 1).toInt();
|
||||
QString file = location.left(pos);
|
||||
if (file.startsWith('"') && file.endsWith('"'))
|
||||
file = file.mid(1, file.size() - 2);
|
||||
@@ -156,9 +156,9 @@ bool BreakpointParameters::isQmlFileAndLineBreakpoint() const
|
||||
if (qmlExtensionString.isEmpty())
|
||||
qmlExtensionString = ".qml;.js";
|
||||
|
||||
const auto qmlFileExtensions = qmlExtensionString.splitRef(';', Qt::SkipEmptyParts);
|
||||
const auto qmlFileExtensions = qmlExtensionString.split(';', Qt::SkipEmptyParts);
|
||||
const QString file = fileName.toString();
|
||||
for (const QStringRef &extension : qmlFileExtensions) {
|
||||
for (const QString &extension : qmlFileExtensions) {
|
||||
if (file.endsWith(extension, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt)
|
||||
QString what = bkpt["what"].data();
|
||||
if (what.startsWith("*0x")) {
|
||||
type = WatchpointAtAddress;
|
||||
address = what.midRef(1).toULongLong(nullptr, 0);
|
||||
address = what.mid(1).toULongLong(nullptr, 0);
|
||||
} else {
|
||||
type = WatchpointAtExpression;
|
||||
expression = what;
|
||||
|
@@ -1026,20 +1026,19 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd)
|
||||
// Post an extension command producing one-line output with a callback,
|
||||
// pass along token for identification in hash.
|
||||
const QString prefix = m_extensionCommandPrefix + dbgCmd.function;
|
||||
QList<QStringRef> splittedArguments;
|
||||
if (dbgCmd.args.isString()) {
|
||||
const QString &arguments = dbgCmd.argsToString();
|
||||
cmd = prefix + arguments;
|
||||
int argumentSplitPos = 0;
|
||||
QList<QStringRef> splittedArguments;
|
||||
QList<QStringView> splittedArguments;
|
||||
int maxArgumentSize = maxCommandLength - prefix.length() - maxTokenLength;
|
||||
while (argumentSplitPos < arguments.size()) {
|
||||
splittedArguments << arguments.midRef(argumentSplitPos, maxArgumentSize);
|
||||
splittedArguments << Utils::midView(arguments, argumentSplitPos, maxArgumentSize);
|
||||
argumentSplitPos += splittedArguments.last().length();
|
||||
}
|
||||
QTC_CHECK(argumentSplitPos == arguments.size());
|
||||
int tokenPart = splittedArguments.size();
|
||||
for (const QStringRef &part : qAsConst(splittedArguments))
|
||||
for (const QStringView &part : qAsConst(splittedArguments))
|
||||
str << prefix << " -t " << token << '.' << --tokenPart << ' ' << part << '\n';
|
||||
} else {
|
||||
cmd = prefix;
|
||||
@@ -1961,8 +1960,8 @@ void CdbEngine::ensureUsing32BitStackInWow64(const DebuggerResponse &response, c
|
||||
{
|
||||
// Parsing the header of the stack output to check which bitness
|
||||
// the cdb is currently using.
|
||||
const QVector<QStringRef> lines = response.data.data().splitRef('\n');
|
||||
for (const QStringRef &line : lines) {
|
||||
const QStringList lines = response.data.data().split('\n');
|
||||
for (const QString &line : lines) {
|
||||
if (!line.startsWith("Child"))
|
||||
continue;
|
||||
if (line.startsWith("ChildEBP")) {
|
||||
@@ -2238,7 +2237,7 @@ static inline bool checkCommandToken(const QString &tokenPrefix, const QString &
|
||||
if (!c.startsWith(tokenPrefix))
|
||||
return false;
|
||||
bool ok;
|
||||
*token = c.midRef(tokenPrefixSize, size - tokenPrefixSize - 1).toInt(&ok);
|
||||
*token = c.mid(tokenPrefixSize, size - tokenPrefixSize - 1).toInt(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -2259,19 +2258,21 @@ void CdbEngine::parseOutputLine(QString line)
|
||||
const int tokenPos = creatorExtPrefix.size() + 2;
|
||||
const int tokenEndPos = line.indexOf('|', tokenPos);
|
||||
QTC_ASSERT(tokenEndPos != -1, return);
|
||||
const int token = line.midRef(tokenPos, tokenEndPos - tokenPos).toInt();
|
||||
const int token = line.mid(tokenPos, tokenEndPos - tokenPos).toInt();
|
||||
// remainingChunks
|
||||
const int remainingChunksPos = tokenEndPos + 1;
|
||||
const int remainingChunksEndPos = line.indexOf('|', remainingChunksPos);
|
||||
QTC_ASSERT(remainingChunksEndPos != -1, return);
|
||||
const int remainingChunks = line.midRef(remainingChunksPos, remainingChunksEndPos - remainingChunksPos).toInt();
|
||||
const int remainingChunks = line.mid(remainingChunksPos,
|
||||
remainingChunksEndPos - remainingChunksPos)
|
||||
.toInt();
|
||||
// const char 'serviceName'
|
||||
const int whatPos = remainingChunksEndPos + 1;
|
||||
const int whatEndPos = line.indexOf('|', whatPos);
|
||||
QTC_ASSERT(whatEndPos != -1, return);
|
||||
const QString what = line.mid(whatPos, whatEndPos - whatPos);
|
||||
// Build up buffer, call handler once last chunk was encountered
|
||||
m_extensionMessageBuffer += line.midRef(whatEndPos + 1);
|
||||
m_extensionMessageBuffer += line.mid(whatEndPos + 1);
|
||||
if (remainingChunks == 0) {
|
||||
handleExtensionMessage(type, token, what, m_extensionMessageBuffer);
|
||||
m_extensionMessageBuffer.clear();
|
||||
@@ -2742,7 +2743,7 @@ void CdbEngine::setupScripting(const DebuggerResponse &response)
|
||||
|
||||
const QString &verOutput = data.childAt(0).data();
|
||||
const QString firstToken = verOutput.split(' ').constFirst();
|
||||
const QVector<QStringRef> pythonVersion = firstToken.splitRef('.');
|
||||
const QStringList pythonVersion = firstToken.split('.');
|
||||
|
||||
bool ok = false;
|
||||
if (pythonVersion.size() == 3) {
|
||||
@@ -2849,7 +2850,7 @@ void CdbEngine::handleWidgetAt(const DebuggerResponse &response)
|
||||
break;
|
||||
}
|
||||
// 0x000 -> nothing found
|
||||
if (!watchExp.midRef(sepPos + 1).toULongLong(nullptr, 0)) {
|
||||
if (!watchExp.mid(sepPos + 1).toULongLong(nullptr, 0)) {
|
||||
message = QString("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY);
|
||||
break;
|
||||
}
|
||||
|
@@ -42,7 +42,11 @@ public:
|
||||
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; }
|
||||
StringInputStream &operator<<(const QStringRef &a) { m_target.append(a); return *this; }
|
||||
StringInputStream &operator<<(const QStringView &a)
|
||||
{
|
||||
m_target.append(a.toString());
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringInputStream &operator<<(int i) { appendInt(i); return *this; }
|
||||
StringInputStream &operator<<(unsigned i) { appendInt(i); return *this; }
|
||||
|
@@ -104,8 +104,13 @@ void ConsoleView::mousePressEvent(QMouseEvent *event)
|
||||
bool handled = false;
|
||||
if (type == ConsoleItem::DefaultType) {
|
||||
bool showTypeIcon = index.parent() == QModelIndex();
|
||||
ConsoleItemPositions positions(m_model, visualRect(index), viewOptions().font, showTypeIcon,
|
||||
true);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
const QStyleOptionViewItem option = viewOptions();
|
||||
#else
|
||||
QStyleOptionViewItem option;
|
||||
initViewItemOption(&option);
|
||||
#endif
|
||||
ConsoleItemPositions positions(m_model, visualRect(index), option.font, showTypeIcon, true);
|
||||
|
||||
if (positions.expandCollapseIcon().contains(pos)) {
|
||||
if (isExpanded(index))
|
||||
|
@@ -2128,7 +2128,9 @@ DebuggerPlugin::DebuggerPlugin()
|
||||
m_instance = this;
|
||||
|
||||
qRegisterMetaType<PerspectiveState>("Utils::PerspectiveState");
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
qRegisterMetaTypeStreamOperators<PerspectiveState>("Utils::PerspectiveState");
|
||||
#endif
|
||||
}
|
||||
|
||||
DebuggerPlugin::~DebuggerPlugin()
|
||||
|
@@ -657,7 +657,7 @@ QString decodeData(const QString &ba, const QString &encoding)
|
||||
case DebuggerEncoding::JulianDateAndMillisecondsSinceMidnight: {
|
||||
const int p = ba.indexOf('/');
|
||||
const QDate date = dateFromData(ba.left(p).toInt());
|
||||
const QTime time = timeFromData(ba.midRef(p + 1 ).toInt());
|
||||
const QTime time = timeFromData(ba.mid(p + 1).toInt());
|
||||
const QDateTime dateTime = QDateTime(date, time);
|
||||
return dateTime.isValid() ? dateTime.toString(Qt::TextDate) : "(invalid)";
|
||||
}
|
||||
@@ -698,15 +698,15 @@ QString decodeData(const QString &ba, const QString &encoding)
|
||||
|
||||
qint64 msecs = ba.left(p0).toLongLong();
|
||||
++p0;
|
||||
Qt::TimeSpec spec = Qt::TimeSpec(ba.midRef(p0, p1 - p0).toInt());
|
||||
Qt::TimeSpec spec = Qt::TimeSpec(ba.mid(p0, p1 - p0).toInt());
|
||||
++p1;
|
||||
qulonglong offset = ba.midRef(p1, p2 - p1).toInt();
|
||||
qulonglong offset = ba.mid(p1, p2 - p1).toInt();
|
||||
++p2;
|
||||
QByteArray timeZoneId = QByteArray::fromHex(ba.mid(p2, p3 - p2).toUtf8());
|
||||
++p3;
|
||||
int status = ba.midRef(p3, p4 - p3).toInt();
|
||||
int status = ba.mid(p3, p4 - p3).toInt();
|
||||
++p4;
|
||||
int tiVersion = ba.midRef(p4).toInt();
|
||||
int tiVersion = ba.mid(p4).toInt();
|
||||
|
||||
QDate date;
|
||||
QTime time;
|
||||
@@ -861,9 +861,9 @@ QString DebuggerCommand::argsToString() const
|
||||
|
||||
DebuggerEncoding::DebuggerEncoding(const QString &data)
|
||||
{
|
||||
const QVector<QStringRef> l = data.splitRef(':');
|
||||
const QStringList l = data.split(':');
|
||||
|
||||
const QStringRef &t = l.at(0);
|
||||
const QString &t = l.at(0);
|
||||
if (t == "latin1") {
|
||||
type = HexEncodedLatin1;
|
||||
size = 1;
|
||||
|
@@ -940,9 +940,9 @@ void DebuggerToolTipHolder::positionShow(const TextEditorWidget *editorWidget)
|
||||
//// Parse a 'yyyyMMdd' date
|
||||
static QDate dateFromString(const QString &date)
|
||||
{
|
||||
return date.size() == 8 ?
|
||||
QDate(date.leftRef(4).toInt(), date.midRef(4, 2).toInt(), date.midRef(6, 2).toInt()) :
|
||||
QDate();
|
||||
return date.size() == 8
|
||||
? QDate(date.left(4).toInt(), date.mid(4, 2).toInt(), date.mid(6, 2).toInt())
|
||||
: QDate();
|
||||
}
|
||||
|
||||
void DebuggerToolTipHolder::saveSessionData(QXmlStreamWriter &w) const
|
||||
|
@@ -46,7 +46,7 @@ void DisassemblerLine::fromString(const QString &unparsed)
|
||||
|
||||
// Mac gdb has an overflow reporting 64bit addresses causing the instruction
|
||||
// to follow the last digit "0x000000013fff4810mov 1,1". Truncate here.
|
||||
if (pos > 19 && unparsed.midRef(3, 16).toULongLong())
|
||||
if (pos > 19 && unparsed.mid(3, 16).toULongLong())
|
||||
pos = 19;
|
||||
|
||||
QString addr = unparsed.left(pos);
|
||||
@@ -190,7 +190,7 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed)
|
||||
}
|
||||
dl.address = address.left(pos1 - 1).toULongLong(nullptr, 0);
|
||||
dl.function = m_lastFunction;
|
||||
dl.offset = address.midRef(pos2).toUInt();
|
||||
dl.offset = address.mid(pos2).toUInt();
|
||||
} else {
|
||||
// Plain data like "0x0000cd64:\tadd\tlr, pc, lr\n"
|
||||
dl.address = address.toULongLong(nullptr, 0);
|
||||
|
@@ -178,7 +178,7 @@ static QString msgWinException(const QString &data, unsigned *exCodeIn = nullptr
|
||||
const int addressPos = blankPos != -1 ? data.indexOf("0x", blankPos + 1) : -1;
|
||||
if (addressPos < 0)
|
||||
return GdbEngine::tr("An exception was triggered.");
|
||||
const unsigned exCode = data.midRef(exCodePos, blankPos - exCodePos).toUInt(nullptr, 0);
|
||||
const unsigned exCode = data.mid(exCodePos, blankPos - exCodePos).toUInt(nullptr, 0);
|
||||
if (exCodeIn)
|
||||
*exCodeIn = exCode;
|
||||
const quint64 address = data.mid(addressPos).trimmed().toULongLong(nullptr, 0);
|
||||
@@ -1388,7 +1388,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
|
||||
const GdbMi wpt = data["wpt"];
|
||||
const QString rid = wpt["number"].data();
|
||||
const Breakpoint bp = breakHandler()->findBreakpointByResponseId(rid);
|
||||
const quint64 bpAddress = wpt["exp"].data().midRef(1).toULongLong(nullptr, 0);
|
||||
const quint64 bpAddress = wpt["exp"].data().mid(1).toULongLong(nullptr, 0);
|
||||
QString msg;
|
||||
if (bp) {
|
||||
if (bp->type() == WatchpointAtExpression)
|
||||
@@ -2149,7 +2149,7 @@ void GdbEngine::handleWatchInsert(const DebuggerResponse &response, const Breakp
|
||||
bp->setResponseId(wpt["number"].data());
|
||||
QString exp = wpt["exp"].data();
|
||||
if (exp.startsWith('*'))
|
||||
bp->setAddress(exp.midRef(1).toULongLong(nullptr, 0));
|
||||
bp->setAddress(exp.mid(1).toULongLong(nullptr, 0));
|
||||
QTC_CHECK(!bp->needsChange());
|
||||
notifyBreakpointInsertOk(bp);
|
||||
} else if (ba.startsWith("Hardware watchpoint ")
|
||||
@@ -2160,7 +2160,7 @@ void GdbEngine::handleWatchInsert(const DebuggerResponse &response, const Breakp
|
||||
const QString address = ba.mid(end + 2).trimmed();
|
||||
bp->setResponseId(ba.mid(begin, end - begin));
|
||||
if (address.startsWith('*'))
|
||||
bp->setAddress(address.midRef(1).toULongLong(nullptr, 0));
|
||||
bp->setAddress(address.mid(1).toULongLong(nullptr, 0));
|
||||
QTC_CHECK(!bp->needsChange());
|
||||
notifyBreakpointInsertOk(bp);
|
||||
} else {
|
||||
@@ -3189,14 +3189,14 @@ void GdbEngine::handleRegisterListing(const DebuggerResponse &response)
|
||||
m_registers.clear();
|
||||
QStringList lines = response.consoleStreamOutput.split('\n');
|
||||
for (int i = 1; i < lines.size(); ++i) {
|
||||
const QVector<QStringRef> parts = lines.at(i).splitRef(' ', Qt::SkipEmptyParts);
|
||||
const QStringList parts = lines.at(i).split(' ', Qt::SkipEmptyParts);
|
||||
if (parts.size() < 7)
|
||||
continue;
|
||||
int gdbRegisterNumber = parts.at(1).toInt();
|
||||
Register reg;
|
||||
reg.name = parts.at(0).toString();
|
||||
reg.name = parts.at(0);
|
||||
reg.size = parts.at(4).toInt();
|
||||
reg.reportedType = parts.at(5).toString();
|
||||
reg.reportedType = parts.at(5);
|
||||
m_registers[gdbRegisterNumber] = reg;
|
||||
}
|
||||
}
|
||||
@@ -3587,7 +3587,7 @@ void GdbEngine::setupEngine()
|
||||
}
|
||||
|
||||
const QString tests = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_TESTS"));
|
||||
foreach (const QStringRef &test, tests.splitRef(','))
|
||||
foreach (const QString &test, tests.split(','))
|
||||
m_testCases.insert(test.toInt());
|
||||
foreach (int test, m_testCases)
|
||||
showMessage("ENABLING TEST CASE: " + QString::number(test));
|
||||
|
@@ -536,14 +536,14 @@ void LogWindow::showOutput(int channel, const QString &output)
|
||||
const int npos = output.indexOf(nchar, pos);
|
||||
const int nnpos = npos == -1 ? n : npos;
|
||||
const int l = nnpos - pos;
|
||||
if (l != 6 || output.midRef(pos, 6) != "(gdb) ") {
|
||||
if (l != 6 || QStringView(output).mid(pos, 6) != QLatin1String("(gdb) ")) {
|
||||
out.append(cchar);
|
||||
if (l > 30000) {
|
||||
// FIXME: QTextEdit asserts on really long lines...
|
||||
out.append(output.midRef(pos, 30000));
|
||||
out.append(output.mid(pos, 30000));
|
||||
out.append(" [...] <cut off>\n");
|
||||
} else {
|
||||
out.append(output.midRef(pos, l + 1));
|
||||
out.append(output.mid(pos, l + 1));
|
||||
}
|
||||
}
|
||||
pos = nnpos + 1;
|
||||
|
@@ -499,7 +499,7 @@ void PdbEngine::handleOutput2(const QString &data)
|
||||
QTC_ASSERT(pos2 != -1, continue);
|
||||
const Utils::FilePath fileName = Utils::FilePath::fromString(
|
||||
line.mid(pos1 + 4, pos2 - pos1 - 4));
|
||||
const int lineNumber = line.midRef(pos2 + 1).toInt();
|
||||
const int lineNumber = line.mid(pos2 + 1).toInt();
|
||||
const Breakpoint bp = Utils::findOrDefault(breakHandler()->breakpoints(), [&](const Breakpoint &bp) {
|
||||
return bp->parameters().isLocatedAt(fileName, lineNumber, bp->markerFileName())
|
||||
|| bp->requestedParameters().isLocatedAt(fileName, lineNumber, bp->markerFileName());
|
||||
|
@@ -440,7 +440,7 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec
|
||||
const int firstIndex = int(strlen("inspect"));
|
||||
const int secondIndex = iname.indexOf('.', firstIndex + 1);
|
||||
if (secondIndex != -1)
|
||||
engineId = iname.midRef(firstIndex + 1, secondIndex - firstIndex - 1).toInt();
|
||||
engineId = iname.mid(firstIndex + 1, secondIndex - firstIndex - 1).toInt();
|
||||
}
|
||||
|
||||
// Still not found? Maybe we're loading the engine itself.
|
||||
@@ -465,7 +465,7 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec
|
||||
int lastIndex = iname.lastIndexOf('.');
|
||||
int secondLastIndex = iname.lastIndexOf('.', lastIndex - 1);
|
||||
if (secondLastIndex != WatchItem::InvalidId)
|
||||
parentId = iname.midRef(secondLastIndex + 1, lastIndex - secondLastIndex - 1).toInt();
|
||||
parentId = iname.mid(secondLastIndex + 1, lastIndex - secondLastIndex - 1).toInt();
|
||||
else
|
||||
parentId = engineId;
|
||||
} else {
|
||||
|
@@ -325,7 +325,7 @@ ContextData getLocationContext(TextDocument *document, int lineNumber)
|
||||
if (!fileName.isEmpty()) {
|
||||
// Possibly one of the "27 [1] foo = x" lines
|
||||
int pos = line.indexOf('[');
|
||||
int ln = line.leftRef(pos - 1).toInt();
|
||||
int ln = line.left(pos - 1).toInt();
|
||||
if (ln > 0) {
|
||||
data.type = LocationByFile;
|
||||
data.fileName = Utils::FilePath::fromString(fileName);
|
||||
|
@@ -2685,7 +2685,7 @@ void WatchHandler::addDumpers(const GdbMi &dumpers)
|
||||
DisplayFormats formats;
|
||||
formats.append(RawFormat);
|
||||
QString reportedFormats = dumper["formats"].data();
|
||||
foreach (const QStringRef &format, reportedFormats.splitRef(',')) {
|
||||
foreach (const QString &format, reportedFormats.split(',')) {
|
||||
if (int f = format.toInt())
|
||||
formats.append(DisplayFormat(f));
|
||||
}
|
||||
|
Reference in New Issue
Block a user