diff options
17 files changed, 707 insertions, 268 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index ebe1bdf5418..f2d627aa0d3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,22 @@ +2005-04-25 Alain Magloire + * cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManger.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResources.properties + * cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java + + cdi/org/eclipse/cdt/debug/mi/core/cdi/Locator.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java + + + cdi/org/eclipse/cdt/debug/mi/core/cdi/model/AddressBreakpoint.java + + cdi/org/eclipse/cdt/debug/mi/core/cdi/model/FunctionBreakpoint.java + + cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LineBreakpoint.java + + cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LocationBreakpoint.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Threa.java + * cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java + 2005-04-05 Alain Magloire PR 90090 * cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java index 1ecee3eac4e..17a6ff6ca83 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java @@ -19,20 +19,31 @@ import java.util.List; import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; import org.eclipse.cdt.debug.core.cdi.ICDICondition; -import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILocator; +import org.eclipse.cdt.debug.core.cdi.model.ICDIAddressBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; 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.cdi.model.AddressBreakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.Exceptionpoint; +import org.eclipse.cdt.debug.mi.core.cdi.model.FunctionBreakpoint; +import org.eclipse.cdt.debug.mi.core.cdi.model.LineBreakpoint; +import org.eclipse.cdt.debug.mi.core.cdi.model.LocationBreakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Watchpoint; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIBreakAfter; +import org.eclipse.cdt.debug.mi.core.command.MIBreakCondition; import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete; import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable; import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable; @@ -298,12 +309,22 @@ public class BreakpointManager extends Manager { boolean success = false; try { bpt.setCondition0(newCondition); - setLocationBreakpoint(bpt); + if (breakpoint instanceof LocationBreakpoint) { + setLocationBreakpoint((LocationBreakpoint)bpt); + } else if (breakpoint instanceof Watchpoint) { + setWatchpoint((Watchpoint)breakpoint); + } else { + throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ + } success = true; } finally { if (!success) { bpt.setCondition0(oldCondition); - setLocationBreakpoint(bpt); + if (breakpoint instanceof LocationBreakpoint) { + setLocationBreakpoint((LocationBreakpoint)bpt); + } else if (breakpoint instanceof Watchpoint) { + setWatchpoint((Watchpoint)breakpoint); + } } } @@ -375,8 +396,8 @@ public class BreakpointManager extends Manager { allMIBreakpoints[i].getFunction(), allMIBreakpoints[i].getLine(), MIFormat.getBigInteger(allMIBreakpoints[i].getAddress())); - - Breakpoint newBreakpoint = new Breakpoint(target, type, location, condition); + // By default new breakpoint are LineBreakpoint + Breakpoint newBreakpoint = new LineBreakpoint(target, type, location, condition); newBreakpoint.setMIBreakpoints(new MIBreakpoint[] {allMIBreakpoints[i]}); bList.add(newBreakpoint); } @@ -520,16 +541,44 @@ public class BreakpointManager extends Manager { return EMPTY_BREAKPOINTS; } - public ICDILocationBreakpoint setLocationBreakpoint(Target target, int type, ICDILocation location, - ICDICondition condition, boolean deferred) throws CDIException { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setLineBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDILineLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDILineBreakpoint setLineBreakpoint(Target target, int type, ICDILineLocation location, + ICDICondition condition, boolean deferred) throws CDIException { + LineBreakpoint bkpt = new LineBreakpoint(target, type, location, condition); + setNewLocationBreakpoint(bkpt, deferred); + return bkpt; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setFunctionBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDIFunctionBreakpoint setFunctionBreakpoint(Target target, int type, ICDIFunctionLocation location, + ICDICondition condition, boolean deferred) throws CDIException { + FunctionBreakpoint bkpt = new FunctionBreakpoint(target, type, location, condition); + setNewLocationBreakpoint(bkpt, deferred); + return bkpt; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setAddressBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDIAddressBreakpoint setAddressBreakpoint(Target target, int type, ICDIAddressLocation location, + ICDICondition condition, boolean deferred) throws CDIException { + AddressBreakpoint bkpt = new AddressBreakpoint(target, type, location, condition); + setNewLocationBreakpoint(bkpt, deferred); + return bkpt; + } + + + protected void setNewLocationBreakpoint(LocationBreakpoint bkpt, boolean deferred) throws CDIException { + Target target = (Target)bkpt.getTarget(); MISession miSession = target.getMISession(); - Breakpoint bkpt = new Breakpoint(target, type, location, condition); try { setLocationBreakpoint(bkpt); List blist = getBreakpointsList(target); blist.add(bkpt); - // Force the reset of the location. - bkpt.setLocation(null); // Fire a created Event. MIBreakpoint[] miBreakpoints = bkpt.getMIBreakpoints(); @@ -553,87 +602,34 @@ public class BreakpointManager extends Manager { throw e; } } - return bkpt; } - MIBreakInsert[] createMIBreakInsert(Breakpoint bkpt) throws CDIException { - boolean hardware = bkpt.isHardware(); - boolean temporary = bkpt.isTemporary(); - String exprCond = null; - int ignoreCount = 0; - String[] threadIds = null; - StringBuffer line = new StringBuffer(); + public ICDIWatchpoint setWatchpoint(Target target, int type, int watchType, String expression, + ICDICondition condition) throws CDIException { - if (bkpt.getCondition() != null) { - ICDICondition condition = bkpt.getCondition(); - exprCond = condition.getExpression(); - ignoreCount = condition.getIgnoreCount(); - threadIds = condition.getThreadIds(); + // HACK: for the IDE, + try { + // Check if this an address watchpoint, and add a '*' + Integer.decode(expression); + expression = '*' + expression; + } catch (NumberFormatException e) { + // } + Watchpoint bkpt = new Watchpoint(target, expression, type, watchType, condition); - if (bkpt.getLocation() != null) { - ICDILocation location = bkpt.getLocation(); - String file = location.getFile(); - String function = location.getFunction(); - if (file != null && file.length() > 0) { - line.append(file).append(':'); - if (function != null && function.length() > 0) { - // GDB does not seem to accept function arguments when - // we use file name: - // (gdb) break file.c:Test(int) - // Will fail, altought it can accept this - // (gdb) break file.c:main - // so fall back to the line number or - // just the name of the function if lineno is invalid. - int paren = function.indexOf('('); - if (paren != -1) { - int no = location.getLineNumber(); - if (no <= 0) { - String func = function.substring(0, paren); - line.append(func); - } else { - line.append(no); - } - } else { - line.append(function); - } - } else { - line.append(location.getLineNumber()); - } - } else if (function != null && function.length() > 0) { - line.append(function); - } else if (location.getLineNumber() != 0) { - line.append(location.getLineNumber()); - } else { - line.append('*').append(location.getAddress()); - } - } + setWatchpoint(bkpt); + List bList = getBreakpointsList(target); + bList.add(bkpt); - MIBreakInsert[] miBreakInserts; - MISession miSession = ((Target)bkpt.getTarget()).getMISession(); - CommandFactory factory = miSession.getCommandFactory(); - if (threadIds == null || threadIds.length == 0) { - MIBreakInsert bi = factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), 0); - miBreakInserts = new MIBreakInsert[] { bi } ; - } else { - List list = new ArrayList(threadIds.length); - for (int i = 0; i < threadIds.length; i++) { - String threadId = threadIds[i]; - int tid = 0; - if (threadId != null && threadId.length() > 0) { - try { - tid = Integer.parseInt(threadId); - list.add(factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), tid)); - } catch (NumberFormatException e) { - } - } - } - miBreakInserts = (MIBreakInsert[]) list.toArray(new MIBreakInsert[list.size()]); - } - return miBreakInserts; + // Fire a created Event. + MISession miSession = target.getMISession(); + MIBreakpoint[] miBreakpoints = bkpt.getMIBreakpoints(); + if (miBreakpoints != null && miBreakpoints.length > 0) + miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, miBreakpoints[0].getNumber())); + return bkpt; } - public void setLocationBreakpoint (Breakpoint bkpt) throws CDIException { + public void setLocationBreakpoint (LocationBreakpoint bkpt) throws CDIException { Target target = (Target)bkpt.getTarget(); MISession miSession = target.getMISession(); boolean state = suspendInferior(target); @@ -690,21 +686,11 @@ public class BreakpointManager extends Manager { bkpt.setMIBreakpoints(allPoints); } - public ICDIWatchpoint setWatchpoint(Target target, int type, int watchType, String expression, - ICDICondition condition) throws CDIException { - - boolean access = ( (watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE && - (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); - boolean read = ( !((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE) && - (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); - - try { - // Check if this an address watchpoint, and add a '*' - Integer.decode(expression); - expression = '*' + expression; - } catch (NumberFormatException e) { - // - } + public void setWatchpoint(Watchpoint watchpoint) throws CDIException { + Target target = (Target)watchpoint.getTarget(); + boolean access = watchpoint.isReadType() && watchpoint.isWriteType(); + boolean read = ! watchpoint.isWriteType() && watchpoint.isReadType(); + String expression = watchpoint.getWatchExpression(); MISession miSession = target.getMISession(); boolean state = suspendInferior(target); @@ -714,29 +700,52 @@ public class BreakpointManager extends Manager { MIBreakpoint[] points = null; try { miSession.postCommand(breakWatch); - MIBreakWatchInfo info = breakWatch.getMIBreakWatchInfo(); - points = info.getMIBreakpoints(); - if (info == null) { + MIBreakWatchInfo winfo = breakWatch.getMIBreakWatchInfo(); + if (winfo == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } + points = winfo.getMIBreakpoints(); if (points == null || points.length == 0) { throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Parsing_Error")); //$NON-NLS-1$ } + + int no = points[0].getNumber(); + + // Put the condition now. + String exprCond = null; + int ignoreCount = 0; + String[] threadIds = null; + StringBuffer line = new StringBuffer(); + + ICDICondition condition = watchpoint.getCondition(); + if (condition != null) { + exprCond = condition.getExpression(); + ignoreCount = condition.getIgnoreCount(); + threadIds = condition.getThreadIds(); + } + if (exprCond != null && exprCond.length() > 0) { + MIBreakCondition breakCondition = factory.createMIBreakCondition(no, exprCond); + miSession.postCommand(breakCondition); + MIInfo info = breakCondition.getMIInfo(); + if (info == null) { + throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ + } + } + if (ignoreCount > 0) { + MIBreakAfter breakAfter = factory.createMIBreakAfter(no, ignoreCount); + miSession.postCommand(breakAfter); + MIInfo info = breakAfter.getMIInfo(); + if (info == null) { + throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ + } + } + // how to deal with threads ??? } catch (MIException e) { throw new MI2CDIException(e); } finally { resumeInferior(target, state); } - Watchpoint bkpt = new Watchpoint(target, expression, type, watchType, condition); - bkpt.setMIBreakpoints(points); - List bList = getBreakpointsList(target); - bList.add(bkpt); - - // Fire a created Event. - MIBreakpoint[] miBreakpoints = bkpt.getMIBreakpoints(); - if (miBreakpoints != null && miBreakpoints.length > 0) - miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, miBreakpoints[0].getNumber())); - return bkpt; + watchpoint.setMIBreakpoints(points); } Breakpoint[] exceptionBps = new Breakpoint[2]; @@ -758,8 +767,8 @@ public class BreakpointManager extends Manager { synchronized(exceptionBps) { int id = EXCEPTION_THROW_IDX; if (exceptionBps[EXCEPTION_THROW_IDX] == null) { - Location location = new Location(null, EXCEPTION_FUNCS[id], 0); - Breakpoint bp = new Breakpoint(target, ICDIBreakpoint.REGULAR, location, null); + Location location = new Location(null, EXCEPTION_FUNCS[id]); + LineBreakpoint bp = new LineBreakpoint(target, ICDIBreakpoint.REGULAR, location, null); setLocationBreakpoint(bp); exceptionBps[id] = bp; miBreakpoints = bp.getMIBreakpoints(); @@ -770,8 +779,8 @@ public class BreakpointManager extends Manager { synchronized(exceptionBps) { int id = EXCEPTION_THROW_IDX; if (exceptionBps[id] == null) { - Location location = new Location(null, EXCEPTION_FUNCS[id], 0); - Breakpoint bp = new Breakpoint(target, ICDIBreakpoint.REGULAR, location, null); + Location location = new Location(null, EXCEPTION_FUNCS[id]); + LineBreakpoint bp = new LineBreakpoint(target, ICDIBreakpoint.REGULAR, location, null); setLocationBreakpoint(bp); exceptionBps[id] = bp; if (miBreakpoints != null) { @@ -786,7 +795,7 @@ public class BreakpointManager extends Manager { } } - Exceptionpoint excp = new Exceptionpoint(target, clazz, stopOnThrow, stopOnCatch); + Exceptionpoint excp = new Exceptionpoint(target, clazz, stopOnThrow, stopOnCatch, null); if (miBreakpoints != null && miBreakpoints.length > 0) { excp.setMIBreakpoints(miBreakpoints); List blist = getBreakpointsList(target); @@ -803,12 +812,102 @@ public class BreakpointManager extends Manager { return new Condition(ignoreCount, expression, tids); } - public Location createLocation(String file, String function, int line) { - return new Location(file, function, line); + public Location createLineLocation(String file, int line) { + return new Location(file, line); } - public Location createLocation(BigInteger address) { + public Location createFunctionLocation(String file, String function) { + return new Location(file, function); + } + + public Location createAddressLocation(BigInteger address) { return new Location(address); } + MIBreakInsert[] createMIBreakInsert(LocationBreakpoint bkpt) throws CDIException { + boolean hardware = bkpt.isHardware(); + boolean temporary = bkpt.isTemporary(); + String exprCond = null; + int ignoreCount = 0; + String[] threadIds = null; + StringBuffer line = new StringBuffer(); + + if (bkpt.getCondition() != null) { + ICDICondition condition = bkpt.getCondition(); + exprCond = condition.getExpression(); + ignoreCount = condition.getIgnoreCount(); + threadIds = condition.getThreadIds(); + } + + if (bkpt.getLocator() != null) { + ICDILocator locator = bkpt.getLocator(); + String file = locator.getFile(); + String function = locator.getFunction(); + int no = locator.getLineNumber(); + if (bkpt instanceof LineBreakpoint) { + if (file != null && file.length() > 0) { + line.append(file).append(':'); + } + line.append(no); + } else if (bkpt instanceof FunctionBreakpoint) { + if (file != null && file.length() > 0) { + line.append(file).append(':'); + } + if (function != null && function.length() > 0) { + // GDB does not seem to accept function arguments when + // we use file name: + // (gdb) break file.c:Test(int) + // Will fail, altought it can accept this + // (gdb) break file.c:main + // so fall back to the line number or + // just the name of the function if lineno is invalid. + int paren = function.indexOf('('); + if (paren != -1) { + if (no <= 0) { + String func = function.substring(0, paren); + line.append(func); + } else { + line.append(no); + } + } else { + line.append(function); + } + } else { + // ??? + line.append(no); + } + } else if (bkpt instanceof AddressBreakpoint) { + line.append('*').append(locator.getAddress()); + } else { + // ??? + if (file != null && file.length() > 0) { + line.append(file).append(':'); + } + line.append(no); + } + } + + MIBreakInsert[] miBreakInserts; + MISession miSession = ((Target)bkpt.getTarget()).getMISession(); + CommandFactory factory = miSession.getCommandFactory(); + if (threadIds == null || threadIds.length == 0) { + MIBreakInsert bi = factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), 0); + miBreakInserts = new MIBreakInsert[] { bi } ; + } else { + List list = new ArrayList(threadIds.length); + for (int i = 0; i < threadIds.length; i++) { + String threadId = threadIds[i]; + int tid = 0; + if (threadId != null && threadId.length() > 0) { + try { + tid = Integer.parseInt(threadId); + list.add(factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), tid)); + } catch (NumberFormatException e) { + } + } + } + miBreakInserts = (MIBreakInsert[]) list.toArray(new MIBreakInsert[list.size()]); + } + return miBreakInserts; + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResources.properties b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResources.properties index 838088b2462..0cd1e174f88 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResources.properties +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResources.properties @@ -30,3 +30,4 @@ cdi.model.Target.Target_not_responding=Target is not responding cdi.model.Target.Cannot_switch_to_thread=Can not switch to thread cdi.model.Target.Inferior_already_running=Inferior is already running cdi.model.MemoryBlock.Bad_Offset=Bad Offset +cdi.mode.Target.Bad_location=Bad location diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java index 535fbd24015..f48af38dee1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Location.java @@ -12,89 +12,144 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.math.BigInteger; +import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; +import org.eclipse.cdt.debug.core.cdi.ICDIFileLocation; +import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; import org.eclipse.cdt.debug.core.cdi.ICDILocation; /** */ -public class Location implements ICDILocation { +public class Location implements ICDIFileLocation, ICDILineLocation, ICDIFunctionLocation, ICDIAddressLocation { - BigInteger addr; - String file = ""; //$NON-NLS-1$ - String function = ""; //$NON-NLS-1$ - int line; + BigInteger fAddress = null; + String fFile = null; + String fFunction = null; + int fLine; - public Location(String f, String fnct, int l) { - this(f, fnct, l, null); + /** + * File location + * @param file + */ + public Location(String file) { + this(file, null, 0, null); } - public Location(String f, String fnct, int l, BigInteger a) { - if (f != null) - file = f; - if (fnct != null) - function = fnct; - line = l; - addr = a; + /** + * File:function location + * @param file + * @param function + */ + public Location(String file, String function) { + this(file, function, 0, null); } + /** + * File:line location + * @param file + * @param line + */ + public Location(String file, int line) { + this (file, null, line, null); + } + + /** + * Address location + * @param address + */ public Location(BigInteger address) { - addr = address; + this (null, null, 0, address); + } + + protected Location(String file, String function, int line, BigInteger address) { + fFile = file; + fFunction = function; + fLine = line; + fAddress = address; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDILocation#getAddress() */ public BigInteger getAddress() { - return addr; + return fAddress; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDILocation#getFile() */ public String getFile() { - return file; + return fFile; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDILocation#getFunction() */ public String getFunction() { - return function; + return fFunction; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDILocation#getLineNumber() */ public int getLineNumber() { - return line; + return fLine; } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDILocation#equals(ICDILocation) */ public boolean equals(ICDILocation location) { - String ofile = location.getFile(); - if (file.length() > 0 && ofile.length() > 0) { - if (file.equals(ofile)) { - int oline = location.getLineNumber(); - if (line != 0 && oline != 0) { - if (line == oline) { - return true; - } + if (location == this) { + return true; + } + if (location instanceof ICDILineLocation) { + ICDILineLocation lineLocation = (ICDILineLocation)location; + String oFile = lineLocation.getFile(); + if (oFile != null && oFile.length() > 0 && fFile != null && fFile.length() > 0 && oFile.equals(fFile)) { + if (lineLocation.getLineNumber() == fLine) { + return true; } - String ofunction = location.getFunction(); - if (function.length() > 0 && ofunction.length() > 0) { - if (function.equals(ofunction)) { - return true; - } + } else if ((fFile == null || fFile.length() == 0) && (oFile == null || oFile.length() == 0)) { + if (lineLocation.getLineNumber() == fLine) { + return true; } } - } - BigInteger oaddr = location.getAddress(); - if (addr != null && oaddr != null) { //IPF_TODO: check ZERO addresses - if (addr.equals(oaddr)) { + } else if (location instanceof ICDIFunctionLocation) { + ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location; + String oFile = funcLocation.getFile(); + String oFunction = funcLocation.getFunction(); + if (oFile != null && oFile.length() > 0 && fFile != null && fFile.length() > 0 && oFile.equals(fFile)) { + if (oFunction != null && oFunction.length() > 0 && fFunction != null && fFunction.length() > 0 && oFunction.equals(fFunction)) { + return true; + } else if ((oFunction == null || oFunction.length() == 0) && (fFunction == null || fFunction.length() == 0)) { + return true; + } + } else if ((fFile == null || fFile.length() == 0) && (oFile == null || oFile.length() == 0)) { + if (oFunction != null && oFunction.length() > 0 && fFunction != null && fFunction.length() > 0 && oFunction.equals(fFunction)) { + return true; + } else if ((oFunction == null || oFunction.length() == 0) && (fFunction == null || fFunction.length() == 0)) { + return true; + } + } + } else if (location instanceof ICDIAddressLocation) { + ICDIAddressLocation addrLocation = (ICDIAddressLocation)location; + BigInteger oAddr = addrLocation.getAddress(); + if (oAddr != null && oAddr.equals(fAddress)) { + return true; + } else if (oAddr == null && fAddress == null) { return true; } + } else if (location instanceof ICDIFileLocation) { + ICDIFileLocation fileLocation = (ICDIFileLocation)location; + String oFile = fileLocation.getFile(); + if (oFile != null && oFile.length() > 0 && fFile != null && fFile.length() > 0 && oFile.equals(fFile)) { + return true; + } else if ((fFile == null || fFile.length() == 0) && (oFile == null || oFile.length() == 0)) { + return true; + } } - return super.equals(location); + return false; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Locator.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Locator.java new file mode 100644 index 00000000000..d99c8f113b2 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Locator.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2000, 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 java.math.BigInteger; + +import org.eclipse.cdt.debug.core.cdi.ICDILocator; + +public class Locator extends Location implements ICDILocator { + + public Locator(String file, String function, int line, BigInteger address) { + super(file, function, line, address); + } + + boolean equalFile(String oFile) { + return equalString(oFile, getFile()); + } + + boolean equalFunction(String oFunction) { + return equalString(oFunction, getFunction()); + } + + boolean equalLine(int oLine) { + return oLine == getLineNumber(); + } + + boolean equalAddress(BigInteger oAddress) { + if (oAddress == null && getAddress() == null) { + return true; + } + if (oAddress != null && oAddress.equals(getAddress())) { + return true; + } + return false; + } + + boolean equalString(String f1, String f2) { + if (f1 != null && f1.length() > 0 && f2 != null && f2.length() > 0) { + return f1.equals(f2); + } else if ((f1 == null || f1.length() == 0) && (f2 == null || f2.length() == 0)) { + return true; + } + return false; + } + + public boolean equals(ICDILocator locator) { + + if (locator == this) { + return true; + } + String oFile = locator.getFile(); + String oFunction = locator.getFunction(); + int oLine = locator.getLineNumber(); + BigInteger oAddress = locator.getAddress(); + + if (equalFile(oFile) && equalFunction(oFunction) && + equalLine(oLine) && equalAddress(oAddress)) { + return true; + } + return false; + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException.java index 22f817e95be..0623b97cb1c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MI2CDIException.java @@ -18,6 +18,11 @@ import org.eclipse.cdt.debug.mi.core.MIException; */ public class MI2CDIException extends CDIException { + /** + * + */ + private static final long serialVersionUID = 1L; + public MI2CDIException(MIException e) { super(e.getMessage(), e.getLogMessage()); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java index 6ba1bc7f059..2d6dad6ec0e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java @@ -27,8 +27,10 @@ import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.mi.core.MIPlugin; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; +import org.eclipse.cdt.debug.mi.core.cdi.model.LocationBreakpoint; 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.Watchpoint; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetAutoSolib; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath; @@ -108,7 +110,13 @@ public class SharedLibraryManager extends Manager { Breakpoint bkpt = (Breakpoint)bpoints[i]; try { boolean enable = bkpt.isEnabled(); - bpMgr.setLocationBreakpoint(bkpt); + if (bkpt instanceof LocationBreakpoint) { + bpMgr.setLocationBreakpoint((LocationBreakpoint)bkpt); + } else if (bkpt instanceof Watchpoint) { + bpMgr.setWatchpoint((Watchpoint)bkpt); + } else { + throw new CDIException(); + } bpMgr.deleteFromDeferredList(bkpt); bpMgr.addToBreakpointList(bkpt); // If the breakpoint was disable in the IDE diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/AddressBreakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/AddressBreakpoint.java new file mode 100644 index 00000000000..62640768e34 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/AddressBreakpoint.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2000, 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; + +import org.eclipse.cdt.debug.core.cdi.ICDICondition; +import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDIAddressBreakpoint; + +public class AddressBreakpoint extends LocationBreakpoint implements + ICDIAddressBreakpoint { + + public AddressBreakpoint(Target target, int kind, ICDILocation loc, + ICDICondition cond) { + super(target, kind, loc, cond); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java index da7ad1e720b..179a618932f 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java @@ -10,37 +10,29 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.cdi.model; - -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDICondition; -import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; -import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.cdi.Condition; -import org.eclipse.cdt.debug.mi.core.cdi.Location; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; /** */ -public class Breakpoint extends CObject implements ICDILocationBreakpoint { +public abstract class Breakpoint extends CObject implements ICDIBreakpoint { - ICDILocation fLocation; ICDICondition condition; MIBreakpoint[] miBreakpoints; int type; boolean enable; - public Breakpoint(Target target, int kind, ICDILocation loc, ICDICondition cond) { + public Breakpoint(Target target, int kind, ICDICondition cond) { super(target); type = kind; - fLocation = loc; condition = cond; enable = true; } @@ -133,27 +125,4 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { enable = on; } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDILocationBreakpoint#getLocation() - */ - public ICDILocation getLocation() throws CDIException { - if (fLocation == null) { - if (miBreakpoints != null && miBreakpoints.length > 0) { - BigInteger addr = BigInteger.ZERO; - String a = miBreakpoints[0].getAddress(); - if (a != null) { - addr = MIFormat.getBigInteger(a); - } - fLocation = new Location (miBreakpoints[0].getFile(), - miBreakpoints[0].getFunction(), - miBreakpoints[0].getLine(), - addr); - } - } - return fLocation; - } - - public void setLocation(ICDILocation loc) { - fLocation = loc; - } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java index 6edaab0ce71..f083be18aef 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; +import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint; @@ -25,8 +26,8 @@ public class Exceptionpoint extends Breakpoint implements ICDIExceptionpoint { /** */ - public Exceptionpoint(Target target, String clazz, boolean stopOnThrow, boolean stopOnCatch) { - super(target, ICDIBreakpoint.REGULAR, null, null); + public Exceptionpoint(Target target, String clazz, boolean stopOnThrow, boolean stopOnCatch, ICDICondition cond) { + super(target, ICDIBreakpoint.REGULAR, cond); fClazz = clazz; fStopOnThrow = stopOnThrow; fStopOnCatch = stopOnCatch; @@ -36,14 +37,6 @@ public class Exceptionpoint extends Breakpoint implements ICDIExceptionpoint { return fClazz; } - /** - * @param target - * @param miBreak - */ -// public Exceptionpoint(Target target, MIBreakpoint miBreak) { -// super(target, miBreak); -// } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint#isStopOnThrow() */ diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/FunctionBreakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/FunctionBreakpoint.java new file mode 100644 index 00000000000..9f1c453c24a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/FunctionBreakpoint.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2000, 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; + +import org.eclipse.cdt.debug.core.cdi.ICDICondition; +import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint; + +public class FunctionBreakpoint extends LocationBreakpoint implements + ICDIFunctionBreakpoint { + + public FunctionBreakpoint(Target target, int kind, ICDILocation loc, + ICDICondition cond) { + super(target, kind, loc, cond); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LineBreakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LineBreakpoint.java new file mode 100644 index 00000000000..80d3aa67c67 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LineBreakpoint.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2000, 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; + +import org.eclipse.cdt.debug.core.cdi.ICDICondition; +import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint; + +public class LineBreakpoint extends LocationBreakpoint implements ICDILineBreakpoint { + + public LineBreakpoint(Target target, int kind, ICDILineLocation loc, ICDICondition cond) { + super(target, kind, loc, cond); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LocationBreakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LocationBreakpoint.java new file mode 100644 index 00000000000..0814000fba4 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/LocationBreakpoint.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2000, 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; + +import java.math.BigInteger; + +import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; +import org.eclipse.cdt.debug.core.cdi.ICDICondition; +import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.ICDILocator; +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; +import org.eclipse.cdt.debug.mi.core.MIFormat; +import org.eclipse.cdt.debug.mi.core.cdi.Locator; + +public abstract class LocationBreakpoint extends Breakpoint implements ICDIBreakpoint { + + ICDILocation fLocation; + + public LocationBreakpoint(Target target, int kind, ICDILocation loc, ICDICondition cond) { + super(target, kind, cond); + fLocation = loc; + } + + public int getLineNumber() { + if (miBreakpoints != null && miBreakpoints.length > 0) { + return miBreakpoints[0].getLine(); + } else if (fLocation instanceof ICDILineLocation) { + return ((ICDILineLocation)fLocation).getLineNumber(); + } + return 0; + } + + public String getFile() { + if (miBreakpoints != null && miBreakpoints.length > 0) { + return miBreakpoints[0].getFile(); + } else if (fLocation instanceof ICDILineLocation) { + return ((ICDILineLocation)fLocation).getFile(); + } else if (fLocation instanceof ICDIFunctionLocation) { + return ((ICDIFunctionLocation)fLocation).getFile(); + } + return null; + } + + public BigInteger getAddress() { + if (miBreakpoints != null && miBreakpoints.length > 0) { + BigInteger addr = BigInteger.ZERO; + String a = miBreakpoints[0].getAddress(); + if (a != null) { + addr = MIFormat.getBigInteger(a); + } + } else if (fLocation instanceof ICDIAddressLocation) { + return ((ICDIAddressLocation)fLocation).getAddress(); + } + return null; + } + + public String getFunction() { + if (miBreakpoints != null && miBreakpoints.length > 0) { + return miBreakpoints[0].getFunction(); + } else if (fLocation instanceof ICDIFunctionLocation) { + return ((ICDIFunctionLocation)fLocation).getFunction(); + } + return null; + } + + public ICDILocator getLocator() { + return new Locator(getFile(), getFunction(), getLineNumber(), getAddress()); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java index 68c2c3eea78..9c72b08eabf 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import java.math.BigInteger; import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.ICDILocator; import org.eclipse.cdt.debug.core.cdi.model.ICDIArgumentDescriptor; import org.eclipse.cdt.debug.core.cdi.model.ICDILocalVariableDescriptor; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; @@ -23,9 +23,9 @@ 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.cdi.CdiResources; +import org.eclipse.cdt.debug.mi.core.cdi.Locator; import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.Session; -import org.eclipse.cdt.debug.mi.core.cdi.Location; import org.eclipse.cdt.debug.mi.core.cdi.VariableManager; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIExecFinish; @@ -42,7 +42,7 @@ public class StackFrame extends CObject implements ICDIStackFrame { int level; ICDIArgumentDescriptor[] argDescs; ICDILocalVariableDescriptor[] localDescs; - Location fLocation; + Locator fLocator; /* * @@ -112,22 +112,22 @@ public class StackFrame extends CObject implements ICDIStackFrame { /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocation() */ - public ICDILocation getLocation() { + public ICDILocator getLocator() { BigInteger addr = BigInteger.ZERO; if (frame != null) { - if (fLocation == null) { + if (fLocator == null) { String a = frame.getAddress(); if (a != null) { addr = MIFormat.getBigInteger(a); } - fLocation = new Location(frame.getFile(), + fLocator = new Locator(frame.getFile(), frame.getFunction(), frame.getLine(), addr); } - return fLocation; + return fLocator; } - return new Location("", "", 0, addr); //$NON-NLS-1$ //$NON-NLS-2$ + return new Locator("", "", 0, addr); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -146,7 +146,7 @@ public class StackFrame extends CObject implements ICDIStackFrame { return cthread != null && cthread.equals(stack.getThread()) && getLevel() == stack.getLevel() && - getLocation().equals(stack.getLocation()); + getLocator().equals(stack.getLocator()); } return super.equals(stackframe); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java index 14948289016..a7d589d98d3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java @@ -15,13 +15,18 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation; import org.eclipse.cdt.debug.core.cdi.ICDICondition; +import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation; +import org.eclipse.cdt.debug.core.cdi.ICDILineLocation; import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDIAddressBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; +import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup; @@ -490,13 +495,31 @@ public class Target extends SessionObject implements ICDITarget { */ public void stepUntil(ICDILocation location) throws CDIException { CommandFactory factory = miSession.getCommandFactory(); - String loc = ""; //$NON-NLS-1$ - if (location.getFile() != null && location.getFile().length() > 0) { - loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$ - } else if (location.getFunction() != null && location.getFunction().length() > 0) { - loc = location.getFunction(); - } else if ( ! location.getAddress().equals(BigInteger.ZERO) ) { - loc = "*" + location.getAddress().toString(); //$NON-NLS-1$ + String loc = null; + if (location instanceof ICDILineLocation) { + ICDILineLocation lineLocation = (ICDILineLocation)location; + if (lineLocation.getFile() != null && lineLocation.getFile().length() > 0) { + loc = lineLocation.getFile() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$ + } + } else if (location instanceof ICDIFunctionLocation) { + ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location; + if (funcLocation.getFunction() != null && funcLocation.getFunction().length() > 0) { + loc = funcLocation.getFunction(); + } + if (funcLocation.getFile() != null && funcLocation.getFile().length() > 0) { + if (loc != null) { + loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$ + } + } + } else if (location instanceof ICDIAddressLocation) { + ICDIAddressLocation addrLocation = (ICDIAddressLocation) location; + if (! addrLocation.getAddress().equals(BigInteger.ZERO)) { + loc = "*0x" + addrLocation.getAddress().toString(16); //$NON-NLS-1$ + } + } + // Throw an exception we do know where to go + if (loc == null) { + throw new CDIException (CdiResources.getString("cdi.mode.Target.Bad_location")); //$NON-NLS-1$ } MIExecUntil until = factory.createMIExecUntil(loc); try { @@ -601,14 +624,33 @@ public class Target extends SessionObject implements ICDITarget { */ public void jump(ICDILocation location) throws CDIException { CommandFactory factory = miSession.getCommandFactory(); - String loc = ""; //$NON-NLS-1$ - if (location.getFile() != null && location.getFile().length() > 0) { - loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$ - } else if (location.getFunction() != null && location.getFunction().length() > 0) { - loc = location.getFunction(); - } else if (! location.getAddress().equals(BigInteger.ZERO)) { - loc = "*" + location.getAddress().toString(); //$NON-NLS-1$ + String loc = null; + if (location instanceof ICDILineLocation) { + ICDILineLocation lineLocation = (ICDILineLocation)location; + if (lineLocation.getFile() != null && lineLocation.getFile().length() > 0) { + loc = lineLocation.getFile() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$ + } + } else if (location instanceof ICDIFunctionLocation) { + ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location; + if (funcLocation.getFunction() != null && funcLocation.getFunction().length() > 0) { + loc = funcLocation.getFunction(); + } + if (funcLocation.getFile() != null && funcLocation.getFile().length() > 0) { + if (loc != null) { + loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$ + } + } + } else if (location instanceof ICDIAddressLocation) { + ICDIAddressLocation addrLocation = (ICDIAddressLocation) location; + if (! addrLocation.getAddress().equals(BigInteger.ZERO)) { + loc = "*0x" + addrLocation.getAddress().toString(16); //$NON-NLS-1$ + } } + // Throw an exception we do know where to go + if (loc == null) { + throw new CDIException (CdiResources.getString("cdi.mode.Target.Bad_location")); //$NON-NLS-1$ + } + MIJump jump = factory.createMIJump(loc); try { miSession.postCommand(jump); @@ -729,41 +771,77 @@ public class Target extends SessionObject implements ICDITarget { // Implementaton of ICDIBreapointManagement. - public ICDIBreakpoint[] getBreakpoints() throws CDIException { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setLineBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDILineLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDILineBreakpoint setLineBreakpoint(int type, ICDILineLocation location, + ICDICondition condition, boolean deferred) throws CDIException { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); - return bMgr.getBreakpoints(this); + return bMgr.setLineBreakpoint(this, type, location, condition, deferred); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setFunctionBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDIFunctionBreakpoint setFunctionBreakpoint(int type, ICDIFunctionLocation location, + ICDICondition condition, boolean deferred) throws CDIException { + BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); + return bMgr.setFunctionBreakpoint(this, type, location, condition, deferred); } - public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setAddressBreakpoint(int, org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean) + */ + public ICDIAddressBreakpoint setAddressBreakpoint(int type, ICDIAddressLocation location, ICDICondition condition, boolean deferred) throws CDIException { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); - return bMgr.setLocationBreakpoint(this, type, location, condition, deferred); + return bMgr.setAddressBreakpoint(this, type, location, condition, deferred); } + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setWatchpoint(int, int, java.lang.String, org.eclipse.cdt.debug.core.cdi.ICDICondition) + */ public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression, - ICDICondition condition) throws CDIException { + ICDICondition condition) throws CDIException { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); return bMgr.setWatchpoint(this, type, watchType, expression, condition); } + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setExceptionBreakpoint(java.lang.String, boolean, boolean) + */ + public ICDIExceptionpoint setExceptionBreakpoint(String clazz, boolean stopOnThrow, boolean stopOnCatch) + throws CDIException { + throw new CDIException(CdiResources.getString("cdi.Common.Not_implemented")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#getBreakpoints() + */ + public ICDIBreakpoint[] getBreakpoints() throws CDIException { + BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); + return bMgr.getBreakpoints(this); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#deleteBreakpoints(org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint[]) + */ public void deleteBreakpoints(ICDIBreakpoint[] breakpoints) throws CDIException { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); bMgr.deleteBreakpoints(this, breakpoints); } + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#deleteAllBreakpoints() + */ public void deleteAllBreakpoints() throws CDIException { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); bMgr.deleteAllBreakpoints(this); } - public ICDIExceptionpoint setExceptionBreakpoint(String clazz, boolean stopOnThrow, boolean stopOnCatch) - throws CDIException { - throw new CDIException(CdiResources.getString("cdi.Common.Not_implemented")); //$NON-NLS-1$ - } - - /* - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createCondition(int, java.lang.String, String) - */ + /* + * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createCondition(int, java.lang.String, String) + */ public ICDICondition createCondition(int ignoreCount, String expression) { return createCondition(ignoreCount, expression, null); } @@ -777,19 +855,27 @@ public class Target extends SessionObject implements ICDITarget { } /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createLocation(java.lang.String, java.lang.String, int) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createLineLocation(java.lang.String, int) + */ + public ICDILineLocation createLineLocation(String file, int line) { + BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); + return bMgr.createLineLocation(file, line); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createFunctionLocation(java.lang.String, java.lang.String) */ - public ICDILocation createLocation(String file, String function, int line) { + public ICDIFunctionLocation createFunctionLocation(String file, String function) { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); - return bMgr.createLocation(file, function, line); + return bMgr.createFunctionLocation(file, function); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createLocation(long) */ - public ICDILocation createLocation(BigInteger address) { + public ICDIAddressLocation createAddressLocation(BigInteger address) { BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager(); - return bMgr.createLocation(address); + return bMgr.createAddressLocation(address); } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java index 7bf1587e90c..35b023d18f3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java @@ -17,14 +17,12 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; 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.ICDIThreadStorageDescriptor; import org.eclipse.cdt.debug.mi.core.MIException; 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.CdiResources; import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; @@ -492,28 +490,6 @@ public class Thread extends CObject implements ICDIThread { return (ICDIBreakpoint[]) list.toArray(new ICDIBreakpoint[list.size()]); } - public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, - ICDICondition condition, boolean deferred) throws CDIException { - Target target = (Target)getTarget(); - String[] threadIds = new String[] { Integer.toString(getId()) }; - int icount = 0; - String exp = new String(); - if (condition != null) { - icount = condition.getIgnoreCount(); - exp = condition.getExpression(); - String[] tids = condition.getThreadIds(); - if (tids != null && tids.length > 0) { - String[] temp = new String[threadIds.length + tids.length]; - System.arraycopy(threadIds, 0, temp, 0, threadIds.length); - System.arraycopy(tids, 0, temp, threadIds.length, tids.length); - threadIds = temp; - } - } - BreakpointManager bMgr = ((Session)target.getSession()).getBreakpointManager(); - ICDICondition newCondition = bMgr.createCondition(icount, exp, threadIds); - return target.setLocationBreakpoint(type, location, newCondition, deferred); - } - /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#getThreadStorageDescriptors() */ diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java index 485cac104ab..6b0476a5b31 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java @@ -23,7 +23,7 @@ public class Watchpoint extends Breakpoint implements ICDIWatchpoint { String what; public Watchpoint(Target target, String expression, int type, int wType, ICDICondition cond) { - super(target, type, null, cond); //$NON-NLS-1$ + super(target, type, cond); watchType = wType; what = expression; } |