Commit 27fa4c04 authored by hjk's avatar hjk

debugger: distinguish between "step into" and "step over" in TrkAdapter.

parent 42eac3c9
......@@ -701,7 +701,8 @@ class SalCommand(gdb.Command):
super(SalCommand, self).__init__("sal", gdb.COMMAND_OBSCURE)
def invoke(self, arg, from_tty):
lines = catchCliOutput("info line *" + arg)
(cmd, addr) = arg.split(",")
lines = catchCliOutput("info line *" + addr)
fromAddr = "0x0"
toAddr = "0x0"
for line in lines:
......@@ -712,10 +713,11 @@ class SalCommand(gdb.Command):
if pos1to > 0:
fromAddr = line[pos0from : pos1from]
toAddr = line[pos0to : pos1to]
gdb.execute("maint packet sal%s,%s" % (fromAddr, toAddr))
gdb.execute("maint packet sal%s,%s,%s" % (cmd,fromAddr, toAddr))
SalCommand()
#######################################################################
#
# The Dumper Class
......
......@@ -1735,7 +1735,7 @@ void GdbEngine::stepExec()
showStatusMessage(tr("Step requested..."), 5000);
StackHandler *stackHandler = manager()->stackHandler();
if (m_gdbAdapter->isTrkAdapter() && stackHandler->stackSize() > 0)
postCommand("sal " + stackHandler->topAddress().toLatin1());
postCommand("sal step," + stackHandler->topAddress().toLatin1());
if (manager()->isReverseDebugging())
postCommand("-reverse-step", RunRequest, CB(handleExecStep));
else
......@@ -1797,7 +1797,7 @@ void GdbEngine::nextExec()
showStatusMessage(tr("Step next requested..."), 5000);
StackHandler *stackHandler = manager()->stackHandler();
if (m_gdbAdapter->isTrkAdapter() && stackHandler->stackSize() > 0)
postCommand("sal " + stackHandler->topAddress().toLatin1());
postCommand("sal next," + stackHandler->topAddress().toLatin1());
if (manager()->isReverseDebugging())
postCommand("-reverse-next", RunRequest, CB(handleExecNext));
else
......
......@@ -374,23 +374,27 @@ QByteArray TrkGdbAdapter::trkWriteMemoryMessage(uint addr, const QByteArray &dat
return ba;
}
QByteArray TrkGdbAdapter::trkStepRangeMessage(trk::byte option)
QByteArray TrkGdbAdapter::trkStepRangeMessage()
{
QByteArray ba;
ba.reserve(17);
appendByte(&ba, option);
//qDebug() << "STEP ON " << hexxNumber(m_snapshot.registers[RegisterPC]);
uint from = m_snapshot.lineFromAddress;
uint to = m_snapshot.lineToAddress;
uint pc = m_snapshot.registers[RegisterPC];
trk::byte option = 0x01; // Step into.
if (from <= pc && pc <= to) {
to = qMax(to - 4, from);
debugMessage("STEP IN " + hexxNumber(from) + " " + hexxNumber(to)
+ " INSTEAD OF " + hexxNumber(pc));
if (m_snapshot.stepOver)
option = 0x11; // Step over.
} else {
from = pc;
to = pc;
}
QByteArray ba;
ba.reserve(17);
appendByte(&ba, option);
appendInt(&ba, from); // Start address
appendInt(&ba, to); // End address
appendInt(&ba, m_session.pid);
......@@ -695,16 +699,24 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
trkReadRegistersMessage());
}
else if (cmd.startsWith("sal")) {
else if (cmd.startsWith("salstep,")) {
// Receive address range for current line for future use when stepping.
sendGdbServerAck();
int pos = cmd.indexOf(',');
//qDebug() << "SAL: " << cmd << cmd.mid(3, pos - 3) << cmd.mid(pos + 1);
m_snapshot.lineFromAddress = cmd.mid(3, pos - 3).toUInt(0, 16);
m_snapshot.lineFromAddress = cmd.mid(8, pos - 8).toUInt(0, 16);
m_snapshot.lineToAddress = cmd.mid(pos + 1).toUInt(0, 16);
//qDebug() << "SAL: " << hexxNumber(m_snapshot.lineFromAddress)
// << hexxNumber(m_snapshot.lineToAddress);
sendGdbServerMessage("", "Stepping range received");
m_snapshot.stepOver = false;
sendGdbServerMessage("", "Stepping range received for Step Into");
}
else if (cmd.startsWith("salnext")) {
// Receive address range for current line for future use when stepping.
sendGdbServerAck();
int pos = cmd.indexOf(',');
m_snapshot.lineFromAddress = cmd.mid(8, pos - 8).toUInt(0, 16);
m_snapshot.lineToAddress = cmd.mid(pos + 1).toUInt(0, 16);
m_snapshot.stepOver = true;
sendGdbServerMessage("", "Stepping range received for Step Over");
}
else if (cmd.startsWith("Hc")) {
......@@ -967,8 +979,8 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
sendGdbServerAck();
//m_snapshot.reset();
m_running = true;
QByteArray ba = trkStepRangeMessage(0x01); // options "step into"
sendTrkMessage(0x19, TrkCB(handleStepInto), ba, "Step range");
QByteArray ba = trkStepRangeMessage();
sendTrkMessage(0x19, TrkCB(handleStep), ba, "Step range");
}
else if (cmd.startsWith('T')) {
......@@ -1576,15 +1588,15 @@ void TrkGdbAdapter::reportReadMemoryBuffered(const TrkResult &result)
}
*/
void TrkGdbAdapter::handleStepInto(const TrkResult &result)
void TrkGdbAdapter::handleStep(const TrkResult &result)
{
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + " in handleStepInto");
logMessage("ERROR: " + result.errorString() + " in handleStep");
// Try fallback with Step Over.
debugMessage("FALLBACK TO 'STEP OVER'");
QByteArray ba = trkStepRangeMessage(0x11); // options "step over"
sendTrkMessage(0x19, TrkCB(handleStepInto2), ba, "Step range");
// Try fallback with Continue.
debugMessage("FALLBACK TO 'CONTINUE'");
sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE");
//sendGdbServerMessage("S05", "Stepping finished");
// Doing nothing as below does not work as gdb seems to insist on
// making some progress through a 'step'.
......@@ -1594,52 +1606,7 @@ void TrkGdbAdapter::handleStepInto(const TrkResult &result)
return;
}
// The gdb server response is triggered later by the Stop Reply packet
logMessage("STEP INTO FINISHED ");
}
void TrkGdbAdapter::handleStepInto2(const TrkResult &result)
{
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + " in handleStepInto2");
// Try fallback with Continue.
debugMessage("FALLBACK TO 'CONTINUE'");
sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE");
//sendGdbServerMessage("S05", "Stepping finished");
// Doing nothing as below does not work as gdb seems to insist on
// making some progress through a 'next'.
// sendTrkMessage(0x12,
// TrkCB(handleAndReportReadRegistersAfterStop),
// trkReadRegistersMessage());
return;
}
logMessage("STEP INTO FINISHED (FALLBACK)");
}
void TrkGdbAdapter::handleStepOver(const TrkResult &result)
{
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + "in handleStepOver");
// Try fallback with Step Into
QByteArray ba = trkStepRangeMessage(0x01); // options "step into"
sendTrkMessage(0x19, TrkCB(handleStepOver2), ba, "Step range");
return;
}
logMessage("STEP OVER FINISHED ");
}
void TrkGdbAdapter::handleStepOver2(const TrkResult &result)
{
if (result.errorCode()) {
logMessage("ERROR: " + result.errorString() + "in handleStepOver2");
// Try fallback with Continue
debugMessage("FALLBACK TO 'CONTINUE'");
sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(), "CONTINUE");
//sendGdbServerMessage("S05", "Stepping finished");
return;
}
logMessage("STEP OVER FINISHED (FALLBACK)");
logMessage("STEP FINISHED ");
}
void TrkGdbAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
......
......@@ -86,18 +86,23 @@ struct MemoryRange
struct Snapshot
{
Snapshot() { reset(); }
void reset();
void insertMemory(const MemoryRange &range, const QByteArray &ba);
uint registers[RegisterCount];
uint lineFromAddress;
uint lineToAddress;
bool registerValid;
typedef QMap<MemoryRange, QByteArray> Memory;
Memory memory;
// Current state.
MemoryRange wantedMemory;
// For next step.
uint lineFromAddress;
uint lineToAddress;
bool stepOver;
};
......@@ -215,10 +220,7 @@ private:
void handleAndReportSetBreakpoint(const TrkResult &result);
void handleReadMemoryBuffered(const TrkResult &result);
void handleReadMemoryUnbuffered(const TrkResult &result);
void handleStepInto(const TrkResult &result);
void handleStepInto2(const TrkResult &result);
void handleStepOver(const TrkResult &result);
void handleStepOver2(const TrkResult &result);
void handleStep(const TrkResult &result);
void handleReadRegisters(const TrkResult &result);
void handleWriteRegister(const TrkResult &result);
void reportToGdb(const TrkResult &result);
......@@ -250,7 +252,7 @@ private:
QByteArray trkReadMemoryMessage(uint addr, uint len);
QByteArray trkWriteMemoryMessage(uint addr, const QByteArray &date);
QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true);
QByteArray trkStepRangeMessage(trk::byte option);
QByteArray trkStepRangeMessage();
QByteArray trkDeleteProcessMessage();
QByteArray trkInterruptMessage();
......
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