2010-06-25 15:06:30 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-06-25 15:06:30 +02:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2010-06-25 15:06:30 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2010-06-25 15:06:30 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-06-25 15:06:30 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2011-02-07 14:26:34 +01:00
|
|
|
#ifndef DEBUGGER_CODAGDBADAPTER_H
|
|
|
|
|
#define DEBUGGER_CODAGDBADAPTER_H
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
#include "abstractgdbadapter.h"
|
2010-11-02 16:14:00 +01:00
|
|
|
#include "localgdbprocess.h"
|
2010-06-25 15:06:30 +02:00
|
|
|
#include "callback.h"
|
|
|
|
|
#include "trkutils.h"
|
|
|
|
|
#include "symbian.h"
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QPointer>
|
|
|
|
|
#include <QtCore/QSharedPointer>
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTcpServer;
|
|
|
|
|
class QTcpSocket;
|
|
|
|
|
class QIODevice;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2011-02-07 14:26:34 +01:00
|
|
|
namespace Coda {
|
|
|
|
|
struct CodaCommandResult;
|
|
|
|
|
class CodaDevice;
|
|
|
|
|
class CodaEvent;
|
|
|
|
|
class CodaRunControlModuleLoadContextSuspendedEvent;
|
2010-06-25 15:06:30 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-21 16:36:49 +01:00
|
|
|
namespace SymbianUtils {
|
|
|
|
|
class SymbianDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 15:06:30 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
struct MemoryRange;
|
|
|
|
|
struct GdbResult;
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2011-02-07 14:26:34 +01:00
|
|
|
// CodaGdbAdapter
|
2010-06-25 15:06:30 +02:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-02-07 14:26:34 +01:00
|
|
|
class CodaGdbAdapter : public AbstractGdbAdapter
|
2010-06-25 15:06:30 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
typedef trk::Callback<const GdbResult &> GdbResultCallback;
|
2011-02-07 14:26:34 +01:00
|
|
|
typedef trk::Callback<const Coda::CodaCommandResult &> CodaCallback;
|
2010-06-25 15:06:30 +02:00
|
|
|
typedef trk::Callback<const GdbResponse &> GdbCallback;
|
|
|
|
|
|
2011-02-07 14:26:34 +01:00
|
|
|
explicit CodaGdbAdapter(GdbEngine *engine);
|
|
|
|
|
virtual ~CodaGdbAdapter();
|
2010-06-25 15:06:30 +02:00
|
|
|
void setGdbServerName(const QString &name);
|
|
|
|
|
QString gdbServerName() const { return m_gdbServerName; }
|
2010-09-09 17:08:45 +02:00
|
|
|
|
2010-06-25 15:06:30 +02:00
|
|
|
Q_SLOT void setVerbose(const QVariant &value);
|
|
|
|
|
void setVerbose(int verbose);
|
|
|
|
|
void setBufferedMemoryRead(bool b) { m_bufferedMemoryRead = b; }
|
|
|
|
|
|
|
|
|
|
void trkReloadRegisters();
|
|
|
|
|
void trkReloadThreads();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void output(const QString &msg);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
//
|
|
|
|
|
// Implementation of GdbProcessBase
|
|
|
|
|
//
|
|
|
|
|
void start(const QString &program, const QStringList &args,
|
|
|
|
|
QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
|
|
|
|
void write(const QByteArray &data);
|
|
|
|
|
bool isTrkAdapter() const { return true; }
|
|
|
|
|
|
|
|
|
|
virtual DumperHandling dumperHandling() const { return DumperNotAvailable; }
|
|
|
|
|
|
|
|
|
|
private:
|
2011-02-07 14:14:57 +01:00
|
|
|
void setupTrkDeviceSignals();
|
2010-06-25 15:06:30 +02:00
|
|
|
void startAdapter();
|
2010-07-08 18:10:50 +02:00
|
|
|
void setupInferior();
|
2010-07-09 17:07:59 +02:00
|
|
|
void runEngine();
|
2010-06-25 15:06:30 +02:00
|
|
|
void interruptInferior();
|
2010-07-09 17:07:59 +02:00
|
|
|
void shutdownInferior();
|
|
|
|
|
void shutdownAdapter();
|
2010-12-02 15:16:53 +01:00
|
|
|
void sendRunControlTerminateCommand();
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleRunControlTerminate(const Coda::CodaCommandResult &);
|
2010-09-09 17:08:45 +02:00
|
|
|
void sendRegistersGetMCommand();
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleWriteRegister(const Coda::CodaCommandResult &result);
|
2010-06-25 15:06:30 +02:00
|
|
|
void reportRegisters();
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleReadRegisters(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleRegisterChildren(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleAndReportReadRegisters(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleAndReportReadRegister(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleAndReportReadRegistersAfterStop(const Coda::CodaCommandResult &result);
|
2010-08-11 15:46:55 +02:00
|
|
|
QByteArray stopMessage() const;
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleAndReportSetBreakpoint(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleClearBreakpoint(const Coda::CodaCommandResult &result);
|
2010-06-25 15:06:30 +02:00
|
|
|
void readMemory(uint addr, uint len, bool buffered);
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleReadMemoryBuffered(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleReadMemoryUnbuffered(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleWriteMemory(const Coda::CodaCommandResult &result);
|
2010-06-25 15:06:30 +02:00
|
|
|
void tryAnswerGdbMemoryRequest(bool buffered);
|
|
|
|
|
inline void sendMemoryGetCommand(const MemoryRange &range, bool buffered);
|
2010-06-30 17:14:57 +02:00
|
|
|
void addThread(unsigned id);
|
2010-06-25 15:06:30 +02:00
|
|
|
inline QByteArray mainThreadContextId() const;
|
2010-06-30 17:14:57 +02:00
|
|
|
inline QByteArray currentThreadContextId() const;
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
|
|
|
|
|
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
|
|
void handleTargetRemote(const GdbResponse &response);
|
|
|
|
|
|
|
|
|
|
QString m_gdbServerName; // 127.0.0.1:(2222+uid)
|
|
|
|
|
bool m_running;
|
2010-09-29 16:39:46 +02:00
|
|
|
int m_stopReason;
|
2011-02-07 14:14:57 +01:00
|
|
|
|
|
|
|
|
QSharedPointer<Coda::CodaDevice> m_codaDevice;
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Gdb
|
|
|
|
|
//
|
|
|
|
|
Q_SLOT void handleGdbConnection();
|
|
|
|
|
Q_SLOT void readGdbServerCommand();
|
2011-03-21 16:36:49 +01:00
|
|
|
Q_SLOT void codaDeviceError(const QString &);
|
|
|
|
|
Q_SLOT void codaDeviceRemoved(const SymbianUtils::SymbianDevice &dev);
|
|
|
|
|
|
2010-06-25 15:06:30 +02:00
|
|
|
void startGdb();
|
2011-02-07 14:26:34 +01:00
|
|
|
Q_SLOT void codaEvent(const Coda::CodaEvent &knownEvent);
|
|
|
|
|
void handleCodaRunControlModuleLoadContextSuspendedEvent(const Coda::CodaRunControlModuleLoadContextSuspendedEvent &e);
|
2010-06-25 15:06:30 +02:00
|
|
|
inline void sendTrkContinue();
|
|
|
|
|
void sendTrkStepRange();
|
2011-02-07 14:26:34 +01:00
|
|
|
void handleStep(const Coda::CodaCommandResult &result);
|
|
|
|
|
void handleCreateProcess(const Coda::CodaCommandResult &result);
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
void readGdbResponse();
|
|
|
|
|
void handleGdbServerCommand(const QByteArray &cmd);
|
|
|
|
|
void sendGdbServerMessage(const QByteArray &msg,
|
|
|
|
|
const QByteArray &logNote = QByteArray());
|
|
|
|
|
void sendGdbServerAck();
|
|
|
|
|
bool sendGdbServerPacket(const QByteArray &packet, bool doFlush);
|
2010-06-30 17:14:57 +02:00
|
|
|
void gdbSetCurrentThread(const QByteArray &cmd, const char *why);
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
void logMessage(const QString &msg, int channel = LogDebug); // triggers output() if m_verbose
|
2011-03-21 16:36:49 +01:00
|
|
|
Q_SLOT void codaLogMessage(const QString &msg);
|
2010-06-25 15:06:30 +02:00
|
|
|
|
|
|
|
|
QPointer<QTcpServer> m_gdbServer;
|
|
|
|
|
QPointer<QTcpSocket> m_gdbConnection;
|
|
|
|
|
QByteArray m_gdbReadBuffer;
|
|
|
|
|
bool m_gdbAckMode;
|
|
|
|
|
|
|
|
|
|
// Debuggee state
|
|
|
|
|
trk::Session m_session; // global-ish data (process id, target information)
|
|
|
|
|
Symbian::Snapshot m_snapshot; // local-ish data (memory and registers)
|
|
|
|
|
QString m_remoteExecutable;
|
|
|
|
|
unsigned m_uid;
|
|
|
|
|
QStringList m_remoteArguments;
|
|
|
|
|
QString m_symbolFile;
|
2010-12-02 14:07:53 +01:00
|
|
|
QString m_symbolFileFolder;
|
2010-06-25 15:06:30 +02:00
|
|
|
int m_verbose;
|
|
|
|
|
bool m_bufferedMemoryRead;
|
2010-08-13 12:38:10 +02:00
|
|
|
bool m_firstResumableExeLoadedEvent;
|
2010-09-09 17:08:45 +02:00
|
|
|
// gdb wants registers, but we don't have the names yet. Continue in handler for names
|
|
|
|
|
bool m_registerRequestPending;
|
2010-06-25 15:06:30 +02:00
|
|
|
QByteArray m_tcfProcessId;
|
|
|
|
|
LocalGdbProcess m_gdbProc;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2011-02-07 14:26:34 +01:00
|
|
|
#endif // DEBUGGER_CODAGDBADAPTER_H
|