abstractgdbadapter.cpp 4.34 KB
Newer Older
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 7 8
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11 12 13 14
** 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.
15 16 17 18 19 20 21 22 23 24
**
** 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.
**
con's avatar
con committed
25 26 27 28 29 30
** 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.
31 32 33 34
**
**************************************************************************/

#include "abstractgdbadapter.h"
35
#include "gdbengine.h"
Friedemann Kleint's avatar
Friedemann Kleint committed
36
#include "debuggerstartparameters.h"
ck's avatar
ck committed
37 38
#include "abstractgdbprocess.h"

39
#include <utils/qtcassert.h>
40 41 42
#ifdef Q_OS_WIN
#include <utils/qtcprocess.h>
#endif
43 44 45 46 47 48 49

#include <QtCore/QProcess>

namespace Debugger {
namespace Internal {

AbstractGdbAdapter::AbstractGdbAdapter(GdbEngine *engine, QObject *parent)
hjk's avatar
hjk committed
50
  : QObject(parent), m_engine(engine)
51 52 53 54 55 56 57 58
{
}

AbstractGdbAdapter::~AbstractGdbAdapter()
{
    disconnect();
}

hjk's avatar
hjk committed
59 60 61
//void AbstractGdbAdapter::shutdown()
//{
//}
62

hjk's avatar
hjk committed
63 64
//void AbstractGdbAdapter::runEngine()
//{
65
//    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
hjk's avatar
hjk committed
66
//}
67

hjk's avatar
hjk committed
68
/*
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
69
const char *AbstractGdbAdapter::inferiorShutdownCommand() const
70
{
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
71
    return "kill";
72
}
hjk's avatar
hjk committed
73
*/
74 75 76

void AbstractGdbAdapter::write(const QByteArray &data)
{
ck's avatar
ck committed
77
    gdbProc()->write(data);
78 79 80 81 82 83 84
}

bool AbstractGdbAdapter::isTrkAdapter() const
{
    return false;
}

85 86 87 88 89 90 91 92 93 94
#ifdef Q_OS_WIN
bool AbstractGdbAdapter::prepareWinCommand()
{
    Utils::QtcProcess::SplitError perr;
    startParameters().processArgs = Utils::QtcProcess::prepareArgs(
                startParameters().processArgs, &perr,
                &startParameters().environment, &startParameters().workingDirectory);
    if (perr != Utils::QtcProcess::SplitOk) {
        // perr == BadQuoting is never returned on Windows
        // FIXME? QTCREATORBUG-2809
95
        m_engine->handleAdapterStartFailed(QCoreApplication::translate("DebuggerEngine", // Same message in CdbEngine
96 97 98 99 100 101 102
            "Debugging complex command lines is currently not supported under Windows"), QString());
        return false;
    }
    return true;
}
#endif

Friedemann Kleint's avatar
Friedemann Kleint committed
103 104 105 106 107 108 109
QString AbstractGdbAdapter::msgGdbStopFailed(const QString &why)
{
    return tr("The Gdb process could not be stopped:\n%1").arg(why);
}

QString AbstractGdbAdapter::msgInferiorStopFailed(const QString &why)
{
110
    return tr("Application process could not be stopped:\n%1").arg(why);
Friedemann Kleint's avatar
Friedemann Kleint committed
111 112
}

hjk's avatar
hjk committed
113
QString AbstractGdbAdapter::msgInferiorSetupOk()
Friedemann Kleint's avatar
Friedemann Kleint committed
114
{
115
    return tr("Application started");
Friedemann Kleint's avatar
Friedemann Kleint committed
116 117
}

hjk's avatar
hjk committed
118
QString AbstractGdbAdapter::msgInferiorRunOk()
Friedemann Kleint's avatar
Friedemann Kleint committed
119
{
120
    return tr("Application running");
Friedemann Kleint's avatar
Friedemann Kleint committed
121 122 123 124
}

QString AbstractGdbAdapter::msgAttachedToStoppedInferior()
{
125
    return tr("Attached to stopped application");
Friedemann Kleint's avatar
Friedemann Kleint committed
126 127 128 129 130 131 132
}

QString AbstractGdbAdapter::msgConnectRemoteServerFailed(const QString &why)
{
    return tr("Connecting to remote server failed:\n%1").arg(why);
}

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
DebuggerState AbstractGdbAdapter::state() const
{
    return m_engine->state();
}

const DebuggerStartParameters &AbstractGdbAdapter::startParameters() const
{
    return m_engine->startParameters();
}

DebuggerStartParameters &AbstractGdbAdapter::startParameters()
{
    return m_engine->startParameters();
}

void AbstractGdbAdapter::showMessage(const QString &msg, int channel, int timeout)
{
    m_engine->showMessage(msg, channel, timeout);
}

153 154 155 156 157 158 159 160 161 162 163
void AbstractGdbAdapter::handleRemoteSetupDone(int gdbServerPort, int qmlPort)
{
    Q_UNUSED(gdbServerPort);
    Q_UNUSED(qmlPort);
}

void AbstractGdbAdapter::handleRemoteSetupFailed(const QString &reason)
{
    Q_UNUSED(reason);
}

164 165
} // namespace Internal
} // namespace Debugger