~ubuntu-branches/ubuntu/karmic/kdevelop/karmic

« back to all changes in this revision

Viewing changes to debuggers/gdb/gdblaunchconfig.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-06-28 20:48:13 UTC
  • mfrom: (1.1.12 upstream) (2.3.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090628204813-m6qlb9e92ig9h04m
Tags: 4:3.9.94-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - Conflict/replace -kde4 packages
  - Remove gdb from recommends, version >= 6.8.50 is not yet in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <outputview/outputmodel.h>
35
35
#include <interfaces/ilaunchconfiguration.h>
36
36
#include <util/environmentgrouplist.h>
37
 
#include <execute/executepluginconstants.h>
 
37
#include <execute/iexecuteplugin.h>
38
38
#include <interfaces/iproject.h>
39
39
#include <project/interfaces/iprojectbuilder.h>
 
40
#include <project/builderjob.h>
40
41
#include <interfaces/iuicontroller.h>
41
42
#include <project/interfaces/ibuildsystemmanager.h>
42
43
#include <util/executecompositejob.h>
45
46
#include "debuggerplugin.h"
46
47
 
47
48
#include "ui_debuggerconfigwidget.h"
 
49
#include <interfaces/iplugincontroller.h>
 
50
#include <interfaces/icore.h>
48
51
 
49
52
GdbConfigPage::GdbConfigPage( QWidget* parent )
50
53
    : LaunchConfigurationPage(parent), ui( new Ui::DebuggerConfigWidget )
72
75
    ui->kcfg_breakOnLoadingLibrary->setChecked( cfg.readEntry( GDBDebugger::breakOnLibLoadEntry, true) );
73
76
    ui->kcfg_dbgTerminal->setChecked( cfg.readEntry( GDBDebugger::separateTerminalEntry, false) );
74
77
    ui->kcfg_enableFloatingToolBar->setChecked( cfg.readEntry(GDBDebugger::floatingToolbarEntry, false) );
75
 
    ui->kcfg_startWithGdb->setChecked( cfg.readEntry(GDBDebugger::startGdbOutputEntry, false) );
76
78
}
77
79
 
78
80
void GdbConfigPage::saveToConfiguration( KConfigGroup cfg ) const
87
89
    cfg.writeEntry(GDBDebugger::breakOnLibLoadEntry, ui->kcfg_breakOnLoadingLibrary->isChecked() );
88
90
    cfg.writeEntry(GDBDebugger::separateTerminalEntry, ui->kcfg_dbgTerminal->isChecked() );
89
91
    cfg.writeEntry(GDBDebugger::floatingToolbarEntry, ui->kcfg_enableFloatingToolBar->isChecked() );
90
 
    cfg.writeEntry(GDBDebugger::startGdbOutputEntry, ui->kcfg_startWithGdb->isChecked() );
91
92
}
92
93
 
93
94
QString GdbConfigPage::title() const
125
126
    }
126
127
    if( launchMode == "debug" )
