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"
47
48
#include "ui_debuggerconfigwidget.h"
49
#include <interfaces/iplugincontroller.h>
50
#include <interfaces/icore.h>
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) );
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() );
93
94
QString GdbConfigPage::title() const
126
127
if( launchMode == "debug" )
128
QStringList deps = cfg->config().readEntry( ExecutePlugin::dependencyEntry, QStringList() );
129
QString depAction = cfg->config().readEntry( ExecutePlugin::dependencyActionEntry, "Nothing" );
130
if( depAction != "Nothing" && !deps.isEmpty() )
133
KDevelop::ProjectModel* model = KDevelop::ICore::self()->projectController()->projectModel();
134
foreach( const QString& dep, deps )
136
KDevelop::ProjectBaseItem* item = model->item( model->pathToIndex( dep.split('/') ) );
139
KDevelop::ProjectBaseItem* folder = item;
140
while( folder && !folder->folder() )
142
folder = dynamic_cast<KDevelop::ProjectBaseItem*>( folder->parent() );
144
if( folder && item->project()->buildSystemManager()->builder( folder->folder() ) )
146
KDevelop::IProjectBuilder* builder = item->project()->buildSystemManager()->builder( folder->folder() );
147
if( depAction == "Build" )
149
l << builder->build( item );
150
} else if( depAction == "Install" )
152
l << builder->install( item );
153
} else if( depAction == "SudoInstall" )
155
KMessageBox::information( KDevelop::ICore::self()->uiController()->activeMainWindow(),
156
i18n("Installing via sudo is not yet implemented"),
157
i18n("Not implemented") );
162
l << new GdbJob( m_plugin, cfg );
163
return new KDevelop::ExecuteCompositeJob( KDevelop::ICore::self()->runController(), l );
166
return new GdbJob( m_plugin, cfg );
129
IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IExecutePlugin")->extension<IExecutePlugin>();
132
KJob* depjob = iface->dependecyJob(cfg);
137
l << new GdbJob( m_plugin, cfg );
138
return new KDevelop::ExecuteCompositeJob( KDevelop::ICore::self()->runController(), l );
169
140
kWarning() << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
188
159
GdbJob::GdbJob( GDBDebugger::CppDebuggerPlugin* p, KDevelop::ILaunchConfiguration* launchcfg, QObject* parent)
189
160
: KDevelop::OutputJob(parent), m_launchcfg( launchcfg )
162
setCapabilities(Killable);
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)));
199
172
KConfigGroup grp = m_launchcfg->config();
200
173
KDevelop::EnvironmentGroupList l(KGlobal::config());
202
QString executable = ExecutePlugin::executableFromConfig( grp );
204
QString envgrp = grp.readEntry( ExecutePlugin::environmentGroupEntry, "" );
206
if( executable.isEmpty() )
209
setErrorText( i18n("No executable specified") );
210
kWarning() << "no executable set";
214
if( KShell::splitArgs( executable, KShell::TildeExpand | KShell::AbortOnMeta, &err ).isEmpty() || err != KShell::NoError )
218
if( err == KShell::BadQuoting )
220
setErrorText( i18n("There is a quoting error in the executable "
221
"for the launch configuration '%1'. "
222
"Aborting start.", m_launchcfg->name() ) );
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() ) );
229
kWarning() << "executable has meta characters";
174
IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension("org.kdevelop.IExecutePlugin")->extension<IExecutePlugin>();
177
QString executable = iface->executable( m_launchcfg, err ).toLocalFile();
178
QString envgrp = iface->environmentGroup( m_launchcfg );
233
187
if( envgrp.isEmpty() )
238
192
envgrp = l.defaultGroup();
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 );
247
if( err == KShell::BadQuoting )
249
setErrorText( i18n("There is a quoting error in the arguments for "
250
"the launch configuration '%1'. Aborting start.", m_launchcfg->name() ) );
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() ) );
257
kDebug() << "arguments have meta characters";
259
201
if( error() != 0 )
271
m_session->startProgram( m_launchcfg, this );
213
m_session->startProgram( m_launchcfg );
216
bool GdbJob::doKill()
219
m_session->stopDebugger();
274
223
void GdbJob::stderrReceived(const QStringList& l )