mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
2004-11-08 Alain Magloire
Fix for 74496 ; we should destroy the global variables if they are in the address range of a shared library being unloaded. * cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
This commit is contained in:
parent
439665d7d0
commit
db8bcbda60
15 changed files with 149 additions and 68 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2004-11-08 Alain Magloire
|
||||||
|
Fix for 74496 ; we should destroy the global
|
||||||
|
variables if they are in the address range of a
|
||||||
|
shared library being unloaded.
|
||||||
|
|
||||||
|
* cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
|
||||||
|
|
||||||
2004-11-08 Mikhail Khodjaiants
|
2004-11-08 Mikhail Khodjaiants
|
||||||
Added support for refresh preferences and properties.
|
Added support for refresh preferences and properties.
|
||||||
* IMIConstants.java
|
* IMIConstants.java
|
||||||
|
|
|
@ -248,7 +248,6 @@ public class BreakpointManager extends Manager {
|
||||||
numbers[i] = miBreakpoints[i].getNumber();
|
numbers[i] = miBreakpoints[i].getNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
Session session = (Session)target.getSession();
|
|
||||||
boolean state = suspendInferior(target);
|
boolean state = suspendInferior(target);
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
|
|
|
@ -23,7 +23,9 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIFormat;
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent;
|
import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent;
|
import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent;
|
||||||
|
@ -34,9 +36,16 @@ import org.eclipse.cdt.debug.mi.core.cdi.event.MemoryChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.event.ResumedEvent;
|
import org.eclipse.cdt.debug.mi.core.cdi.event.ResumedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.event.SuspendedEvent;
|
import org.eclipse.cdt.debug.mi.core.cdi.event.SuspendedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.GlobalVariable;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary;
|
||||||
|
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.Target;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
|
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.cdi.model.type.FunctionValue;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.type.PointerValue;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.type.ReferenceValue;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
import org.eclipse.cdt.debug.mi.core.command.Command;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIExecContinue;
|
import org.eclipse.cdt.debug.mi.core.command.MIExecContinue;
|
||||||
|
@ -47,7 +56,6 @@ import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIChangedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIChangedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MICreatedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MICreatedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIDestroyedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIDestroyedEvent;
|
||||||
|
@ -341,13 +349,60 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
Session session = (Session)getSession();
|
Session session = (Session)getSession();
|
||||||
MISession miSession = unLoaded.getMISession();
|
MISession miSession = unLoaded.getMISession();
|
||||||
Target target = session.getTarget(miSession);
|
Target target = session.getTarget(miSession);
|
||||||
|
|
||||||
|
// We do not nee to do fancy checking we can jsut delete all
|
||||||
|
// the expression variable and let the recreate them by reevaluating.
|
||||||
ExpressionManager expMgr = session.getExpressionManager();
|
ExpressionManager expMgr = session.getExpressionManager();
|
||||||
VariableManager varMgr = session.getVariableManager();
|
|
||||||
try {
|
try {
|
||||||
expMgr.destroyAllExpressions(target);
|
expMgr.deleteAllVariables(target);
|
||||||
varMgr.destroyAllVariables(target);
|
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do this only for global variable for now.
|
||||||
|
// we nee to look at the address of the variable
|
||||||
|
// and see if they are in the range of the library if yes
|
||||||
|
// destroy them
|
||||||
|
SharedLibraryManager sharedMgr = session.getSharedLibraryManager();
|
||||||
|
SharedLibrary lib = sharedMgr.getSharedLibrary(target, unLoaded.getName());
|
||||||
|
if (lib != null) {
|
||||||
|
BigInteger startAddress = lib.getStartAddress();
|
||||||
|
BigInteger endAddress = lib.getEndAddress();
|
||||||
|
try {
|
||||||
|
Thread thread = (Thread)target.getCurrentThread();
|
||||||
|
StackFrame frame = thread.getCurrentStackFrame();
|
||||||
|
VariableManager varMgr = session.getVariableManager();
|
||||||
|
Variable[] vars = varMgr.getVariables(target);
|
||||||
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
if (vars[i] instanceof GlobalVariable) {
|
||||||
|
try {
|
||||||
|
ICDIValue value = vars[i].getValue();
|
||||||
|
String result = null;
|
||||||
|
if (value instanceof PointerValue ||
|
||||||
|
value instanceof ReferenceValue ||
|
||||||
|
value instanceof FunctionValue) {
|
||||||
|
result = target.evaluateExpressionToString(frame, vars[i].getFullName()); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
result = target.evaluateExpressionToString(frame, "&" + vars[i].getFullName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
if (result != null && result.length() > 0) {
|
||||||
|
BigInteger address = MIFormat.decodeAdress(result);
|
||||||
|
int op = address.compareTo(startAddress);
|
||||||
|
if (op == 0 || op == 1) {
|
||||||
|
op = address.compareTo(endAddress);
|
||||||
|
if (op == 0 || op == -1) {
|
||||||
|
varMgr.destroyVariable(vars[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CDIException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CDIException e) {
|
||||||
|
// ignore it. ???
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,12 +581,12 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean processBreakpointHitEvent(MIStoppedEvent stopped) {
|
boolean processBreakpointHitEvent(MIStoppedEvent stopped) {
|
||||||
Session session = (Session)getSession();
|
// Session session = (Session)getSession();
|
||||||
if (stopped instanceof MIBreakpointHitEvent) {
|
// if (stopped instanceof MIBreakpointHitEvent) {
|
||||||
MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped;
|
// MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped;
|
||||||
BreakpointManager bpMgr = session.getBreakpointManager();
|
// BreakpointManager bpMgr = session.getBreakpointManager();
|
||||||
int bpNo = bpEvent.getNumber();
|
// int bpNo = bpEvent.getNumber();
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,11 +103,11 @@ public class SharedLibraryManager extends Manager {
|
||||||
MIShared[] miLibs = getMIShareds(miSession);
|
MIShared[] miLibs = getMIShareds(miSession);
|
||||||
ArrayList eventList = new ArrayList(miLibs.length);
|
ArrayList eventList = new ArrayList(miLibs.length);
|
||||||
for (int i = 0; i < miLibs.length; i++) {
|
for (int i = 0; i < miLibs.length; i++) {
|
||||||
ICDISharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName());
|
SharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName());
|
||||||
if (sharedlib != null) {
|
if (sharedlib != null) {
|
||||||
if (hasSharedLibChanged(sharedlib, miLibs[i])) {
|
if (hasSharedLibChanged(sharedlib, miLibs[i])) {
|
||||||
// Fire ChangedEvent
|
// Fire ChangedEvent
|
||||||
((SharedLibrary)sharedlib).setMIShared(miLibs[i]);
|
sharedlib.setMIShared(miLibs[i]);
|
||||||
eventList.add(new MISharedLibChangedEvent(miSession, miLibs[i].getName()));
|
eventList.add(new MISharedLibChangedEvent(miSession, miLibs[i].getName()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,7 +120,7 @@ public class SharedLibraryManager extends Manager {
|
||||||
// Check if any libraries was unloaded.
|
// Check if any libraries was unloaded.
|
||||||
List sharedList = (List)sharedMap.get(target);
|
List sharedList = (List)sharedMap.get(target);
|
||||||
if (sharedList != null) {
|
if (sharedList != null) {
|
||||||
ICDISharedLibrary[] oldlibs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]);
|
SharedLibrary[] oldlibs = (SharedLibrary[]) sharedList.toArray(new SharedLibrary[sharedList.size()]);
|
||||||
for (int i = 0; i < oldlibs.length; i++) {
|
for (int i = 0; i < oldlibs.length; i++) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int j = 0; j < miLibs.length; j++) {
|
for (int j = 0; j < miLibs.length; j++) {
|
||||||
|
@ -138,7 +138,7 @@ public class SharedLibraryManager extends Manager {
|
||||||
return eventList;
|
return eventList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSharedLibChanged(ICDISharedLibrary lib, MIShared miLib) {
|
public boolean hasSharedLibChanged(SharedLibrary lib, MIShared miLib) {
|
||||||
return !miLib.getName().equals(lib.getFileName()) ||
|
return !miLib.getName().equals(lib.getFileName()) ||
|
||||||
!MIFormat.getBigInteger(miLib.getFrom()).equals(lib.getStartAddress()) ||
|
!MIFormat.getBigInteger(miLib.getFrom()).equals(lib.getStartAddress()) ||
|
||||||
!MIFormat.getBigInteger(miLib.getTo()).equals(lib.getEndAddress()) ||
|
!MIFormat.getBigInteger(miLib.getTo()).equals(lib.getEndAddress()) ||
|
||||||
|
@ -148,7 +148,7 @@ public class SharedLibraryManager extends Manager {
|
||||||
/*
|
/*
|
||||||
* this for the events
|
* this for the events
|
||||||
*/
|
*/
|
||||||
public void deleteSharedLibrary(MISession miSession, ICDISharedLibrary lib) {
|
public void deleteSharedLibrary(MISession miSession, SharedLibrary lib) {
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
Target target = ((Session)getSession()).getTarget(miSession);
|
||||||
List sharedList = (List)sharedMap.get(target);
|
List sharedList = (List)sharedMap.get(target);
|
||||||
if (sharedList != null) {
|
if (sharedList != null) {
|
||||||
|
@ -156,14 +156,14 @@ public class SharedLibraryManager extends Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDISharedLibrary getSharedLibrary(MISession miSession, String name) {
|
public SharedLibrary getSharedLibrary(MISession miSession, String name) {
|
||||||
Target target = ((Session)getSession()).getTarget(miSession);
|
Target target = ((Session)getSession()).getTarget(miSession);
|
||||||
return getSharedLibrary(target, name);
|
return getSharedLibrary(target, name);
|
||||||
}
|
}
|
||||||
public ICDISharedLibrary getSharedLibrary(Target target, String name) {
|
public SharedLibrary getSharedLibrary(Target target, String name) {
|
||||||
List sharedList = (List)sharedMap.get(target);
|
List sharedList = (List)sharedMap.get(target);
|
||||||
if (sharedList != null) {
|
if (sharedList != null) {
|
||||||
ICDISharedLibrary[] libs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]);
|
SharedLibrary[] libs = (SharedLibrary[]) sharedList.toArray(new SharedLibrary[sharedList.size()]);
|
||||||
for (int i = 0; i < libs.length; i++) {
|
for (int i = 0; i < libs.length; i++) {
|
||||||
if (name.equals(libs[i].getFileName())) {
|
if (name.equals(libs[i].getFileName())) {
|
||||||
return libs[i];
|
return libs[i];
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class SourceManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSourcePaths(Target target, String[] dirs) throws CDIException {
|
public void addSourcePaths(Target target, String[] dirs) throws CDIException {
|
||||||
Session session = (Session)getSession();
|
|
||||||
MISession mi = target.getMISession();
|
MISession mi = target.getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs);
|
MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs);
|
||||||
|
@ -400,7 +399,6 @@ public class SourceManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetailTypeName(StackFrame frame, String typename) throws CDIException {
|
public String getDetailTypeName(StackFrame frame, String typename) throws CDIException {
|
||||||
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();
|
||||||
|
@ -425,7 +423,6 @@ public class SourceManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeName(StackFrame frame, String variable) throws CDIException {
|
public String getTypeName(StackFrame frame, String variable) throws CDIException {
|
||||||
Session session = (Session)getSession();
|
|
||||||
Target target = (Target)frame.getTarget();
|
Target target = (Target)frame.getTarget();
|
||||||
Thread currentThread = null;
|
Thread currentThread = null;
|
||||||
StackFrame currentFrame = null;
|
StackFrame currentFrame = null;
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.event;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
|
|
||||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager;
|
||||||
|
@ -21,6 +20,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
import org.eclipse.cdt.debug.mi.core.cdi.VariableManager;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.CObject;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.CObject;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
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.Thread;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
@ -82,7 +82,7 @@ public class DestroyedEvent implements ICDIDestroyedEvent {
|
||||||
SharedLibraryManager mgr = session.getSharedLibraryManager();
|
SharedLibraryManager mgr = session.getSharedLibraryManager();
|
||||||
MISession miSession = slib.getMISession();
|
MISession miSession = slib.getMISession();
|
||||||
String name = slib.getName();
|
String name = slib.getName();
|
||||||
ICDISharedLibrary lib = mgr.getSharedLibrary(miSession, name);
|
SharedLibrary lib = mgr.getSharedLibrary(miSession, name);
|
||||||
if (lib != null) {
|
if (lib != null) {
|
||||||
mgr.deleteSharedLibrary(miSession, lib);
|
mgr.deleteSharedLibrary(miSession, lib);
|
||||||
source = lib;
|
source = lib;
|
||||||
|
|
|
@ -40,13 +40,13 @@ public class Register extends Variable implements ICDIRegister {
|
||||||
* @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName()
|
* @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName()
|
||||||
*/
|
*/
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
if (fullName == null) {
|
if (fFullName == null) {
|
||||||
String n = getName();
|
String n = getName();
|
||||||
if (!n.startsWith("$")) { //$NON-NLS-1$
|
if (!n.startsWith("$")) { //$NON-NLS-1$
|
||||||
fullName = "$" + n; //$NON-NLS-1$
|
fFullName = "$" + n; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fullName;
|
return fFullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Variable createVariable(Target target, Thread thread, StackFrame frame, String name, String fullName, int pos, int depth, MIVar miVar) {
|
protected Variable createVariable(Target target, Thread thread, StackFrame frame, String name, String fullName, int pos, int depth, MIVar miVar) {
|
||||||
|
|
|
@ -26,12 +26,12 @@ public class RegisterDescriptor extends VariableDescriptor implements ICDIRegist
|
||||||
* @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName()
|
* @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName()
|
||||||
*/
|
*/
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
if (fullName == null) {
|
if (fFullName == null) {
|
||||||
String n = getName();
|
String n = getName();
|
||||||
if (!n.startsWith("$")) { //$NON-NLS-1$
|
if (!n.startsWith("$")) { //$NON-NLS-1$
|
||||||
fullName = "$" + n; //$NON-NLS-1$
|
fFullName = "$" + n; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fullName;
|
return fFullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
*/
|
*/
|
||||||
public class RuntimeOptions extends CObject implements ICDIRuntimeOptions {
|
public class RuntimeOptions extends CObject implements ICDIRuntimeOptions {
|
||||||
|
|
||||||
Target target;
|
|
||||||
|
|
||||||
public RuntimeOptions(Target t) {
|
public RuntimeOptions(Target t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -634,7 +634,6 @@ public class Target extends SessionObject implements ICDITarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException {
|
public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException {
|
||||||
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();
|
||||||
|
|
|
@ -71,7 +71,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo;
|
||||||
*/
|
*/
|
||||||
public abstract class Variable extends VariableDescriptor implements ICDIVariable {
|
public abstract class Variable extends VariableDescriptor implements ICDIVariable {
|
||||||
|
|
||||||
MIVar miVar;
|
MIVar fMiVar;
|
||||||
Value value;
|
Value value;
|
||||||
ICDIVariable[] children = new ICDIVariable[0];
|
ICDIVariable[] children = new ICDIVariable[0];
|
||||||
String editable = null;
|
String editable = null;
|
||||||
|
@ -80,16 +80,16 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
|
|
||||||
public Variable(VariableDescriptor obj, MIVar v) {
|
public Variable(VariableDescriptor obj, MIVar v) {
|
||||||
super(obj);
|
super(obj);
|
||||||
miVar = v;
|
fMiVar = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable(Target target, Thread thread, StackFrame frame, String n, String q, int pos, int depth, MIVar v) {
|
public Variable(Target target, Thread thread, StackFrame frame, String n, String q, int pos, int depth, MIVar v) {
|
||||||
super(target, thread, frame, n, q, pos, depth);
|
super(target, thread, frame, n, q, pos, depth);
|
||||||
miVar = v;
|
fMiVar = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIVar getMIVar() {
|
public MIVar getMIVar() {
|
||||||
return miVar;
|
return fMiVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable getChild(String name) {
|
public Variable getChild(String name) {
|
||||||
|
@ -179,7 +179,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
if (subType instanceof ICDIStructType) {
|
if (subType instanceof ICDIStructType) {
|
||||||
if (isCPPLanguage()) {
|
if (isCPPLanguage()) {
|
||||||
if (!isFake()
|
if (!isFake()
|
||||||
|| (isFake() && !(name.equals("private") || name.equals("public") || name.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|| (isFake() && !(fName.equals("private") || fName.equals("public") || fName.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
childFake = true;
|
childFake = true;
|
||||||
childType = t;
|
childType = t;
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +210,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
// So we choose to ignore the first set of children
|
// So we choose to ignore the first set of children
|
||||||
// but carry over to those "fake" variables the typename and the qualified name
|
// but carry over to those "fake" variables the typename and the qualified name
|
||||||
if (!isFake()
|
if (!isFake()
|
||||||
|| (isFake() && !(name.equals("private") || name.equals("public") || name.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|| (isFake() && !(fName.equals("private") || fName.equals("public") || fName.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
childFake = true;
|
childFake = true;
|
||||||
childType = t;
|
childType = t;
|
||||||
} else {
|
} else {
|
||||||
|
@ -224,7 +224,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
childName, fn, getPosition(), getStackDepth(), vars[i]);
|
childName, fn, getPosition(), getStackDepth(), vars[i]);
|
||||||
if (childType != null) {
|
if (childType != null) {
|
||||||
// Hack to reset the typename to a known value
|
// Hack to reset the typename to a known value
|
||||||
v.type = childType;
|
v.fType = childType;
|
||||||
}
|
}
|
||||||
v.setIsFake(childFake);
|
v.setIsFake(childFake);
|
||||||
children[i] = v;
|
children[i] = v;
|
||||||
|
@ -239,7 +239,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
String name, String fullName, int pos, int depth, MIVar miVar);
|
String name, String fullName, int pos, int depth, MIVar miVar);
|
||||||
|
|
||||||
public int getChildrenNumber() throws CDIException {
|
public int getChildrenNumber() throws CDIException {
|
||||||
return miVar.getNumChild();
|
return fMiVar.getNumChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -299,7 +299,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
Target target = (Target)getTarget();
|
Target target = (Target)getTarget();
|
||||||
MISession miSession = target.getMISession();
|
MISession miSession = target.getMISession();
|
||||||
CommandFactory factory = miSession.getCommandFactory();
|
CommandFactory factory = miSession.getCommandFactory();
|
||||||
MIVarAssign var = factory.createMIVarAssign(miVar.getVarName(), expression);
|
MIVarAssign var = factory.createMIVarAssign(fMiVar.getVarName(), expression);
|
||||||
try {
|
try {
|
||||||
miSession.postCommand(var);
|
miSession.postCommand(var);
|
||||||
MIInfo info = var.getMIInfo();
|
MIInfo info = var.getMIInfo();
|
||||||
|
@ -312,7 +312,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
|
|
||||||
// If the assign was succesfull fire a MIVarChangedEvent() for the variable
|
// If the assign was succesfull fire a MIVarChangedEvent() for the variable
|
||||||
// Note GDB will not fire an event for the changed variable we have to do it manually.
|
// Note GDB will not fire an event for the changed variable we have to do it manually.
|
||||||
MIVarChangedEvent change = new MIVarChangedEvent(miSession, var.getToken(), miVar.getVarName());
|
MIVarChangedEvent change = new MIVarChangedEvent(miSession, var.getToken(), fMiVar.getVarName());
|
||||||
miSession.fireEvent(change);
|
miSession.fireEvent(change);
|
||||||
|
|
||||||
// Changing values may have side effects i.e. affecting other variables
|
// Changing values may have side effects i.e. affecting other variables
|
||||||
|
@ -348,7 +348,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
if (editable == null) {
|
if (editable == null) {
|
||||||
MISession mi = ((Target) getTarget()).getMISession();
|
MISession mi = ((Target) getTarget()).getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName());
|
MIVarShowAttributes var = factory.createMIVarShowAttributes(fMiVar.getVarName());
|
||||||
try {
|
try {
|
||||||
mi.postCommand(var);
|
mi.postCommand(var);
|
||||||
MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo();
|
MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo();
|
||||||
|
@ -370,7 +370,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
int fmt = Format.toMIFormat(format);
|
int fmt = Format.toMIFormat(format);
|
||||||
MISession mi = ((Target) getTarget()).getMISession();
|
MISession mi = ((Target) getTarget()).getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIVarSetFormat var = factory.createMIVarSetFormat(miVar.getVarName(), fmt);
|
MIVarSetFormat var = factory.createMIVarSetFormat(fMiVar.getVarName(), fmt);
|
||||||
try {
|
try {
|
||||||
mi.postCommand(var);
|
mi.postCommand(var);
|
||||||
MIInfo info = var.getMIInfo();
|
MIInfo info = var.getMIInfo();
|
||||||
|
@ -388,7 +388,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
|
||||||
public boolean equals(ICDIVariable var) {
|
public boolean equals(ICDIVariable var) {
|
||||||
if (var instanceof Variable) {
|
if (var instanceof Variable) {
|
||||||
Variable variable = (Variable) var;
|
Variable variable = (Variable) var;
|
||||||
return miVar.getVarName().equals(variable.getMIVar().getVarName());
|
return fMiVar.getVarName().equals(variable.getMIVar().getVarName());
|
||||||
}
|
}
|
||||||
return super.equals(var);
|
return super.equals(var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,15 +37,15 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
int castingIndex;
|
int castingIndex;
|
||||||
int castingLength;
|
int castingLength;
|
||||||
|
|
||||||
String name;
|
String fName;
|
||||||
int position;
|
int position;
|
||||||
StackFrame fStackFrame;
|
StackFrame fStackFrame;
|
||||||
Thread fThread;
|
Thread fThread;
|
||||||
int stackdepth;
|
int stackdepth;
|
||||||
|
|
||||||
String qualifiedName = null;
|
String qualifiedName = null;
|
||||||
String fullName = null;
|
String fFullName = null;
|
||||||
ICDIType type = null;
|
ICDIType fType = null;
|
||||||
String typename = null;
|
String typename = null;
|
||||||
String sizeof = null;
|
String sizeof = null;
|
||||||
|
|
||||||
|
@ -55,10 +55,10 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
*/
|
*/
|
||||||
public VariableDescriptor(VariableDescriptor desc) {
|
public VariableDescriptor(VariableDescriptor desc) {
|
||||||
super((Target)desc.getTarget());
|
super((Target)desc.getTarget());
|
||||||
name = desc.getName();
|
fName = desc.getName();
|
||||||
fullName = desc.fullName;
|
fFullName = desc.fFullName;
|
||||||
sizeof = desc.sizeof;
|
sizeof = desc.sizeof;
|
||||||
type = desc.type;
|
fType = desc.fType;
|
||||||
try {
|
try {
|
||||||
fStackFrame = (StackFrame)desc.getStackFrame();
|
fStackFrame = (StackFrame)desc.getStackFrame();
|
||||||
fThread = (Thread)desc.getThread();
|
fThread = (Thread)desc.getThread();
|
||||||
|
@ -73,8 +73,8 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
|
|
||||||
public VariableDescriptor(Target target, Thread thread, StackFrame stack, String n, String fn, int pos, int depth) {
|
public VariableDescriptor(Target target, Thread thread, StackFrame stack, String n, String fn, int pos, int depth) {
|
||||||
super(target);
|
super(target);
|
||||||
name = n;
|
fName = n;
|
||||||
fullName = fn;
|
fFullName = fn;
|
||||||
fStackFrame = stack;
|
fStackFrame = stack;
|
||||||
fThread = thread;
|
fThread = thread;
|
||||||
position = pos;
|
position = pos;
|
||||||
|
@ -150,24 +150,24 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
if (fullName == null) {
|
if (fFullName == null) {
|
||||||
fullName = getName();
|
fFullName = getName();
|
||||||
}
|
}
|
||||||
return fullName;
|
return fFullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableDescriptor#getName()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableDescriptor#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType()
|
||||||
*/
|
*/
|
||||||
public ICDIType getType() throws CDIException {
|
public ICDIType getType() throws CDIException {
|
||||||
if (type == null) {
|
if (fType == null) {
|
||||||
Target target = (Target)getTarget();
|
Target target = (Target)getTarget();
|
||||||
Session session = (Session) (target.getSession());
|
Session session = (Session) (target.getSession());
|
||||||
StackFrame frame = (StackFrame)getStackFrame();
|
StackFrame frame = (StackFrame)getStackFrame();
|
||||||
|
@ -182,29 +182,29 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
SourceManager sourceMgr = session.getSourceManager();
|
SourceManager sourceMgr = session.getSourceManager();
|
||||||
String nametype = sourceMgr.getTypeName(frame, getQualifiedName());
|
String nametype = sourceMgr.getTypeName(frame, getQualifiedName());
|
||||||
try {
|
try {
|
||||||
type = sourceMgr.getType(frame, nametype);
|
fType = sourceMgr.getType(frame, nametype);
|
||||||
} catch (CDIException e) {
|
} catch (CDIException e) {
|
||||||
// Try with ptype.
|
// Try with ptype.
|
||||||
try {
|
try {
|
||||||
String ptype = sourceMgr.getDetailTypeName(frame, nametype);
|
String ptype = sourceMgr.getDetailTypeName(frame, nametype);
|
||||||
type = sourceMgr.getType(frame, ptype);
|
fType = sourceMgr.getType(frame, ptype);
|
||||||
} catch (CDIException ex) {
|
} catch (CDIException ex) {
|
||||||
// Some version of gdb does not work woth the name of the class
|
// Some version of gdb does not work woth the name of the class
|
||||||
// ex: class data foo --> ptype data --> fails
|
// ex: class data foo --> ptype data --> fails
|
||||||
// ex: class data foo --> ptype foo --> succeed
|
// ex: class data foo --> ptype foo --> succeed
|
||||||
try {
|
try {
|
||||||
String ptype = sourceMgr.getDetailTypeName(frame, getQualifiedName());
|
String ptype = sourceMgr.getDetailTypeName(frame, getQualifiedName());
|
||||||
type = sourceMgr.getType(frame, ptype);
|
fType = sourceMgr.getType(frame, ptype);
|
||||||
} catch (CDIException e2) {
|
} catch (CDIException e2) {
|
||||||
// give up.
|
// give up.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == null) {
|
if (fType == null) {
|
||||||
type = new IncompleteType(frame, nametype);
|
fType = new IncompleteType(frame, nametype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return type;
|
return fType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -213,7 +213,6 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable
|
||||||
public int sizeof() throws CDIException {
|
public int sizeof() throws CDIException {
|
||||||
if (sizeof == null) {
|
if (sizeof == null) {
|
||||||
Target target = (Target) getTarget();
|
Target target = (Target) getTarget();
|
||||||
Session session = (Session) (target.getSession());
|
|
||||||
Thread currentThread = (Thread)target.getCurrentThread();
|
Thread currentThread = (Thread)target.getCurrentThread();
|
||||||
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
StackFrame currentFrame = currentThread.getCurrentStackFrame();
|
||||||
StackFrame frame = (StackFrame)getStackFrame();
|
StackFrame frame = (StackFrame)getStackFrame();
|
||||||
|
|
|
@ -34,6 +34,35 @@ public final class MIFormat {
|
||||||
private MIFormat() {
|
private MIFormat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We are assuming that GDB will print the address in hex format
|
||||||
|
* like:
|
||||||
|
* 0xbfffe5f0 "hello"
|
||||||
|
* (int *) 0xbfffe2b8
|
||||||
|
*
|
||||||
|
* @param buffer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BigInteger decodeAdress(String buffer) {
|
||||||
|
int radix = 10;
|
||||||
|
int cursor = 0;
|
||||||
|
int offset = 0;
|
||||||
|
int len = buffer.length();
|
||||||
|
|
||||||
|
if ((offset = buffer.indexOf("0x")) != -1 || //$NON-NLS-1$
|
||||||
|
(offset = buffer.indexOf("0X")) != -1) { //$NON-NLS-1$
|
||||||
|
radix = 16;
|
||||||
|
cursor = offset + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cursor < len && Character.digit(buffer.charAt(cursor), radix) != -1) {
|
||||||
|
cursor++;
|
||||||
|
}
|
||||||
|
|
||||||
|
String s = buffer.substring(offset, cursor);
|
||||||
|
return getBigInteger(s);
|
||||||
|
}
|
||||||
|
|
||||||
public static BigInteger getBigInteger(String address) {
|
public static BigInteger getBigInteger(String address) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int radix = 10;
|
int radix = 10;
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
|
import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.cdt.utils.pty.PTY;
|
import org.eclipse.cdt.utils.pty.PTY;
|
||||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
|
@ -133,7 +133,6 @@ public class MIProcessAdapter implements MIProcess {
|
||||||
if (fGDBProcess instanceof Spawner) {
|
if (fGDBProcess instanceof Spawner) {
|
||||||
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
||||||
gdbSpawner.interrupt();
|
gdbSpawner.interrupt();
|
||||||
int state;
|
|
||||||
synchronized (inferior) {
|
synchronized (inferior) {
|
||||||
// Allow (5 secs) for the interrupt to propagate.
|
// Allow (5 secs) for the interrupt to propagate.
|
||||||
for (int i = 0; inferior.isRunning() && i < 5; i++) {
|
for (int i = 0; inferior.isRunning() && i < 5; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue