mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 135250: Patch to fix function breakpoints.
This commit is contained in:
parent
0bcf54bfc5
commit
b3e38d9e19
5 changed files with 97 additions and 35 deletions
|
@ -770,7 +770,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
|
|||
try {
|
||||
ICDILocator location = cdiBreakpoint.getLocator();
|
||||
String file = location.getFile();
|
||||
if ( !isEmpty( file ) ) {
|
||||
if ( cdiBreakpoint instanceof ICDILineBreakpoint ) {
|
||||
Object sourceElement = getSourceElement( file );
|
||||
String sourceHandle = file;
|
||||
IResource resource = getProject();
|
||||
|
@ -783,17 +783,11 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
|
|||
resource = ResourcesPlugin.getWorkspace().getRoot();
|
||||
}
|
||||
breakpoint = createLineBreakpoint( sourceHandle, resource, cdiBreakpoint );
|
||||
// else if ( !isEmpty( cdiBreakpoint.getLocation().getFunction() ) ) {
|
||||
// breakpoint = createFunctionBreakpoint( cdiBreakpoint );
|
||||
// }
|
||||
// else if ( ! cdiBreakpoint.getLocation().getAddress().equals( BigInteger.ZERO ) ) {
|
||||
// breakpoint = createAddressBreakpoint( cdiBreakpoint );
|
||||
// }
|
||||
}
|
||||
else if ( !isEmpty( location.getFunction() ) ) {
|
||||
else if ( cdiBreakpoint instanceof ICDIFunctionBreakpoint ) {
|
||||
breakpoint = createFunctionBreakpoint( cdiBreakpoint );
|
||||
}
|
||||
else if ( !location.getAddress().equals( BigInteger.ZERO ) ) {
|
||||
else if ( cdiBreakpoint instanceof ICDIAddressBreakpoint ) {
|
||||
breakpoint = createAddressBreakpoint( cdiBreakpoint );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,9 +373,15 @@ public class BreakpointManager extends Manager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void update(Target target) throws CDIException {
|
||||
update(target, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the event that causes this update
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=135250
|
||||
*/
|
||||
public void update(Target target, MIEvent event) throws CDIException {
|
||||
MISession miSession = target.getMISession();
|
||||
MIBreakpoint[] allMIBreakpoints = getAllMIBreakpoints(miSession);
|
||||
List bList = getBreakpointsList(target);
|
||||
|
@ -429,29 +435,33 @@ public class BreakpointManager extends Manager {
|
|||
wpoint.setMIBreakpoints(new MIBreakpoint[] {allMIBreakpoints[i]});
|
||||
bList.add(wpoint);
|
||||
} else {
|
||||
int hint = MIBreakpointChangedEvent.HINT_NONE;
|
||||
if (event instanceof MIBreakpointChangedEvent) {
|
||||
hint = ((MIBreakpointChangedEvent)event).getHint();
|
||||
}
|
||||
String function = allMIBreakpoints[i].getFunction();
|
||||
String file = allMIBreakpoints[i].getFile();
|
||||
int line = allMIBreakpoints[i].getLine();
|
||||
String addr = allMIBreakpoints[i].getAddress();
|
||||
boolean enabled = allMIBreakpoints[i].isEnabled();
|
||||
|
||||
if (file != null && file.length() > 0 && line > 0) {
|
||||
if (hint == MIBreakpointChangedEvent.HINT_NEW_LINE_BREAKPOINT ||
|
||||
(hint == MIBreakpointChangedEvent.HINT_NONE && file != null && file.length() > 0 && line > 0)) {
|
||||
LineLocation location = createLineLocation (allMIBreakpoints[i].getFile(),
|
||||
allMIBreakpoints[i].getLine());
|
||||
// By default new breakpoint are LineBreakpoint
|
||||
Breakpoint newBreakpoint = new LineBreakpoint(target, type, location, condition, enabled);
|
||||
newBreakpoint.setMIBreakpoints(new MIBreakpoint[] {allMIBreakpoints[i]});
|
||||
bList.add(newBreakpoint);
|
||||
} else if (function != null && function.length() > 0) {
|
||||
} else if (hint == MIBreakpointChangedEvent.HINT_NEW_FUNCTION_BREAKPOINT ||
|
||||
(hint == MIBreakpointChangedEvent.HINT_NONE && function != null && function.length() > 0)) {
|
||||
FunctionLocation location = createFunctionLocation(file, function);
|
||||
// By default new breakpoint are LineBreakpoint
|
||||
Breakpoint newBreakpoint = new FunctionBreakpoint(target, type, location, condition, enabled);
|
||||
newBreakpoint.setMIBreakpoints(new MIBreakpoint[] {allMIBreakpoints[i]});
|
||||
bList.add(newBreakpoint);
|
||||
} else if (addr != null && addr.length() > 0) {
|
||||
} else if (hint == MIBreakpointChangedEvent.HINT_NEW_ADDRESS_BREAKPOINT ||
|
||||
(hint == MIBreakpointChangedEvent.HINT_NONE && addr != null && addr.length() > 0)) {
|
||||
BigInteger big = MIFormat.getBigInteger(addr);
|
||||
AddressLocation location = createAddressLocation (big);
|
||||
// By default new breakpoint are LineBreakpoint
|
||||
Breakpoint newBreakpoint = new AddressBreakpoint(target, type, location, condition, enabled);
|
||||
newBreakpoint.setMIBreakpoints(new MIBreakpoint[] {allMIBreakpoints[i]});
|
||||
bList.add(newBreakpoint);
|
||||
|
|
|
@ -126,10 +126,10 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
if (bpoint.getNumber() > 0) {
|
||||
cdiList.add(new ChangedEvent(session, bpoint));
|
||||
} else {
|
||||
// Something change we do not know what
|
||||
// Let the breakpoint manager handle it with an update().
|
||||
try {
|
||||
session.getBreakpointManager().update(currentTarget);
|
||||
// Pass the event to access to the event's hint
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=135250
|
||||
session.getBreakpointManager().update(currentTarget, miEvent);
|
||||
} catch (CDIException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
package org.eclipse.cdt.debug.mi.core;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
|
||||
|
@ -47,7 +49,8 @@ public class CLIProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
void processStateChanges(int token, String operation) {
|
||||
void processStateChanges(int token, String op) {
|
||||
String operation = op;
|
||||
// Get the command name.
|
||||
int indx = operation.indexOf(' ');
|
||||
if (indx != -1) {
|
||||
|
@ -83,8 +86,9 @@ public class CLIProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
void processSettingChanges(int token, String operation) {
|
||||
void processSettingChanges(int token, String command) {
|
||||
// Get the command name.
|
||||
String operation = command;
|
||||
int indx = operation.indexOf(' ');
|
||||
if (indx != -1) {
|
||||
operation = operation.substring(0, indx).trim();
|
||||
|
@ -100,7 +104,14 @@ public class CLIProcessor {
|
|||
isDeletingBreakpoint(operation)) {
|
||||
// We know something change, we just do not know what.
|
||||
// So the easiest way is to let the top layer handle it.
|
||||
session.fireEvent(new MIBreakpointChangedEvent(session, 0));
|
||||
// But we can parse the command line to hint the top layer
|
||||
// on the breakpoint type.
|
||||
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=135250
|
||||
int hint = MIBreakpointChangedEvent.HINT_NONE;
|
||||
if (isSettingBreakpoint(operation)) {
|
||||
hint = getBreakpointHint(command);
|
||||
}
|
||||
session.fireEvent(new MIBreakpointChangedEvent(session, 0, hint));
|
||||
} else if (isSettingSignal(operation)) {
|
||||
// We do no know which signal let the upper layer find it.
|
||||
session.fireEvent(new MISignalChangedEvent(session, "")); //$NON-NLS-1$
|
||||
|
@ -201,6 +212,41 @@ public class CLIProcessor {
|
|||
return isChange;
|
||||
}
|
||||
|
||||
int getBreakpointHint(String command) {
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
// get operation
|
||||
String op = st.nextToken();
|
||||
if (op.startsWith("rb") && "rbreak".indexOf(op) != -1) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// only function breakpoints can be set using rbreak
|
||||
return MIBreakpointChangedEvent.HINT_NEW_FUNCTION_BREAKPOINT;
|
||||
}
|
||||
if ( !st.hasMoreTokens() ) {
|
||||
// "break" with no arguments
|
||||
return MIBreakpointChangedEvent.HINT_NEW_LINE_BREAKPOINT;
|
||||
}
|
||||
String token = st.nextToken();
|
||||
if ("if".equals(token) || "ignore".equals(token) || token.charAt(0) == '+' || token.charAt(0) == '-') { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// conditional "break" with no location argument
|
||||
// or "break +/- offset"
|
||||
return MIBreakpointChangedEvent.HINT_NEW_LINE_BREAKPOINT;
|
||||
}
|
||||
if (token.charAt(0) == '*') {
|
||||
return MIBreakpointChangedEvent.HINT_NEW_ADDRESS_BREAKPOINT;
|
||||
}
|
||||
int index = token.lastIndexOf( ':' );
|
||||
String lineNumber = token;
|
||||
if (index != -1 && index+1 < token.length()) {
|
||||
lineNumber = token.substring(index+1, token.length());
|
||||
}
|
||||
try {
|
||||
Integer.parseInt( lineNumber );
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
return MIBreakpointChangedEvent.HINT_NEW_FUNCTION_BREAKPOINT;
|
||||
}
|
||||
return MIBreakpointChangedEvent.HINT_NEW_LINE_BREAKPOINT;
|
||||
}
|
||||
|
||||
boolean isSettingSignal(String operation) {
|
||||
boolean isChange = false;
|
||||
/* changing signal: handle, signal */
|
||||
|
@ -217,6 +263,4 @@ public class CLIProcessor {
|
|||
boolean isDetach(String operation) {
|
||||
return (operation.startsWith("det") && "detach".indexOf(operation) != -1); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,26 +12,40 @@ package org.eclipse.cdt.debug.mi.core.event;
|
|||
|
||||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class MIBreakpointChangedEvent extends MIChangedEvent {
|
||||
|
||||
int no;
|
||||
/**
|
||||
* We need these flags to notify the upper layer what kind of a breakpoint
|
||||
* has been set from the console.
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=135250
|
||||
*/
|
||||
public static final int HINT_NONE = 0;
|
||||
public static final int HINT_NEW_LINE_BREAKPOINT = 1;
|
||||
public static final int HINT_NEW_FUNCTION_BREAKPOINT = 2;
|
||||
public static final int HINT_NEW_ADDRESS_BREAKPOINT = 3;
|
||||
|
||||
int no = 0;
|
||||
int hint = HINT_NONE;
|
||||
|
||||
public MIBreakpointChangedEvent(MISession source, int number) {
|
||||
this(source, 0, number);
|
||||
this(source, 0, number, 0);
|
||||
}
|
||||
|
||||
public MIBreakpointChangedEvent(MISession source, int id, int number) {
|
||||
public MIBreakpointChangedEvent(MISession source, int number, int hint) {
|
||||
this(source, 0, number, hint);
|
||||
}
|
||||
|
||||
public MIBreakpointChangedEvent(MISession source, int id, int number, int hint) {
|
||||
super(source, id);
|
||||
no = number;
|
||||
this.no = number;
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return no;
|
||||
}
|
||||
|
||||
public int getHint() {
|
||||
return hint;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue