~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to debuggers/gdb/gdblaunchconfig.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* GDB Debugger Support
 
3
*
 
4
* Copyright 2006 Vladimir Prus <ghost@cs.msu.su>
 
5
* Copyright 2007 Hamish Rodda <rodda@kde.org>
 
6
* Copyright 2009 Andreas Pakulat <apaku@gmx.de>
 
7
*
 
8
* This program is free software; you can redistribute it and/or modify
 
9
* it under the terms of the GNU General Public License as
 
10
* published by the Free Software Foundation; either version 2 of the
 
11
* License, or (at your option) any later version.
 
12
*
 
13
* This program is distributed in the hope that it will be useful,
 
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
* GNU General Public License for more details.
 
17
*
 
18
* You should have received a copy of the GNU General Public
 
19
* License along with this program; if not, write to the
 
20
* Free Software Foundation, Inc.,
 
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
22
*/
 
23
 
 
24
 
 
25
#include "gdblaunchconfig.h"
 
26
 
 
27
#include <kconfiggroup.h>
 
28
#include <kicon.h>
 
29
#include <klocale.h>
 
30
#include <kshell.h>
 
31
#include <kmessagebox.h>
 
32
#include <kparts/mainwindow.h>
 
33
 
 
34
#include <outputview/outputmodel.h>
 
35
#include <interfaces/ilaunchconfiguration.h>
 
36
#include <util/environmentgrouplist.h>
 
37
#include <interfaces/iproject.h>
 
38
#include <project/interfaces/iprojectbuilder.h>
 
39
#include <project/builderjob.h>
 
40
#include <interfaces/iuicontroller.h>
 
41
#include <project/interfaces/ibuildsystemmanager.h>
 
42
#include <util/executecompositejob.h>
 
43
#include <execute/iexecuteplugin.h>
 
44
 
 
45
#include "debugsession.h"
 
46
#include "debuggerplugin.h"
 
47
 
 
48
#include "ui_debuggerconfigwidget.h"
 
49
#include <interfaces/iplugincontroller.h>
 
50
#include <interfaces/icore.h>
 
51
#include "debugjob.h"
 
52
 
 
53
using namespace KDevelop;
 
54
 
 
55
GdbConfigPage::GdbConfigPage( QWidget* parent )
 
56
    : LaunchConfigurationPage(parent), ui( new Ui::DebuggerConfigWidget )
 
