Bug 446786

Summary: gdb front end fails for certain .gdbinit files (noticed with https://github.com/hugsy/gef)
Product: [Applications] kdevelop Reporter: David Oldford <david_oldford>
Component: CPP DebuggerAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: minor CC: niko.sams
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.12.230800
Sentry Crash Report:
Attachments: the error message I get

Description David Oldford 2021-12-10 14:06:25 UTC
Created attachment 144432 [details]
the error message I get

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. install GEF 
2. Attempt to debug a C/C++ project with gdb


OBSERVED RESULT
debugging will fail to start and you'll get a drop down message that your version of gdb is too old with escaped binary in place of info about gdb that should have been detected


EXPECTED RESULT
I'm not really sure the best way to handle it and the expected result would depend on that. Either the debugger would work as expected or the error message would be fixed with a hint about the .gdbinit file.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: This should apply to all versions and any oses that support gdb I tested with Kubuntu 21.10 plasma 5.22.5
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
if gdb were run with -nx it would not load a .gdbinit file. I've used gdb for reverse engineering on occasion, but rarely for CTFs so I'm not really familiar with the power of .gdbinit files and I'm not sure if kdevelop can cope with .gdbinit files other than gef or if there could be value in loading them?. I have a feeling this solution makes the most sense. The alternative would require altering the regex used to look for gdb version information and altering the error message given when kdevelop thinks debugging can't work.
Comment 1 Bug Janitor Service 2023-07-22 10:06:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/468
Comment 2 Igor Kushnir 2023-07-25 17:23:30 UTC
Git commit a974c3c66130f9e454de1006a7894e4002541dd0 by Igor Kushnir, on behalf of Denis Biryukov.
Committed on 25/07/2023 at 19:22.
Pushed by igorkushnir into branch 'release/23.08'.

gdb: skip to GDB version string

This change allows to use ~/.gdbinit file with constructions like
`skip -gfi /usr/include/c++/*`.
Problem with current implementation is that when .gdbinit contains such
strings GDB output produced is following:
```
File(s) /usr/include/c++/* will be skipped when stepping.
GNU gdb (Ubuntu 8.2.91.20190405-0ubuntu3) 8.2.91.20190405-git
```
And current implementation expects version on the first output from GDB.

This change fixes it by adding skip functionality during GDB session
initialization.
Related: bug 409702, bug 428688
FIXED-IN: 5.12.230800

M  +29   -15   plugins/gdb/debugsession.cpp

https://invent.kde.org/kdevelop/kdevelop/-/commit/a974c3c66130f9e454de1006a7894e4002541dd0