Commit 87b1dc25 authored by Denis Mingulov's avatar Denis Mingulov Committed by hjk

Debugger: use QString::fromLatin1 instead of QString::fromAscii

By source - latin1 is really expected as there is no any check
or usage of QTextCodec::setCodecForCStrings() currently.

QString::fromAscii() might break 'Latin1' input in some cases.

A quote from documentation about QString::fromAscii():

"Note that, despite the name, this function actually uses the
codec defined by QTextCodec::setCodecForCStrings() to convert str
to Unicode. Depending on the codec, it may not accept valid
US-ASCII (ANSI X3.4-1986) input. If no codec has been set, this
function does the same as fromLatin1()."

Change-Id: I49cf047ca674d2ec621b517c635d1927bb2e796f
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent d766c2e7
......@@ -92,7 +92,7 @@ static QString stateToString(BreakpointState state)
static QString msgBreakpointAtSpecialFunc(const char *func)
{
return BreakHandler::tr("Breakpoint at \"%1\"").arg(QString::fromAscii(func));
return BreakHandler::tr("Breakpoint at \"%1\"").arg(QString::fromLatin1(func));
}
static QString typeToString(BreakpointType type)
......@@ -578,7 +578,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
case 4:
if (role == Qt::DisplayRole)
if (res.address)
return QString::fromAscii("0x%1").arg(res.address, 0, 16);
return QString::fromLatin1("0x%1").arg(res.address, 0, 16);
}
return QVariant();
}
......@@ -646,7 +646,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
if (role == Qt::DisplayRole) {
const quint64 address = orig ? data.address : response.address;
if (address)
return QString::fromAscii("0x%1").arg(address, 0, 16);
return QString::fromLatin1("0x%1").arg(address, 0, 16);
return QVariant();
}
break;
......
......@@ -315,7 +315,7 @@ void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data)
if (mask & AddressPart) {
if (data.address) {
m_ui.lineEditAddress->setText(
QString::fromAscii("0x%1").arg(data.address, 0, 16));
QString::fromLatin1("0x%1").arg(data.address, 0, 16));
} else {
m_ui.lineEditAddress->clear();
}
......
......@@ -748,7 +748,7 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa
arguments << QLatin1String("-lines") << QLatin1String("-G")
// register idle (debuggee stop) notification
<< QLatin1String("-c")
<< QLatin1String(".idle_cmd ") + QString::fromAscii(m_extensionCommandPrefixBA) + QLatin1String("idle");
<< QLatin1String(".idle_cmd ") + QString::fromLatin1(m_extensionCommandPrefixBA) + QLatin1String("idle");
if (sp.useTerminal) // Separate console
arguments << QLatin1String("-2");
if (!m_options->symbolPaths.isEmpty())
......@@ -1049,7 +1049,7 @@ void CdbEngine::handleAddWatch(const CdbExtensionCommandPtr &reply)
item.setError(tr("Unable to add expression"));
watchHandler()->insertData(item);
showMessage(QString::fromLatin1("Unable to add watch item '%1'/'%2': %3").
arg(QString::fromAscii(item.iname), QString::fromAscii(item.exp),
arg(QString::fromLatin1(item.iname), QString::fromLatin1(item.exp),
QString::fromLocal8Bit(reply->errorMessage)), LogError);
}
}
......@@ -1383,7 +1383,7 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd, unsigned flags,
{
if (!m_accessible) {
const QString msg = QString::fromLatin1("Attempt to issue builtin command '%1' to non-accessible session (%2)")
.arg(QString::fromLocal8Bit(cmd), QString::fromAscii(stateName(state())));
.arg(QString::fromLocal8Bit(cmd), QString::fromLatin1(stateName(state())));
showMessage(msg, LogError);
return;
}
......@@ -1420,7 +1420,7 @@ void CdbEngine::postExtensionCommand(const QByteArray &cmd,
{
if (!m_accessible) {
const QString msg = QString::fromLatin1("Attempt to issue extension command '%1' to non-accessible session (%2)")
.arg(QString::fromLocal8Bit(cmd), QString::fromAscii(stateName(state())));
.arg(QString::fromLocal8Bit(cmd), QString::fromLatin1(stateName(state())));
showMessage(msg, LogError);
return;
}
......@@ -1878,8 +1878,8 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply)
modules.reserve(value.childCount());
foreach (const GdbMi &gdbmiModule, value.children()) {
Module module;
module.moduleName = QString::fromAscii(gdbmiModule.findChild("name").data());
module.modulePath = QString::fromAscii(gdbmiModule.findChild("image").data());
module.moduleName = QString::fromLatin1(gdbmiModule.findChild("name").data());
module.modulePath = QString::fromLatin1(gdbmiModule.findChild("image").data());
module.startAddress = gdbmiModule.findChild("start").data().toULongLong(0, 0);
module.endAddress = gdbmiModule.findChild("end").data().toULongLong(0, 0);
if (gdbmiModule.findChild("deferred").type() == GdbMi::Invalid)
......@@ -2034,7 +2034,7 @@ static inline QString msgCheckingConditionalBreakPoint(BreakpointModelId id, con
const QString &threadId)
{
return CdbEngine::tr("Conditional breakpoint %1 (%2) in thread %3 triggered, examining expression '%4'.")
.arg(id.toString()).arg(number).arg(threadId, QString::fromAscii(condition));
.arg(id.toString()).arg(number).arg(threadId, QString::fromLatin1(condition));
}
unsigned CdbEngine::examineStopReason(const GdbMi &stopReason,
......@@ -2057,7 +2057,7 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason,
// Additional stop messages occurring for debuggee function calls (widgetAt, etc). Just log.
if (state() == InferiorStopOk) {
*message = QString::fromLatin1("Ignored stop notification from function call (%1).").
arg(QString::fromAscii(reason));
arg(QString::fromLatin1(reason));
rc |= StopReportLog;
return rc;
}
......@@ -2248,14 +2248,14 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
return;
}
} else {
showMessage(QString::fromAscii(stopReason.findChild("stackerror").data()), LogError);
showMessage(QString::fromLatin1(stopReason.findChild("stackerror").data()), LogError);
}
}
const GdbMi threads = stopReason.findChild("threads");
if (threads.isValid()) {
parseThreads(threads, forcedThreadId);
} else {
showMessage(QString::fromAscii(stopReason.findChild("threaderror").data()), LogError);
showMessage(QString::fromLatin1(stopReason.findChild("threaderror").data()), LogError);
}
// Fire off remaining commands asynchronously
if (!m_pendingBreakpointMap.isEmpty())
......@@ -2379,7 +2379,7 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
}
if (what == "event") {
showStatusMessage(QString::fromAscii(message), 5000);
showStatusMessage(QString::fromLatin1(message), 5000);
return;
}
......@@ -2873,7 +2873,7 @@ unsigned CdbEngine::parseStackTrace(const GdbMi &data, bool sourceStepInto)
const bool hasFile = !frames.at(i).file.isEmpty();
// jmp-frame hit by step into, do another 't' and abort sequence.
if (!hasFile && i == 0 && sourceStepInto && frames.at(i).function.contains(QLatin1String("ILT+"))) {
showMessage(QString::fromAscii("Step into: Call instruction hit, performing additional step..."), LogMisc);
showMessage(QString::fromLatin1("Step into: Call instruction hit, performing additional step..."), LogMisc);
return ParseStackStepInto;
}
if (hasFile) {
......@@ -2982,19 +2982,19 @@ void CdbEngine::handleWidgetAt(const CdbExtensionCommandPtr &reply)
QString message;
do {
if (!reply->success) {
message = QString::fromAscii(reply->errorMessage);
message = QString::fromLatin1(reply->errorMessage);
break;
}
// Should be "namespace::QWidget:0x555"
QString watchExp = QString::fromAscii(reply->reply);
QString watchExp = QString::fromLatin1(reply->reply);
const int sepPos = watchExp.lastIndexOf(QLatin1Char(':'));
if (sepPos == -1) {
message = QString::fromAscii("Invalid output: %1").arg(watchExp);
message = QString::fromLatin1("Invalid output: %1").arg(watchExp);
break;
}
// 0x000 -> nothing found
if (!watchExp.mid(sepPos + 1).toULongLong(0, 0)) {
message = QString::fromAscii("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY);
message = QString::fromLatin1("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY);
break;
}
// Turn into watch expression: "*(namespace::QWidget*)0x555"
......@@ -3031,13 +3031,13 @@ void CdbEngine::handleBreakPoints(const CdbExtensionCommandPtr &reply)
if (debugBreakpoints)
qDebug("CdbEngine::handleBreakPoints: success=%d: %s", reply->success, reply->reply.constData());
if (!reply->success) {
showMessage(QString::fromAscii(reply->errorMessage), LogError);
showMessage(QString::fromLatin1(reply->errorMessage), LogError);
return;
}
GdbMi value;
value.fromString(reply->reply);
if (value.type() != GdbMi::List) {
showMessage(QString::fromAscii("Unabled to parse breakpoints reply"), LogError);
showMessage(QString::fromLatin1("Unabled to parse breakpoints reply"), LogError);
return;
}
handleBreakPoints(value);
......@@ -3105,7 +3105,7 @@ void CdbEngine::watchPoint(const QPoint &p)
break;
default:
showMessage(tr("\"Select Widget to Watch\": Not supported in state '%1'.").
arg(QString::fromAscii(stateName(state()))), LogWarning);
arg(QString::fromLatin1(stateName(state()))), LogWarning);
break;
}
}
......
......@@ -263,7 +263,7 @@ static inline bool parseThread(QByteArray line, ThreadData *thread, bool *curren
const QByteArray &pidTid = tokens.at(2);
const int dotPos = pidTid.indexOf('.');
if (dotPos != -1)
thread->targetId = QLatin1String("0x") + QString::fromAscii(pidTid.mid(dotPos + 1));
thread->targetId = QLatin1String("0x") + QString::fromLatin1(pidTid.mid(dotPos + 1));
}
case 1:
thread->id = tokens.at(0).toInt();
......
......@@ -1093,7 +1093,7 @@ QString StartRemoteCdbDialog::connection() const
QRegExp ipRegexp(QLatin1String("([\\w\\.\\-_]+):([0-9]{1,4})"));
QTC_ASSERT(ipRegexp.isValid(), return QString());
if (ipRegexp.exactMatch(rc))
return QString::fromAscii("tcp:server=%1,port=%2").arg(ipRegexp.cap(1), ipRegexp.cap(2));
return QString::fromLatin1("tcp:server=%1,port=%2").arg(ipRegexp.cap(1), ipRegexp.cap(2));
return rc;
}
......
......@@ -816,7 +816,7 @@ void DebuggerToolTipWidget::saveSessionData(QXmlStreamWriter &w) const
{
w.writeStartElement(QLatin1String(toolTipElementC));
QXmlStreamAttributes attributes;
attributes.append(QLatin1String(toolTipClassAttributeC), QString::fromAscii(metaObject()->className()));
attributes.append(QLatin1String(toolTipClassAttributeC), QString::fromLatin1(metaObject()->className()));
attributes.append(QLatin1String(fileNameAttributeC), m_context.fileName);
if (!m_context.function.isEmpty())
attributes.append(QLatin1String(functionAttributeC), m_context.function);
......
......@@ -275,7 +275,7 @@ static double getDumperVersion(const GdbMi &contents)
const GdbMi dumperVersionG = contents.findChild("dumperversion");
if (dumperVersionG.type() != GdbMi::Invalid) {
bool ok;
const double v = QString::fromAscii(dumperVersionG.data()).toDouble(&ok);
const double v = QString::fromLatin1(dumperVersionG.data()).toDouble(&ok);
if (ok)
return v;
}
......
......@@ -438,9 +438,9 @@ void CodaGdbAdapter::readGdbServerCommand()
m_gdbReadBuffer.append(packet);
logMessage(QLatin1String("gdb: -> ") + currentTime()
+ QLatin1Char(' ') + QString::fromAscii(packet));
+ QLatin1Char(' ') + QString::fromLatin1(packet));
if (packet != m_gdbReadBuffer)
logMessage(_("buffer: ") + QString::fromAscii(m_gdbReadBuffer));
logMessage(_("buffer: ") + QString::fromLatin1(m_gdbReadBuffer));
QByteArray &ba = m_gdbReadBuffer;
while (ba.size()) {
......@@ -550,7 +550,7 @@ void CodaGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArra
packet.append(checkSum);
int pad = qMax(0, 24 - packet.size());
logMessage(QLatin1String("gdb: <- ") + currentTime() + QLatin1Char(' ')
+ QString::fromAscii(packet) + QString(pad, QLatin1Char(' '))
+ QString::fromLatin1(packet) + QString(pad, QLatin1Char(' '))
+ QLatin1String(logNote));
sendGdbServerPacket(packet, true);
}
......@@ -712,7 +712,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
}
logMessage(_("Writing %1 bytes from 0x%2: %3").
arg(addrLength.second).arg(addrLength.first, 0, 16).
arg(QString::fromAscii(data.toHex())));
arg(QString::fromLatin1(data.toHex())));
m_codaDevice->sendMemorySetCommand(
CodaCallback(this, &CodaGdbAdapter::handleWriteMemory),
m_codaProcessId, addrLength.first, data);
......@@ -976,7 +976,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
if (!handled) {
const QString msg = _("FIXME unknown 'XFER'-request: ")
+ QString::fromAscii(cmd);
+ QString::fromLatin1(cmd);
logMessage(msgGdbPacket(msg), LogWarning);
sendGdbServerMessage("E20", msg.toLatin1());
}
......@@ -984,7 +984,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
} // qPart/qXfer
else {
logMessage(msgGdbPacket(_("FIXME unknown: ")
+ QString::fromAscii(cmd)), LogWarning);
+ QString::fromLatin1(cmd)), LogWarning);
}
}
......@@ -1126,7 +1126,7 @@ void CodaGdbAdapter::setupInferior()
QStringList libraries;
const unsigned libraryCount = sizeof(librariesC)/sizeof(char *);
for (unsigned i = 0; i < libraryCount; ++i)
libraries.push_back(QString::fromAscii(librariesC[i]));
libraries.push_back(QString::fromLatin1(librariesC[i]));
m_codaDevice->sendProcessStartCommand(
CodaCallback(this, &CodaGdbAdapter::handleCreateProcess),
......@@ -1337,7 +1337,7 @@ void CodaGdbAdapter::handleRegisterChildren(const CodaCommandResult &result)
registerNames[i].remove(0, contextLength);
if (i)
msg += QLatin1Char(',');
msg += QString::fromAscii(registerNames[i]);
msg += QString::fromLatin1(registerNames[i]);
}
logMessage(msg);
m_codaDevice->setRegisterNames(registerNames);
......
......@@ -970,7 +970,7 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
// Ideally, this code should not be present at all.
showMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN (%2). "
"TWO RESPONSES FOR ONE COMMAND?").arg(token).
arg(QString::fromAscii(stateName(state()))));
arg(QString::fromLatin1(stateName(state()))));
if (response->resultClass == GdbResultError) {
QByteArray msg = response->data.findChild("msg").data();
if (msg == "Cannot find new threads: generic error") {
......
......@@ -620,7 +620,7 @@ QByteArray symFileLoadCommand(const QString &symFileNameIn,
QString msgLoadLocalSymFile(const QString &symFileName,
const QByteArray &libName, quint64 code)
{
return QString::fromAscii("Loading symbol file '%1' for '%2' at 0x%3").
return QString::fromLatin1("Loading symbol file '%1' for '%2' at 0x%3").
arg(symFileName, QString::fromLatin1(libName)).
arg(code, 0, 16);
}
......
......@@ -184,7 +184,7 @@ QList<MemoryMarkup> RegisterMemoryView::registerMarkup(quint64 a, const QString
void RegisterMemoryView::init(RegisterHandler *h, int registerIndex)
{
m_registerIndex = registerIndex;
m_registerName = QString::fromAscii(h->registerAt(registerIndex).name);
m_registerName = QString::fromLatin1(h->registerAt(registerIndex).name);
// Known issue: CDB might reset the model by changing the special
// registers it reports.
connect(h, SIGNAL(modelReset()), this, SLOT(close()));
......
......@@ -380,7 +380,7 @@ QString Register::displayValue(int base, int strlen) const
{
const QVariant editV = editValue();
if (editV.type() == QVariant::ULongLong)
return QString::fromAscii("%1").arg(editV.toULongLong(), strlen, base);
return QString::fromLatin1("%1").arg(editV.toULongLong(), strlen, base);
const QString stringValue = editV.toString();
if (stringValue.size() < strlen)
return QString(strlen - stringValue.size(), QLatin1Char(' ')) + QLatin1String(value);
......
......@@ -207,7 +207,7 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
actEditMemory->setText(tr("Open Memory Editor at 0x%1").arg(address, 0, 16));
actEditMemory->setEnabled(canShow);
actViewMemory->setText(tr("Open Memory View at Value of Register %1 0x%2")
.arg(QString::fromAscii(aRegister.name)).arg(address, 0, 16));
.arg(QString::fromLatin1(aRegister.name)).arg(address, 0, 16));
actShowDisassemblerAt->setText(tr("Open Disassembler at 0x%1")
.arg(address, 0, 16));
actShowDisassemblerAt->setEnabled(engine->hasCapability(DisassemblerCapability));
......@@ -243,7 +243,7 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
if (act == actReload)
engine->reloadRegisters();
else if (act == actEditMemory) {
const QString registerName = QString::fromAscii(aRegister.name);
const QString registerName = QString::fromLatin1(aRegister.name);
engine->openMemoryView(address, 0,
RegisterMemoryView::registerMarkup(address, registerName),
QPoint(), RegisterMemoryView::title(registerName), 0);
......
......@@ -112,7 +112,7 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
return frame.line >= 0 ? QVariant(frame.line) : QVariant();
case 4: // Address
if (frame.address)
return QString::fromAscii("0x%1").arg(frame.address, 0, 16);
return QString::fromLatin1("0x%1").arg(frame.address, 0, 16);
return QString();
}
return QVariant();
......
......@@ -311,7 +311,7 @@ Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread)
const GdbMi frame = item.findChild("frame");
ThreadData thread;
thread.id = item.findChild("id").data().toInt();
thread.targetId = QString::fromAscii(item.findChild("target-id").data());
thread.targetId = QString::fromLatin1(item.findChild("target-id").data());
thread.core = QString::fromLatin1(item.findChild("core").data());
thread.state = QString::fromLatin1(item.findChild("state").data());
thread.address = frame.findChild("addr").data().toULongLong(&ok, 0);
......
......@@ -379,10 +379,10 @@ QString WatchData::toToolTip() const
}
formatToolTipRow(str, tr("Value"), val);
formatToolTipRow(str, tr("Object Address"),
QString::fromAscii(hexAddress()));
QString::fromLatin1(hexAddress()));
if (referencingAddress)
formatToolTipRow(str, tr("Referencing Address"),
QString::fromAscii(hexReferencingAddress()));
QString::fromLatin1(hexReferencingAddress()));
if (size)
formatToolTipRow(str, tr("Size"), QString::number(size));
formatToolTipRow(str, tr("Internal ID"), QLatin1String(iname));
......
......@@ -236,7 +236,7 @@ void IntegerWatchLineEdit::setModelData(const QVariant &v)
}
break;
case QVariant::ByteArray:
setNumberText(QString::fromAscii(v.toByteArray()));
setNumberText(QString::fromLatin1(v.toByteArray()));
break;
case QVariant::String:
setNumberText(v.toString());
......@@ -281,7 +281,7 @@ void FloatWatchLineEdit::setModelData(const QVariant &v)
setText(v.toString());
break;
case QVariant::ByteArray:
setText(QString::fromAscii(v.toByteArray()));
setText(QString::fromLatin1(v.toByteArray()));
break;
default:
qWarning("Invalid value (%s) passed to FloatWatchLineEdit::setModelData",
......
......@@ -713,14 +713,14 @@ int WatchModel::itemFormat(const WatchData &data) const
static inline QString expression(const WatchItem *item)
{
if (!item->exp.isEmpty())
return QString::fromAscii(item->exp);
return QString::fromLatin1(item->exp);
if (item->address && !item->type.isEmpty()) {
return QString::fromAscii("*(%1*)%2").
return QString::fromLatin1("*(%1*)%2").
arg(QLatin1String(item->type), QLatin1String(item->hexAddress()));
}
if (const WatchItem *parent = item->parent) {
if (!parent->exp.isEmpty())
return QString::fromAscii("(%1).%2")
return QString::fromLatin1("(%1).%2")
.arg(QString::fromLatin1(parent->exp), item->name);
}
return QString();
......
......@@ -181,7 +181,7 @@ RegisterMap registerMap(const DebuggerEngine *engine)
foreach (const Register &reg, engine->registerHandler()->registers()) {
const QVariant v = reg.editValue();
if (v.type() == QVariant::ULongLong)
result.insert(v.toULongLong(), QString::fromAscii(reg.name));
result.insert(v.toULongLong(), QString::fromLatin1(reg.name));
}
return result;
}
......
Markdown is supported
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