Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311965

Summary: [launch] Remote attach launch does not work with GDB 7.1
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: john.cortell, pawel.1.piech
Version: 7.0Flags: john.cortell: review+
john.cortell: review+
Target Milestone: 7.0.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Messed up launch
marc.khouzam: iplog-
Fix for HEAD
marc.khouzam: iplog-
Fix for 7.0.1 marc.khouzam: iplog-

Description Marc Khouzam CLA 2010-05-06 16:00:25 EDT
Created attachment 167383 [details]
Messed up launch

On my Linux I run:

gdbserver.7.1 --multi :9999

Then, in Eclipse, I create an attach launch using gdbserver and gdb.7.1 and press debug. The resulting launch is messed up as shown in the snapshot.
Comment 1 Marc Khouzam CLA 2010-06-30 08:52:38 EDT
This problem is because with GDB 7.1, we can receive a bogus process when we are not debugging anything
  -list-thread-groups
  ^done,groups=[{id="0",type="process",pid="0"}]

I also noticed that GDB HEAD, which will soon become GDB 7.2, the pid field is missing altogether in this case
  -list-thread-groups
  ^done,groups=[{id="i1",type="process"}]

We should ignore those kind of entries since they don't actually indicate a process that is being debugged.
Comment 2 Marc Khouzam CLA 2010-06-30 09:02:33 EDT
Created attachment 173087 [details]
Fix for HEAD

Fix committed to HEAD
Comment 3 Marc Khouzam CLA 2010-06-30 09:04:44 EDT
John, this is a small patch, can you review?
Comment 4 Marc Khouzam CLA 2010-06-30 09:05:03 EDT
Adding John for a review
Comment 6 John Cortell CLA 2010-06-30 11:08:49 EDT
(In reply to comment #3)
> John, this is a small patch, can you review?

I don't claim to fully understand the reasoning behind the logic since I'm not all that familiar with gdb thread groups, but superficially, I see nothing wrong with the changes. I do question whether the assumption that a pid of zero is bogus. Does gdb reserve that value? Is is not possible some environment might actually have a process with ID 0? I would keep this fix but pursue this issue with the gdb folks since this seems to me more of a workaround than a solution.
Comment 7 Marc Khouzam CLA 2010-06-30 11:57:33 EDT
(In reply to comment #6)
> (In reply to comment #3)
> > John, this is a small patch, can you review?
> 
> I don't claim to fully understand the reasoning behind the logic since I'm not
> all that familiar with gdb thread groups, but superficially, I see nothing
> wrong with the changes. I do question whether the assumption that a pid of zero
> is bogus. Does gdb reserve that value? Is is not possible some environment
> might actually have a process with ID 0? I would keep this fix but pursue this
> issue with the gdb folks since this seems to me more of a workaround than a
> solution.

:-)
http://sourceware.org/ml/gdb/2010-06/msg00138.html
But no answer yet.

P.S. I'm working on a patch for 7.0.1 as well.
Comment 8 Marc Khouzam CLA 2010-06-30 15:08:08 EDT
Created attachment 173147 [details]
Fix for 7.0.1

This is the fix for 7.0.1.  It's pretty much the same as for HEAD, but smaller, as I only added the exact changes that were actually needed.  In HEAD, I had added support for a more detailed parsing of GDB output, which is not needed for 7.0.1.

Committed to 7.0.1
Comment 9 Marc Khouzam CLA 2010-06-30 15:08:56 EDT
John, another quick review just to make sure I didn't make a stupid mistake in this patch.  Thanks.