Bug 377633

Summary: Remote debugging via gdbserver not working
Product: [Applications] kdevelop Reporter: Massimo Burcheri <burcheri.massimo+bugs-kde>
Component: CPP DebuggerAssignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: niko.sams, pavel, pfyu817
Priority: NOR    
Version First Reported In: 5.0.80   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Massimo Burcheri 2017-03-15 09:09:45 UTC
As I have never seen the remote gdb support working and because it is not documented well, it became obvious to file a bug report here.

Moreover nearly nobody seems to use those features as I tried to get support on many channels like Freenodes #kdevelop, #gdb, the kde forums and stackoverflow...:

https://forum.kde.org/viewtopic.php?f=218&t=139176

Using a script for starting a remote gdbserver:
#!/usr/bin/env bash
server="target-srv"
target="foo"
ssh "$server" "gdbserver --remote-debug --attach localhost:8888 \$(pgrep -fo $target)"

The gdb script:
shell sleep 2
target remote target-srv:8888


Debugging starts and attaches to the remote process, but is never able to pause or set any breakpoint.





I tried another approach by providing a script replacing the local gdb that does the gdb session within ssh:
#!/usr/bin/env bash
server="target-srv"
target="foo"
ssh "$server" "gdb ${@:2} $target \$(pgrep -fo $target)"

Then it seems that KDevelop is parsing the gdb STDOUT but fails with

You need gdb 7.0.0 or higher
You are using: Reading symbols from foo...
Comment 1 Pavel Vymetalek 2017-09-08 12:52:50 UTC
>Then it seems that KDevelop is parsing the gdb STDOUT but fails with

>You need gdb 7.0.0 or higher
>You are using: Reading symbols from foo...

Similar experience with arm-none-eabi-gdb (version 7.6.2) or msp430-elf-gdb (version 7.2). 

.gdbinit 
target remote localhost:3333
- for using with openocd or mspdebug in case of msp430
Comment 2 Pavel Vymetalek 2017-09-08 12:54:56 UTC
(In reply to Pavel Vymetalek from comment #1)
> >Then it seems that KDevelop is parsing the gdb STDOUT but fails with
> 
> >You need gdb 7.0.0 or higher
> >You are using: Reading symbols from foo...
> 
> Similar experience with arm-none-eabi-gdb (version 7.6.2) or msp430-elf-gdb
> (version 7.2). 
> 
> .gdbinit 
> target remote localhost:3333
> - for using with openocd or mspdebug in case of msp430

I use workaround by this patch

--- debuggers/gdb/debugsession.cpp	2017-05-13 12:13:46.000000003 +0200
+++ debuggers/gdb/debugsession.cpp	2017-09-08 14:10:20.847162202 +0200
@@ -289,12 +289,12 @@
             qFatal("You need a graphical application.");
         }

-        KMessageBox::error(
-            qApp->activeWindow(),
-            i18n("<b>You need gdb 7.0.0 or higher.</b><br />"
-            "You are using: %1", s.first()),
-            i18n("gdb error"));
-        stopDebugger();
+//        KMessageBox::error(
+//            qApp->activeWindow(),
+//            i18n("<b>You need gdb 7.0.0 or higher.</b><br />"
+//            "You are using: %1", s.first()),
+//            i18n("gdb error"));
+//        stopDebugger();
     }
 }
Comment 3 Kevin Funk 2017-09-08 16:02:30 UTC
Pavel Vymetalek: Want to check whether there's a cleaner approach? Helping hands with KDevelop's GDB support are always needed.

Get in touch with us if you like, best to join our IRC channel.
  https://www.kdevelop.org/contribute-kdevelop