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

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