Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 445360 - Can't debug when GDB path contains spaces.
Summary: Can't debug when GDB path contains spaces.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.4.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.6.0   Edit
Assignee: Iulia Vasii CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-29 09:55 EDT by Iulia Vasii CLA
Modified: 2015-02-02 09:20 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Iulia Vasii CLA 2014-09-29 09:55:15 EDT
Steps to reproduce:
1. install gdb in a path with spaces
2. in eclipse launch configuration specify the full gdb path in 'GDB command' field
Debug session will fail because of the unresolved spaces.
I noticed this happens only on Linux.

The most common case is when eclipse is installed in a path with spaces and 'GDB command' is relative to the eclipse directory, i.e:
GDB command: ${eclipse_home}../gdb/bin/gdb
Debug session will fail due to the same reason.
Comment 1 Iulia Vasii CLA 2014-09-29 11:24:15 EDT
Uploaded patch with a proposed fix:
https://git.eclipse.org/r/#/c/34052/

If someone can have a look. Thanks!
Comment 2 Marc Khouzam CLA 2014-10-01 14:18:37 EDT
Committed to master.

Thanks!
Comment 3 Teodor Madan CLA 2014-10-08 10:55:19 EDT
I missed the backword compatibility regression for a gdb backend that does override deprecated methods.

I have pushed another patch that would address this as well:

https://git.eclipse.org/r/#/c/34578/
Comment 4 Marc Khouzam CLA 2014-10-08 12:58:58 EDT
Issues with extenders have come up:

https://dev.eclipse.org/mhonarc/lists/cdt-dev/msg28256.html
Comment 5 Marc Khouzam CLA 2014-10-08 13:03:49 EDT
(In reply to Teodor Madan from comment #3)
> I missed the backword compatibility regression for a gdb backend that does
> override deprecated methods.
> 
> I have pushed another patch that would address this as well:
> 
> https://git.eclipse.org/r/#/c/34578/

Thanks Teo.
I have to admit I am not a big fan of this solution which seems hacky.  Can we do better?

The issue is that launchGDBProcess(String) is not being called any more. I would like to try a solution that still calls this method and then changes the before, probably splitting the string.  I'll try out things on my side as well.
Comment 6 Marc Khouzam CLA 2014-10-08 13:40:36 EDT
(In reply to Marc Khouzam from comment #5)
> (In reply to Teodor Madan from comment #3)
> > I missed the backword compatibility regression for a gdb backend that does
> > override deprecated methods.
> > 
> > I have pushed another patch that would address this as well:
> > 
> > https://git.eclipse.org/r/#/c/34578/

I've pushed a new patchset which I think solves the issue.  For CDT we will use the new API but we still call the old one first.
Comment 7 Marc Khouzam CLA 2014-10-08 13:52:57 EDT
(In reply to Marc Khouzam from comment #6)
> (In reply to Marc Khouzam from comment #5)
> > (In reply to Teodor Madan from comment #3)
> > > I missed the backword compatibility regression for a gdb backend that does
> > > override deprecated methods.
> > > 
> > > I have pushed another patch that would address this as well:
> > > 
> > > https://git.eclipse.org/r/#/c/34578/
> 
> I've pushed a new patchset which I think solves the issue.  For CDT we will
> use the new API but we still call the old one first.

Actually, this proposed fix works when launchGDBProcess(String) is overridden but not when only getGDBCommandLine() is overridden.

I'll make a better fix, but Elena, can you confirm which situation you are in?
Comment 8 Marc Khouzam CLA 2014-10-08 15:43:00 EDT
(In reply to Marc Khouzam from comment #7)
> > > > https://git.eclipse.org/r/#/c/34578/
> > 
> > I've pushed a new patchset which I think solves the issue.  For CDT we will
> > use the new API but we still call the old one first.
> 
> Actually, this proposed fix works when launchGDBProcess(String) is
> overridden but not when only getGDBCommandLine() is overridden.

I pushed another version which I think works for all combinations of overriding.  It is not as elegant as I hoped though.  It has to rely on comparing the commandLine string with the getGDBCommandLineArray() to see if anything changed.

I'm not sure if it is more understandable than Teo's fix (patchset 1).  I'm ok with choosing to go back to Teo's fix if you prefer.

One advantage of the latest patchset over the first is that for extenders that don't modify the commandLine parameter but do override either method, we will still use the new call to Process.exec which accepts spaces.  This is not such a valuable aspect though.

What do you guys prefer? (assuming both solution work for Elena)
Comment 9 Teodor Madan CLA 2014-10-09 03:20:22 EDT
It is hard to keep compatibility for a method that must be backward compatible  with respect to existing callers and to existing overridden cases without resorting to a hacky solution. 
IMHO, the cleanest code would've been to break compatibility for such cases. Nevertheless, this case does not worth IMO, and cleaning could be done on other occasions.


Between java reflection and the commandLine string comparison I think the later is better as it also covers gradual transition to new API. Java reflection case solution would have require GDBBackend extenders to remove old method.

To close, it is enough for Elena to verify that latest patch works.
Comment 10 Marc Khouzam CLA 2014-10-09 16:09:39 EDT
(In reply to Teodor Madan from comment #9)

> Between java reflection and the commandLine string comparison I think the
> later is better as it also covers gradual transition to new API. Java
> reflection case solution would have require GDBBackend extenders to remove
> old method.

Good point!

> To close, it is enough for Elena to verify that latest patch works.

Elena confirmed so I committed to master.
Comment 11 Iulia Vasii CLA 2014-10-10 03:56:20 EDT
Sorry about that and thanks for fixing this!
Comment 12 Marc Khouzam CLA 2015-02-02 09:20:11 EST
Please note that this fix has been improved to use shell-parsing syntax.  See Bug 458499 for details.