Commit 0bde89ee authored by hjk's avatar hjk
Browse files

debugger: use the direct access withing trkadapter to list threads

parent f0314d0f
......@@ -57,8 +57,6 @@ public:
virtual ~AbstractGdbAdapter();
virtual void write(const QByteArray &data);
virtual bool isTrkAdapter() const;
virtual void trkReloadRegisters() {}
virtual void startAdapter() = 0;
virtual void startInferior() = 0;
......@@ -76,6 +74,11 @@ public:
static QString msgInferiorRunning();
static QString msgConnectRemoteServerFailed(const QString &why);
// Trk specific stuff
virtual bool isTrkAdapter() const;
virtual void trkReloadRegisters() {}
virtual void trkReloadThreads() {}
signals:
void adapterStarted();
......
......@@ -1377,8 +1377,11 @@ void GdbEngine::handleStop1(const GdbMi &data)
if (supportsThreads()) {
int currentId = data.findChild("thread-id").data().toInt();
postCommand("-thread-list-ids", WatchUpdate,
CB(handleStackListThreads), currentId);
if (m_gdbAdapter->isTrkAdapter())
m_gdbAdapter->trkReloadThreads();
else
postCommand("-thread-list-ids", WatchUpdate,
CB(handleStackListThreads), currentId);
}
//
......@@ -1415,7 +1418,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
QRegExp supported(_("GNU gdb(.*) (\\d+)\\.(\\d+)(\\.(\\d+))?(-(\\d+))?"));
if (supported.indexIn(msg) >= 0) {
debugMessage(_("UNSUPPORTED GDB VERSION ") + msg);
debugMessage(_("SUPPORTED GDB VERSION ") + msg);
m_gdbVersion = 10000 * supported.cap(2).toInt()
+ 100 * supported.cap(3).toInt()
+ 1 * supported.cap(5).toInt();
......@@ -1441,6 +1444,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
}
if (!foundIt) {
debugMessage(_("UNSUPPORTED GDB VERSION ") + msg);
#if 0
QStringList list = msg.split(_c('\n'));
while (list.size() > 2)
......
......@@ -198,7 +198,10 @@ void GdbEngine::updateAllPython()
postCommand("-stack-list-frames", WatchUpdate, CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, true)));
manager()->stackHandler()->setCurrentIndex(0);
if (supportsThreads())
qDebug() << "IS TRK: " << m_gdbAdapter->isTrkAdapter();
if (m_gdbAdapter->isTrkAdapter())
m_gdbAdapter->trkReloadThreads();
else
postCommand("-thread-list-ids", WatchUpdate, CB(handleStackListThreads), 0);
manager()->reloadRegisters();
updateLocals();
......
......@@ -36,6 +36,7 @@
#include "bluetoothlistener_gui.h"
#include "registerhandler.h"
#include "stackhandler.h"
#include "debuggeractions.h"
#include "debuggerstringutils.h"
#ifndef STANDALONE_RUNNER
......@@ -381,17 +382,18 @@ QByteArray TrkGdbAdapter::trkStepRangeMessage()
uint to = m_snapshot.lineToAddress;
uint pc = m_snapshot.registers[RegisterPC];
trk::byte option = 0x01; // Step into.
if (m_snapshot.stepOver)
option = 0x11; // Step over.
if (from <= pc && pc <= to) {
to = qMax(to - 4, from);
//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;
}
//qDebug() << "USING" << int(option) << (option == 1 ? " INTO " : " OVER");
QByteArray ba;
ba.reserve(17);
appendByte(&ba, option);
......@@ -702,17 +704,17 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
else if (cmd.startsWith("salstep,")) {
// Receive address range for current line for future use when stepping.
sendGdbServerAck();
int pos = cmd.indexOf(',');
int pos = cmd.indexOf(',', 8);
m_snapshot.lineFromAddress = cmd.mid(8, pos - 8).toUInt(0, 16);
m_snapshot.lineToAddress = cmd.mid(pos + 1).toUInt(0, 16);
m_snapshot.stepOver = false;
sendGdbServerMessage("", "Stepping range received for Step Into");
}
else if (cmd.startsWith("salnext")) {
else if (cmd.startsWith("salnext,")) {
// Receive address range for current line for future use when stepping.
sendGdbServerAck();
int pos = cmd.indexOf(',');
int pos = cmd.indexOf(',', 8);
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;
......@@ -1823,9 +1825,9 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
m_engine->postCommand("set breakpoint auto-hw on");
m_engine->postCommand("set trust-readonly-sections"); // No difference?
m_engine->postCommand("set displaced-stepping on"); // No difference?
m_engine->postCommand("set mem inaccessible-by-default");
//m_engine->postCommand("set mem inaccessible-by-default");
m_engine->postCommand("mem 0x00400000 0x00800000 cache");
m_engine->postCommand("mem 0x70000000 0x80000000 cache");
m_engine->postCommand("mem 0x70000000 0x80000000 cache ro");
// FIXME: replace with stack-cache for newer gdb?
m_engine->postCommand("set remotecache on"); // "info dcache" to check
m_engine->postCommand("target remote " + gdbServerName().toLatin1(),
......@@ -2107,6 +2109,17 @@ void TrkGdbAdapter::trkReloadRegisters()
handler->setRegisters(registers);
}
void TrkGdbAdapter::trkReloadThreads()
{
// Take advantage of direct access to cached register values.
QTC_ASSERT(m_snapshot.registerValid, /**/);
QList<ThreadData> threads;
foreach (const Session::Thread &thread, m_session.threads) {
threads.append(thread);
}
ThreadsHandler *handler = m_engine->manager()->threadsHandler();
handler->setThreads(threads);
}
} // namespace Internal
} // namespace Debugger
......@@ -151,6 +151,7 @@ public:
void setBufferedMemoryRead(bool b) { m_bufferedMemoryRead = b; }
trk::Session &session() { return m_session; }
void trkReloadRegisters();
void trkReloadThreads();
signals:
void output(const QString &msg);
......
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