2009-09-23 15:28:50 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-09-23 15:28:50 +02:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2009-09-23 15:28:50 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2009-09-23 15:28:50 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2009-09-23 15:28:50 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "attachgdbadapter.h"
|
2010-11-02 16:14:00 +01:00
|
|
|
#include "gdbmi.h"
|
2011-01-10 10:14:23 +01:00
|
|
|
#include "debuggerstartparameters.h"
|
2009-09-23 15:28:50 +02:00
|
|
|
|
|
|
|
|
#include "gdbengine.h"
|
|
|
|
|
#include "procinterrupt.h"
|
2009-09-25 15:02:16 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2009-09-23 15:28:50 +02:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
#define CB(callback) \
|
2012-06-13 10:15:56 +02:00
|
|
|
static_cast<GdbEngine::GdbCommandCallback>(&GdbAttachEngine::callback), \
|
2009-09-23 15:28:50 +02:00
|
|
|
STRINGIFY(callback)
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AttachGdbAdapter
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-08-15 14:33:39 +02:00
|
|
|
GdbAttachEngine::GdbAttachEngine(const DebuggerStartParameters &startParameters)
|
|
|
|
|
: GdbEngine(startParameters)
|
2009-09-23 15:28:50 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::setupEngine()
|
2009-09-23 15:28:50 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("TRYING TO START ADAPTER"));
|
2012-06-13 10:15:56 +02:00
|
|
|
startGdb();
|
2012-06-05 11:05:58 +02:00
|
|
|
}
|
2009-09-23 15:28:50 +02:00
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::setupInferior()
|
2009-09-29 17:12:35 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
2009-09-24 11:16:00 +02:00
|
|
|
const qint64 pid = startParameters().attachPID;
|
2012-06-13 10:15:56 +02:00
|
|
|
postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
|
2009-09-23 15:28:50 +02:00
|
|
|
// Task 254674 does not want to remove them
|
|
|
|
|
//qq->breakHandler()->removeAllBreakpoints();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::runEngine()
|
2010-07-09 17:07:59 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
2012-06-13 10:15:56 +02:00
|
|
|
showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
|
|
|
|
|
notifyEngineRunAndInferiorStopOk();
|
|
|
|
|
handleStop1(GdbMi());
|
2010-07-09 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::handleAttach(const GdbResponse &response)
|
2009-09-23 15:28:50 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
2012-01-02 10:42:01 +01:00
|
|
|
switch (response.resultClass) {
|
|
|
|
|
case GdbResultDone:
|
|
|
|
|
case GdbResultRunning:
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("INFERIOR ATTACHED"));
|
|
|
|
|
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
2012-06-13 10:15:56 +02:00
|
|
|
handleInferiorPrepared();
|
2012-01-02 10:42:01 +01:00
|
|
|
break;
|
|
|
|
|
case GdbResultError:
|
|
|
|
|
if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") {
|
2012-06-13 10:15:56 +02:00
|
|
|
notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode));
|
2012-01-02 10:42:01 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// if msg != "ptrace: ..." fall through
|
|
|
|
|
default:
|
2010-01-04 14:11:07 +01:00
|
|
|
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
|
2012-06-13 10:15:56 +02:00
|
|
|
notifyInferiorSetupFailed(msg);
|
2009-09-23 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::interruptInferior2()
|
2009-09-23 15:28:50 +02:00
|
|
|
{
|
2012-02-02 09:30:22 +01:00
|
|
|
interruptLocalInferior(startParameters().attachPID);
|
2010-07-09 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
void GdbAttachEngine::shutdownEngine()
|
2010-07-09 17:07:59 +02:00
|
|
|
{
|
2012-06-13 10:15:56 +02:00
|
|
|
notifyAdapterShutdownOk();
|
2009-09-23 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|