1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 487998: [breakpoints] Editing code while debug is active

Change-Id: I68361b490a1ba84f0530db37a2da7558c1b762c7
Also-by: Jonah Graham <jonah@kichwacoders.com>
Signed-off-by: Stefan Sprenger <stefan@sprenger.software>
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
Stefan Sprenger 2016-04-27 10:18:55 +01:00 committed by Jonah Graham
parent 0265ee09a7
commit 2469e0e117
4 changed files with 40 additions and 7 deletions

View file

@ -57,6 +57,18 @@ public interface ICLineBreakpoint2 extends ICLineBreakpoint, ICBreakpoint2 {
*/
public static final String REQUESTED_SOURCE_HANDLE = "requestedSourceHandle"; //$NON-NLS-1$
/**
* Breakpoint attribute which is set if the installed line number of a
* breakpoint is changed.
*
* Triggers an update of the installed location, if set.
*
* This attribute is a <code>Boolean</code>.
*
* @since 8.0
*/
public static final String RESET_INSTALLED_LOCATION = "resetInstalledLocation"; //$NON-NLS-1$
/**
* Returns the line number where the breakpoint was set before it was relocated to a
* valid source line.

View file

@ -150,22 +150,29 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi
@Override
public void setRequestedSourceHandle(String fileName) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName );
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
}
@Override
public synchronized int decrementInstallCount() throws CoreException {
int count = super.decrementInstallCount();
if (count == 0) {
resetInstalledLocation();
if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) {
resetInstalledLocation();
setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE);
}
}
return count;
}
@Override
public void setInstalledLineNumber(int line) throws CoreException {
int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
if (line != existingValue) {
setAttribute(IMarker.LINE_NUMBER, line);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@ -175,6 +182,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1);
if (charStart != existingValue) {
setAttribute(IMarker.CHAR_START, charStart);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@ -184,6 +192,7 @@ public abstract class AbstractLineBreakpoint extends CBreakpoint implements ICLi
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1);
if (charEnd != existingValue) {
setAttribute(IMarker.CHAR_END, charEnd);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}

View file

@ -50,9 +50,14 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint,
@Override
public synchronized int decrementInstallCount() throws CoreException {
int count = super.decrementInstallCount();
if (count == 0) {
resetInstalledLocation();
if (Boolean.TRUE.equals(this.getMarker().getAttribute(RESET_INSTALLED_LOCATION))) {
if (count == 0) {
resetInstalledLocation();
setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE);
}
}
return count;
}
@ -102,6 +107,7 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint,
@Override
public void setRequestedSourceHandle(String fileName) throws CoreException {
setAttribute( ICLineBreakpoint2.REQUESTED_SOURCE_HANDLE, fileName );
setAttribute(RESET_INSTALLED_LOCATION, Boolean.FALSE);
}
@Override
@ -109,6 +115,7 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint,
int existingValue = ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
if (line != existingValue) {
setAttribute(IMarker.LINE_NUMBER, line);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@ -118,6 +125,7 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint,
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_START, -1);
if (charStart != existingValue) {
setAttribute(IMarker.CHAR_START, charStart);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}
@ -127,6 +135,7 @@ public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint,
int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1);
if (charEnd != existingValue) {
setAttribute(IMarker.CHAR_END, charEnd);
setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE);
setAttribute( IMarker.MESSAGE, getMarkerMessage() );
}
}

View file

@ -200,10 +200,13 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
}
else if ( property.equals( IMarker.LINE_NUMBER ) ) {
if (breakpoint instanceof ICLineBreakpoint2) {
// Must set the REQUESTED_LINE attribute first, or else the breakpoint
// message will be refreshed improperly
// refresh message and line number
// Note there are no API methods to set the line number of a Line Breakpoint, so we
// replicate what is done in CDIDebugModel.setLineBreakpointAttributes()
// to set the line number fields properly and then refresh the message if possible
((ICLineBreakpoint2)breakpoint).setRequestedLine(getInt(IMarker.LINE_NUMBER));
((ICLineBreakpoint2)breakpoint).setInstalledLineNumber(getInt(IMarker.LINE_NUMBER));
breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getInt(IMarker.LINE_NUMBER));
((ICBreakpoint2)breakpoint).refreshMessage();
} else {
// already workspace runnable, setting markers are safe
breakpoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getInt(IMarker.LINE_NUMBER));