Commit a0a4b3a3 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Trk: make adapter compile

parent a3fb0c83
......@@ -28,7 +28,7 @@
**************************************************************************/
#include "trkutils.h"
#include "trkdevice.h"
#include "trkolddevice.h"
#include <QtCore/QPointer>
#include <QtCore/QCoreApplication>
......@@ -104,7 +104,7 @@ class Adapter : public QObject
Q_OBJECT
public:
typedef Debugger::Callback<const TrkResult &> TrkCallback;
typedef trk::Callback<const TrkResult &> TrkCallback;
Adapter();
~Adapter();
......@@ -171,9 +171,9 @@ private:
void startInferiorIfNeeded();
void interruptInferior();
QSharedPointer<TrkWriteQueueDevice> m_trkDevice;
QSharedPointer<trkold::TrkWriteQueueDevice> m_trkDevice;
QSharedPointer<QIODevice> m_socket;
QSharedPointer<TrkWriteQueueIODevice> m_socketDevice;
QSharedPointer<trkold::TrkWriteQueueIODevice> m_socketDevice;
QString m_trkServerName;
QByteArray m_trkReadBuffer;
......@@ -427,7 +427,7 @@ void Adapter::sendGdbMessage(const QByteArray &msg, const QByteArray &logNote)
void Adapter::sendGdbMessageAfterSync(const QByteArray &msg, const QByteArray &logNote)
{
QByteArray ba = msg + char(1) + logNote;
sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCallback(this, &Adapter::reportToGdb), "", ba); // Answer gdb
sendTrkMessage(trkold::TRK_WRITE_QUEUE_NOOP_CODE, TrkCallback(this, &Adapter::reportToGdb), "", ba); // Answer gdb
}
void Adapter::reportToGdb(const TrkResult &result)
......@@ -476,7 +476,7 @@ void Adapter::handleGdbResponse(const QByteArray &response)
// Indicate the reason the target halted.
// The reply is the same as for step and continue.
sendGdbAckMessage();
startInferiorIfNeeded();
startInferiorIfNeeded();
sendGdbMessage("T05library:r;", "target halted (library load)");
// trap 05
// sendGdbMessage("S05", "target halted (trap)");
......@@ -597,32 +597,32 @@ void Adapter::handleGdbResponse(const QByteArray &response)
//sendGdbMessage("0000", "current IP");
sendGdbAckMessage();
#if 0
A1 = 0, first integer-like argument
A4 = 3, last integer-like argument
A1 = 0, first integer-like argument
A4 = 3, last integer-like argument
AP = 11,
IP = 12,
SP = 13, Contains address of top of stack
LR = 14, address to return to from a function call
PC = 15, Contains program counter
F0 = 16, first floating point register
F3 = 19, last floating point argument register
F7 = 23, last floating point register
FPS = 24, floating point status register
PS = 25, Contains processor status
WR0, WMMX data registers.
SP = 13, Contains address of top of stack
LR = 14, address to return to from a function call
PC = 15, Contains program counter
F0 = 16, first floating point register
F3 = 19, last floating point argument register
F7 = 23, last floating point register
FPS = 24, floating point status register
PS = 25, Contains processor status
WR0, WMMX data registers.
WR15 = WR0 + 15,
WC0, WMMX control registers.
WC0, WMMX control registers.
WCSSF = WC0 + 2,
WCASF = WC0 + 3,
WC7 = WC0 + 7,
WCGR0, WMMX general purpose registers.
WCGR0, WMMX general purpose registers.
WCGR3 = WCGR0 + 3,
WCGR7 = WCGR0 + 7,
NUM_REGS,
// Other useful registers.
FP = 11, Frame register in ARM code, if used.
THUMB_FP = 7, Frame register in Thumb code, if used.
FP = 11, Frame register in ARM code, if used.
THUMB_FP = 7, Frame register in Thumb code, if used.
NUM_ARG_REGS = 4,
LAST_ARG = A4,
NUM_FP_ARG_REGS = 4,
......@@ -803,7 +803,7 @@ void Adapter::handleGdbResponse(const QByteArray &response)
if (data.startsWith("auxv:read::")) {
const int offsetPos = data.lastIndexOf(':') + 1;
const int commaPos = data.lastIndexOf(',');
if (commaPos != -1) {
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);
......@@ -837,14 +837,14 @@ bool Adapter::openTrkPort(const QString &port, QString *errorMessage)
delete socket;
return false;
}
m_socketDevice = QSharedPointer<TrkWriteQueueIODevice>(new TrkWriteQueueIODevice(m_socket));
m_socketDevice = QSharedPointer<trkold::TrkWriteQueueIODevice>(new trkold::TrkWriteQueueIODevice(m_socket));
connect(m_socketDevice.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
if (m_verbose > 1)
m_socketDevice->setVerbose(true);
m_socketDevice->setSerialFrame(m_serialFrame);
return true;
}
m_trkDevice = QSharedPointer<TrkWriteQueueDevice>(new TrkWriteQueueDevice);
m_trkDevice = QSharedPointer<trkold::TrkWriteQueueDevice>(new trkold::TrkWriteQueueDevice);
connect(m_trkDevice.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
if (m_verbose > 1)
m_trkDevice->setVerbose(true);
......@@ -1419,7 +1419,7 @@ void Adapter::readMemory(uint addr, uint len)
}
}
const qulonglong cookie = (qulonglong(addr) << 32) + len;
sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCallback(this, &Adapter::reportReadMemoryBuffered), QByteArray(), cookie);
sendTrkMessage(trkold::TRK_WRITE_QUEUE_NOOP_CODE, TrkCallback(this, &Adapter::reportReadMemoryBuffered), QByteArray(), cookie);
} else {
if (m_verbose)
logMessage(QString::fromLatin1("Requesting unbuffered memory %1 bytes from 0x%2").arg(len).arg(addr, 0, 16));
......
TEMPLATE = app
DEBUGGERHOME = ../../../src/plugins/debugger/gdb
TRK_DIR=../../../src/shared/trk
include($$TRK_DIR/trk.pri)
INCLUDEPATH *= $$DEBUGGERHOME
INCLUDEPATH *= $$TRK_DIR
UTILSDIR = ../../../src/libs
QT = core network
win32:CONFIG+=console
HEADERS += \
$$DEBUGGERHOME/trkutils.h \
$$DEBUGGERHOME/callback.h \
$$PWD/trkdevice.h \
trkolddevice.h
SOURCES += \
$$DEBUGGERHOME/trkutils.cpp \
$$PWD/trkdevice.cpp \
$$PWD/adapter.cpp \
trkolddevice.cpp \
adapter.cpp
TEMPLATE = subdirs
SUBDIRS = trkserver swapendian runner.pro
SUBDIRS = trkserver swapendian runner.pro adapter.pro
trkserver.file = trkserver.pro
adapter.file = adapter.pro
swapendian.file = swapendian.pro
......@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "trkdevice.h"
#include "trkolddevice.h"
#include "trkutils.h"
#include <QtCore/QString>
......@@ -55,7 +55,7 @@ enum { TimerInterval = 100 };
#ifdef Q_OS_WIN
// Format windows error from GetLastError() value: TODO: Use the one provided by the utisl lib.
QString winErrorMessage(unsigned long error)
static QString winErrorMessage(unsigned long error)
{
QString rc = QString::fromLatin1("#%1: ").arg(error);
ushort *lpMsgBuf;
......@@ -73,7 +73,7 @@ QString winErrorMessage(unsigned long error)
}
// Non-blocking replacement for win-api ReadFile function
BOOL WINAPI TryReadFile(HANDLE hFile,
static BOOL WINAPI TryReadFile(HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
......@@ -96,7 +96,7 @@ BOOL WINAPI TryReadFile(HANDLE hFile,
}
#endif
namespace trk {
namespace trkold {
struct TrkDevicePrivate {
TrkDevicePrivate();
......@@ -291,7 +291,7 @@ void TrkDevice::tryTrkRead()
logMessage("Read" + d->trkReadBuffer.toHex());
if (!totalCharsRead)
return;
const ushort len = isValidTrkResult(d->trkReadBuffer, d->serialFrame);
const ushort len = trk::isValidTrkResult(d->trkReadBuffer, d->serialFrame);
if (!len) {
const QString msg = QString::fromLatin1("Partial message: %1").arg(stringFromArray(d->trkReadBuffer));
emitError(msg);
......@@ -305,7 +305,7 @@ void TrkDevice::tryTrkRead()
if (verbose())
logMessage("READ " + data.toHex());
d->trkReadBuffer.append(data);
const ushort len = isValidTrkResult(d->trkReadBuffer, d->serialFrame);
const ushort len = trk::isValidTrkResult(d->trkReadBuffer, d->serialFrame);
if (!len) {
if (d->trkReadBuffer.size() > 10) {
const QString msg = QString::fromLatin1("Unable to extract message from '%1' '%2'").
......@@ -315,7 +315,7 @@ void TrkDevice::tryTrkRead()
return;
}
#endif // Q_OS_WIN
TrkResult r;
trk::TrkResult r;
QByteArray rawData;
while (extractResult(&d->trkReadBuffer, d->serialFrame, &r, &rawData)) {
if (verbose())
......@@ -340,7 +340,7 @@ void TrkDevice::emitError(const QString &s)
/* A message to be send to TRK, triggering a callback on receipt
* of the answer. */
typedef Debugger::Callback<const TrkResult &> TrkCallback;
typedef trk::Callback<const trk::TrkResult &> TrkCallback;
struct TrkMessage {
explicit TrkMessage(unsigned char code = 0u,
unsigned char token = 0u,
......@@ -380,7 +380,7 @@ public:
void queueTrkInitialPing();
// Call this from the device read notification with the results.
void slotHandleResult(const TrkResult &result);
void slotHandleResult(const trk::TrkResult &result);
// This can be called periodically in a timer to retrieve
// the pending messages to be sent.
......@@ -439,7 +439,7 @@ bool TrkWriteQueue::pendingMessage(SharedPointerTrkMessage *message)
if (trkWriteQueue.front()->code == TRK_WRITE_QUEUE_NOOP_CODE) {
const SharedPointerTrkMessage noopMessage = trkWriteQueue.dequeue();
if (noopMessage->callback) {
TrkResult result;
trk::TrkResult result;
result.code = noopMessage->code;
result.token = noopMessage->token;
result.data = noopMessage->data;
......@@ -458,17 +458,17 @@ bool TrkWriteQueue::pendingMessage(SharedPointerTrkMessage *message)
void TrkWriteQueue::notifyWriteResult(bool ok)
{
// On success, dequeue message and await result
if (ok) {
if (ok) {
const SharedPointerTrkMessage firstMsg = trkWriteQueue.dequeue();
writtenTrkMessages.insert(firstMsg->token, firstMsg);
trkWriteBusy = true;
}
}
void TrkWriteQueue::slotHandleResult(const TrkResult &result)
void TrkWriteQueue::slotHandleResult(const trk::TrkResult &result)
{
trkWriteBusy = false;
if (result.code != TrkNotifyAck && result.code != TrkNotifyNak)
if (result.code != trk::TrkNotifyAck && result.code != trk::TrkNotifyNak)
return;
// Find which request the message belongs to and invoke callback
// if ACK or on NAK if desired.
......@@ -476,10 +476,10 @@ void TrkWriteQueue::slotHandleResult(const TrkResult &result)
if (it == writtenTrkMessages.end())
return;
const bool invokeCB = it.value()->callback
&& (result.code == TrkNotifyAck || it.value()->invokeOnNAK);
&& (result.code == trk::TrkNotifyAck || it.value()->invokeOnNAK);
if (invokeCB) {
TrkResult result1 = result;
trk::TrkResult result1 = result;
result1.cookie = it.value()->cookie;
it.value()->callback(result1);
}
......@@ -545,9 +545,9 @@ void TrkWriteQueueDevice::tryTrkWrite()
bool TrkWriteQueueDevice::trkWriteRawMessage(const TrkMessage &msg)
{
const QByteArray ba = frameMessage(msg.code, msg.token, msg.data, serialFrame());
const QByteArray ba = trk::frameMessage(msg.code, msg.token, msg.data, serialFrame());
if (verbose())
logMessage("WRITE: " + stringFromArray(ba));
logMessage("WRITE: " + trk::stringFromArray(ba));
QString errorMessage;
const bool rc = write(ba, &errorMessage);
if (!rc)
......@@ -561,7 +561,7 @@ void TrkWriteQueueDevice::timerEvent(QTimerEvent *ev)
TrkDevice::timerEvent(ev);
}
void TrkWriteQueueDevice::slotHandleResult(const TrkResult &result)
void TrkWriteQueueDevice::slotHandleResult(const trk::TrkResult &result)
{
qd->slotHandleResult(result);
}
......@@ -657,9 +657,9 @@ void TrkWriteQueueIODevice::tryTrkWrite()
bool TrkWriteQueueIODevice::trkWriteRawMessage(const TrkMessage &msg)
{
const QByteArray ba = frameMessage(msg.code, msg.token, msg.data, serialFrame());
const QByteArray ba = trk::frameMessage(msg.code, msg.token, msg.data, serialFrame());
if (verbose())
logMessage("WRITE: " + stringFromArray(ba));
logMessage("WRITE: " + trk::stringFromArray(ba));
const bool ok = d->device->write(ba) != -1;
if (!ok) {
const QString msg = QString::fromLatin1("Unable to write %1 bytes: %2:").arg(ba.size()).arg(d->device->errorString());
......@@ -677,9 +677,9 @@ void TrkWriteQueueIODevice::tryTrkRead()
//if (verbose())
logMessage("READ " + newData.toHex());
d->readBuffer.append(newData);
TrkResult r;
trk::TrkResult r;
QByteArray rawData;
while (extractResult(&(d->readBuffer), d->serialFrame, &r, &rawData)) {
while (trk::extractResult(&(d->readBuffer), d->serialFrame, &r, &rawData)) {
d->queue.slotHandleResult(r);
emit messageReceived(r);
if (!rawData.isEmpty())
......@@ -687,4 +687,4 @@ void TrkWriteQueueIODevice::tryTrkRead()
}
}
} // namespace tr
} // namespace trkold
......@@ -27,8 +27,8 @@
**
**************************************************************************/
#ifndef TRKDEVICE_H
#define TRKDEVICE_H
#ifndef TRKOLDDEVICE_H
#define TRKOLDDEVICE_H
#include "callback.h"
......@@ -41,9 +41,13 @@ QT_BEGIN_NAMESPACE
class QIODevice;
QT_END_NAMESPACE
namespace trk {
struct TrkResult;
}
namespace trkold {
struct TrkResult;
struct TrkMessage;
struct TrkDevicePrivate;
class TrkWriteQueue;
......@@ -85,7 +89,7 @@ signals:
void rawDataReceived(const QByteArray &data);
void error(const QString &msg);
void logMessage(const QString &msg);
protected:
void emitError(const QString &msg);
virtual void timerEvent(QTimerEvent *ev);
......@@ -112,7 +116,7 @@ public:
virtual ~TrkWriteQueueDevice();
// Construct as 'TrkWriteQueueDevice::TrkCallback(instance, &Class::method);'
typedef Debugger::Callback<const TrkResult &> TrkCallback;
typedef trk::Callback<const trk::TrkResult &> TrkCallback;
// Enqueue a message with a notification callback.
void sendTrkMessage(unsigned char code,
......@@ -155,7 +159,7 @@ class TrkWriteQueueIODevice : public QObject
Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame)
Q_PROPERTY(bool verbose READ verbose WRITE setVerbose)
public:
typedef Debugger::Callback<const TrkResult &> TrkCallback;
typedef trk::Callback<const trk::TrkResult &> TrkCallback;
explicit TrkWriteQueueIODevice(const QSharedPointer<QIODevice> &device,
QObject *parent = 0);
......@@ -186,13 +190,13 @@ protected:
virtual void timerEvent(QTimerEvent *ev);
private:
void tryTrkRead();
void tryTrkRead();
void tryTrkWrite();
bool trkWriteRawMessage(const TrkMessage &msg);
TrkWriteQueueIODevicePrivate *d;
};
} // namespace trk
} // namespace trkold
#endif // TRKDEVICE_H
#endif // TRKOLDDEVICE_H
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