57
{
 
58
    ui->setupUi( this );
 
59
    ui->kcfg_gdbPath->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
 
60
    connect(ui->kcfg_asmDemangle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
61
    connect(ui->kcfg_breakOnLoadingLibrary, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
62
    connect(ui->kcfg_configGdbScript, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
63
    //connect(ui->kcfg_dbgTerminal, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
64
    connect(ui->kcfg_debuggingShell, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
65
    connect(ui->kcfg_displayStaticMembers, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
66
    connect(ui->kcfg_gdbPath, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
67
    connect(ui->kcfg_runGdbScript, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
68
    connect(ui->kcfg_runShellScript, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
69
}
 
70
 
 
71
KIcon GdbConfigPage::icon() const
 
72
{
 
73
    return KIcon();
 
74
}
 
75
 
 
76
void GdbConfigPage::loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject*  )
 
77
{
 
78
    bool block = blockSignals( true );
 
79
    ui->kcfg_gdbPath->setUrl( cfg.readEntry( GDBDebugger::gdbPathEntry, KUrl() ) );
 
80
    ui->kcfg_debuggingShell->setUrl( cfg.readEntry( GDBDebugger::debuggerShellEntry, KUrl() ) );
 
81
    ui->kcfg_configGdbScript->setUrl( cfg.readEntry( GDBDebugger::remoteGdbConfigEntry, KUrl() ) );
 
82
    ui->kcfg_runShellScript->setUrl( cfg.readEntry( GDBDebugger::remoteGdbShellEntry, KUrl() ) );
 
83
    ui->kcfg_runGdbScript->setUrl( cfg.readEntry( GDBDebugger::remoteGdbRunEntry, KUrl() ) );
 
84
    ui->kcfg_displayStaticMembers->setChecked( cfg.readEntry(GDBDebugger::staticMembersEntry, false) );
 
85
    ui->kcfg_asmDemangle->setChecked( cfg.readEntry( GDBDebugger::demangleNamesEntry, true) );
 
86
    //TODO: add ui for this
 
87
    //ui->kcfg_allowForceBP->setChecked( cfg.readEtnry( GDBDebugger::allowForcedBPEntry, true ) );
 
88
    ui->kcfg_breakOnLoadingLibrary->setChecked( cfg.readEntry( GDBDebugger::breakOnLibLoadEntry, true) );
 
89
    //ui->kcfg_dbgTerminal->setChecked( cfg.readEntry( GDBDebugger::separateTerminalEntry, false) );
 
90
    blockSignals( block );
 
91
}
 
92
 
 
93
void GdbConfigPage::saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* ) const
 
94
{
 
95
    cfg.writeEntry(GDBDebugger::gdbPathEntry, ui->kcfg_gdbPath->url() );
 
96
    cfg.writeEntry(GDBDebugger::debuggerShellEntry, ui->kcfg_debuggingShell->url() );
 
97
    cfg.writeEntry(GDBDebugger::remoteGdbConfigEntry, ui->kcfg_configGdbScript->url() );
 
98
    cfg.writeEntry(GDBDebugger::remoteGdbShellEntry, ui->kcfg_runShellScript->url() );
 
99
    cfg.writeEntry(GDBDebugger::remoteGdbRunEntry, ui->kcfg_runGdbScript->url() );
 
100
    cfg.writeEntry(GDBDebugger::staticMembersEntry, ui->kcfg_displayStaticMembers->isChecked() );
 
101
    cfg.writeEntry(GDBDebugger::demangleNamesEntry, ui->kcfg_asmDemangle->isChecked() );
 
102
    cfg.writeEntry(GDBDebugger::breakOnLibLoadEntry, ui->kcfg_breakOnLoadingLibrary->isChecked() );
 
103
    //cfg.writeEntry(GDBDebugger::separateTerminalEntry, ui->kcfg_dbgTerminal->isChecked() );
 
104
}
 
105
 
 
106
QString GdbConfigPage::title() const
 
107
{
 
108
    return i18n( "GDB Configuration" );
 
109
}
 
110
 
 
111
 
 
112
GdbLauncher::GdbLauncher( GDBDebugger::CppDebuggerPlugin* p ) : m_plugin( p )
 
113
{
 
114
    factoryList << new GdbConfigPageFactory();
 
115
}
 
116
 
 
117
QList< KDevelop::LaunchConfigurationPageFactory* > GdbLauncher::configPages() const
 
118
{
 
119
    return factoryList;
 
120
}
 
121
 
 
122
QString GdbLauncher::id()
 
123
{
 
124
    return "gdb";
 
125
}
 
126
 
 
127
QString GdbLauncher::name() const
 
128
{
 
129
    return i18n("GDB");
 
130
}
 
131
 
 
132
KJob* GdbLauncher::start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg)
 
133
{
 
134
    Q_ASSERT(cfg);
 
135
    if( !cfg )
 
136
    {
 
137
        return 0;
 
138
    }
 
139
    if( launchMode == "debug" )
 
140
    {
 
141
        IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IExecutePlugin")->extension<IExecutePlugin>();
 
142
        Q_ASSERT(iface);
 
143
        QList<KJob*> l;
 
144
        KJob* depjob = iface->dependecyJob(cfg);
 
145
        if( depjob ) 
 
146
        {
 
147
            l << depjob;
 
148
        }
 
149
        l << new GDBDebugger::DebugJob( m_plugin, cfg );
 
150
        return new KDevelop::ExecuteCompositeJob( KDevelop::ICore::self()->runController(), l );
 
151
    }
 
152
    kWarning() << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
 
153
    return 0;
 
154
}
 
155
 
 
156
QStringList GdbLauncher::supportedModes() const
 
157
{
 
158
    return QStringList() << "debug";
 
159
}
 
160
 
 
161
QString GdbLauncher::description() const
 
162
{
 
163
    return i18n("Executes a Native application in GDB");
 
164
}
 
165
 
 
166
KDevelop::LaunchConfigurationPage* GdbConfigPageFactory::createWidget( QWidget* parent )
 
167
{
 
168
    return new GdbConfigPage( parent );
 
169
}
 
170
 
 
171
 
 
172
 
 
173
#include "gdblaunchconfig.moc"