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

Bug 343752

Summary: Restart no longer works with GDB >= 7.0
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: cdtdoug, pawel.1.piech
Version: 7.0Flags: pawel.1.piech: review+
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix marc.khouzam: iplog-

Description Marc Khouzam CLA 2011-04-25 13:09:53 EDT
While fixing Bug 338319, I seem to have broken the Restart feature for GDB >= 7.0.

The reason seems to be that starting with GDB 7.0, when we restart a process, we get a =thread-group-exited event, which is translated to an IExitedEvent for a container, which will make use kill GDB, assuming the option to "kill gdb when the last inferior is gone" has been chosen.
Comment 1 Marc Khouzam CLA 2011-04-30 14:20:43 EDT
Created attachment 194428 [details]
Fix

Previously, this used to work because we only killed GDB if the inferior was marked as Terminated, which was done when getting an *stopped,reason="exited-normally" or the like from GDB.  We are no longer making use of that event.

So, what GDB does is the following.  When a process terminates, it sends an =thread-group-exited event, even if the process will be restarted.  However, the *stopped,reason="exited-normally" is only sent by GDB if the process terminates and will _not_ be restarted.  That seems to be the only way GDB informs us of the restart case.

So, one solution would be to not only trigger off an IExitedDMEvent but also on an MIInferiorExitEvent/MIInferiorSignalExitEvent to know that a process has exited and will not restart.  In that case it will be safe to kill GDB.  However, this approach is very dependent on this weird use of GDB events, which may even change in the future.

Instead, we can simply keep an internal flag to know that we are doing a restart.  This is what this simple patch does.

Committed to HEAD.
Comment 2 Marc Khouzam CLA 2011-04-30 14:23:08 EDT
Fixed.

Pawel, can you review?
Comment 3 CDT Genie CLA 2011-04-30 15:23:01 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 343752: Restart no longer works with GDB &gt;= 7.0

[*] GDBProcesses_7_0.java 1.48 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java?root=Tools_Project&r1=1.47&r2=1.48
Comment 4 Pawel Piech CLA 2011-05-06 19:19:47 EDT
Seems logical to me.