Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339379 - Instruction pointer is not always removed when terminating launch
Summary: Instruction pointer is not always removed when terminating launch
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-09 10:53 EST by Marc Khouzam CLA
Modified: 2011-05-27 15:23 EDT (History)
5 users (show)

See Also:
aleherb+eclipse: review+


Attachments
Close the streams from the user of the stream (3.03 KB, patch)
2011-05-26 22:34 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff
Fix for GDB <= 6.8 (2.54 KB, patch)
2011-05-27 15:17 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2011-03-09 10:53:31 EST
In bug 338136 comment 18, Marc-Andre says:

"While testing with gdb 6.8, I noticed the instruction pointer often not being
removed after the launch was terminated. It seems to be OK with 7.0.1, 7.1 and
7.2."

I was able to reproduce the is when selecting the launch node and terminating in a normal debug session.  Like M-A says, it is for GDB 6.8 (and maybe earlier).  I also don't see this problem with CDT 7.0.

I've been modifying the terminating code as part of bug 338319.  I must have missed something.  My guess is some missing event, like containerExited, or commandControlExited.
Comment 1 Marc Khouzam CLA 2011-05-26 15:42:52 EDT
I'm seeing this with GDB 7.2 also
Comment 2 Marc Khouzam CLA 2011-05-26 15:44:31 EDT
The reason is that DsfSourceDisplayAdapter is expecting an IExitedDMEvent but it does not always receive it.

For GDB >= 7.0, we rely on GDB's MI events to report our own IExitedDMEvent, but it seems that when terminating GDB, we close the streams before we get those events in some cases.

I'm looking into it.
Comment 3 Marc Khouzam CLA 2011-05-26 15:50:36 EDT
I believe it is my fix to Bug 345164 that makes this happen for GDB >= 7.0.  What seems to happen is that we close the streams in GDBBackend.destroy() before we have received all the data from GDB, so we can miss some events.
Comment 4 Marc Khouzam CLA 2011-05-26 22:34:08 EDT
Created attachment 196721 [details]
Close the streams from the user of the stream

This fix is for GDB >= 7.0.

The problem was that we would close the streams too early in GDBBackend.destroy(), and miss some data given by GDB.

This patch lets the actual user of the streams take care of closing it.  This allows us to finish reading the stream and get all the data from GDB.

With this change, I see that the IP is removed properly, because we get the proper IExitedDMEvent triggered from the GDB events:

  =thread-exited,id="1",group-id="i1"
  =thread-group-exited,id="i1"

Committed to HEAD.

Toni, can you review this fix?
Comment 6 Anton Leherbauer CLA 2011-05-27 03:08:28 EDT
Makes perfect sense.
Comment 7 Marc Khouzam CLA 2011-05-27 15:17:44 EDT
Created attachment 196803 [details]
Fix for GDB <= 6.8

This fix is for GDB <= 6.8.  The problem was that the ContainerExitedDMEvent was not being sent at all when GDB itself was dying.  Previously, when we received an ^exit from GDB, MIInferiorProcess would send that event.  However, when I re-designed that part, I forgot to keep sending the event.

My first attempt to fix this was to send the event in MIRunControlEventProcessor when we get the same ^exit.  But I ran into a race condition where we sometimes call stopCommandProcessing() before we got the ^exit.  This was because we would detect that GDB was dead through GDBBackend.MonitorJob which monitors the actual GDB process, before we got the ^exit.

This patch sends the ContainerExitedDMEvent when we receive the ICommandControlShutdownDMEvent event.

Committed to HEAD.
Comment 8 Marc Khouzam CLA 2011-05-27 15:18:29 EDT
Fixed for all GDB versions
Comment 9 CDT Genie CLA 2011-05-27 15:23:23 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 339379: Instruction pointer is not always removed when terminating launch (GDB &lt;= 6.8 solution)

[*] GDBControl.java 1.31 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java?root=Tools_Project&r1=1.30&r2=1.31