127
128
    {
128
 
        QStringList deps = cfg->config().readEntry( ExecutePlugin::dependencyEntry, QStringList() );
129
 
        QString depAction = cfg->config().readEntry( ExecutePlugin::dependencyActionEntry, "Nothing" );
130
 
        if( depAction != "Nothing" && !deps.isEmpty() )
131
 
        {
132
 
            QList<KJob*> l;
133
 
            KDevelop::ProjectModel* model = KDevelop::ICore::self()->projectController()->projectModel();
134
 
            foreach( const QString& dep, deps )
135
 
            {
136
 
                KDevelop::ProjectBaseItem* item = model->item( model->pathToIndex( dep.split('/') ) );
137
 
                if( item )
138
 
                {
139
 
                    KDevelop::ProjectBaseItem* folder = item;
140
 
                    while( folder && !folder->folder() )
141
 
                    {
142
 
                        folder = dynamic_cast<KDevelop::ProjectBaseItem*>( folder->parent() );
143
 
                    }
144
 
                    if( folder && item->project()->buildSystemManager()->builder( folder->folder() ) )
145
 
                    {
146
 
                        KDevelop::IProjectBuilder* builder = item->project()->buildSystemManager()->builder( folder->folder() );
147
 
                        if( depAction == "Build" )
148
 
                        {
149
 
                            l << builder->build( item );
150
 
                        } else if( depAction == "Install" )
151
 
                        {
152
 
                            l << builder->install( item );
153
 
                        } else if( depAction == "SudoInstall" )
154
 
                        {
155
 
                            KMessageBox::information( KDevelop::ICore::self()->uiController()->activeMainWindow(),
156
 
                                                    i18n("Installing via sudo is not yet implemented"),
157
 
                                                    i18n("Not implemented") );
158
 
                        }
159
 
                    }
160
 
                }
161
 
            }
162
 
            l << new GdbJob( m_plugin, cfg );
163
 
            return new KDevelop::ExecuteCompositeJob( KDevelop::ICore::self()->runController(), l );
164
 
        }else
165
 
        {
166
 
            return new GdbJob( m_plugin, cfg );
 
129
        IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IExecutePlugin")->extension<IExecutePlugin>();
 
130
        Q_ASSERT(iface);
 
131
        QList<KJob*> l;
 
132
        KJob* depjob = iface->dependecyJob(cfg);
 
133
        if( depjob ) 
 
134
        {
 
135
            l << depjob;
167
136
        }
 
137
        l << new GdbJob( m_plugin, cfg );
 
138
        return new KDevelop::ExecuteCompositeJob( KDevelop::ICore::self()->runController(), l );
168
139
    }
169
140
    kWarning() << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
170
141
    return 0;
188
159
GdbJob::GdbJob( GDBDebugger::CppDebuggerPlugin* p, KDevelop::ILaunchConfiguration* launchcfg, QObject* parent) 
189
160
    : KDevelop::OutputJob(parent), m_launchcfg( launchcfg )
190
161
{
 
162
    setCapabilities(Killable);
 
163
 
191
164
    m_session = p->createSession();
192
165
    connect(m_session, SIGNAL(applicationStandardOutputLines(QStringList)), SLOT(stderrReceived(QStringList)));
193
166
    connect(m_session, SIGNAL(applicationStandardErrorLines(QStringList)), SLOT(stdoutReceived(QStringList)));
198
171
{
199
172
    KConfigGroup grp = m_launchcfg->config();
200
173
    KDevelop::EnvironmentGroupList l(KGlobal::config());
201
 
    
202
 
    QString executable = ExecutePlugin::executableFromConfig( grp );
203
 
    
204
 
    QString envgrp = grp.readEntry( ExecutePlugin::environmentGroupEntry, "" );
205
 
    
206
 
    if( executable.isEmpty() )
207
 
    {
208
 
        setError(-1);
209
 
        setErrorText( i18n("No executable specified") );
210
 
        kWarning() << "no executable set";
211
 
    } else
212
 
    {
213
 
        KShell::Errors err;
214
 
        if( KShell::splitArgs( executable, KShell::TildeExpand | KShell::AbortOnMeta, &err ).isEmpty() || err != KShell::NoError )
215
 
        {
216
 
            
217
 
            setError( -1 );
218
 
            if( err == KShell::BadQuoting ) 
219
 
            {
220
 
                setErrorText( i18n("There is a quoting error in the executable "
221
 
                "for the launch configuration '%1'. "
222
 
                "Aborting start.", m_launchcfg->name() ) );
223
 
            } else 
224
 
            {   
225
 
                setErrorText( i18n("A shell meta character was included in the "
226
 
                "executable for the launch configuration '%1', "
227
 
                "this is not supported currently. Aborting start.", m_launchcfg->name() ) );
228
 
            }
229
 
            kWarning() << "executable has meta characters";
230
 
        }
 
174
    IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IExecutePlugin")->extension<IExecutePlugin>();
 
175
    Q_ASSERT(iface);
 
176
    QString err;
 
177
    QString executable = iface->executable( m_launchcfg, err ).toLocalFile();
 
178
    QString envgrp = iface->environmentGroup( m_launchcfg );
 
179
    
 
180
    if( !err.isEmpty() )
 
181
    {
 
182
        setError( -1 );
 
183
        setErrorText( err );
 
184
        return;
231
185
    }
232
186
    
233
187
    if( envgrp.isEmpty() )
238
192
        envgrp = l.defaultGroup();
239
193
    }
240
194
    
241
 
    KShell::Errors err;
242
 
    QStringList arguments = KShell::splitArgs( grp.readEntry( ExecutePlugin::argumentsEntry, "" ), KShell::TildeExpand | KShell::AbortOnMeta, &err );
243
 
    if( err != KShell::NoError )
 
195
    QStringList arguments = iface->arguments( m_launchcfg, err );
 
196
    if( !err.isEmpty() )
244
197
    {
245
 
        
246
198
        setError( -1 );
247
 
        if( err == KShell::BadQuoting ) 
248
 
        {
249
 
            setErrorText( i18n("There is a quoting error in the arguments for "
250
 
            "the launch configuration '%1'. Aborting start.", m_launchcfg->name() ) );
251
 
        } else 
252
 
        {   
253
 
            setErrorText( i18n("A shell meta character was included in the "
254
 
            "arguments for the launch configuration '%1', "
255
 
            "this is not supported currently. Aborting start.", m_launchcfg->name() ) );
256
 
        }
257
 
        kDebug() << "arguments have meta characters";
 
199
        setErrorText( err );
258
200
    }
259
201
    if( error() != 0 )
260
202
    {
268
210
    
269
211
    startOutput();
270
212
    
271
 
    m_session->startProgram( m_launchcfg, this );
 
213
    m_session->startProgram( m_launchcfg );
 
214
}
 
215
 
 
216
bool GdbJob::doKill()
 
217
{
 
218
    kDebug();
 
219
    m_session->stopDebugger();
 
220
    return true;
272
221
}
273
222
 
274
223
void GdbJob::stderrReceived(const QStringList& l )