Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fe6d5c87b96cf2eb30939ba2851a13d1ce3cb252 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**********************************************************************
 * 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());
		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(target, 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();
	}

}

Back to the top