2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-07-24 17:02:42 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2012-07-24 17:02:42 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-07-24 17:02:42 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-07-24 17:02:42 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-07-24 17:02:42 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-07-24 17:02:42 +02:00
|
|
|
|
|
|
|
|
#include "loadcoredialog.h"
|
|
|
|
|
|
|
|
|
|
#include "debuggerstartparameters.h"
|
2012-09-05 10:55:05 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2014-02-10 13:53:24 +01:00
|
|
|
#include "debuggerkitinformation.h"
|
|
|
|
|
#include "gdb/coregdbadapter.h"
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2013-03-27 13:03:15 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-07-24 17:02:42 +02:00
|
|
|
#include <ssh/sftpfilesystemmodel.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
#include <QCheckBox>
|
2012-07-24 17:02:42 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QRegExp>
|
|
|
|
|
#include <QTemporaryFile>
|
|
|
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QHeaderView>
|
2012-10-22 11:14:18 +02:00
|
|
|
#include <QLabel>
|
2012-07-24 17:02:42 +02:00
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
#include <QTextBrowser>
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace QSsh;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// SelectRemoteFileDialog
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class SelectRemoteFileDialog : public QDialog
|
|
|
|
|
{
|
2015-02-26 17:43:41 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::SelectRemoteFileDialog)
|
2012-07-24 17:02:42 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit SelectRemoteFileDialog(QWidget *parent);
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void attachToDevice(Kit *k);
|
2012-07-24 17:02:42 +02:00
|
|
|
QString localFile() const { return m_localFile; }
|
|
|
|
|
QString remoteFile() const { return m_remoteFile; }
|
|
|
|
|
|
2015-02-05 12:26:16 +01:00
|
|
|
private:
|
2015-02-03 23:58:49 +02:00
|
|
|
void handleSftpOperationFinished(SftpJobId, const QString &error);
|
2012-07-24 17:02:42 +02:00
|
|
|
void handleSftpOperationFailed(const QString &errorMessage);
|
|
|
|
|
void handleConnectionError(const QString &errorMessage);
|
|
|
|
|
void handleRemoteError(const QString &errorMessage);
|
|
|
|
|
void selectFile();
|
|
|
|
|
|
|
|
|
|
QSortFilterProxyModel m_model;
|
|
|
|
|
SftpFileSystemModel m_fileSystemModel;
|
|
|
|
|
QTreeView *m_fileSystemView;
|
|
|
|
|
QTextBrowser *m_textBrowser;
|
|
|
|
|
QDialogButtonBox *m_buttonBox;
|
|
|
|
|
QString m_localFile;
|
|
|
|
|
QString m_remoteFile;
|
|
|
|
|
SftpJobId m_sftpJobId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SelectRemoteFileDialog::SelectRemoteFileDialog(QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
{
|
|
|
|
|
m_model.setSourceModel(&m_fileSystemModel);
|
|
|
|
|
|
|
|
|
|
m_fileSystemView = new QTreeView(this);
|
|
|
|
|
m_fileSystemView->setModel(&m_model);
|
|
|
|
|
m_fileSystemView->setSortingEnabled(true);
|
2012-10-10 20:15:27 +02:00
|
|
|
m_fileSystemView->sortByColumn(1, Qt::AscendingOrder);
|
2012-07-24 17:02:42 +02:00
|
|
|
m_fileSystemView->setUniformRowHeights(true);
|
|
|
|
|
m_fileSystemView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
m_fileSystemView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
m_fileSystemView->header()->setDefaultSectionSize(100);
|
|
|
|
|
m_fileSystemView->header()->setStretchLastSection(true);
|
|
|
|
|
|
|
|
|
|
m_textBrowser = new QTextBrowser(this);
|
|
|
|
|
m_textBrowser->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
m_buttonBox = new QDialogButtonBox(this);
|
|
|
|
|
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
|
layout->addWidget(m_fileSystemView);
|
|
|
|
|
layout->addWidget(m_textBrowser);
|
|
|
|
|
layout->addWidget(m_buttonBox);
|
|
|
|
|
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(m_buttonBox, &QDialogButtonBox::rejected,
|
|
|
|
|
this, &QDialog::reject);
|
|
|
|
|
connect(m_buttonBox, &QDialogButtonBox::accepted,
|
|
|
|
|
this, &SelectRemoteFileDialog::selectFile);
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(&m_fileSystemModel, &SftpFileSystemModel::sftpOperationFailed,
|
|
|
|
|
this, &SelectRemoteFileDialog::handleSftpOperationFailed);
|
|
|
|
|
connect(&m_fileSystemModel, &SftpFileSystemModel::connectionError,
|
|
|
|
|
this, &SelectRemoteFileDialog::handleConnectionError);
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void SelectRemoteFileDialog::attachToDevice(Kit *k)
|
2012-07-24 17:02:42 +02:00
|
|
|
{
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
2012-09-03 18:31:44 +02:00
|
|
|
QTC_ASSERT(k, return);
|
|
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(k);
|
2012-07-24 17:02:42 +02:00
|
|
|
QTC_ASSERT(device, return);
|
2015-02-03 23:58:49 +02:00
|
|
|
SshConnectionParameters sshParams = device->sshParameters();
|
2012-07-24 17:02:42 +02:00
|
|
|
m_fileSystemModel.setSshConnection(sshParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectRemoteFileDialog::handleSftpOperationFailed(const QString &errorMessage)
|
|
|
|
|
{
|
|
|
|
|
m_textBrowser->append(errorMessage);
|
|
|
|
|
//reject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectRemoteFileDialog::handleConnectionError(const QString &errorMessage)
|
|
|
|
|
{
|
|
|
|
|
m_textBrowser->append(errorMessage);
|
|
|
|
|
//reject();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void SelectRemoteFileDialog::handleSftpOperationFinished(SftpJobId, const QString &error)
|
2012-07-24 17:02:42 +02:00
|
|
|
{
|
|
|
|
|
if (error.isEmpty()) {
|
|
|
|
|
m_textBrowser->append(tr("Download of remote file succeeded."));
|
|
|
|
|
accept();
|
|
|
|
|
} else {
|
|
|
|
|
m_textBrowser->append(error);
|
|
|
|
|
//reject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectRemoteFileDialog::handleRemoteError(const QString &errorMessage)
|
|
|
|
|
{
|
|
|
|
|
m_textBrowser->append(errorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectRemoteFileDialog::selectFile()
|
|
|
|
|
{
|
2012-10-10 00:18:12 +02:00
|
|
|
QModelIndex idx = m_model.mapToSource(m_fileSystemView->currentIndex());
|
|
|
|
|
if (!idx.isValid())
|
2012-07-24 17:02:42 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
|
|
|
|
m_fileSystemView->setEnabled(false);
|
|
|
|
|
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(&m_fileSystemModel, &SftpFileSystemModel::sftpOperationFinished,
|
|
|
|
|
this, &SelectRemoteFileDialog::handleSftpOperationFinished);
|
2012-07-24 17:02:42 +02:00
|
|
|
|
|
|
|
|
{
|
2012-08-22 11:58:33 +02:00
|
|
|
QTemporaryFile localFile(QDir::tempPath() + QLatin1String("/remotecore-XXXXXX"));
|
2012-07-24 17:02:42 +02:00
|
|
|
localFile.open();
|
|
|
|
|
m_localFile = localFile.fileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idx = idx.sibling(idx.row(), 1);
|
|
|
|
|
m_remoteFile = m_fileSystemModel.data(idx, SftpFileSystemModel::PathRole).toString();
|
|
|
|
|
m_sftpJobId = m_fileSystemModel.downloadFile(idx, m_localFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// AttachCoreDialog
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class AttachCoreDialogPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-09-03 18:31:44 +02:00
|
|
|
KitChooser *kitChooser;
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
QCheckBox *forceLocalCheckBox;
|
|
|
|
|
QLabel *forceLocalLabel;
|
2012-07-24 17:02:42 +02:00
|
|
|
PathChooser *localExecFileName;
|
|
|
|
|
PathChooser *localCoreFileName;
|
|
|
|
|
QLineEdit *remoteCoreFileName;
|
|
|
|
|
QPushButton *selectRemoteCoreButton;
|
|
|
|
|
|
|
|
|
|
PathChooser *overrideStartScriptFileName;
|
|
|
|
|
|
|
|
|
|
QDialogButtonBox *buttonBox;
|
2014-07-21 14:39:54 +02:00
|
|
|
|
|
|
|
|
struct State
|
|
|
|
|
{
|
|
|
|
|
bool isValid() const
|
|
|
|
|
{
|
|
|
|
|
return validKit && validLocalExecFilename && validCoreFilename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool validKit;
|
|
|
|
|
bool validLocalExecFilename;
|
|
|
|
|
bool validCoreFilename;
|
|
|
|
|
bool localCoreFile;
|
|
|
|
|
bool localKit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
State getDialogState(const AttachCoreDialog &p) const
|
|
|
|
|
{
|
|
|
|
|
State st;
|
|
|
|
|
st.localCoreFile = p.useLocalCoreFile();
|
|
|
|
|
st.validKit = (kitChooser->currentKit() != 0);
|
|
|
|
|
st.validLocalExecFilename = localExecFileName->isValid();
|
|
|
|
|
|
|
|
|
|
if (st.localCoreFile)
|
|
|
|
|
st.validCoreFilename = localCoreFileName->isValid();
|
|
|
|
|
else
|
|
|
|
|
st.validCoreFilename = !p.remoteCoreFile().isEmpty();
|
|
|
|
|
|
|
|
|
|
st.localKit = p.isLocalKit();
|
|
|
|
|
return st;
|
|
|
|
|
}
|
2012-07-24 17:02:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
|
|
|
|
: QDialog(parent), d(new AttachCoreDialogPrivate)
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Load Core File"));
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
|
2014-07-16 13:57:22 +02:00
|
|
|
d->buttonBox = new QDialogButtonBox(this);
|
|
|
|
|
d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
d->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
|
|
|
|
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
|
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging, this);
|
2012-09-05 10:55:05 +02:00
|
|
|
d->kitChooser->populate();
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
d->forceLocalCheckBox = new QCheckBox(this);
|
|
|
|
|
d->forceLocalLabel = new QLabel(this);
|
|
|
|
|
d->forceLocalLabel->setText(tr("Use local core file:"));
|
|
|
|
|
d->forceLocalLabel->setBuddy(d->forceLocalCheckBox);
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2014-07-16 13:57:22 +02:00
|
|
|
d->remoteCoreFileName = new QLineEdit(this);
|
2015-01-14 14:58:24 +01:00
|
|
|
d->selectRemoteCoreButton = new QPushButton(PathChooser::browseButtonLabel(), this);
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2013-03-18 14:19:31 +01:00
|
|
|
d->localCoreFileName = new PathChooser(this);
|
2013-11-25 14:33:54 +01:00
|
|
|
d->localCoreFileName->setHistoryCompleter(QLatin1String("Debugger.CoreFile.History"));
|
2013-03-18 14:19:31 +01:00
|
|
|
d->localCoreFileName->setExpectedKind(PathChooser::File);
|
|
|
|
|
d->localCoreFileName->setPromptDialogTitle(tr("Select Core File"));
|
|
|
|
|
|
2014-07-16 13:57:22 +02:00
|
|
|
d->localExecFileName = new PathChooser(this);
|
|
|
|
|
d->localExecFileName->setHistoryCompleter(QLatin1String("LocalExecutable"));
|
|
|
|
|
d->localExecFileName->setExpectedKind(PathChooser::File);
|
|
|
|
|
d->localExecFileName->setPromptDialogTitle(tr("Select Executable"));
|
|
|
|
|
|
2012-07-24 17:02:42 +02:00
|
|
|
d->overrideStartScriptFileName = new PathChooser(this);
|
2013-11-25 14:33:54 +01:00
|
|
|
d->overrideStartScriptFileName->setHistoryCompleter(QLatin1String("Debugger.StartupScript.History"));
|
2012-07-24 17:02:42 +02:00
|
|
|
d->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
|
|
|
|
|
d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
|
|
|
|
|
|
2015-02-26 17:43:41 +01:00
|
|
|
auto coreLayout = new QHBoxLayout;
|
2012-07-24 17:02:42 +02:00
|
|
|
coreLayout->addWidget(d->localCoreFileName);
|
|
|
|
|
coreLayout->addWidget(d->remoteCoreFileName);
|
|
|
|
|
coreLayout->addWidget(d->selectRemoteCoreButton);
|
|
|
|
|
|
2015-02-26 17:43:41 +01:00
|
|
|
auto formLayout = new QFormLayout;
|
2012-07-24 17:02:42 +02:00
|
|
|
formLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
formLayout->setHorizontalSpacing(6);
|
|
|
|
|
formLayout->setVerticalSpacing(6);
|
2012-09-03 18:31:44 +02:00
|
|
|
formLayout->addRow(tr("Kit:"), d->kitChooser);
|
2012-10-22 11:14:18 +02:00
|
|
|
formLayout->addRow(d->forceLocalLabel, d->forceLocalCheckBox);
|
2012-07-24 17:02:42 +02:00
|
|
|
formLayout->addRow(tr("Core file:"), coreLayout);
|
2014-02-10 13:53:24 +01:00
|
|
|
formLayout->addRow(tr("&Executable:"), d->localExecFileName);
|
2012-07-24 17:02:42 +02:00
|
|
|
formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName);
|
|
|
|
|
|
2015-02-26 17:43:41 +01:00
|
|
|
auto line = new QFrame(this);
|
2012-07-24 17:02:42 +02:00
|
|
|
line->setFrameShape(QFrame::HLine);
|
|
|
|
|
line->setFrameShadow(QFrame::Sunken);
|
|
|
|
|
|
|
|
|
|
formLayout->addRow(d->buttonBox);
|
|
|
|
|
|
2015-02-26 17:43:41 +01:00
|
|
|
auto vboxLayout = new QVBoxLayout(this);
|
2012-07-24 17:02:42 +02:00
|
|
|
vboxLayout->addLayout(formLayout);
|
2012-08-14 10:16:53 +02:00
|
|
|
vboxLayout->addStretch();
|
2012-07-24 17:02:42 +02:00
|
|
|
vboxLayout->addWidget(line);
|
|
|
|
|
vboxLayout->addWidget(d->buttonBox);
|
2012-10-22 11:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AttachCoreDialog::~AttachCoreDialog()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
int AttachCoreDialog::exec()
|
|
|
|
|
{
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(d->selectRemoteCoreButton, &QAbstractButton::clicked, this, &AttachCoreDialog::selectRemoteCoreFile);
|
|
|
|
|
connect(d->remoteCoreFileName, &QLineEdit::textChanged, this, &AttachCoreDialog::coreFileChanged);
|
2015-08-20 14:56:30 +02:00
|
|
|
connect(d->localExecFileName, &PathChooser::rawPathChanged, this, &AttachCoreDialog::changed);
|
|
|
|
|
connect(d->localCoreFileName, &PathChooser::rawPathChanged, this, &AttachCoreDialog::coreFileChanged);
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(d->forceLocalCheckBox, &QCheckBox::stateChanged, this, &AttachCoreDialog::changed);
|
|
|
|
|
connect(d->kitChooser, &KitChooser::currentIndexChanged, this, &AttachCoreDialog::changed);
|
|
|
|
|
connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
connect(d->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
2012-10-10 00:08:56 +02:00
|
|
|
changed();
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2014-07-21 14:39:54 +02:00
|
|
|
AttachCoreDialogPrivate::State st = d->getDialogState(*this);
|
|
|
|
|
if (!st.validKit) {
|
|
|
|
|
d->kitChooser->setFocus();
|
|
|
|
|
} else if (!st.validCoreFilename) {
|
|
|
|
|
if (st.localCoreFile)
|
|
|
|
|
d->localCoreFileName->setFocus();
|
|
|
|
|
else
|
|
|
|
|
d->remoteCoreFileName->setFocus();
|
|
|
|
|
} else if (!st.validLocalExecFilename) {
|
|
|
|
|
d->localExecFileName->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
return QDialog::exec();
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
bool AttachCoreDialog::isLocalKit() const
|
2012-07-24 17:02:42 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *k = d->kitChooser->currentKit();
|
|
|
|
|
QTC_ASSERT(k, return false);
|
|
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(k);
|
2012-07-24 17:02:42 +02:00
|
|
|
QTC_ASSERT(device, return false);
|
2012-10-22 11:14:18 +02:00
|
|
|
return device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AttachCoreDialog::useLocalCoreFile() const
|
|
|
|
|
{
|
|
|
|
|
return isLocalKit() || d->forceLocalCheckBox->isChecked();
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-10 13:53:24 +01:00
|
|
|
void AttachCoreDialog::coreFileChanged(const QString &core)
|
|
|
|
|
{
|
2015-02-03 23:58:49 +02:00
|
|
|
if (!HostOsInfo::isWindowsHost() && QFile::exists(core)) {
|
2014-07-14 15:04:47 +03:00
|
|
|
Kit *k = d->kitChooser->currentKit();
|
|
|
|
|
QTC_ASSERT(k, return);
|
|
|
|
|
FileName cmd = DebuggerKitInformation::debuggerCommand(k);
|
2014-07-24 11:56:40 +02:00
|
|
|
GdbCoreEngine::CoreInfo cinfo =
|
|
|
|
|
GdbCoreEngine::readExecutableNameFromCore(cmd.toString(), core);
|
|
|
|
|
if (!cinfo.foundExecutableName.isEmpty())
|
|
|
|
|
d->localExecFileName->setFileName(FileName::fromString(cinfo.foundExecutableName));
|
|
|
|
|
else if (!d->localExecFileName->isValid() && !cinfo.rawStringFromCore.isEmpty())
|
|
|
|
|
d->localExecFileName->setFileName(FileName::fromString(cinfo.rawStringFromCore));
|
2014-07-14 15:04:47 +03:00
|
|
|
}
|
2014-02-10 13:53:24 +01:00
|
|
|
changed();
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-24 17:02:42 +02:00
|
|
|
void AttachCoreDialog::changed()
|
|
|
|
|
{
|
2014-07-21 14:39:54 +02:00
|
|
|
AttachCoreDialogPrivate::State st = d->getDialogState(*this);
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2014-07-21 14:39:54 +02:00
|
|
|
d->forceLocalLabel->setVisible(!st.localKit);
|
|
|
|
|
d->forceLocalCheckBox->setVisible(!st.localKit);
|
|
|
|
|
if (st.localCoreFile) {
|
2012-07-24 17:02:42 +02:00
|
|
|
d->localCoreFileName->setVisible(true);
|
|
|
|
|
d->remoteCoreFileName->setVisible(false);
|
|
|
|
|
d->selectRemoteCoreButton->setVisible(false);
|
|
|
|
|
} else {
|
2012-10-22 11:14:18 +02:00
|
|
|
d->localCoreFileName->setVisible(false);
|
2012-07-24 17:02:42 +02:00
|
|
|
d->remoteCoreFileName->setVisible(true);
|
|
|
|
|
d->selectRemoteCoreButton->setVisible(true);
|
|
|
|
|
}
|
2012-10-22 11:14:18 +02:00
|
|
|
|
2014-07-21 14:39:54 +02:00
|
|
|
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(st.isValid());
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::selectRemoteCoreFile()
|
|
|
|
|
{
|
|
|
|
|
changed();
|
2012-10-22 11:14:18 +02:00
|
|
|
QTC_ASSERT(!isLocalKit(), return);
|
2012-07-24 17:02:42 +02:00
|
|
|
SelectRemoteFileDialog dlg(this);
|
|
|
|
|
dlg.setWindowTitle(tr("Select Remote Core File"));
|
2012-09-03 18:31:44 +02:00
|
|
|
dlg.attachToDevice(d->kitChooser->currentKit());
|
2012-07-24 17:02:42 +02:00
|
|
|
if (dlg.exec() == QDialog::Rejected)
|
|
|
|
|
return;
|
|
|
|
|
d->localCoreFileName->setPath(dlg.localFile());
|
|
|
|
|
d->remoteCoreFileName->setText(dlg.remoteFile());
|
|
|
|
|
changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AttachCoreDialog::localCoreFile() const
|
|
|
|
|
{
|
|
|
|
|
return d->localCoreFileName->path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AttachCoreDialog::localExecutableFile() const
|
|
|
|
|
{
|
|
|
|
|
return d->localExecFileName->path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::setLocalExecutableFile(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
d->localExecFileName->setPath(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::setLocalCoreFile(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
d->localCoreFileName->setPath(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::setRemoteCoreFile(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
d->remoteCoreFileName->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AttachCoreDialog::remoteCoreFile() const
|
|
|
|
|
{
|
|
|
|
|
return d->remoteCoreFileName->text();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void AttachCoreDialog::setKitId(Id id)
|
2012-07-24 17:02:42 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
d->kitChooser->setCurrentKitId(id);
|
2012-10-22 11:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::setForceLocalCoreFile(bool on)
|
|
|
|
|
{
|
|
|
|
|
d->forceLocalCheckBox->setChecked(on);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AttachCoreDialog::forcesLocalCoreFile() const
|
|
|
|
|
{
|
|
|
|
|
return d->forceLocalCheckBox->isChecked();
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *AttachCoreDialog::kit() const
|
2012-07-24 17:02:42 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
return d->kitChooser->currentKit();
|
2012-07-24 17:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AttachCoreDialog::overrideStartScript() const
|
|
|
|
|
{
|
|
|
|
|
return d->overrideStartScriptFileName->path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AttachCoreDialog::setOverrideStartScript(const QString &scriptName)
|
|
|
|
|
{
|
|
|
|
|
d->overrideStartScriptFileName->setPath(scriptName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|