2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
** contact the sales department at qt-sales@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerrunner.h"
|
|
|
|
|
|
|
|
#include "debuggermanager.h"
|
|
|
|
|
|
|
|
#include <projectexplorer/applicationrunconfiguration.h>
|
|
|
|
#include <projectexplorer/environment.h>
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QtCore/QFileInfo>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-03 10:55:18 +01:00
|
|
|
#include <QtGui/QTextDocument>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
using namespace Debugger::Internal;
|
|
|
|
|
|
|
|
using ProjectExplorer::RunConfiguration;
|
|
|
|
using ProjectExplorer::RunControl;
|
|
|
|
using ProjectExplorer::ApplicationRunConfiguration;
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// DebuggerRunner
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
DebuggerRunner::DebuggerRunner(DebuggerManager *manager)
|
|
|
|
: m_manager(manager)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool DebuggerRunner::canRun(RunConfigurationPtr runConfiguration, const QString &mode)
|
|
|
|
{
|
|
|
|
return mode == ProjectExplorer::Constants::DEBUGMODE
|
|
|
|
&& !qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration).isNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DebuggerRunner::displayName() const
|
|
|
|
{
|
|
|
|
return QObject::tr("Debug");
|
|
|
|
}
|
|
|
|
|
|
|
|
RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, const QString &mode)
|
|
|
|
{
|
2008-12-09 15:25:01 +01:00
|
|
|
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
ApplicationRunConfigurationPtr rc =
|
|
|
|
qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration);
|
2008-12-09 15:25:01 +01:00
|
|
|
QTC_ASSERT(rc, return 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
//qDebug() << "***** Debugging" << rc->name() << rc->executable();
|
|
|
|
return new DebuggerRunControl(m_manager, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *DebuggerRunner::configurationWidget(RunConfigurationPtr runConfiguration)
|
|
|
|
{
|
|
|
|
// NBS TODO: Add GDB-specific configuration widget
|
|
|
|
Q_UNUSED(runConfiguration);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// DebuggerRunControl
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
|
|
|
QSharedPointer<ApplicationRunConfiguration> runConfiguration)
|
|
|
|
: RunControl(runConfiguration), m_manager(manager), m_running(false)
|
|
|
|
{
|
|
|
|
connect(m_manager, SIGNAL(debuggingFinished()),
|
2009-02-13 13:50:50 +01:00
|
|
|
this, SLOT(debuggingFinished()),
|
|
|
|
Qt::QueuedConnection);
|
2009-01-15 14:30:49 +01:00
|
|
|
connect(m_manager, SIGNAL(applicationOutputAvailable(QString)),
|
2009-02-13 13:50:50 +01:00
|
|
|
this, SLOT(slotAddToOutputWindowInline(QString)),
|
|
|
|
Qt::QueuedConnection);
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_manager, SIGNAL(inferiorPidChanged(qint64)),
|
2009-02-13 13:50:50 +01:00
|
|
|
this, SLOT(bringApplicationToForeground(qint64)),
|
|
|
|
Qt::QueuedConnection);
|
2009-02-16 13:29:57 +01:00
|
|
|
connect(this, SIGNAL(stopRequested()),
|
|
|
|
m_manager, SLOT(exitDebugger()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunControl::start()
|
|
|
|
{
|
|
|
|
m_running = true;
|
|
|
|
ApplicationRunConfigurationPtr rc =
|
|
|
|
qSharedPointerCast<ApplicationRunConfiguration>(runConfiguration());
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(rc, return);
|
2008-12-02 12:01:29 +01:00
|
|
|
ProjectExplorer::Project *project = rc->project();
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(project, return);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
m_manager->m_executable = rc->executable();
|
|
|
|
m_manager->m_environment = rc->environment().toStringList();
|
|
|
|
m_manager->m_workingDir = rc->workingDirectory();
|
|
|
|
m_manager->m_processArgs = rc->commandLineArguments();
|
|
|
|
m_manager->m_buildDir =
|
|
|
|
project->buildDirectory(project->activeBuildConfiguration());
|
|
|
|
//<daniel> andre: + "\qtc-gdbmacros\"
|
|
|
|
|
|
|
|
//emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable));
|
2009-02-16 13:58:43 +01:00
|
|
|
if (m_manager->startNewDebugger(DebuggerManager::StartInternal))
|
2008-12-02 12:01:29 +01:00
|
|
|
emit started();
|
|
|
|
else
|
|
|
|
debuggingFinished();
|
|
|
|
}
|
|
|
|
|
2009-01-15 14:30:49 +01:00
|
|
|
void DebuggerRunControl::slotAddToOutputWindowInline(const QString &data)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-15 14:30:49 +01:00
|
|
|
emit addToOutputWindowInline(this, data);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunControl::stop()
|
|
|
|
{
|
2009-02-16 13:29:57 +01:00
|
|
|
//qDebug() << "DebuggerRunControl::stop";
|
|
|
|
m_running = false;
|
|
|
|
emit stopRequested();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunControl::debuggingFinished()
|
|
|
|
{
|
|
|
|
m_running = false;
|
2009-02-16 13:29:57 +01:00
|
|
|
//qDebug() << "DebuggerRunControl::finished";
|
2008-12-02 12:01:29 +01:00
|
|
|
//emit addToOutputWindow(this, tr("Debugging %1 finished").arg(m_executable));
|
|
|
|
emit finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DebuggerRunControl::isRunning() const
|
|
|
|
{
|
2009-02-16 13:29:57 +01:00
|
|
|
//qDebug() << "DebuggerRunControl::isRunning" << m_running;
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_running;
|
|
|
|
}
|