Commit 436a0ffe authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger[CDB]: Fix expanding arrays.

Strip '[', ']' off inames in coreengine so
that the name lookup for them works.
Handle 64bit-addresses in .dvalloc-output
parsing for dumpers. Some debug formatting.

Task-number: QTCREATORBUG-1216
parent 5a659e14
......@@ -218,7 +218,7 @@ static inline void fixDumperResult(const WatchData &source,
// classes (see note in its header documentation).
bool WatchHandleDumperInserter::expandPointerToDumpable(const WatchData &wd, QString *errorMessage)
{
if (debugCDBWatchHandling)
if (debugCDBWatchHandling > 1)
qDebug() << ">expandPointerToDumpable" << wd.toString();
bool handled = false;
......@@ -252,7 +252,7 @@ bool WatchHandleDumperInserter::expandPointerToDumpable(const WatchData &wd, QSt
m_wh->insertBulkData(m_dumperResult);
handled = true;
} while (false);
if (debugCDBWatchHandling)
if (debugCDBWatchHandling > 1)
qDebug() << "<expandPointerToDumpable returns " << handled << *errorMessage;
return handled;
}
......@@ -368,14 +368,6 @@ unsigned CdbSymbolGroupContext::watchDataAt(unsigned long index, WatchData *wd)
const unsigned rc = dumpValue(index, &iname, &(wd->name), &address,
&typeId, &type, &value);
wd->exp = wd->iname = iname.toLatin1();
// Trigger numeric sorting for arrays "local.[22]" -> "local.22"
if (wd->iname.endsWith(']')) {
const int openingBracketPos = wd->iname.lastIndexOf('[');
if (openingBracketPos != -1) {
wd->iname.truncate(wd->iname.size() - 1);
wd->iname.remove(openingBracketPos, 1);
}
}
wd->setAddress(("0x") + QByteArray::number(address, 16));
wd->setType(type, false);
if (rc & OutOfScope) {
......@@ -396,8 +388,7 @@ unsigned CdbSymbolGroupContext::watchDataAt(unsigned long index, WatchData *wd)
bool CdbSymbolGroupContext::populateModelInitially(WatchHandler *wh, QString *errorMessage)
{
if (debugCDBWatchHandling)
qDebug() << "populateModelInitially dumpers=" << m_useDumpers
<< toString();
qDebug() << ">populateModelInitially dumpers=" << m_useDumpers;
// Recurse down items that are initially expanded in the view, stop processing for
// dumper items.
const CdbSymbolGroupRecursionContext rctx(this, OwnerSymbolGroupDumper);
......@@ -412,6 +403,8 @@ bool CdbSymbolGroupContext::populateModelInitially(WatchHandler *wh, QString *er
WatchHandlerExpandedPredicate(wh),
falsePredicate,
errorMessage);
if (debugCDBWatchHandling)
qDebug("<populateModelInitially\n%s\n", qPrintable(toString()));
return rc;
}
......@@ -420,7 +413,9 @@ bool CdbSymbolGroupContext::completeData(const WatchData &incompleteLocal,
QString *errorMessage)
{
if (debugCDBWatchHandling)
qDebug() << ">completeData src=" << incompleteLocal.source << incompleteLocal.toString();
qDebug(">completeData src=%d %s\n%s\n",
incompleteLocal.source, qPrintable(incompleteLocal.toString()),
qPrintable(toString()));
const CdbSymbolGroupRecursionContext rctx(this, OwnerSymbolGroupDumper);
// Expand symbol group items, recurse one level from desired item
......
......@@ -30,6 +30,7 @@
#include "coreengine.h"
#include "debugeventcallbackbase.h"
#include "debugoutputbase.h"
#include "symbolgroupcontext.h"
#include <utils/winutils.h>
#include <utils/abstractprocess.h>
......@@ -725,9 +726,9 @@ bool CoreEngine::endSession(QString *appendableErrorMessage)
return true;
}
bool CoreEngine::allocDebuggeeMemory(int size, ULONG64 *address, QString *errorMessage)
bool CoreEngine::allocDebuggeeMemory(int size, ULONG64 *addressPtr, QString *errorMessage)
{
*address = 0;
*addressPtr = 0;
const QString allocCmd = QLatin1String(".dvalloc ") + QString::number(size);
QSharedPointer<StringOutputHandler> outputHandler(new StringOutputHandler);
......@@ -735,22 +736,20 @@ bool CoreEngine::allocDebuggeeMemory(int size, ULONG64 *address, QString *errorM
Q_UNUSED(redir)
if (!executeDebuggerCommand(allocCmd, errorMessage))
return false;
// "Allocated 1000 bytes starting at 003a0000" .. hopefully never localized
bool ok = false;
const QString output = outputHandler->result();
// "Allocated 1000 bytes starting at 003a0000" or
// "Allocated 1000 bytes starting at 00000000'000023ab" (64bit) / hopefully never localized
const QString output = outputHandler->result().trimmed();
const int lastBlank = output.lastIndexOf(QLatin1Char(' '));
if (lastBlank != -1) {
const qint64 addri = output.mid(lastBlank + 1).toLongLong(&ok, 16);
if (ok)
*address = addri;
}
if (debug > 1)
qDebug() << Q_FUNC_INFO << '\n' << output << *address << ok;
if (!ok) {
*errorMessage = QString::fromLatin1("Failed to parse output '%1'").arg(output);
return false;
}
return true;
const QString hexNumberS = QLatin1String("0x") + output.mid(lastBlank + 1);
quint64 address;
if (SymbolGroupContext::getUnsignedHexValue(hexNumberS, &address)) {
*addressPtr = address;
return true;
}
} // blank
*errorMessage = QString::fromLatin1("Failed to parse output '%1'").arg(output);
return false;
}
// Alloc an AscII string in debuggee
......
......@@ -229,6 +229,12 @@ void SymbolGroupContext::populateINameIndexMap(const QString &prefix, unsigned l
symbolName = QLatin1String("<unnamed");
symbolName += QString::number(m_unnamedSymbolNumber++);
symbolName += QLatin1Char('>');
} else {
// Trigger numeric sorting for arrays "local.[22]" -> "local.22"
if (symbolName.startsWith(QLatin1Char('[')) && symbolName.endsWith(QLatin1Char(']'))) {
symbolName.truncate(symbolName.size() - 1);
symbolName.remove(0, 1);
}
}
// Find a unique name in case the variable is shadowed by
// an existing one
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment