1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 339456: Thread created event with wrong id after restart for GDB < 7.0

This commit is contained in:
Marc Khouzam 2011-05-13 15:01:50 +00:00
parent e2e514ace6
commit f0be94ea01

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
import org.eclipse.cdt.dsf.debug.service.ISignals.ISignalsDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
@ -42,6 +43,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadCreatedEvent;
import org.eclipse.cdt.dsf.mi.service.command.output.MIConsoleStreamOutput;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOOBRecord;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
/**
@ -55,7 +57,7 @@ public class CLIEventProcessor
private final ICommandControlDMContext fControlDmc;
// Last Thread ID created
private static int fLastThreadId;
private int fLastThreadId;
private final DsfServicesTracker fServicesTracker;
@ -68,11 +70,12 @@ public class CLIEventProcessor
fServicesTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fCommandControl.getSession().getId());
connection.addCommandListener(this);
connection.addEventListener(this);
// Re-set the counter
fLastThreadId = 0;
fCommandControl.getSession().addServiceEventListener(this, null);
}
public void dispose() {
fCommandControl.getSession().removeServiceEventListener(this);
fCommandControl.removeCommandListener(this);
fCommandControl.removeEventListener(this);
fServicesTracker.dispose();
@ -129,17 +132,6 @@ public class CLIEventProcessor
}
}
// Look for an event that indicates a start/restart. This will tell use
// we should reset our thread number counter
// The printout that seems to occur on restarts (and start) is
// [Thread debugging using libthread_db enabled]
// Bug 339456
pattern = Pattern.compile("^\\[Thread debugging using "); //$NON-NLS-1$
matcher = pattern.matcher(exec.getCString());
if (matcher.find()) {
fLastThreadId = 0;
}
// For GDB thread exit events, we won't use the events generated by GDB. This event is
// raised in GDBRunControl class by polling and comparing the ExecutionContexts returned by
// -thread-list-ids command. This is done as threads reported by exit event are still reported till
@ -371,4 +363,14 @@ public class CLIEventProcessor
return (operation.startsWith("det") && "detach".indexOf(operation) != -1); //$NON-NLS-1$ //$NON-NLS-2$
}
/** @since 4.0 */
@DsfServiceEventHandler
public void eventDispatched(IStartedDMEvent e) {
if (e.getDMContext() instanceof IContainerDMContext) {
// If a process restarts, we must reset the thread id
// No need to worry about multi-process in this version.
fLastThreadId = 0;
}
}
}