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
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
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) \
|
|
|
|
|
static_cast<GdbEngine::AdapterCallback>(&AttachGdbAdapter::callback), \
|
|
|
|
|
STRINGIFY(callback)
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AttachGdbAdapter
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-03-24 15:05:45 +01:00
|
|
|
AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine)
|
|
|
|
|
: AbstractGdbAdapter(engine)
|
2009-09-23 15:28:50 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachGdbAdapter::startAdapter()
|
|
|
|
|
{
|
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"));
|
2009-09-23 15:28:50 +02:00
|
|
|
|
2009-10-20 11:02:16 +02:00
|
|
|
if (!m_engine->startGdb())
|
|
|
|
|
return;
|
2009-09-23 15:28:50 +02:00
|
|
|
|
2010-07-08 12:41:26 +02:00
|
|
|
m_engine->handleAdapterStarted();
|
2009-09-23 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:10:50 +02:00
|
|
|
void AttachGdbAdapter::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;
|
2010-01-05 16:51:55 +01:00
|
|
|
m_engine->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();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void AttachGdbAdapter::runEngine()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
2010-07-12 15:39:22 +02:00
|
|
|
m_engine->showStatusMessage(tr("Attached to process %1.")
|
|
|
|
|
.arg(m_engine->inferiorPid()));
|
2010-11-23 12:31:47 +01:00
|
|
|
m_engine->notifyEngineRunAndInferiorStopOk();
|
|
|
|
|
GdbMi data;
|
|
|
|
|
m_engine->handleStop0(data);
|
2010-07-09 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-24 11:16:00 +02:00
|
|
|
void AttachGdbAdapter::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);
|
2010-07-08 12:41:26 +02:00
|
|
|
m_engine->handleInferiorPrepared();
|
2012-01-02 10:42:01 +01:00
|
|
|
break;
|
|
|
|
|
case GdbResultError:
|
|
|
|
|
if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") {
|
2012-01-06 14:29:05 +01:00
|
|
|
m_engine->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());
|
2010-07-09 17:07:59 +02:00
|
|
|
m_engine->notifyInferiorSetupFailed(msg);
|
2009-09-23 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachGdbAdapter::interruptInferior()
|
|
|
|
|
{
|
2012-02-02 09:30:22 +01:00
|
|
|
interruptLocalInferior(startParameters().attachPID);
|
2010-07-09 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachGdbAdapter::shutdownAdapter()
|
|
|
|
|
{
|
|
|
|
|
m_engine->notifyAdapterShutdownOk();
|
2009-09-23 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|