From 45d013d2531d660fd795921905303f3dc12140f5 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 18 Feb 2004 03:51:06 +0000 Subject: [PATCH] save the PID when attaching. --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 8 +++++++ .../eclipse/cdt/debug/mi/core/MIInferior.java | 23 ++++++++++++------- .../eclipse/cdt/debug/mi/core/MIPlugin.java | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index d23317fa2dc..025247ad5f5 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,11 @@ +2004-02-17 Alain Magloire + + If we attach save the PID for later + for example to be able to suspend. + + * src/org/eclipse/cdt/debug/mi/core/MIInferior.java + * src/org/eclipse/cdt/debug/mi/core/MIPlugin.java + 2004-02-11 Alain Magloire Use String.endsWith("(gdb)") to detect the prompt. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java index 3e100d5f6c2..6dc56e5ad36 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java @@ -46,7 +46,7 @@ public class MIInferior extends Process { PipedOutputStream errPiped; PTY pty; - int inferiorPid; + int inferiorPID; MIInferior(MISession mi, PTY p) { session = mi; @@ -200,9 +200,9 @@ public class MIInferior extends Process { } catch (InterruptedException e) { } } - if ((state == RUNNING) && inferiorPid > 0) { + if ((state == RUNNING) && getInferiorPID() > 0) { // lets try something else. - gdbSpawner.raise(inferiorPid, gdbSpawner.INT); + gdbSpawner.raise(getInferiorPID(), gdbSpawner.INT); for (int i = 0;(state == RUNNING) && i < 5; i++) { try { wait(1000); @@ -315,7 +315,8 @@ public class MIInferior extends Process { } public void update() { - if (inferiorPid == 0) { + if (getInferiorPID() == 0) { + int pid = 0; // Do not try this on attach session. if (!isConnected()) { // Try to discover the pid @@ -324,15 +325,21 @@ public class MIInferior extends Process { try { session.postCommand(prog); MIInfoProgramInfo info = prog.getMIInfoProgramInfo(); - inferiorPid = info.getPID(); + pid = info.getPID(); } catch (MIException e) { // no rethrown. } } // We fail permantely. - if (inferiorPid == 0) { - inferiorPid = -1; - } + setInferiorPID((pid == 0) ? -1: pid); } } + + public void setInferiorPID(int pid) { + inferiorPID = pid; + } + + public int getInferiorPID() { + return inferiorPID; + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java index 54348253ea7..e7290437d50 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java @@ -274,6 +274,7 @@ public class MIPlugin extends Plugin { if (info == null) { throw new MIException("No answer"); } + session.getMIInferior().setInferiorPID(pid); } } catch (MIException e) { pgdb.destroy();