branches/KDE/3.5/kdevelop/languages/cpp/debugger

Vladimir Prus ghost at cs.msu.su
Thu Aug 18 13:01:59 UTC 2005


SVN commit 450506 by vprus:

Improve start/stop behaviour of the debugger.

- When application exists, don't kill the debugger. So, we don't need
  to restart debugger again, and restarting can be very slow due
  to loading numerous symbols. Also, now the debugger windows don't
  disappear when applications exists, only when user explicitly stops 
  the debugger, so
    - he can look at gdb output 
    - the variables window is not constantly shown/hidden when restarting
      debugger

- Add "Restart" action that runs the program from the beginning without
  restarting the debugger.

* debuggerpart.cpp
  (DebuggerPart::slotStatus): Revert revision 377895 that introduced
  "stop debugger on application exit" behaviour in attempt to workaround
  bug 73946.  
  (DebuggerPart::DebuggerPart): Create new action. It turns out we even 
  have icon for it already.

* gdbcontroller.cpp
  (GDBController::programNoApp): Really fix bug 73946.
  (GDBController::slotRestart): New slot.

CCBUG: 73946
BUG: 108534
CCMAIL: kdevelop-devel at kdevelop.org


 M  +1 -0      dbgcontroller.h  
 M  +24 -2     debuggerpart.cpp  
 M  +1 -0      debuggerpart.h  
 M  +19 -1     gdbcontroller.cpp  
 M  +1 -0      gdbcontroller.h  
 M  +2 -0      kdevdebugger.rc  


--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/dbgcontroller.h #450505:450506
@@ -95,6 +95,7 @@
     virtual void slotStopDebugger()                                         = 0;
 
     virtual void slotRun()                                                  = 0;
+    virtual void slotRestart()                                              = 0;
     virtual void slotRunUntil(const QString &fileName, int lineNum)         = 0;
     virtual void slotJumpTo(const QString &fileName, int lineNum)           = 0;
     virtual void slotStepInto()                                             = 0;
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/debuggerpart.cpp #450505:450506
@@ -176,6 +176,16 @@
                                "while it is running, in order to get information "
                                "about variables, frame stack, and so on.") );
 
+    action = new KAction(i18n("&Restart"), "dbgrestart", 0,
+                         this, SLOT(slotRestart()),
+                         actionCollection(), "debug_restart");
+    action->setToolTip( i18n("Restart program") );
+    action->setWhatsThis( i18n("<b>Restarts application</b><p>"
+                               "Restarts applications from the beginning."
+                              ) );
+    action->setEnabled(false);
+
+
     action = new KAction(i18n("Sto&p"), "stop", 0,
                          this, SLOT(slotStop()),
                          actionCollection(), "debug_stop");
@@ -782,6 +792,14 @@
     controller->slotRun();
 }
 
+void DebuggerPart::slotRestart()
+{
+    // We could have directly connect KAction to controller->slotRestart()
+    // but controller is created after actions, and I did not want to 
+    // create unconnected action and connect it later, as it would make
+    // it harder to understand the code.
+    controller->slotRestart();
+}
 
 void DebuggerPart::slotExamineCore()
 {
@@ -948,6 +966,7 @@
     if (state & s_dbgNotStarted)
     {
         stateIndicator = " ";
+        mainWindow()->lowerView(variableWidget);
     }
     else if (state & s_appBusy)
     {
@@ -964,8 +983,6 @@
         ac->action("debug_run")->setToolTip( i18n("Restart the program in the debugger") );
         ac->action("debug_run")->setWhatsThis( i18n("Restart in debugger\n\n"
                                            "Restarts the program in the debugger") );
-        slotStop();
-        mainWindow()->lowerView(variableWidget);
     }
     else
     {
@@ -984,6 +1001,11 @@
         }
     }
 
+    // If program is started, enable the 'restart' comand.
+    actionCollection()->action("debug_restart")->setEnabled(
+        !(state & s_programExited));
+
+
     // As soon as debugger clears 's_appNotStarted' flag, we
     // set 'justRestarted' variable. 
     // The other approach would be to set justRestarted in slotRun, slotCore
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/debuggerpart.h #450505:450506
@@ -68,6 +68,7 @@
     void slotActivePartChanged(KParts::Part*);
 
     void slotRun();
+    void slotRestart();
     void slotExamineCore();
     void slotAttachProcess();
     void slotStopDebugger();
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/gdbcontroller.cpp #450505:450506
@@ -438,6 +438,12 @@
     viewedThread_ = -1;
     currentFrame_ = 0;
 
+    // Delete the tty that waits for application output. Without
+    // this, KDevelop will be hanging, eating 100% CPU. Don't know
+    // why and don't understand this TTY stuff either.
+    delete tty_;
+    tty_ = 0;
+
     frameStack_->clear();
 
     if (msgBox)
@@ -1474,6 +1480,18 @@
     }
 }
 
+
+void GDBController::slotRestart()
+{
+    if (stateIsOn(s_dbgNotStarted|s_shuttingDown))
+        return;
+
+    if (stateIsOn(s_appBusy))
+        pauseApp();
+
+    queueCmd(new GDBCommand("run", RUNCMD, NOTINFOCMD, 0));        
+}
+
 // **************************************************************************
 
 void GDBController::slotRunUntil(const QString &fileName, int lineNum)
@@ -2006,7 +2024,7 @@
       emit debuggerRunError(127);
 
     destroyCmds();
-    state_ = s_appNotStarted|s_programExited|(state_&(s_viewLocals|s_shuttingDown));
+    state_ = s_dbgNotStarted|s_appNotStarted|s_programExited|(state_&(s_viewLocals|s_shuttingDown));
     emit dbgStatus (i18n("Process exited"), state_);
 
     emit gdbStdout("(gdb) Process exited\n");
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/gdbcontroller.h #450505:450506
@@ -96,6 +96,7 @@
     void slotStopDebugger();
 
     void slotRun();
+    void slotRestart();
     void slotRunUntil(const QString &filename, int lineNum);
     void slotJumpTo(const QString &filename, int lineNum);
     void slotStepInto();
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/kdevdebugger.rc #450505:450506
@@ -6,6 +6,7 @@
   <Action name="debug_run" group="debug"/>
   <Action name="debug_stop" group="debug"/>
   <Action name="debug_pause" group="debug"/>
+  <Action name="debug_restart" group="debug"/>
   <Action name="debug_runtocursor" group="debug"/>
   <Action name="debug_jumptocursor" group="debug"/>
   <Separator group="debug"/>
@@ -27,6 +28,7 @@
 <ToolBar name="debugToolBar">
   <text>Debugger Toolbar</text>
   <Action name="debug_run"/>
+  <Action name="debug_restart"/>
   <Action name="debug_stepover"/>
   <Action name="debug_stepinto"/>
   <Action name="debug_stepout"/>




More information about the KDevelop-devel mailing list