Commit 6fc1bfb2 authored by hjk's avatar hjk Committed by con
Browse files

debugger: backport some symbian fixes

Reviewed-by: Robert Loehning
parent 86567e68
......@@ -82,7 +82,7 @@ static const char *registerNames[KnownRegisters] =
0, "PSGdb"
};
static QByteArray dumpRegister(int n, uint value)
static QByteArray dumpRegister(uint n, uint value)
{
QByteArray ba;
ba += ' ';
......@@ -152,7 +152,7 @@ void Snapshot::reset()
void Snapshot::insertMemory(const MemoryRange &range, const QByteArray &ba)
{
QTC_ASSERT(range.size() == ba.size(),
QTC_ASSERT(range.size() == uint(ba.size()),
qDebug() << "RANGE: " << range << " BA SIZE: " << ba.size(); return);
MEMORY_DEBUG("INSERT: " << range);
......@@ -164,18 +164,20 @@ void Snapshot::insertMemory(const MemoryRange &range, const QByteArray &ba)
MEMORY_DEBUG("COMBINING " << it.key() << " AND " << range);
QByteArray data = *it;
data.append(ba);
const MemoryRange res(it.key().from, range.to);
memory.remove(it.key());
memory.insert(MemoryRange(it.key().from, range.to), data);
MEMORY_DEBUG(" TO " << MemoryRange(it.key().from, range.to));
memory.insert(res, data);
MEMORY_DEBUG(" TO(1) " << res);
return;
}
if (it.key().from == range.to) {
MEMORY_DEBUG("COMBINING " << range << " AND " << it.key());
QByteArray data = ba;
data.append(*it);
const MemoryRange res(range.from, it.key().to);
memory.remove(it.key());
memory.insert(MemoryRange(range.from, it.key().to), data);
MEMORY_DEBUG(" TO " << MemoryRange(range.from, it.key().to));
memory.insert(res, data);
MEMORY_DEBUG(" TO(2) " << res);
return;
}
}
......@@ -183,7 +185,6 @@ void Snapshot::insertMemory(const MemoryRange &range, const QByteArray &ba)
// Not combinable, add chunk.
memory.insert(range, ba);
}
///////////////////////////////////////////////////////////////////////////
//
// TrkGdbAdapter
......@@ -343,7 +344,7 @@ QByteArray TrkGdbAdapter::trkStepRangeMessage(byte option)
QByteArray ba;
ba.reserve(17);
appendByte(&ba, option);
qDebug() << "STEP ON " << hexxNumber(m_snapshot.registers[RegisterPC]);
//qDebug() << "STEP ON " << hexxNumber(m_snapshot.registers[RegisterPC]);
appendInt(&ba, m_snapshot.registers[RegisterPC]); // Start address
appendInt(&ba, m_snapshot.registers[RegisterPC]); // End address
appendInt(&ba, m_session.pid);
......@@ -615,7 +616,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
//Reply: See section D.3 Stop Reply Packets, for the reply specifications.
sendGdbServerAck();
bool ok = false;
uint signalNumber = cmd.mid(1).toInt(&ok, 16);
uint signalNumber = cmd.mid(1).toUInt(&ok, 16);
QByteArray ba;
appendInt(&ba, m_session.pid);
appendInt(&ba, m_session.tid);
......@@ -649,7 +650,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
// for 'other operations. 0 - any thread
//$Hg0#df
sendGdbServerAck();
m_session.currentThread = cmd.mid(2).toInt(0, 16);
m_session.currentThread = cmd.mid(2).toUInt(0, 16);
sendGdbServerMessage("OK", "Set current thread "
+ QByteArray::number(m_session.currentThread));
}
......@@ -691,7 +692,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
//sendGdbServerMessage("0000", "current IP");
sendGdbServerAck();
bool ok = false;
const uint registerNumber = cmd.mid(1).toInt(&ok, 16);
const uint registerNumber = cmd.mid(1).toUInt(&ok, 16);
QByteArray logMsg = "Read Register";
if (registerNumber == RegisterPSGdb) {
QByteArray ba;
......@@ -718,8 +719,8 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
QByteArray regName = cmd.mid(1, pos - 1);
QByteArray valueName = cmd.mid(pos + 1);
bool ok = false;
const uint registerNumber = regName.toInt(&ok, 16);
const uint value = swapEndian(valueName.toInt(&ok, 16));
const uint registerNumber = regName.toUInt(&ok, 16);
const uint value = swapEndian(valueName.toUInt(&ok, 16));
// FIXME: Assume all goes well.
m_snapshot.registers[registerNumber] = value;
QByteArray ba = trkWriteRegisterMessage(registerNumber, value);
......@@ -875,14 +876,22 @@ i */
logMessage(msgGdbPacket(QLatin1String("Insert breakpoint")));
// $Z0,786a4ccc,4#99
const int pos = cmd.lastIndexOf(',');
bool ok = false;
const uint addr = cmd.mid(3, pos - 3).toInt(&ok, 16);
const uint len = cmd.mid(pos + 1).toInt(&ok, 16);
//qDebug() << "ADDR: " << hexNumber(addr) << " LEN: " << len;
logMessage(_("Inserting breakpoint at 0x%1, %2")
.arg(addr, 0, 16).arg(len));
const QByteArray ba = trkBreakpointMessage(addr, len, len == 4);
sendTrkMessage(0x1B, TrkCB(handleAndReportSetBreakpoint), ba, addr);
bool ok1 = false;
bool ok2 = false;
const uint addr = cmd.mid(3, pos - 3).toUInt(&ok1, 16);
const uint len = cmd.mid(pos + 1).toUInt(&ok2, 16);
if (!ok1) {
logMessage("MISPARSED ADDRESS FROM " + cmd +
" (" + cmd.mid(3, pos - 3) + ")");
} else if (!ok2) {
logMessage("MISPARSED BREAKPOINT SIZE FROM " + cmd);
} else {
//qDebug() << "ADDR: " << hexNumber(addr) << " LEN: " << len;
logMessage(_("Inserting breakpoint at 0x%1, %2")
.arg(addr, 0, 16).arg(len));
const QByteArray ba = trkBreakpointMessage(addr, len, len == 4);
sendTrkMessage(0x1B, TrkCB(handleAndReportSetBreakpoint), ba, addr);
}
}
else if (cmd.startsWith("z0,") || cmd.startsWith("z1,")) {
......@@ -892,8 +901,8 @@ i */
// $z0,786a4ccc,4#99
const int pos = cmd.lastIndexOf(',');
bool ok = false;
const uint addr = cmd.mid(3, pos - 3).toInt(&ok, 16);
const uint len = cmd.mid(pos + 1).toInt(&ok, 16);
const uint addr = cmd.mid(3, pos - 3).toUInt(&ok, 16);
const uint len = cmd.mid(pos + 1).toUInt(&ok, 16);
const uint bp = m_session.addressToBP[addr];
if (bp == 0) {
logMessage(_("NO RECORDED BP AT 0x%1, %2")
......@@ -917,8 +926,8 @@ i */
if (commaPos != -1) {
bool ok1 = false, ok2 = false;
const int offset = data.mid(offsetPos, commaPos - offsetPos)
.toInt(&ok1, 16);
const int length = data.mid(commaPos + 1).toInt(&ok2, 16);
.toUInt(&ok1, 16);
const int length = data.mid(commaPos + 1).toUInt(&ok2, 16);
if (ok1 && ok2) {
const QString msg = _("Read of OS auxilary "
"vector (%1, %2) not implemented.").arg(offset).arg(length);
......@@ -961,7 +970,9 @@ void TrkGdbAdapter::handleTrkError(const QString &msg)
void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
{
if (result.isDebugOutput) {
sendTrkAck(result.token);
// It looks like those messages _must not_ be acknowledged.
// If we do so, TRK will complain about wrong sequencing.
//sendTrkAck(result.token);
logMessage(QLatin1String("APPLICATION OUTPUT: ") +
QString::fromAscii(result.data));
sendGdbServerMessage("O" + result.data.toHex());
......@@ -982,6 +993,8 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
}
case 0x90: { // Notified Stopped
// 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00
debugMessage(_("RESET SNAPSHOT (NOTIFY STOPPED)"));
m_snapshot.reset();
const char *data = result.data.data();
const uint addr = extractInt(data);
const uint pid = extractInt(data + 4);
......@@ -1007,11 +1020,15 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
break;
}
case 0x91: { // Notify Exception (obsolete)
debugMessage(_("RESET SNAPSHOT (NOTIFY EXCEPTION)"));
m_snapshot.reset();
logMessage(prefix + "NOTE: EXCEPTION " + str);
sendTrkAck(result.token);
break;
}
case 0x92: { //
debugMessage(_("RESET SNAPSHOT (NOTIFY INTERNAL ERROR)"));
m_snapshot.reset();
logMessage(prefix + "NOTE: INTERNAL ERROR: " + str);
sendTrkAck(result.token);
break;
......@@ -1019,6 +1036,10 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
// target->host OS notification
case 0xa0: { // Notify Created
debugMessage(_("RESET SNAPSHOT (NOTIFY CREATED)"));
// Sending this ACK does not seem to make a difference. Why?
//sendTrkAck(result.token);
m_snapshot.reset();
const char *data = result.data.data();
const byte error = result.data.at(0);
// type: 1 byte; for dll item, this value is 2.
......@@ -1049,10 +1070,16 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
// With CS gdb 6.4 we get a non-standard $qfDllInfo#7f+ request
// afterwards, so don't use it for now.
//sendGdbServerMessage("T05library:;");
/*
// Causes too much "stopped" (by SIGTRAP) messages that need
// to be answered by "continue". Auto-continuing each SIGTRAP
// is not possible as this is also the real message for a user
// initiated interrupt.
sendGdbServerMessage("T05load:Name=" + lib.name.toHex()
+ ",TextSeg=" + hexNumber(lib.codeseg)
+ ",DataSeg=" + hexNumber(lib.dataseg) + ';');
//sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE");
*/
sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE");
break;
}
case 0xa1: { // NotifyDeleted
......@@ -1358,6 +1385,7 @@ void TrkGdbAdapter::reportReadMemoryBuffered(const TrkResult &result)
void TrkGdbAdapter::handleStepInto(const TrkResult &result)
{
debugMessage(_("RESET SNAPSHOT"));
m_snapshot.reset();
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + " in handleStepInto");
......@@ -1384,6 +1412,7 @@ void TrkGdbAdapter::handleStepInto2(const TrkResult &result)
void TrkGdbAdapter::handleStepOver(const TrkResult &result)
{
debugMessage(_("RESET SNAPSHOT"));
m_snapshot.reset();
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + "in handleStepOver");
......@@ -1414,7 +1443,8 @@ void TrkGdbAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
// Error: 0x00
// [80 09 00 00 00 00 0A]
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString());
logMessage("ERROR WHEN SETTING BREAKPOINT: " + result.errorString());
sendGdbServerMessage("E21");
return;
}
uint bpnr = extractInt(result.data.data() + 1);
......@@ -1438,7 +1468,7 @@ void TrkGdbAdapter::handleClearBreakpoint(const TrkResult &result)
void TrkGdbAdapter::handleSignalContinue(const TrkResult &result)
{
int signalNumber = result.cookie.toInt();
int signalNumber = result.cookie.toUInt();
logMessage(" HANDLE SIGNAL CONTINUE: " + stringFromArray(result.data));
logMessage("NUMBER" + QString::number(signalNumber));
sendGdbServerMessage("O" + QByteArray("Console output").toHex());
......@@ -1602,9 +1632,11 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
m_session.tid = extractInt(data + 5);
m_session.codeseg = extractInt(data + 9);
m_session.dataseg = extractInt(data + 13);
const QString startMsg = tr("Process started, PID: 0x%1, thread id: 0x%2, code segment: 0x%3, data segment: 0x%4.")
.arg(m_session.pid, 0, 16).arg(m_session.tid, 0, 16)
.arg(m_session.codeseg, 0, 16).arg(m_session.dataseg, 0, 16);
const QString startMsg =
tr("Process started, PID: 0x%1, thread id: 0x%2, "
"code segment: 0x%3, data segment: 0x%4.")
.arg(m_session.pid, 0, 16).arg(m_session.tid, 0, 16)
.arg(m_session.codeseg, 0, 16).arg(m_session.dataseg, 0, 16);
logMessage(startMsg);
......@@ -1654,7 +1686,7 @@ void TrkGdbAdapter::write(const QByteArray &data)
if (data1.endsWith(' '))
data1.chop(1);
bool ok;
uint addr = data1.toInt(&ok, 0);
uint addr = data1.toUInt(&ok, 0);
qDebug() << "Writing: " << quoteUnprintableLatin1(data1) << addr;
directStep(addr);
return;
......
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