Bug 82956 - Featurewish: Setting the instruction pointer within the KDevelop debugger
Summary: Featurewish: Setting the instruction pointer within the KDevelop debugger
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-06 23:31 UTC by Joachim Eibl
Modified: 2005-11-01 22:55 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Eibl 2004-06-06 23:31:33 UTC
Version:           3.0.90 (using KDE KDE 3.2.90)
Installed from:    Compiled From Sources

I would like to be able to set the instruction pointer within the debugger via the user interface.

Whithin gdb this can be achieved via the "jump"-command plus a temporary breakpoint at the jump target.

This is very useful in many situations. E.g. when you accidently stepped over the important function and want to step in; or to repeat or skip a certain section for whatever reason.

It would be similar like "Run to cursor" in the Debug-menu but instead "Jump to cursor" or "Set next instruction".

Joachim
Comment 1 Robert Gruber 2005-07-27 14:38:37 UTC
SVN commit 439210 by rgruber:

Added toolbar button to set the instruction pointer to a different
location using gdb's jump command
BUGS:82956


 M  +1 -0      languages/cpp/debugger/dbgcontroller.h  
 M  +24 -1     languages/cpp/debugger/debuggerpart.cpp  
 M  +1 -0      languages/cpp/debugger/debuggerpart.h  
 M  +13 -0     languages/cpp/debugger/gdbcontroller.cpp  
 M  +1 -0      languages/cpp/debugger/gdbcontroller.h  
 M  +1 -0      languages/cpp/debugger/kdevdebugger.rc  
 M  +1 -1      pics/toolbar/Makefile.am  
 AM            pics/toolbar/hi22-action-dbgjumpto.png  


--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/dbgcontroller.h #439209:439210
@@ -96,6 +96,7 @@
 
     virtual void slotRun()                                                  = 0;
     virtual void slotRunUntil(const QString &fileName, int lineNum)         = 0;
+    virtual void slotJumpTo(const QString &fileName, int lineNum)           = 0;
     virtual void slotStepInto()                                             = 0;
     virtual void slotStepOver()                                             = 0;
     virtual void slotStepIntoIns()                                          = 0;
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/debuggerpart.cpp #439209:439210
@@ -194,6 +194,13 @@
     action->setWhatsThis(i18n("<b>Run to cursor</b><p>Continues execution until the cursor position is reached."));
 
 
+    action = new KAction(i18n("Set E&xecution Position to Cursor"), "dbgjumpto", 0,
+                         this, SLOT(slotJumpToCursor()),
+                         actionCollection(), "debug_jumptocursor");
+    action->setToolTip( i18n("Jump to cursor") );
+    action->setWhatsThis(i18n("<b>Set Execution Position </b><p>Set the execution pointer to the current cursor position."));
+
+
     action = new KAction(i18n("Step &Over"), "dbgnext", 0,
                          this, SLOT(slotStepOver()),
                          actionCollection(), "debug_stepover");
@@ -805,9 +812,25 @@
     uint line, col;
     cursorIface->cursorPosition(&line, &col);
 
-    controller->slotRunUntil(rwpart->url().path(), line);
+    controller->slotRunUntil(rwpart->url().path(), ++line);
 }
 
+void DebuggerPart::slotJumpToCursor()
+{
+    KParts::ReadWritePart *rwpart
+            = dynamic_cast<KParts::ReadWritePart*>(partController()->activePart());
+    KTextEditor::ViewCursorInterface *cursorIface
+            = dynamic_cast<KTextEditor::ViewCursorInterface*>(partController()->activeWidget());
+
+    if (!rwpart || !rwpart->url().isLocalFile() || !cursorIface)
+        return;
+
+    uint line, col;
+    cursorIface->cursorPositionReal(&line, &col);
+
+    controller->slotJumpTo(rwpart->url().path(), ++line);
+}
+
 void DebuggerPart::slotStepOver()
 {
     controller->slotStepOver();
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/debuggerpart.h #439209:439210
@@ -74,6 +74,7 @@
     void slotStop(KDevPlugin* which = 0);
     void slotPause();
     void slotRunToCursor();
+    void slotJumpToCursor();
     void slotStepOver();
     void slotStepOverInstruction();
     void slotStepIntoInstruction();
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/gdbcontroller.cpp #439209:439210
@@ -1492,6 +1492,19 @@
 
 // **************************************************************************
 
+void GDBController::slotJumpTo(const QString &fileName, int lineNum)
+{
+    if (stateIsOn(s_appBusy|s_dbgNotStarted|s_shuttingDown))
+        return;
+
+    if (!fileName.isEmpty()) {
+        queueCmd(new GDBCommand(QCString().sprintf("tbreak %s:%d", fileName.latin1(), lineNum), NOTRUNCMD, NOTINFOCMD, 0));
+        queueCmd(new GDBCommand(QCString().sprintf("jump %s:%d", fileName.latin1(), lineNum), RUNCMD, NOTINFOCMD, 0));
+    }
+}
+
+// **************************************************************************
+
 void GDBController::slotStepInto()
 {
     if (stateIsOn(s_appBusy|s_appNotStarted|s_shuttingDown))
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/gdbcontroller.h #439209:439210
@@ -97,6 +97,7 @@
 
     void slotRun();
     void slotRunUntil(const QString &filename, int lineNum);
+    void slotJumpTo(const QString &filename, int lineNum);
     void slotStepInto();
     void slotStepOver();
     void slotStepIntoIns();
--- branches/KDE/3.5/kdevelop/languages/cpp/debugger/kdevdebugger.rc #439209:439210
@@ -7,6 +7,7 @@
   <Action name="debug_stop" group="debug"/>
   <Action name="debug_pause" group="debug"/>
   <Action name="debug_runtocursor" group="debug"/>
+  <Action name="debug_jumptocursor" group="debug"/>
   <Separator group="debug"/>
   <Action name="debug_stepover" group="debug"/>
   <Action name="debug_stepoverinst" group="debug"/>
--- branches/KDE/3.5/kdevelop/pics/toolbar/Makefile.am #439209:439210
@@ -2,7 +2,7 @@
 kdevelop_ICON = AUTO
 
 kdevdebuggerdir = $(kde_datadir)/kdevdebugger/icons
-kdevdebugger_ICON = dbgnext dbgwatchvar dbgrun dbgstepout dbgmemview dbgparam dbgrunto dbgstep dbgnextinst dbgrestart dbgstepinst dbgvar debugger
+kdevdebugger_ICON = dbgnext dbgwatchvar dbgrun dbgstepout dbgmemview dbgparam dbgrunto dbgstep dbgnextinst dbgrestart dbgstepinst dbgvar debugger dbgjumpto
 
 cppsupportdir = $(kde_datadir)/kdevcppsupport/icons
 cppsupport_ICON = classnew classwiz
** branches/KDE/3.5/kdevelop/pics/toolbar/hi22-action-dbgjumpto.png #property changes
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream
Comment 2 Joachim Eibl 2005-11-01 22:55:52 UTC
Hi, I just tested this and it works great. Thank you very much.
Cheers, Joachim