mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
2005-08-31 Alain Magloire
Improve performance by caching the type result on the frame and on the RegisterManager. The patch is originally from Chris Wiebe with modifications. * cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java
This commit is contained in:
parent
1dab68cabe
commit
b2960a2e43
5 changed files with 96 additions and 29 deletions
|
@ -1,3 +1,12 @@
|
|||
2005-08-31 Alain Magloire
|
||||
Improve performance by caching the type result on the frame
|
||||
and on the RegisterManager. The patch is originally from Chris Wiebe
|
||||
with modifications.
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java
|
||||
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java
|
||||
|
||||
2005-08-31 Alain Magloire
|
||||
Fix Pr 107571: Do not create the Console pipe is we
|
||||
have no consumer.
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.mi.core.cdi;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -21,6 +22,7 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Register;
|
||||
|
@ -122,6 +124,7 @@ public class RegisterManager extends Manager {
|
|||
Map regsMap;
|
||||
Map varsMap;
|
||||
MIVarChange[] noChanges = new MIVarChange[0];
|
||||
HashMap fTypeCache;
|
||||
|
||||
public RegisterManager(Session session) {
|
||||
super(session, true);
|
||||
|
@ -129,8 +132,17 @@ public class RegisterManager extends Manager {
|
|||
varsMap = new Hashtable();
|
||||
// The register bookkeeping provides better update control.
|
||||
setAutoUpdate( true );
|
||||
fTypeCache = new HashMap();
|
||||
}
|
||||
|
||||
public ICDIType getFromTypeCache(String typeName) {
|
||||
return (ICDIType)fTypeCache.get(typeName);
|
||||
}
|
||||
public void addToTypeCache(String typeName, ICDIType type) {
|
||||
fTypeCache.put(typeName, type);
|
||||
}
|
||||
|
||||
|
||||
synchronized List getRegistersList(Target target) {
|
||||
List regsList = (List)regsMap.get(target);
|
||||
if (regsList == null) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
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.RegisterManager;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
|
||||
|
@ -44,6 +45,19 @@ public class Register extends Variable implements ICDIRegister {
|
|||
super(obj, var);
|
||||
}
|
||||
|
||||
|
||||
protected void addToTypeCache(String nameType, ICDIType type) throws CDIException {
|
||||
Session session = (Session)getTarget().getSession();
|
||||
RegisterManager mgr = session.getRegisterManager();
|
||||
mgr.addToTypeCache(nameType, type);
|
||||
}
|
||||
|
||||
protected ICDIType getFromTypeCache(String nameType) throws CDIException {
|
||||
Session session = (Session)getTarget().getSession();
|
||||
RegisterManager mgr = session.getRegisterManager();
|
||||
return mgr.getFromTypeCache(nameType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName()
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.debug.mi.core.cdi.model;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDILocator;
|
||||
|
@ -21,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDILocalVariableDescriptor;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||
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.MIException;
|
||||
import org.eclipse.cdt.debug.mi.core.MIFormat;
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
|
@ -45,6 +47,10 @@ public class StackFrame extends CObject implements ICDIStackFrame {
|
|||
ICDIArgumentDescriptor[] argDescs;
|
||||
ICDILocalVariableDescriptor[] localDescs;
|
||||
Locator fLocator;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private HashMap fTypeCache;
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -74,12 +80,20 @@ public class StackFrame extends CObject implements ICDIStackFrame {
|
|||
cthread = thread;
|
||||
frame = f;
|
||||
level = l;
|
||||
fTypeCache = new HashMap();
|
||||
}
|
||||
|
||||
public MIFrame getMIFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
public ICDIType getFromTypeCache(String typeName) {
|
||||
return (ICDIType)fTypeCache.get(typeName);
|
||||
}
|
||||
public void addToTypeCache(String typeName, ICDIType typeDefinition) {
|
||||
fTypeCache.put(typeName, typeDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getThread()
|
||||
*/
|
||||
|
|
|
@ -155,6 +155,22 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
|||
return fFullName;
|
||||
}
|
||||
|
||||
protected ICDIType getFromTypeCache(String nameType) throws CDIException {
|
||||
StackFrame frame = (StackFrame)getStackFrame();
|
||||
ICDIType detailedType = null;
|
||||
if (frame != null) {
|
||||
detailedType = frame.getFromTypeCache(nameType);
|
||||
}
|
||||
return detailedType;
|
||||
}
|
||||
|
||||
protected void addToTypeCache(String nameType, ICDIType typeDefinition) throws CDIException {
|
||||
StackFrame frame = (StackFrame)getStackFrame();
|
||||
if (frame != null) {
|
||||
frame.addToTypeCache(nameType, typeDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableDescriptor#getName()
|
||||
*/
|
||||
|
@ -174,6 +190,14 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
|||
try {
|
||||
fType = sourceMgr.getType(target, nametype);
|
||||
} catch (CDIException e) {
|
||||
// We are here because the parser did not recognize the type, it may be something
|
||||
// like "builtin_x86_vector" or even a class or a typedef
|
||||
// typedef struct foobar Foobar_t
|
||||
// for this case we need to call "Ptype" for more details.
|
||||
|
||||
// For speed we save the type definitions in the stackframe, try it first.
|
||||
fType = getFromTypeCache(nametype);
|
||||
if (fType == null) {
|
||||
// Try with ptype.
|
||||
try {
|
||||
String ptype = sourceMgr.getDetailTypeName(target, nametype);
|
||||
|
@ -199,9 +223,12 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fType == null) {
|
||||
fType = new IncompleteType(target, nametype);
|
||||
}
|
||||
// cache the result
|
||||
addToTypeCache(nametype, fType);
|
||||
}
|
||||
return fType;
|
||||
}
|
||||
|
@ -382,13 +409,4 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
|||
return mgr.getVariableDescriptorAsType(this, type);
|
||||
}
|
||||
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor#createVariable()
|
||||
// */
|
||||
// public ICDIVariable createVariable() throws CDIException {
|
||||
// Session session = (Session)getTarget().getSession();
|
||||
// VariableManager mgr = session.getVariableManager();
|
||||
// return mgr.createVariable(this);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue