From 2638b185d217ab771641f22597b3ea8d049a6a4e Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 14 Nov 2002 21:03:49 +0000 Subject: [PATCH] 2 new methods getStackFrame(int low, int hi) and getStackFrameCount(). --- .../cdt/debug/mi/core/cdi/CThread.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java index e1f2fbf2e08..6a1b08007d2 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CThread.java @@ -11,10 +11,12 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIStackInfoDepth; import org.eclipse.cdt.debug.mi.core.command.MIStackListFrames; import org.eclipse.cdt.debug.mi.core.command.MIStackSelectFrame; import org.eclipse.cdt.debug.mi.core.output.MIFrame; import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import org.eclipse.cdt.debug.mi.core.output.MIStackInfoDepthInfo; import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo; /** @@ -84,6 +86,62 @@ public class CThread extends CObject implements ICDIThread { return stack; } + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#getStackFrames() + */ + public int getStackFrameCount() throws CDIException { + CSession session = getCTarget().getCSession(); + MISession mi = session.getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIStackInfoDepth depth = factory.createMIStackInfoDepth(); + try { + mi.postCommand(depth); + MIStackInfoDepthInfo info = depth.getMIStackInfoDepthInfo(); + if (info == null) { + throw new CDIException("No answer"); + } + return info.getDepth(); + } catch (MIException e) { + throw new CDIException(e.getMessage()); + //System.out.println(e); + } + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#getStackFrames() + */ + public ICDIStackFrame[] getStackFrames(int low, int high) throws CDIException { + StackFrame[] stack = noStack; + CSession session = getCTarget().getCSession(); + + MISession mi = session.getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIStackListFrames frames = factory.createMIStackListFrames(low, high); + try { + ICDIThread oldThread = getCTarget().getCurrentThread(); + getCTarget().setCurrentThread(this); + mi.postCommand(frames); + MIStackListFramesInfo info = frames.getMIStackListFramesInfo(); + if (info == null) { + throw new CDIException("No answer"); + } + MIFrame[] miFrames = info.getMIFrames(); + stack = new StackFrame[miFrames.length]; + for (int i = 0; i < stack.length; i++) { + stack[i] = new StackFrame(this, miFrames[i]); + } + getCTarget().setCurrentThread(oldThread); + return stack; + } catch (MIException e) { + //throw new CDIException(e.getMessage()); + //System.out.println(e); + } catch (CDIException e) { + //throw e; + //System.out.println(e); + } + return stack; + } + /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#setCurrentStackFrame(ICDIStackFrame) */