debugger: refactoring, use QByteArray instead of QString when appropriate

This commit is contained in:
hjk
2010-01-05 16:51:55 +01:00
parent 84e2e8933d
commit e3712f9687
22 changed files with 497 additions and 470 deletions

View File

@@ -139,7 +139,7 @@ public:
}
}
}
m_data->lineNumber = QString::number(lineNumber);
m_data->lineNumber = QByteArray::number(lineNumber);
m_data->handler()->updateMarkers();
}
@@ -386,13 +386,13 @@ void BreakHandler::loadBreakpoints()
data->fileName = v.toString();
v = map.value(QLatin1String("linenumber"));
if (v.isValid())
data->lineNumber = v.toString();
data->lineNumber = v.toString().toLatin1();
v = map.value(QLatin1String("condition"));
if (v.isValid())
data->condition = v.toString();
data->condition = v.toString().toLatin1();
v = map.value(QLatin1String("ignorecount"));
if (v.isValid())
data->ignoreCount = v.toInt();
data->ignoreCount = v.toString().toLatin1();
v = map.value(QLatin1String("funcname"));
if (v.isValid())
data->funcName = v.toString();
@@ -561,7 +561,7 @@ bool BreakHandler::setData(const QModelIndex &mi, const QVariant &value, int rol
case 4: {
QString val = value.toString();
if (val != data->condition) {
data->condition = val;
data->condition = val.toLatin1();
dataChanged(mi, mi);
}
return true;
@@ -569,7 +569,7 @@ bool BreakHandler::setData(const QModelIndex &mi, const QVariant &value, int rol
case 5: {
QString val = value.toString();
if (val != data->ignoreCount) {
data->ignoreCount = val;
data->ignoreCount = val.toLatin1();
dataChanged(mi, mi);
}
return true;
@@ -660,7 +660,7 @@ void BreakHandler::setBreakpoint(const QString &fileName, int lineNumber)
BreakpointData *data = new BreakpointData(this);
data->fileName = fileName;
data->lineNumber = QString::number(lineNumber);
data->lineNumber = QByteArray::number(lineNumber);
data->pending = true;
data->markerFileName = fileName;
data->markerLineNumber = lineNumber;

View File

@@ -77,18 +77,18 @@ public:
// this "user requested information". will get stored in the session
QString fileName; // short name of source file
QString condition; // condition associated with breakpoint
QString ignoreCount; // ignore count associated with breakpoint
QString lineNumber; // line in source file
QByteArray condition; // condition associated with breakpoint
QByteArray ignoreCount; // ignore count associated with breakpoint
QByteArray lineNumber; // line in source file
QString funcName; // name of containing function
bool useFullPath; // should we use the full path when setting the bp?
// this is what gdb produced in response
QString bpNumber; // breakpoint number assigned by the debugger engine
QString bpCondition; // condition acknowledged by the debugger engine
QString bpIgnoreCount; // ignore count acknowledged by the debugger engine
QByteArray bpNumber; // breakpoint number assigned by the debugger engine
QByteArray bpCondition; // condition acknowledged by the debugger engine
QByteArray bpIgnoreCount;// ignore count acknowledged by the debugger engine
QString bpFileName; // file name acknowledged by the debugger engine
QString bpLineNumber; // line number acknowledged by the debugger engine
QByteArray bpLineNumber; // line number acknowledged by the debugger engine
QString bpFuncName; // function name acknowledged by the debugger engine
QString bpAddress; // address acknowledged by the debugger engine
bool bpMultiple; // happens in constructors/gdb

View File

@@ -84,7 +84,7 @@ bool getRegisters(CIDebugControl *ctl,
return false;
}
Register reg;
reg.name = QString::fromUtf16(reinterpret_cast<const ushort *>(wszBuf));
reg.name = QString::fromUtf16(reinterpret_cast<const ushort *>(wszBuf)).toLatin1();
registers->push_back(reg);
}
// get values

View File

@@ -564,7 +564,7 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl,
handler->takeInsertedBreakPoint(nbd);
updateMarkers = true;
nbd->pending = false;
nbd->bpNumber = QString::number(id);
nbd->bpNumber = QByteArray::number(uint(id));
nbd->bpAddress = QLatin1String("0x") + QString::number(address, 16);
// Take over rest as is
nbd->bpCondition = nbd->condition;

View File

@@ -985,7 +985,7 @@ void CdbDebugEngine::updateWatchData(const WatchData &incomplete)
qDebug() << Q_FUNC_INFO << "\n " << incomplete.toString();
WatchHandler *watchHandler = manager()->watchHandler();
if (incomplete.iname.startsWith(QLatin1String("watch."))) {
if (incomplete.iname.startsWith("watch.")) {
WatchData watchData = incomplete;
evaluateWatcher(&watchData);
watchHandler->insertData(watchData);
@@ -1311,7 +1311,7 @@ void CdbDebugEngine::assignValueInDebugger(const QString &expr, const QString &v
break;
// Update view
WatchHandler *watchHandler = manager()->watchHandler();
if (WatchData *fwd = watchHandler->findItem(expr)) {
if (WatchData *fwd = watchHandler->findItem(expr.toLatin1())) {
fwd->setValue(newValue);
watchHandler->insertData(*fwd);
watchHandler->updateWatchers();

View File

@@ -230,7 +230,7 @@ bool WatchHandleDumperInserter::expandPointerToDumpable(const WatchData &wd, QSt
derefedWd.setType(type);
derefedWd.setAddress(hexAddrS);
derefedWd.name = QString(QLatin1Char('*'));
derefedWd.iname = wd.iname + QLatin1String(".*");
derefedWd.iname = wd.iname + ".*";
derefedWd.source = OwnerDumper | CdbStackFrameContext::ChildrenKnownBit;
const CdbDumperHelper::DumpResult dr = m_dumper->dumpType(derefedWd, true, &m_dumperResult, errorMessage);
if (dr != CdbDumperHelper::DumpOk)

View File

@@ -470,11 +470,11 @@ static inline QString fixValue(const QString &value, const QString &type)
WatchData CdbSymbolGroupContext::watchDataAt(unsigned long index) const
{
WatchData wd;
wd.iname = symbolINameAt(index);
wd.iname = symbolINameAt(index).toLatin1();
wd.exp = wd.iname;
// Determine name from iname and format shadowed variables correctly
// as "<shadowed X>, see populateINameIndexMap().
const int lastDelimiterPos = wd.iname.lastIndexOf(m_nameDelimiter);
const int lastDelimiterPos = wd.iname.lastIndexOf(m_nameDelimiter.toLatin1());
QString name = lastDelimiterPos == -1 ? wd.iname : wd.iname.mid(lastDelimiterPos + 1);
int shadowedNumber = 0;
const int shadowedPos = name.lastIndexOf(QLatin1Char(iNameShadowDelimiter));
@@ -486,7 +486,7 @@ WatchData CdbSymbolGroupContext::watchDataAt(unsigned long index) const
// (std::map extends std::tree<>... Remove them for display only.
const QString fullShadowedName = WatchData::shadowedName(name, shadowedNumber);
wd.name = WatchData::shadowedName(removeInnerTemplateType(name), shadowedNumber);
wd.addr = hexSymbolOffset(m_symbolGroup, index);
wd.addr = hexSymbolOffset(m_symbolGroup, index).toLatin1();
const QString type = getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolTypeNameWide, index);
wd.setType(type);
// Check for unitialized variables at level 0 only.

View File

@@ -137,7 +137,7 @@ bool insertSymbolRecursion(WatchData wd,
return false;
} else {
const QString msg = QString::fromLatin1("WARNING: Skipping invalid child symbol #%2 (type %3) of '%4'.").
arg(QLatin1String(Q_FUNC_INFO)).arg(c).arg(cwd.type, wd.iname);
arg(QLatin1String(Q_FUNC_INFO)).arg(c).arg(cwd.type, QString::fromLatin1(wd.iname));
qWarning("%s\n", qPrintable(msg));
}
}

View File

@@ -70,7 +70,7 @@ void AttachGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
const qint64 pid = startParameters().attachPID;
m_engine->postCommand(_("attach %1").arg(pid), CB(handleAttach));
m_engine->postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
// Task 254674 does not want to remove them
//qq->breakHandler()->removeAllBreakpoints();
}

View File

@@ -97,8 +97,9 @@ void CoreGdbAdapter::loadExeAndSyms()
{
// Do that first, otherwise no symbols are loaded.
QFileInfo fi(m_executable);
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
QByteArray path = fi.absoluteFilePath().toLocal8Bit();
m_engine->postCommand("-file-exec-and-symbols \"" + path + '"',
CB(handleFileExecAndSymbols));
}
void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
@@ -118,8 +119,8 @@ void CoreGdbAdapter::loadCoreFile()
{
// Quoting core name below fails in gdb 6.8-debian.
QFileInfo fi(startParameters().coreFile);
QString coreName = fi.absoluteFilePath();
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore));
QByteArray coreName = fi.absoluteFilePath().toLocal8Bit();
m_engine->postCommand("target core " + coreName, CB(handleTargetCore));
}
void CoreGdbAdapter::handleTargetCore(const GdbResponse &response)
@@ -144,7 +145,7 @@ void CoreGdbAdapter::handleTargetCore(const GdbResponse &response)
if (QFile::exists(m_executable)) {
// Finish extra round ...
showStatusMessage(tr("Attached to core temporarily."));
m_engine->postCommand(_("detach"));
m_engine->postCommand("detach");
// ... and retry.
loadExeAndSyms();
return;

File diff suppressed because it is too large Load Diff

View File

@@ -201,7 +201,7 @@ private: ////////// Gdb Command Management //////////
GdbCommandCallback callback;
AdapterCallback adapterCallback;
const char *callbackName;
QString command;
QByteArray command;
QVariant cookie;
QTime postTime;
};
@@ -211,20 +211,20 @@ private: ////////// Gdb Command Management //////////
// send and decrements on receipt, effectively preventing
// watch model updates before everything is finished.
void flushCommand(const GdbCommand &cmd);
void postCommand(const QString &command,
void postCommand(const QByteArray &command,
GdbCommandFlags flags,
GdbCommandCallback callback = 0,
const char *callbackName = 0,
const QVariant &cookie = QVariant());
void postCommand(const QString &command,
void postCommand(const QByteArray &command,
GdbCommandCallback callback = 0,
const char *callbackName = 0,
const QVariant &cookie = QVariant());
void postCommand(const QString &command,
void postCommand(const QByteArray &command,
AdapterCallback callback,
const char *callbackName,
const QVariant &cookie = QVariant());
void postCommand(const QString &command,
void postCommand(const QByteArray &command,
GdbCommandFlags flags,
AdapterCallback callback,
const char *callbackName,
@@ -458,7 +458,7 @@ private: ////////// View & Data Stuff //////////
void setWatchDataType(WatchData &data, const GdbMi &mi);
void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi);
QSet<QString> m_processedNames;
QSet<QByteArray> m_processedNames;
QMap<QString, QString> m_varToType;
private: ////////// Dumper Management //////////

View File

@@ -99,11 +99,13 @@ void PlainGdbAdapter::startAdapter()
void PlainGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (!startParameters().processArgs.isEmpty())
m_engine->postCommand(_("-exec-arguments ")
+ startParameters().processArgs.join(_(" ")));
if (!startParameters().processArgs.isEmpty()) {
QString args = startParameters().processArgs.join(_(" "));
m_engine->postCommand("-exec-arguments " + args.toLocal8Bit());
}
QFileInfo fi(startParameters().executable);
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fi.absoluteFilePath()),
QByteArray path = fi.absoluteFilePath().toLocal8Bit();
m_engine->postCommand("-file-exec-and-symbols \"" + path + '"',
CB(handleFileExecAndSymbols));
}
@@ -116,7 +118,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
// Note that successfully preloading the debugging helpers will
// automatically load pthreads, so this will be unnecessary.
if (m_engine->m_gdbVersion < 70000)
m_engine->postCommand(_("info target"), CB(handleInfoTarget));
m_engine->postCommand("info target", CB(handleInfoTarget));
#endif
emit inferiorPrepared();
} else {
@@ -138,7 +140,7 @@ void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
if (needle.indexIn(msg) != -1) {
m_engine->m_entryPoint =
"0x" + needle.cap(1).toLatin1().rightJustified(sizeof(void *) * 2, '0');
m_engine->postCommand(_("tbreak *0x") + needle.cap(1));
m_engine->postCommand("tbreak *0x" + needle.cap(1).toAscii());
// Do nothing here - inferiorPrepared handles the sequencing.
} else {
emit inferiorStartFailed(_("Parsing start address failed"));
@@ -152,7 +154,7 @@ void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
void PlainGdbAdapter::startInferiorPhase2()
{
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
m_engine->postCommand("-exec-run", GdbEngine::RunRequest, CB(handleExecRun));
}
void PlainGdbAdapter::handleExecRun(const GdbResponse &response)

View File

@@ -155,21 +155,24 @@ void RemoteGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
m_engine->postCommand(_("set architecture %1")
.arg(startParameters().remoteArchitecture));
m_engine->postCommand(_("set sysroot %1").arg(startParameters().sysRoot));
m_engine->postCommand(_("set solib-search-path %1").
arg(QFileInfo(startParameters().dumperLibrary).path()));
m_engine->postCommand("set architecture "
+ startParameters().remoteArchitecture.toLatin1());
m_engine->postCommand("set sysroot "
+ startParameters().sysRoot.toLocal8Bit());
m_engine->postCommand("set solib-search-path "
+ QFileInfo(startParameters().dumperLibrary).path().toLocal8Bit());
if (!startParameters().processArgs.isEmpty())
m_engine->postCommand(_("-exec-arguments ")
+ startParameters().processArgs.join(_(" ")));
if (!startParameters().processArgs.isEmpty()) {
QString args = startParameters().processArgs.join(_(" "));
m_engine->postCommand("-exec-arguments " + args.toLocal8Bit());
}
m_engine->postCommand(_("set target-async on"), CB(handleSetTargetAsync));
m_engine->postCommand("set target-async on", CB(handleSetTargetAsync));
QString x = startParameters().executable;
QFileInfo fi(startParameters().executable);
QString fileName = fi.absoluteFilePath();
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName),
m_engine->postCommand("-file-exec-and-symbols \""
+ fileName.toLocal8Bit() + '"',
CB(handleFileExecAndSymbols));
}
@@ -191,7 +194,7 @@ void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
// (2) starts the remote application
// (3) stops the remote application (early, e.g. in the dynamic linker)
QString channel = startParameters().remoteChannel;
m_engine->postCommand(_("target remote %1").arg(channel),
m_engine->postCommand("target remote " + channel.toLatin1(),
CB(handleTargetRemote));
} else {
QString msg = tr("Starting remote executable failed:\n");
@@ -224,7 +227,7 @@ void RemoteGdbAdapter::startInferiorPhase2()
void RemoteGdbAdapter::interruptInferior()
{
m_engine->postCommand(_("-exec-interrupt"));
m_engine->postCommand("-exec-interrupt");
}
void RemoteGdbAdapter::shutdown()

View File

@@ -129,7 +129,8 @@ void TermGdbAdapter::startInferior()
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
const qint64 attachedPID = m_stubProc.applicationPID();
m_engine->handleInferiorPidChanged(attachedPID);
m_engine->postCommand(_("attach %1").arg(attachedPID), CB(handleStubAttached));
m_engine->postCommand("attach " + QByteArray::number(attachedPID),
CB(handleStubAttached));
}
void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
@@ -140,7 +141,7 @@ void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
debugMessage(_("INFERIOR ATTACHED"));
emit inferiorPrepared();
#ifdef Q_OS_LINUX
m_engine->postCommand(_("-stack-list-frames 0 0"), CB(handleEntryPoint));
m_engine->postCommand("-stack-list-frames 0 0", CB(handleEntryPoint));
#endif
} else if (response.resultClass == GdbResultError) {
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());

View File

@@ -1685,15 +1685,15 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
logMessage(startMsg);
const QString fileName = m_symbolFile;
if (m_symbolFile.isEmpty()) {
const QByteArray symbolFile = m_symbolFile.toLocal8Bit();
if (symbolFile.isEmpty()) {
logMessage(_("WARNING: No symbol file available."));
} else {
m_engine->postCommand(_("add-symbol-file \"%1\" %2").arg(m_symbolFile)
.arg(m_session.codeseg));
m_engine->postCommand(_("symbol-file \"%1\"").arg(m_symbolFile));
m_engine->postCommand("add-symbol-file \"" + symbolFile + "\" "
+ QByteArray::number(m_session.codeseg));
m_engine->postCommand("symbol-file \"" + symbolFile + "\"");
}
m_engine->postCommand(_("target remote ") + gdbServerName(),
m_engine->postCommand("target remote " + gdbServerName().toLatin1(),
CB(handleTargetRemote));
}

View File

@@ -46,10 +46,10 @@ class Register
{
public:
Register() : changed(true) {}
Register(QString const &name_) : name(name_), changed(true) {}
Register(QByteArray const &name_) : name(name_), changed(true) {}
public:
QString name;
QByteArray name;
QString value;
bool changed;
};

View File

@@ -390,7 +390,7 @@ void ScriptEngine::attemptBreakpointSynchronization()
updateNeeded = true;
}
if (data->bpNumber.isEmpty()) {
data->bpNumber = QString::number(index + 1);
data->bpNumber = QByteArray::number(index + 1);
updateNeeded = true;
}
if (!data->fileName.isEmpty() && data->markerFileName.isEmpty()) {
@@ -560,7 +560,7 @@ void ScriptEngine::maybeBreakNow(bool byFunction)
// we just run into a breakpoint
//SDEBUG("RESOLVING BREAKPOINT AT " << fileName << lineNumber);
BreakpointData *data = handler->at(index);
data->bpLineNumber = QString::number(lineNumber);
data->bpLineNumber = QByteArray::number(lineNumber);
data->bpFileName = fileName;
data->bpFuncName = functionName;
data->markerLineNumber = lineNumber;
@@ -703,8 +703,8 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
while (it.hasNext()) {
it.next();
WatchData data1;
data1.iname = data.iname + "." + it.name();
data1.exp = it.name();
data1.iname = data.iname + "." + it.name().toLatin1();
data1.exp = it.name().toLatin1();
data1.name = it.name();
data1.scriptValue = it.value();
if (manager()->watchHandler()->isExpandedIName(data1.iname))

View File

@@ -224,7 +224,7 @@ void WatchData::setType(const QString &str, bool guessChildrenFromType)
void WatchData::setAddress(const QString &str)
{
addr = str;
addr = str.toLatin1();
}
QString WatchData::toString() const
@@ -349,15 +349,15 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type)
switch (m_type) {
case LocalsWatch:
m_root->iname = QLatin1String("local");
m_root->iname = "local";
m_root->name = WatchHandler::tr("Locals");
break;
case WatchersWatch:
m_root->iname = QLatin1String("watch");
m_root->iname = "watch";
m_root->name = WatchHandler::tr("Watchers");
break;
case TooltipsWatch:
m_root->iname = QLatin1String("tooltip");
m_root->iname = "tooltip";
m_root->name = WatchHandler::tr("Tooltip");
break;
}
@@ -461,11 +461,11 @@ void WatchModel::destroyItem(WatchItem *item)
delete item;
}
static QString parentName(const QString &iname)
static QByteArray parentName(const QByteArray &iname)
{
int pos = iname.lastIndexOf(QLatin1Char('.'));
int pos = iname.lastIndexOf('.');
if (pos == -1)
return QString();
return QByteArray();
return iname.left(pos);
}
@@ -931,9 +931,9 @@ QVariant WatchModel::headerData(int section, Qt::Orientation orientation, int ro
return QVariant();
}
struct IName : public QString
struct IName : public QByteArray
{
IName(const QString &iname) : QString(iname) {}
IName(const QByteArray &iname) : QByteArray(iname) {}
};
bool iNameLess(const QString &iname1, const QString &iname2)
@@ -1028,7 +1028,7 @@ void WatchModel::insertBulkData(const QList<WatchData> &list)
//foreach (const WatchItem &data, list)
// qDebug() << "BULK: " << ++bulk << data.toString();
QTC_ASSERT(!list.isEmpty(), return);
QString parentIName = parentName(list.at(0).iname);
QByteArray parentIName = parentName(list.at(0).iname);
WatchItem *parent = findItem(parentIName, m_root);
if (!parent) {
WatchData parent;
@@ -1117,7 +1117,7 @@ void WatchModel::insertBulkData(const QList<WatchData> &list)
dump();
}
WatchItem *WatchModel::findItem(const QString &iname, WatchItem *root) const
WatchItem *WatchModel::findItem(const QByteArray &iname, WatchItem *root) const
{
if (root->iname == iname)
return root;
@@ -1248,7 +1248,7 @@ void WatchHandler::insertBulkData(const QList<WatchData> &list)
if (list.isEmpty())
return;
QMap<QString, QList<WatchData> > hash;
QMap<QByteArray, QList<WatchData> > hash;
foreach (const WatchData &data, list) {
// we insert everything, including incomplete stuff
@@ -1259,7 +1259,7 @@ void WatchHandler::insertBulkData(const QList<WatchData> &list)
qWarning("%s:%d: Attempt to bulk-insert invalid watch item: %s", __FILE__, __LINE__, qPrintable(data.toString()));
}
}
foreach (const QString &parentIName, hash.keys()) {
foreach (const QByteArray &parentIName, hash.keys()) {
WatchModel *model = modelForIName(parentIName);
QTC_ASSERT(model, return);
model->insertBulkData(hash[parentIName]);
@@ -1271,7 +1271,7 @@ void WatchHandler::insertBulkData(const QList<WatchData> &list)
}
}
void WatchHandler::removeData(const QString &iname)
void WatchHandler::removeData(const QByteArray &iname)
{
WatchModel *model = modelForIName(iname);
if (!model)
@@ -1287,21 +1287,21 @@ void WatchHandler::watchExpression()
watchExpression(action->data().toString());
}
QString WatchHandler::watcherName(const QString &exp)
QByteArray WatchHandler::watcherName(const QByteArray &exp)
{
return QLatin1String("watch.") + QString::number(m_watcherNames[exp]);
return "watch." + QByteArray::number(m_watcherNames[exp]);
}
void WatchHandler::watchExpression(const QString &exp)
{
// FIXME: 'exp' can contain illegal characters
m_watcherNames[exp] = watcherCounter++;
WatchData data;
data.exp = exp;
data.exp = exp.toLatin1();
data.name = exp;
m_watcherNames[data.exp] = watcherCounter++;
if (exp.isEmpty() || exp == watcherEditPlaceHolder())
data.setAllUnneeded();
data.iname = watcherName(exp);
data.iname = watcherName(data.exp);
IDebuggerEngine *engine = m_manager->currentEngine();
if (engine && engine->isSynchroneous())
m_manager->updateWatchData(data);
@@ -1392,8 +1392,9 @@ void WatchHandler::removeWatchExpression()
removeWatchExpression(action->data().toString());
}
void WatchHandler::removeWatchExpression(const QString &exp)
void WatchHandler::removeWatchExpression(const QString &exp0)
{
QByteArray exp = exp0.toLatin1();
MODEL_DEBUG("REMOVE WATCH: " << exp);
m_watcherNames.remove(exp);
foreach (WatchItem *item, m_watchers->rootItem()->children) {
@@ -1409,7 +1410,7 @@ void WatchHandler::updateWatchers()
{
//qDebug() << "UPDATE WATCHERS";
// copy over all watchers and mark all watchers as incomplete
foreach (const QString &exp, m_watcherNames.keys()) {
foreach (const QByteArray &exp, m_watcherNames.keys()) {
WatchData data;
data.iname = watcherName(exp);
data.setAllNeeded();
@@ -1423,7 +1424,7 @@ void WatchHandler::loadWatchers()
{
QVariant value = m_manager->sessionValue("Watchers");
foreach (const QString &exp, value.toStringList())
m_watcherNames[exp] = watcherCounter++;
m_watcherNames[exp.toLatin1()] = watcherCounter++;
//qDebug() << "LOAD WATCHERS: " << m_watchers;
//reinitializeWatchersHelper();
@@ -1433,7 +1434,7 @@ QStringList WatchHandler::watchedExpressions() const
{
// Filter out invalid watchers.
QStringList watcherNames;
QHashIterator<QString, int> it(m_watcherNames);
QHashIterator<QByteArray, int> it(m_watcherNames);
while (it.hasNext()) {
it.next();
const QString &watcherName = it.key();
@@ -1487,7 +1488,7 @@ void WatchHandler::loadSessionData()
{
loadWatchers();
loadTypeFormats();
foreach (const QString &exp, m_watcherNames.keys()) {
foreach (const QByteArray &exp, m_watcherNames.keys()) {
WatchData data;
data.iname = watcherName(exp);
data.setAllUnneeded();
@@ -1508,19 +1509,19 @@ WatchModel *WatchHandler::model(WatchType type) const
return 0;
}
WatchModel *WatchHandler::modelForIName(const QString &iname) const
WatchModel *WatchHandler::modelForIName(const QByteArray &iname) const
{
if (iname.startsWith(QLatin1String("local")))
if (iname.startsWith("local"))
return m_locals;
if (iname.startsWith(QLatin1String("watch")))
if (iname.startsWith("watch"))
return m_watchers;
if (iname.startsWith(QLatin1String("tooltip")))
if (iname.startsWith("tooltip"))
return m_tooltips;
QTC_ASSERT(false, qDebug() << "INAME: " << iname);
return 0;
}
WatchData *WatchHandler::findItem(const QString &iname) const
WatchData *WatchHandler::findItem(const QByteArray &iname) const
{
const WatchModel *model = modelForIName(iname);
QTC_ASSERT(model, return 0);

View File

@@ -109,8 +109,8 @@ public:
QString toString() const;
QString toToolTip() const;
bool isLocal() const { return iname.startsWith(QLatin1String("local.")); }
bool isWatcher() const { return iname.startsWith(QLatin1String("watch.")); }
bool isLocal() const { return iname.startsWith("local."); }
bool isWatcher() const { return iname.startsWith("watch."); }
bool isValid() const { return !iname.isEmpty(); }
bool isEqual(const WatchData &other) const;
@@ -119,17 +119,17 @@ public:
static QString shadowedName(const QString &name, int seen);
public:
QString iname; // internal name sth like 'local.baz.public.a'
QString exp; // the expression
QByteArray iname; // internal name sth like 'local.baz.public.a'
QByteArray exp; // the expression
QString name; // displayed name
QString value; // displayed value
QByteArray editvalue; // displayed value
QString valuetooltip; // tooltip in value column
QString type; // type for further processing
QString displayedType;// displayed type (optional)
QString variable; // name of internal Gdb variable if created
QString addr; // displayed adress
QString saddr; // stored address (pointer in container)
QByteArray variable; // name of internal Gdb variable if created
QByteArray addr; // displayed adress
QByteArray saddr; // stored address (pointer in container)
QString framekey; // key for type cache
QScriptValue scriptValue; // if needed...
bool hasChildren;
@@ -215,7 +215,7 @@ private:
void insertData(const WatchData &data);
void insertBulkData(const QList<WatchData> &data);
WatchItem *findItem(const QString &iname, WatchItem *root) const;
WatchItem *findItem(const QByteArray &iname, WatchItem *root) const;
void reinitialize();
void removeOutdated();
void removeOutdatedHelper(WatchItem *item);
@@ -243,7 +243,7 @@ private:
WatchHandler *m_handler;
WatchType m_type;
WatchItem *m_root;
QSet<QString> m_fetchTriggered;
QSet<QByteArray> m_fetchTriggered;
// Part of the workaround to update the [+] marker when items
// are added to a container.
bool m_inExtraLayoutChanged;
@@ -256,7 +256,7 @@ class WatchHandler : public QObject
public:
explicit WatchHandler(DebuggerManager *manager);
WatchModel *model(WatchType type) const;
WatchModel *modelForIName(const QString &data) const;
WatchModel *modelForIName(const QByteArray &iname) const;
//public slots:
void cleanup();
@@ -272,20 +272,20 @@ public:
void insertData(const WatchData &data);
void insertBulkData(const QList<WatchData> &data);
void removeData(const QString &iname);
WatchData *findItem(const QString &iname) const;
void removeData(const QByteArray &iname);
WatchData *findItem(const QByteArray &iname) const;
void loadSessionData();
void saveSessionData();
bool isDisplayedIName(const QString &iname) const
bool isDisplayedIName(const QByteArray &iname) const
{ return m_displayedINames.contains(iname); }
bool isExpandedIName(const QString &iname) const
bool isExpandedIName(const QByteArray &iname) const
{ return m_expandedINames.contains(iname); }
QSet<QString> expandedINames() const
QSet<QByteArray> expandedINames() const
{ return m_expandedINames; }
QStringList watchedExpressions() const;
QHash<QString, int> watcherNames() const
QHash<QByteArray, int> watcherNames() const
{ return m_watcherNames; }
static QString watcherEditPlaceHolder();
@@ -306,14 +306,14 @@ private:
typedef QMap<QString, QPointer<QWidget> > EditWindows;
EditWindows m_editWindows;
QHash<QString, int> m_watcherNames;
QString watcherName(const QString &exp);
QHash<QByteArray, int> m_watcherNames;
QByteArray watcherName(const QByteArray &exp);
QHash<QString, int> m_typeFormats;
QHash<QString, int> m_individualFormats;
void setDisplayedIName(const QString &iname, bool on);
QSet<QString> m_expandedINames; // those expanded in the treeview
QSet<QString> m_displayedINames; // those with "external" viewers
QSet<QByteArray> m_expandedINames; // those expanded in the treeview
QSet<QByteArray> m_displayedINames; // those with "external" viewers
WatchModel *m_locals;
WatchModel *m_watchers;

View File

@@ -138,12 +138,11 @@ QDebug operator<<(QDebug d, const Scope &scope)
namespace Debugger {
namespace Internal {
QString dotEscape(QString str)
QByteArray dotEscape(QByteArray str)
{
const QChar dot = QLatin1Char('.');
str.replace(QLatin1Char(' '), dot);
str.replace(QLatin1Char('\\'), dot);
str.replace(QLatin1Char('/'), dot);
str.replace(' ', '.');
str.replace('\\', '.');
str.replace('/', '.');
return str;
}
@@ -275,15 +274,6 @@ bool isCharPointerType(const QString &type)
|| type == QLatin1String("char const *");
}
bool isAccessSpecifier(const QString &str)
{
static const QStringList items = QStringList()
<< QLatin1String("private")
<< QLatin1String("protected")
<< QLatin1String("public");
return items.contains(str);
}
bool startsWithDigit(const QString &str)
{
return !str.isEmpty() && str.at(0).isDigit();
@@ -1270,13 +1260,13 @@ void QtDumperHelper::evaluationParameters(const WatchData &data,
inBuffer->clear();
inBuffer->append(outertype.toUtf8());
inBuffer->append('\0');
inBuffer->append(data.iname.toUtf8());
inBuffer->append(data.iname);
inBuffer->append('\0');
inBuffer->append(data.exp.toUtf8());
inBuffer->append(data.exp);
inBuffer->append('\0');
inBuffer->append(inner.toUtf8());
inBuffer->append('\0');
inBuffer->append(data.iname.toUtf8());
inBuffer->append(data.iname);
inBuffer->append('\0');
if (debug)
@@ -1361,6 +1351,17 @@ static bool gdbMiGetStringValue(QString *target,
return true;
}
static bool gdbMiGetByteArrayValue(QByteArray *target,
const GdbMi &node,
const char *child,
const char *encodingChild = 0)
{
QString str;
const bool success = gdbMiGetStringValue(&str, node, child, encodingChild);
*target = str.toLatin1();
return success;
}
static bool gdbMiGetBoolValue(bool *target,
const GdbMi &node,
const char *child)
@@ -1377,7 +1378,8 @@ static bool gdbMiGetBoolValue(bool *target,
* (next level only, it is not further inherited). For example, the root item
* can provide a "childtype" node that specifies the type of the children. */
struct GdbMiRecursionContext {
struct GdbMiRecursionContext
{
GdbMiRecursionContext(int recursionLevelIn = 0) :
recursionLevel(recursionLevelIn), childNumChild(-1), childIndex(0) {}
@@ -1385,7 +1387,7 @@ struct GdbMiRecursionContext {
int childNumChild;
int childIndex;
QString childType;
QString parentIName;
QByteArray parentIName;
};
static void gbdMiToWatchData(const GdbMi &root,
@@ -1396,16 +1398,19 @@ static void gbdMiToWatchData(const GdbMi &root,
qDebug() << Q_FUNC_INFO << '\n' << root.toString(false, 0);
WatchData w;
QString v;
QByteArray b;
// Check for name/iname and use as expression default
if (ctx.recursionLevel == 0) {
// parents have only iname, from which name is derived
if (!gdbMiGetStringValue(&w.iname, root, "iname"))
QString iname;
if (!gdbMiGetStringValue(&iname, root, "iname"))
qWarning("Internal error: iname missing");
w.name = w.iname;
w.iname = iname.toLatin1();
w.name = iname;
const int lastDotPos = w.name.lastIndexOf(QLatin1Char('.'));
if (lastDotPos != -1)
w.name.remove(0, lastDotPos + 1);
w.exp = w.name;
w.exp = w.name.toLatin1();
} else {
// Children can have a 'name' attribute. If missing, assume array index
// For display purposes, it can be overridden by "key"
@@ -1414,8 +1419,8 @@ static void gbdMiToWatchData(const GdbMi &root,
}
// Set iname
w.iname = ctx.parentIName;
w.iname += QLatin1Char('.');
w.iname += w.name;
w.iname += '.';
w.iname += w.name.toLatin1();
// Key?
QString key;
if (gdbMiGetStringValue(&key, root, "key", "keyencoded")) {
@@ -1427,12 +1432,12 @@ static void gbdMiToWatchData(const GdbMi &root,
qWarning("%s\n", qPrintable(msg));
}
gdbMiGetStringValue(&w.displayedType, root, "displayedtype");
if (gdbMiGetStringValue(&v, root, "editvalue"))
w.editvalue = v.toLatin1();
if (gdbMiGetStringValue(&v, root, "exp"))
w.exp = v;
gdbMiGetStringValue(&w.addr, root, "addr");
gdbMiGetStringValue(&w.saddr, root, "saddr");
if (gdbMiGetByteArrayValue(&b, root, "editvalue"))
w.editvalue = b;
if (gdbMiGetByteArrayValue(&b, root, "exp"))
w.exp = b;
gdbMiGetByteArrayValue(&w.addr, root, "addr");
gdbMiGetByteArrayValue(&w.saddr, root, "saddr");
gdbMiGetBoolValue(&w.valueEnabled, root, "valueenabled");
gdbMiGetBoolValue(&w.valueEditable, root, "valueeditable");
if (gdbMiGetStringValue(&v, root, "valuetooltip", "valuetooltipencoded"))

View File

@@ -55,7 +55,7 @@ namespace Internal {
class WatchData;
class GdbMi;
QString dotEscape(QString str);
QByteArray dotEscape(QByteArray str);
QString currentTime();
bool isSkippableFunction(const QString &funcName, const QString &fileName);
bool isLeavableFunction(const QString &funcName, const QString &fileName);
@@ -71,7 +71,6 @@ bool hasSideEffects(const QString &exp);
bool isKeyWord(const QString &exp);
bool isPointerType(const QString &type);
bool isCharPointerType(const QString &type);
bool isAccessSpecifier(const QString &str);
bool startsWithDigit(const QString &str);
QString stripPointerType(QString type);
QString gdbQuoteTypes(const QString &type);