Changeset View
Changeset View
Standalone View
Standalone View
shell/debugcontroller.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | #include "../debugger/breakpoint/breakpointmodel.h" | 45 | #include "../debugger/breakpoint/breakpointmodel.h" | ||
46 | #include "../debugger/breakpoint/breakpointwidget.h" | 46 | #include "../debugger/breakpoint/breakpointwidget.h" | ||
47 | #include "../debugger/variable/variablewidget.h" | 47 | #include "../debugger/variable/variablewidget.h" | ||
48 | #include "../debugger/framestack/framestackmodel.h" | 48 | #include "../debugger/framestack/framestackmodel.h" | ||
49 | #include "../debugger/framestack/framestackwidget.h" | 49 | #include "../debugger/framestack/framestackwidget.h" | ||
50 | #include "core.h" | 50 | #include "core.h" | ||
51 | #include "debug.h" | 51 | #include "debug.h" | ||
52 | #include "uicontroller.h" | 52 | #include "uicontroller.h" | ||
53 | #include "iruncontroller.h" | ||||
54 | #include "launchconfigurationdialog.h" | ||||
53 | 55 | | |||
54 | 56 | | |||
55 | namespace KDevelop { | 57 | namespace KDevelop { | ||
56 | 58 | | |||
57 | template<class T> | 59 | template<class T> | ||
58 | class DebuggerToolFactory : public KDevelop::IToolViewFactory | 60 | class DebuggerToolFactory : public KDevelop::IToolViewFactory | ||
59 | { | 61 | { | ||
60 | public: | 62 | public: | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | |||||
191 | { | 193 | { | ||
192 | return m_currentSession.data(); | 194 | return m_currentSession.data(); | ||
193 | } | 195 | } | ||
194 | 196 | | |||
195 | void DebugController::setupActions() | 197 | void DebugController::setupActions() | ||
196 | { | 198 | { | ||
197 | KActionCollection* ac = actionCollection(); | 199 | KActionCollection* ac = actionCollection(); | ||
198 | 200 | | |||
199 | QAction* action = m_continueDebugger = new QAction(QIcon::fromTheme(QStringLiteral("media-playback-start")), i18n("&Continue"), this); | 201 | QAction* action = m_continueDebugger = new QAction(this); | ||
200 | action->setToolTip( i18n("Continue application execution") ); | 202 | setContinueStartsDebug(true); | ||
201 | action->setWhatsThis( i18n("Continues the execution of your application in the " | | |||
202 | "debugger. This only takes effect when the application " | | |||
203 | "has been halted by the debugger (i.e. a breakpoint has " | | |||
204 | "been activated or the interrupt was pressed).") ); | | |||
205 | ac->addAction(QStringLiteral("debug_continue"), action); | 203 | ac->addAction(QStringLiteral("debug_continue"), action); | ||
206 | connect(action, &QAction::triggered, this, &DebugController::run); | 204 | connect(action, &QAction::triggered, this, &DebugController::run); | ||
207 | 205 | | |||
208 | #if 0 | 206 | #if 0 | ||
209 | m_restartDebugger = action = new QAction(QIcon::fromTheme("media-seek-backward"), i18n("&Restart"), this); | 207 | m_restartDebugger = action = new QAction(QIcon::fromTheme("media-seek-backward"), i18n("&Restart"), this); | ||
210 | action->setToolTip( i18n("Restart program") ); | 208 | action->setToolTip( i18n("Restart program") ); | ||
211 | action->setWhatsThis( i18n("Restarts applications from the beginning.") ); | 209 | action->setWhatsThis( i18n("Restarts applications from the beginning.") ); | ||
212 | action->setEnabled(false); | 210 | action->setEnabled(false); | ||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 394 | { | |||
399 | 397 | | |||
400 | qCDebug(SHELL) << state; | 398 | qCDebug(SHELL) << state; | ||
401 | switch (state) { | 399 | switch (state) { | ||
402 | case IDebugSession::StoppedState: | 400 | case IDebugSession::StoppedState: | ||
403 | case IDebugSession::NotStartedState: | 401 | case IDebugSession::NotStartedState: | ||
404 | case IDebugSession::StoppingState: | 402 | case IDebugSession::StoppingState: | ||
405 | qCDebug(SHELL) << "new state: stopped"; | 403 | qCDebug(SHELL) << "new state: stopped"; | ||
406 | stateChanged(QStringLiteral("stopped")); | 404 | stateChanged(QStringLiteral("stopped")); | ||
405 | setContinueStartsDebug(true); | ||||
407 | //m_restartDebugger->setEnabled(session->restartAvailable()); | 406 | //m_restartDebugger->setEnabled(session->restartAvailable()); | ||
408 | break; | 407 | break; | ||
409 | case IDebugSession::StartingState: | 408 | case IDebugSession::StartingState: | ||
410 | case IDebugSession::PausedState: | 409 | case IDebugSession::PausedState: | ||
411 | qCDebug(SHELL) << "new state: paused"; | 410 | qCDebug(SHELL) << "new state: paused"; | ||
412 | stateChanged(QStringLiteral("paused")); | 411 | stateChanged(QStringLiteral("paused")); | ||
412 | setContinueStartsDebug(false); | ||||
413 | //m_restartDebugger->setEnabled(session->restartAvailable()); | 413 | //m_restartDebugger->setEnabled(session->restartAvailable()); | ||
414 | break; | 414 | break; | ||
415 | case IDebugSession::ActiveState: | 415 | case IDebugSession::ActiveState: | ||
416 | qCDebug(SHELL) << "new state: active"; | 416 | qCDebug(SHELL) << "new state: active"; | ||
417 | stateChanged(QStringLiteral("active")); | 417 | stateChanged(QStringLiteral("active")); | ||
418 | setContinueStartsDebug(false); | ||||
418 | //m_restartDebugger->setEnabled(false); | 419 | //m_restartDebugger->setEnabled(false); | ||
419 | break; | 420 | break; | ||
420 | case IDebugSession::EndedState: | 421 | case IDebugSession::EndedState: | ||
421 | qCDebug(SHELL) << "new state: ended"; | 422 | qCDebug(SHELL) << "new state: ended"; | ||
422 | stateChanged(QStringLiteral("ended")); | 423 | stateChanged(QStringLiteral("ended")); | ||
424 | setContinueStartsDebug(true); | ||||
423 | //m_restartDebugger->setEnabled(false); | 425 | //m_restartDebugger->setEnabled(false); | ||
424 | break; | 426 | break; | ||
425 | } | 427 | } | ||
426 | if (state == IDebugSession::PausedState && ICore::self()->uiController()->activeMainWindow()) { | 428 | if (state == IDebugSession::PausedState && ICore::self()->uiController()->activeMainWindow()) { | ||
427 | ICore::self()->uiController()->activeMainWindow()->activateWindow(); | 429 | ICore::self()->uiController()->activeMainWindow()->activateWindow(); | ||
428 | } | 430 | } | ||
429 | } | 431 | } | ||
430 | 432 | | |||
433 | void DebugController::setContinueStartsDebug(bool startsDebug) | ||||
mwolff: rename to: setContinueStartsDebug | |||||
434 | { | ||||
435 | if (startsDebug) { | ||||
436 | m_continueDebugger->setText(i18n("Debug Launch")); | ||||
437 | m_continueDebugger->setIcon(QIcon::fromTheme(QStringLiteral("debug-run"))); | ||||
438 | m_continueDebugger->setToolTip(i18n("Debug current launch")); | ||||
439 | m_continueDebugger->setWhatsThis(i18n("Executes the target or the program specified in " | ||||
440 | "currently active launch configuration inside a Debugger.")); | ||||
441 | } else { | ||||
442 | m_continueDebugger->setText(i18n("&Continue")); | ||||
443 | m_continueDebugger->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); | ||||
444 | m_continueDebugger->setToolTip(i18n("Continue application execution") ); | ||||
445 | m_continueDebugger->setWhatsThis(i18n("Continues the execution of your application in the " | ||||
446 | "debugger. This only takes effect when the application " | ||||
447 | "has been halted by the debugger (i.e. a breakpoint has " | ||||
448 | "been activated or the interrupt was pressed).") ); | ||||
449 | } | ||||
450 | } | ||||
451 | | ||||
431 | ContextMenuExtension DebugController::contextMenuExtension( Context* context ) | 452 | ContextMenuExtension DebugController::contextMenuExtension( Context* context ) | ||
432 | { | 453 | { | ||
433 | ContextMenuExtension menuExt; | 454 | ContextMenuExtension menuExt; | ||
434 | 455 | | |||
435 | if( context->type() != Context::EditorContext ) | 456 | if( context->type() != Context::EditorContext ) | ||
436 | return menuExt; | 457 | return menuExt; | ||
437 | 458 | | |||
438 | KDevelop::EditorContext *econtext = dynamic_cast<KDevelop::EditorContext*>(context); | 459 | KDevelop::EditorContext *econtext = dynamic_cast<KDevelop::EditorContext*>(context); | ||
Show All 9 Lines | |||||
448 | } | 469 | } | ||
449 | return menuExt; | 470 | return menuExt; | ||
450 | } | 471 | } | ||
451 | 472 | | |||
452 | #if 0 | 473 | #if 0 | ||
453 | void DebugController::restartDebugger() { | 474 | void DebugController::restartDebugger() { | ||
454 | if (m_currentSession) { | 475 | if (m_currentSession) { | ||
455 | m_currentSession.data()->restartDebugger(); | 476 | m_currentSession.data()->restartDebugger(); | ||
456 | } | 477 | } | ||
mwolff: join to next line, add space after else, such that it reads: `} else {` | |||||
457 | } | 478 | } | ||
mwolff: space after if | |||||
458 | #endif | 479 | #endif | ||
459 | 480 | | |||
460 | void DebugController::stopDebugger() { | 481 | void DebugController::stopDebugger() { | ||
461 | if (m_currentSession) { | 482 | if (m_currentSession) { | ||
if the dialog gets canceled, we may still not have a launch, right? will that still work fine (i.e. no crash/warning), or should that be catched explicitly here? mwolff: if the dialog gets canceled, we may still not have a launch, right? will that still work fine… | |||||
A crash should not happen, further execution will be stopped here and a warning will be written to console. It's the same why how the real debug action is implemented. void KDevelop::RunController::executeDefaultLaunch(const QString& runMode) { auto dl = defaultLaunch(); if( !dl ) { qWarning() << "no default launch!"; return; } execute( runMode, dl ); } dporobic: A crash should not happen, further execution will be stopped here and a warning will be written… | |||||
462 | m_currentSession.data()->stopDebugger(); | 483 | m_currentSession.data()->stopDebugger(); | ||
463 | } | 484 | } | ||
464 | } | 485 | } | ||
465 | void DebugController::interruptDebugger() { | 486 | void DebugController::interruptDebugger() { | ||
466 | if (m_currentSession) { | 487 | if (m_currentSession) { | ||
467 | m_currentSession.data()->interruptDebugger(); | 488 | m_currentSession.data()->interruptDebugger(); | ||
468 | } | 489 | } | ||
469 | } | 490 | } | ||
470 | 491 | | |||
471 | void DebugController::run() { | 492 | void DebugController::run() { | ||
472 | if (m_currentSession) { | 493 | if (m_currentSession) { | ||
473 | m_currentSession.data()->run(); | 494 | m_currentSession.data()->run(); | ||
495 | } else { | ||||
496 | if (ICore::self()->runController()->launchConfigurations().isEmpty()) { | ||||
497 | LaunchConfigurationDialog d; | ||||
498 | d.exec(); | ||||
499 | } | ||||
500 | ICore::self()->runController()->executeDefaultLaunch(QStringLiteral("debug")); | ||||
474 | } | 501 | } | ||
475 | } | 502 | } | ||
476 | 503 | | |||
477 | void DebugController::runToCursor() { | 504 | void DebugController::runToCursor() { | ||
478 | if (m_currentSession) { | 505 | if (m_currentSession) { | ||
479 | m_currentSession.data()->runToCursor(); | 506 | m_currentSession.data()->runToCursor(); | ||
480 | } | 507 | } | ||
481 | } | 508 | } | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
rename to: setContinueStartsDebug