Debugger: Compile with QT_NO_CAST_FROM_ASCII.

(except gdbmi.cpp, name_demangler.cpp). Remove some unneeded
conversions, change some maps to take QByteArray keys.

Change-Id: I010f1251998a441fe5c8c87901b1e0c277c0391c
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2011-12-21 14:02:52 +01:00
committed by hjk
parent ec49390052
commit a92e38f47f
38 changed files with 327 additions and 328 deletions

View File

@@ -54,6 +54,7 @@
#include <dlfcn.h>
#endif
#include <cctype>
#define PRECONDITION QTC_CHECK(!hasPython())
@@ -144,11 +145,11 @@ QString DumperHelper::toString(bool debug) const
return rc;
}
const QString nameSpace = m_qtNamespace.isEmpty()
? QCoreApplication::translate("QtDumperHelper", "<none>") : m_qtNamespace;
? QCoreApplication::translate("QtDumperHelper", "<none>") : QLatin1String(m_qtNamespace);
return QCoreApplication::translate("QtDumperHelper",
"%n known types, Qt version: %1, Qt namespace: %2 Dumper version: %3",
0, QCoreApplication::CodecForTr,
m_nameTypeMap.size()).arg(qtVersionString(), nameSpace).arg(m_dumperVersion);
m_nameTypeMap.size()).arg(QLatin1String(qtVersionString()), nameSpace).arg(m_dumperVersion);
}
DumperHelper::Type DumperHelper::simpleType(const QByteArray &simpleType) const
@@ -475,13 +476,13 @@ DumperHelper::SpecialSizeType DumperHelper::specialSizeType(const QByteArray &ty
return SpecialSizeCount;
}
static inline bool isInteger(const QString &n)
static inline bool isInteger(const QByteArray &n)
{
const int size = n.size();
if (!size)
return false;
for (int i = 0; i < size; i++)
if (!n.at(i).isDigit())
if (!std::isdigit(n.at(i)))
return false;
return true;
}
@@ -506,12 +507,12 @@ void DumperHelper::evaluationParameters(const WatchData &data,
for (int i = 0; i != inners.size(); ++i)
inners[i] = inners[i].simplified();
QString outertype = td.isTemplate ? td.tmplate : data.type;
QByteArray outertype = td.isTemplate ? td.tmplate : data.type;
// adjust the data extract
if (outertype == m_qtNamespace + "QWidget")
outertype = m_qtNamespace + "QObject";
QString inner = td.inner;
QByteArray inner = td.inner;
const QByteArray zero = "0";
extraArgs.clear();
@@ -644,13 +645,13 @@ void DumperHelper::evaluationParameters(const WatchData &data,
}
inBuffer->clear();
inBuffer->append(outertype.toUtf8());
inBuffer->append(outertype);
inBuffer->append('\0');
inBuffer->append(data.iname);
inBuffer->append('\0');
inBuffer->append(data.exp);
inBuffer->append('\0');
inBuffer->append(inner.toUtf8());
inBuffer->append(inner);
inBuffer->append('\0');
inBuffer->append(data.iname);
inBuffer->append('\0');
@@ -860,8 +861,8 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
// Try automatic dereferentiation
data.exp = "(*(" + data.exp + "))";
data.type = data.type + '.'; // FIXME: fragile HACK to avoid recursion
if (data.value.startsWith("0x"))
data.value = "@" + data.value;
if (data.value.startsWith(QLatin1String("0x")))
data.value.insert(0, QLatin1Char('@'));
insertData(data);
} else {
data.setChildrenUnneeded();
@@ -1201,7 +1202,7 @@ void GdbEngine::handleStackListArgumentsClassic(const GdbResponse &response)
} else {
// Seems to occur on "RedHat 4 based Linux" gdb 7.0.1:
// ^error,msg="Cannot access memory at address 0x0"
showMessage(_("UNEXPECTED RESPONSE: ") + response.toString());
showMessage(_("UNEXPECTED RESPONSE: ") + QLatin1String(response.toString()));
}
}
@@ -1239,7 +1240,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response)
if (!m_resultVarName.isEmpty()) {
WatchData rd;
rd.iname = "return.0";
rd.name = "return";
rd.name = QLatin1String("return");
rd.exp = m_resultVarName;
list.append(rd);
}
@@ -1310,10 +1311,10 @@ void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &resp
if (response.resultClass == GdbResultDone) {
QString value = _(response.data.findChild("value").data());
QString debuggeeQtVersion = value.section(QLatin1Char('"'), 1, 1);
QString dumperQtVersion = m_dumperHelper.qtVersionString();
QString dumperQtVersion = QLatin1String(m_dumperHelper.qtVersionString());
if (debuggeeQtVersion.isEmpty()) {
showMessage(_("DUMPER VERSION CHECK SKIPPED, NO qVersion() OUTPUT IN")
+ response.toString());
+ QLatin1String(response.toString()));
} else if (dumperQtVersion.isEmpty()) {
showMessage(_("DUMPER VERSION CHECK SKIPPED, NO VERSION STRING"));
} else if (dumperQtVersion != debuggeeQtVersion) {
@@ -1328,7 +1329,7 @@ void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &resp
+ dumperQtVersion);
}
} else {
showMessage("DUMPER VERSION CHECK NOT COMPLETED");
showMessage(QLatin1String("DUMPER VERSION CHECK NOT COMPLETED"));
}
}
@@ -1354,7 +1355,7 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item,
//iname += '.' + exp;
postCommand(cmd, WatchUpdate,
CB(handleVarListChildrenClassic), QVariant::fromValue(data));
} else if (!startsWithDigit(exp)
} else if (!startsWithDigit(QLatin1String(exp))
&& item.findChild("numchild").data() == "0") {
// Happens for structs without data, e.g. interfaces.
WatchData data;
@@ -1393,7 +1394,7 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item,
data.setChildrenUnneeded();
data.name = _(exp);
if (data.type == data.name) {
if (data.name == QLatin1String(data.type)) {
if (isPointerType(parent.type)) {
data.exp = "*(" + parent.exp + ')';
data.name = _("*") + parent.name;

View File

@@ -167,7 +167,7 @@ CodaGdbAdapter::~CodaGdbAdapter()
SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice);
cleanup();
logMessage("Shutting down.\n");
logMessage(QLatin1String("Shutting down.\n"));
}
void CodaGdbAdapter::setVerbose(const QVariant &value)
@@ -375,7 +375,7 @@ void CodaGdbAdapter::codaEvent(const CodaEvent &e)
}
break;
case CodaEvent::LoggingWriteEvent: // TODO: Not tested yet.
showMessage(e.toString() + '\n', AppOutput);
showMessage(e.toString() + QLatin1Char('\n'), AppOutput);
break;
default:
break;
@@ -416,7 +416,7 @@ void CodaGdbAdapter::logMessage(const QString &msg, int channel)
//
void CodaGdbAdapter::handleGdbConnection()
{
logMessage("HANDLING GDB CONNECTION");
logMessage(QLatin1String("HANDLING GDB CONNECTION"));
QTC_CHECK(m_gdbConnection == 0);
m_gdbConnection = m_gdbServer->nextPendingConnection();
QTC_ASSERT(m_gdbConnection, return);
@@ -437,9 +437,10 @@ void CodaGdbAdapter::readGdbServerCommand()
QByteArray packet = m_gdbConnection->readAll();
m_gdbReadBuffer.append(packet);
logMessage("gdb: -> " + currentTime() + ' ' + QString::fromAscii(packet));
logMessage(QLatin1String("gdb: -> ") + currentTime()
+ QLatin1Char(' ') + QString::fromAscii(packet));
if (packet != m_gdbReadBuffer)
logMessage(_("buffer: ") + m_gdbReadBuffer);
logMessage(_("buffer: ") + QString::fromAscii(m_gdbReadBuffer));
QByteArray &ba = m_gdbReadBuffer;
while (ba.size()) {
@@ -452,27 +453,27 @@ void CodaGdbAdapter::readGdbServerCommand()
}
if (code == '-') {
logMessage("NAK: Retransmission requested", LogError);
logMessage(QLatin1String("NAK: Retransmission requested"), LogError);
// This seems too harsh.
//emit adapterCrashed("Communication problem encountered.");
continue;
}
if (code == char(0x03)) {
logMessage("INTERRUPT RECEIVED");
logMessage(QLatin1String("INTERRUPT RECEIVED"));
interruptInferior();
continue;
}
if (code != '$') {
logMessage("Broken package (2) " + quoteUnprintableLatin1(ba)
+ Coda::hexNumber(code), LogError);
logMessage(QLatin1String("Broken package (2) ") + quoteUnprintableLatin1(ba)
+ QLatin1String(Coda::hexNumber(code)), LogError);
continue;
}
int pos = ba.indexOf('#');
if (pos == -1) {
logMessage("Invalid checksum format in "
logMessage(QLatin1String("Invalid checksum format in ")
+ quoteUnprintableLatin1(ba), LogError);
continue;
}
@@ -480,7 +481,7 @@ void CodaGdbAdapter::readGdbServerCommand()
bool ok = false;
uint checkSum = ba.mid(pos + 1, 2).toUInt(&ok, 16);
if (!ok) {
logMessage("Invalid checksum format 2 in "
logMessage(QLatin1String("Invalid checksum format 2 in ")
+ quoteUnprintableLatin1(ba), LogError);
return;
}
@@ -491,8 +492,8 @@ void CodaGdbAdapter::readGdbServerCommand()
sum += ba.at(i);
if (sum != checkSum) {
logMessage(QString("ERROR: Packet checksum wrong: %1 %2 in "
+ quoteUnprintableLatin1(ba)).arg(checkSum).arg(sum), LogError);
logMessage(QString::fromLatin1("ERROR: Packet checksum wrong: %1 %2 in %3").
arg(checkSum).arg(sum).arg(quoteUnprintableLatin1(ba)), LogError);
}
QByteArray cmd = ba.left(pos);
@@ -527,7 +528,7 @@ void CodaGdbAdapter::sendGdbServerAck()
{
if (!m_gdbAckMode)
return;
logMessage("gdb: <- +");
logMessage(QLatin1String("gdb: <- +"));
sendGdbServerPacket(QByteArray(1, '+'), false);
}
@@ -548,7 +549,9 @@ void CodaGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArra
packet.append('#');
packet.append(checkSum);
int pad = qMax(0, 24 - packet.size());
logMessage("gdb: <- " + currentTime() + ' ' + packet + QByteArray(pad, ' ') + logNote);
logMessage(QLatin1String("gdb: <- ") + currentTime() + QLatin1Char(' ')
+ QString::fromAscii(packet) + QString(pad, QLatin1Char(' '))
+ QLatin1String(logNote));
sendGdbServerPacket(packet, true);
}
@@ -869,7 +872,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
else if (cmd == "QStartNoAckMode") {
//$qSupported#37
logMessage("Handling 'QStartNoAckMode'");
logMessage(QLatin1String("Handling 'QStartNoAckMode'"));
sendGdbServerAck();
sendGdbServerMessage("OK", "ack no-ack mode");
m_gdbAckMode = false;
@@ -932,7 +935,8 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
CodaCallback(this, &CodaGdbAdapter::handleAndReportSetBreakpoint),
bp);
} else {
logMessage(_("MISPARSED BREAKPOINT '") + cmd + "'')" , LogError);
logMessage(_("MISPARSED BREAKPOINT '") + QLatin1String(cmd)
+ QLatin1String("'')") , LogError);
}
}
@@ -1059,7 +1063,7 @@ void CodaGdbAdapter::startAdapter()
const QString reason = m_codaDevice.isNull() ?
tr("Could not obtain device.") :
m_codaDevice->device()->errorString();
const QString msg = QString("Could not open serial device '%1': %2")
const QString msg = QString::fromLatin1("Could not open serial device '%1': %2")
.arg(parameters.remoteChannel, reason);
logMessage(msg, LogError);
m_engine->handleAdapterStartFailed(msg, QString());
@@ -1091,14 +1095,14 @@ void CodaGdbAdapter::startAdapter()
const QPair<QString, unsigned short> address = splitIpAddressSpec(m_gdbServerName);
if (!m_gdbServer->listen(QHostAddress(address.first), address.second)) {
QString msg = QString("Unable to start the gdb server at %1: %2.")
QString msg = QString::fromLatin1("Unable to start the gdb server at %1: %2.")
.arg(m_gdbServerName).arg(m_gdbServer->errorString());
logMessage(msg, LogError);
m_engine->handleAdapterStartFailed(msg, QString());
return;
}
logMessage(QString("Gdb server running on %1.\nLittle endian assumed.")
logMessage(QString::fromLatin1("Gdb server running on %1.\nLittle endian assumed.")
.arg(m_gdbServerName));
connect(m_gdbServer, SIGNAL(newConnection()),
@@ -1246,7 +1250,7 @@ void CodaGdbAdapter::shutdownAdapter()
} else {
// Something is wrong, gdb crashed. Kill debuggee (see handleDeleteProcess2)
if (m_codaDevice && m_codaDevice->device()->isOpen()) {
logMessage("Emergency shutdown of CODA", LogError);
logMessage(QLatin1String("Emergency shutdown of CODA"), LogError);
sendRunControlTerminateCommand();
}
}
@@ -1300,8 +1304,9 @@ void CodaGdbAdapter::handleRegisterChildren(const CodaCommandResult &result)
QTC_ASSERT(m_codaDevice, return);
const QByteArray contextId = result.cookie.toByteArray();
if (!result) {
logMessage("Error retrieving register children of " + contextId
+ ": " + result.errorString(), LogError);
logMessage(QLatin1String("Error retrieving register children of ")
+ result.cookie.toString() + QLatin1String(": ")
+ result.errorString(), LogError);
return;
}
// Parse out registers.
@@ -1346,7 +1351,7 @@ void CodaGdbAdapter::handleReadRegisters(const CodaCommandResult &result)
{
// Check for errors.
if (!result) {
logMessage("ERROR: " + result.errorString(), LogError);
logMessage(QLatin1String("ERROR: ") + result.errorString(), LogError);
return;
}
if (result.values.isEmpty() || result.values.front().type() != Json::JsonValue::String) {
@@ -1435,9 +1440,10 @@ void CodaGdbAdapter::handleAndReportSetBreakpoint(const CodaCommandResult &resul
void CodaGdbAdapter::handleClearBreakpoint(const CodaCommandResult &result)
{
logMessage("CLEAR BREAKPOINT ");
logMessage(QLatin1String("CLEAR BREAKPOINT "));
if (!result)
logMessage("Error clearing breakpoint: " + result.errorString(), LogError);
logMessage(QLatin1String("Error clearing breakpoint: ") +
result.errorString(), LogError);
sendGdbServerMessage("OK");
}
@@ -1551,7 +1557,7 @@ void CodaGdbAdapter::tryAnswerGdbMemoryRequest(bool buffered)
}
// Happens when chunks are not combined
QTC_CHECK(false);
showMessage("CHUNKS NOT COMBINED");
showMessage(QLatin1String("CHUNKS NOT COMBINED"));
# ifdef MEMORY_DEBUG
qDebug() << "CHUNKS NOT COMBINED";
it = m_snapshot.memory.begin();
@@ -1639,8 +1645,8 @@ void CodaGdbAdapter::sendStepRange()
void CodaGdbAdapter::handleStep(const CodaCommandResult &result)
{
if (!result) { // Try fallback with Continue.
logMessage(_("Error while stepping: %1 (fallback to 'continue')").
arg(result.errorString()), LogWarning);
logMessage(QString::fromLatin1("Error while stepping: %1 (fallback to 'continue')").
arg(result.errorString()), LogWarning);
sendContinue();
// Doing nothing as below does not work as gdb seems to insist on
// making some progress through a 'step'.
@@ -1650,7 +1656,7 @@ void CodaGdbAdapter::handleStep(const CodaCommandResult &result)
return;
}
// The gdb server response is triggered later by the Stop Reply packet.
logMessage("STEP FINISHED " + currentTime());
logMessage(QLatin1String("STEP FINISHED ") + currentTime());
}
} // namespace Internal

View File

@@ -133,7 +133,7 @@ void CoreGdbAdapter::handleTemporaryTargetCore(const GdbResponse &response)
return;
}
m_executable = console.mid(pos1 + 1, pos2 - pos1 - 1);
m_executable = QLatin1String(console.mid(pos1 + 1, pos2 - pos1 - 1));
// Strip off command line arguments. FIXME: make robust.
int idx = m_executable.indexOf(_c(' '));
if (idx >= 0)

View File

@@ -169,7 +169,7 @@ public:
static QString msgDumperOutdated(double requiredVersion, double currentVersion);
private:
typedef QMap<QString, Type> NameTypeMap;
typedef QMap<QByteArray, Type> NameTypeMap;
typedef QMap<QByteArray, int> SizeCache;
// Look up a simple (namespace) type

View File

@@ -165,7 +165,7 @@ void LocalPlainGdbAdapter::checkForReleaseBuild()
// "30 .debug_info 00087d36 00000000 00000000 0006bbd5 2**0\n"
// " CONTENTS, READONLY, DEBUGGING"
if (ba.contains("Sections:") && !ba.contains(".debug_info")) {
showMessageBox(QMessageBox::Information, "Warning",
showMessageBox(QMessageBox::Information, tr("Warning"),
tr("This does not seem to be a \"Debug\" build.\n"
"Setting breakpoints by file name and line number may fail."));
}

View File

@@ -87,7 +87,7 @@ void MemoryRange::operator-=(const MemoryRange &other)
QDebug operator<<(QDebug d, const MemoryRange &range)
{
return d << QString("[%1,%2] (size %3) ")
return d << QString::fromLatin1("[%1,%2] (size %3) ")
.arg(range.from, 0, 16).arg(range.to, 0, 16).arg(range.size());
}