mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
2004-11-08 Alain Magloire
Implement new Interface ICDIFunctionFinished. It returns the return value of the function. * cdi/org/eclipse/cdt/debug/mi/core/cdi/FunctionFinished.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java * mi/org/eclipse/cdt/debug/mi/core/event/MIFuncitonFinishedEvent.java
This commit is contained in:
parent
e35ddb8ef1
commit
cf5df1e48f
9 changed files with 162 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2004-11-08 Alain Magloire
|
||||||
|
Implement new Interface ICDIFunctionFinished.
|
||||||
|
It returns the return value of the function.
|
||||||
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/FunctionFinished.java
|
||||||
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java
|
||||||
|
* mi/org/eclipse/cdt/debug/mi/core/event/MIFuncitonFinishedEvent.java
|
||||||
|
|
||||||
2004-11-07 Alain Magloire
|
2004-11-07 Alain Magloire
|
||||||
Support for MIInterpreterExec
|
Support for MIInterpreterExec
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionFinished;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.LocalVariableDescriptor;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FunctionFinished
|
||||||
|
*/
|
||||||
|
public class FunctionFinished extends EndSteppingRange implements ICDIFunctionFinished {
|
||||||
|
|
||||||
|
MIFunctionFinishedEvent fMIEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param session
|
||||||
|
*/
|
||||||
|
public FunctionFinished(Session session, MIFunctionFinishedEvent event) {
|
||||||
|
super(session);
|
||||||
|
fMIEvent = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIFunctionFinished#getReturnType()
|
||||||
|
*/
|
||||||
|
public ICDIType getReturnType() throws CDIException {
|
||||||
|
Session session = (Session)getSession();
|
||||||
|
Target target = session.getTarget(fMIEvent.getMISession());
|
||||||
|
Thread thread = (Thread)target.getCurrentThread();
|
||||||
|
StackFrame frame = thread.getCurrentStackFrame();
|
||||||
|
String rType = fMIEvent.getReturnType();
|
||||||
|
if (rType == null || rType.length() == 0) {
|
||||||
|
throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
SourceManager srcMgr = session.getSourceManager();
|
||||||
|
return srcMgr.getType(frame, rType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIFunctionFinished#getReturnValue()
|
||||||
|
*/
|
||||||
|
public ICDIValue getReturnValue() throws CDIException {
|
||||||
|
Session session = (Session)getSession();
|
||||||
|
Target target = session.getTarget(fMIEvent.getMISession());
|
||||||
|
Thread thread = (Thread)target.getCurrentThread();
|
||||||
|
StackFrame frame = thread.getCurrentStackFrame();
|
||||||
|
String gdbVariable = fMIEvent.getGDBResultVar();
|
||||||
|
if (gdbVariable == null || gdbVariable.length() == 0) {
|
||||||
|
throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
LocalVariableDescriptor varDesc = new LocalVariableDescriptor(target, thread, frame, gdbVariable, null, 0, 0);
|
||||||
|
VariableManager varMgr = session.getVariableManager();
|
||||||
|
Variable var = varMgr.createVariable(varDesc);
|
||||||
|
return var.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -95,6 +95,10 @@ public class VariableManager extends Manager {
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
Target target = ((Session)getSession()).getTarget(miSession);
|
||||||
return getVariable(target, varName);
|
return getVariable(target, varName);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Return the element that have the uniq varName.
|
||||||
|
* null is return if the element is not in the cache.
|
||||||
|
*/
|
||||||
public Variable getVariable(Target target, String varName) {
|
public Variable getVariable(Target target, String varName) {
|
||||||
Variable[] vars = getVariables(target);
|
Variable[] vars = getVariables(target);
|
||||||
for (int i = 0; i < vars.length; i++) {
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
@ -163,7 +167,6 @@ public class VariableManager extends Manager {
|
||||||
*/
|
*/
|
||||||
public void checkType(StackFrame frame, String type) throws CDIException {
|
public void checkType(StackFrame frame, String type) throws CDIException {
|
||||||
if (type != null && type.length() > 0) {
|
if (type != null && type.length() > 0) {
|
||||||
Session session = (Session)getSession();
|
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
|
@ -203,6 +206,12 @@ public class VariableManager extends Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove variable form the maintained cache list.
|
||||||
|
* @param miSession
|
||||||
|
* @param varName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Variable removeVariableFromList(MISession miSession, String varName) {
|
public Variable removeVariableFromList(MISession miSession, String varName) {
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
Target target = ((Session)getSession()).getTarget(miSession);
|
||||||
List varList = getVariablesList(target);
|
List varList = getVariablesList(target);
|
||||||
|
@ -218,6 +227,14 @@ public class VariableManager extends Manager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode the variableDescriptor as an array
|
||||||
|
* @param varDesc
|
||||||
|
* @param start
|
||||||
|
* @param length
|
||||||
|
* @return
|
||||||
|
* @throws CDIException
|
||||||
|
*/
|
||||||
public VariableDescriptor getVariableDescriptorAsArray(VariableDescriptor varDesc, int start, int length)
|
public VariableDescriptor getVariableDescriptorAsArray(VariableDescriptor varDesc, int start, int length)
|
||||||
throws CDIException {
|
throws CDIException {
|
||||||
Target target = (Target)varDesc.getTarget();
|
Target target = (Target)varDesc.getTarget();
|
||||||
|
@ -248,6 +265,13 @@ public class VariableManager extends Manager {
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode the variableDescriptor in a typecasting.
|
||||||
|
* @param varDesc
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
* @throws CDIException
|
||||||
|
*/
|
||||||
public VariableDescriptor getVariableDescriptorAsType(VariableDescriptor varDesc, String type) throws CDIException {
|
public VariableDescriptor getVariableDescriptorAsType(VariableDescriptor varDesc, String type) throws CDIException {
|
||||||
// throw an exception if not a good type.
|
// throw an exception if not a good type.
|
||||||
Target target = (Target)varDesc.getTarget();
|
Target target = (Target)varDesc.getTarget();
|
||||||
|
@ -301,7 +325,7 @@ public class VariableManager extends Manager {
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDIVariable createVariable(VariableDescriptor varDesc) throws CDIException {
|
public Variable createVariable(VariableDescriptor varDesc) throws CDIException {
|
||||||
if (varDesc instanceof ArgumentDescriptor) {
|
if (varDesc instanceof ArgumentDescriptor) {
|
||||||
return createArgument((ArgumentDescriptor)varDesc);
|
return createArgument((ArgumentDescriptor)varDesc);
|
||||||
} else if (varDesc instanceof LocalVariableDescriptor) {
|
} else if (varDesc instanceof LocalVariableDescriptor) {
|
||||||
|
@ -326,7 +350,6 @@ public class VariableManager extends Manager {
|
||||||
if (argument == null) {
|
if (argument == null) {
|
||||||
String name = argDesc.getQualifiedName();
|
String name = argDesc.getQualifiedName();
|
||||||
StackFrame stack = (StackFrame)argDesc.getStackFrame();
|
StackFrame stack = (StackFrame)argDesc.getStackFrame();
|
||||||
Session session = (Session) getSession();
|
|
||||||
Target target = (Target)argDesc.getTarget();
|
Target target = (Target)argDesc.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
|
@ -356,7 +379,6 @@ public class VariableManager extends Manager {
|
||||||
|
|
||||||
public ICDIArgumentDescriptor[] getArgumentDescriptors(StackFrame frame) throws CDIException {
|
public ICDIArgumentDescriptor[] getArgumentDescriptors(StackFrame frame) throws CDIException {
|
||||||
List argObjects = new ArrayList();
|
List argObjects = new ArrayList();
|
||||||
Session session = (Session) getSession();
|
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
|
@ -424,7 +446,6 @@ public class VariableManager extends Manager {
|
||||||
}
|
}
|
||||||
if (global == null) {
|
if (global == null) {
|
||||||
String name = varDesc.getQualifiedName();
|
String name = varDesc.getQualifiedName();
|
||||||
Session session = (Session) getSession();
|
|
||||||
Target target = (Target)varDesc.getTarget();
|
Target target = (Target)varDesc.getTarget();
|
||||||
try {
|
try {
|
||||||
MISession mi = target.getMISession();
|
MISession mi = target.getMISession();
|
||||||
|
@ -447,7 +468,6 @@ public class VariableManager extends Manager {
|
||||||
|
|
||||||
public ICDILocalVariableDescriptor[] getLocalVariableDescriptors(StackFrame frame) throws CDIException {
|
public ICDILocalVariableDescriptor[] getLocalVariableDescriptors(StackFrame frame) throws CDIException {
|
||||||
List varObjects = new ArrayList();
|
List varObjects = new ArrayList();
|
||||||
Session session = (Session) getSession();
|
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
|
@ -488,7 +508,6 @@ public class VariableManager extends Manager {
|
||||||
}
|
}
|
||||||
if (local == null) {
|
if (local == null) {
|
||||||
String name = varDesc.getQualifiedName();
|
String name = varDesc.getQualifiedName();
|
||||||
Session session = (Session) getSession();
|
|
||||||
StackFrame stack = (StackFrame)varDesc.getStackFrame();
|
StackFrame stack = (StackFrame)varDesc.getStackFrame();
|
||||||
Target target = (Target)varDesc.getTarget();
|
Target target = (Target)varDesc.getTarget();
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointHit;
|
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointHit;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.EndSteppingRange;
|
import org.eclipse.cdt.debug.mi.core.cdi.EndSteppingRange;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.ErrorInfo;
|
import org.eclipse.cdt.debug.mi.core.cdi.ErrorInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.FunctionFinished;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryEvent;
|
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.SignalReceived;
|
import org.eclipse.cdt.debug.mi.core.cdi.SignalReceived;
|
||||||
|
@ -60,7 +61,7 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
||||||
} else if (event instanceof MILocationReachedEvent) {
|
} else if (event instanceof MILocationReachedEvent) {
|
||||||
return new EndSteppingRange(session);
|
return new EndSteppingRange(session);
|
||||||
} else if (event instanceof MIFunctionFinishedEvent) {
|
} else if (event instanceof MIFunctionFinishedEvent) {
|
||||||
return new EndSteppingRange(session);
|
return new FunctionFinished(session, (MIFunctionFinishedEvent)event);
|
||||||
} else if (event instanceof MIErrorEvent) {
|
} else if (event instanceof MIErrorEvent) {
|
||||||
return new ErrorInfo(session, (MIErrorEvent)event);
|
return new ErrorInfo(session, (MIErrorEvent)event);
|
||||||
} else if (event instanceof MISharedLibEvent) {
|
} else if (event instanceof MISharedLibEvent) {
|
||||||
|
|
|
@ -18,6 +18,9 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
|
||||||
*/
|
*/
|
||||||
public class VoidType extends Type implements ICDIVoidType {
|
public class VoidType extends Type implements ICDIVoidType {
|
||||||
|
|
||||||
|
public VoidType(StackFrame frame) {
|
||||||
|
this(frame, "void"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
public VoidType(StackFrame frame, String typename) {
|
public VoidType(StackFrame frame, String typename) {
|
||||||
super(frame, typename);
|
super(frame, typename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VoidValue
|
||||||
|
*/
|
||||||
|
public class VoidValue extends Value {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param v
|
||||||
|
*/
|
||||||
|
public VoidValue(Variable v) {
|
||||||
|
super(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -82,7 +82,7 @@ public class CLIProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSteppingOperationKind(String operation) {
|
static int getSteppingOperationKind(String operation) {
|
||||||
int type = -1;
|
int type = -1;
|
||||||
/* execution commands: n, next, s, step, si, stepi, u, until, finish,
|
/* execution commands: n, next, s, step, si, stepi, u, until, finish,
|
||||||
c, continue, fg */
|
c, continue, fg */
|
||||||
|
@ -112,6 +112,17 @@ public class CLIProcessor {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the operation is a stepping operation.
|
||||||
|
*
|
||||||
|
* @param operation
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSteppingOperation(String operation) {
|
||||||
|
int type = getSteppingOperationKind(operation);
|
||||||
|
return type != -1;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isSettingBreakpoint(String operation) {
|
boolean isSettingBreakpoint(String operation) {
|
||||||
boolean isbreak = false;
|
boolean isbreak = false;
|
||||||
/* breakpoints: b, break, hbreak, tbreak, rbreak, thbreak */
|
/* breakpoints: b, break, hbreak, tbreak, rbreak, thbreak */
|
||||||
|
|
|
@ -78,7 +78,9 @@ public class SessionProcess extends Process {
|
||||||
String str = buf.toString().trim();
|
String str = buf.toString().trim();
|
||||||
buf.setLength(0);
|
buf.setLength(0);
|
||||||
Command cmd = null;
|
Command cmd = null;
|
||||||
if (session.useExecConsole() && str.length() > 0) {
|
// Do not use the interpreterexec for stepping operation
|
||||||
|
// the UI will fall out of step.
|
||||||
|
if (session.useExecConsole() && str.length() > 0 && !CLIProcessor.isSteppingOperation(str)) {
|
||||||
cmd = new MIInterpreterExecConsole(str);
|
cmd = new MIInterpreterExecConsole(str);
|
||||||
} else {
|
} else {
|
||||||
cmd = new CLICommand(str);
|
cmd = new CLICommand(str);
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class MIFunctionFinishedEvent extends MIStoppedEvent {
|
||||||
|
|
||||||
String gdbResult = ""; //$NON-NLS-1$
|
String gdbResult = ""; //$NON-NLS-1$
|
||||||
String returnValue = ""; //$NON-NLS-1$
|
String returnValue = ""; //$NON-NLS-1$
|
||||||
|
String returnType = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
public MIFunctionFinishedEvent(MISession source, MIExecAsyncOutput async) {
|
public MIFunctionFinishedEvent(MISession source, MIExecAsyncOutput async) {
|
||||||
super(source, async);
|
super(source, async);
|
||||||
|
@ -45,10 +46,15 @@ public class MIFunctionFinishedEvent extends MIStoppedEvent {
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReturnType() {
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("gdb-result-var=" + gdbResult + "\n"); //$NON-NLS-1$//$NON-NLS-2$
|
buffer.append("gdb-result-var=" + gdbResult + "\n"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
buffer.append("return-value=" + returnValue + "\n"); //$NON-NLS-1$//$NON-NLS-2$
|
buffer.append("return-value=" + returnValue + "\n"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
buffer.append("return-type=" + returnType + "\n"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
buffer.append("thread-id=").append(getThreadId()).append('\n'); //$NON-NLS-1$
|
buffer.append("thread-id=").append(getThreadId()).append('\n'); //$NON-NLS-1$
|
||||||
MIFrame f = getFrame();
|
MIFrame f = getFrame();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
|
@ -80,6 +86,8 @@ public class MIFunctionFinishedEvent extends MIStoppedEvent {
|
||||||
gdbResult = str;
|
gdbResult = str;
|
||||||
} else if (var.equals("return-value")) { //$NON-NLS-1$
|
} else if (var.equals("return-value")) { //$NON-NLS-1$
|
||||||
returnValue = str;
|
returnValue = str;
|
||||||
|
} else if (var.equals("return-type")) { //$NON-NLS-1$
|
||||||
|
returnType = str;
|
||||||
} else if (var.equals("thread-id")) { //$NON-NLS-1$
|
} else if (var.equals("thread-id")) { //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(str.trim());
|
int id = Integer.parseInt(str.trim());
|
||||||
|
|
Loading…
Add table
Reference in a new issue