1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "remoteplaingdbadapter.h"
35 #include "gdbengine.h"
36 #include "debuggerstartparameters.h"
38 #include <debugger/debuggeractions.h>
39 #include <debugger/debuggerstringutils.h>
40 #include <utils/qtcassert.h>
45 RemotePlainGdbAdapter::RemotePlainGdbAdapter(GdbEngine *engine, QObject *parent)
46 : AbstractPlainGdbAdapter(engine, parent),
47 m_gdbProc(engine->startParameters().connParams, this)
49 connect(&m_gdbProc, SIGNAL(started()), this, SLOT(handleGdbStarted()));
50 connect(&m_gdbProc, SIGNAL(startFailed()), this,
51 SLOT(handleGdbStartFailed()));
54 void RemotePlainGdbAdapter::startAdapter()
56 QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
57 showMessage(QLatin1String("TRYING TO START ADAPTER"));
58 m_engine->requestRemoteSetup();
61 void RemotePlainGdbAdapter::setupInferior()
63 AbstractPlainGdbAdapter::setupInferior();
64 m_engine->postCommand("directory "
65 + m_engine->startParameters().remoteSourcesDir);
68 void RemotePlainGdbAdapter::interruptInferior()
70 m_gdbProc.interruptInferior();
73 QByteArray RemotePlainGdbAdapter::execFilePath() const
75 return startParameters().executable.toUtf8();
78 bool RemotePlainGdbAdapter::infoTargetNecessary() const
83 QByteArray RemotePlainGdbAdapter::toLocalEncoding(const QString &s) const
88 QString RemotePlainGdbAdapter::fromLocalEncoding(const QByteArray &b) const
90 return QString::fromUtf8(b);
93 void RemotePlainGdbAdapter::handleApplicationOutput(const QByteArray &output)
95 showMessage(QString::fromUtf8(output), AppOutput);
98 void RemotePlainGdbAdapter::shutdownInferior()
100 m_engine->defaultInferiorShutdown("kill");
103 void RemotePlainGdbAdapter::shutdownAdapter()
105 m_engine->notifyAdapterShutdownOk();
108 void RemotePlainGdbAdapter::handleRemoteSetupDone(int gdbServerPort, int qmlPort)
110 Q_UNUSED(gdbServerPort);
111 QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
114 startParameters().qmlServerPort = qmlPort;
115 if (!startParameters().workingDirectory.isEmpty())
116 m_gdbProc.setWorkingDirectory(startParameters().workingDirectory);
117 if (startParameters().environment.size())
118 m_gdbProc.setEnvironment(startParameters().environment.toStringList());
119 m_gdbProc.realStart(m_engine->startParameters().debuggerCommand,
120 QStringList() << QLatin1String("-i") << QLatin1String("mi"),
121 m_engine->startParameters().executable);
124 void RemotePlainGdbAdapter::handleGdbStarted()
126 if (m_engine->startGdb(QStringList(),
127 m_engine->startParameters().debuggerCommand))
128 m_engine->handleAdapterStarted();
131 void RemotePlainGdbAdapter::handleGdbStartFailed()
133 m_engine->handleAdapterStartFailed(m_gdbProc.errorString());
136 void RemotePlainGdbAdapter::handleRemoteSetupFailed(const QString &reason)
138 QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
140 m_engine->handleAdapterStartFailed(reason);
143 } // namespace Internal
144 } // namespace Debugger