mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
[248606] Add support for toggling watchpoints in the variables and expressions views.
This commit is contained in:
parent
8a6292bcf4
commit
d8ba081c40
7 changed files with 86 additions and 25 deletions
|
@ -56,4 +56,16 @@ public class CRequest implements IRequest {
|
|||
public void setStatus(IStatus status) {
|
||||
fStatus= status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the request completed successfully or not. If the request
|
||||
* monitor was canceled it is considered a failure, regardless of the
|
||||
* status. If the status has a severity higher than INFO (i.e., WARNING,
|
||||
* ERROR or CANCEL), it is considered a failure. Note that as per IRequest
|
||||
* documentation, a null status object is equivalent to IStatu#OK.
|
||||
*/
|
||||
public boolean isSuccess() {
|
||||
IStatus status = getStatus();
|
||||
return !isCanceled() && (status == null || status.getSeverity() <= IStatus.INFO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ AddWatchpointDialog.3=Write
|
|||
AddWatchpointDialog.4=Read
|
||||
AddWatchpointDialog.5=Memory space:
|
||||
AddWatchpointDialog.6=Units:
|
||||
AddWatchpointOnVariableActionDelegate.No_Element_Size=Failed to get variable/expression size
|
||||
AddWatchpointOnVariableActionDelegate.Error_Dlg_Title=Error
|
||||
ResumeAtLineAdapter.0=Empty editor
|
||||
ResumeAtLineAdapter.1=Missing document
|
||||
ResumeAtLineAdapter.2=Empty editor
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeSelection;
|
||||
|
@ -33,11 +34,12 @@ import org.eclipse.ui.progress.WorkbenchJob;
|
|||
*/
|
||||
public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate implements IObjectActionDelegate {
|
||||
|
||||
/**
|
||||
* The target variable/expression
|
||||
*/
|
||||
/** The target variable/expression */
|
||||
private ICWatchpointTarget fVar;
|
||||
|
||||
/** The view where fVar was selected */
|
||||
private IWorkbenchPart fActivePart;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -49,7 +51,7 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe
|
|||
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
|
||||
*/
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
// Don't care. Our logic is agnostic to the view we're invoked from.
|
||||
fActivePart = targetPart;
|
||||
}
|
||||
|
||||
private static class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest {
|
||||
|
@ -81,26 +83,40 @@ public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDe
|
|||
// synchronously)
|
||||
final ICWatchpointTarget.GetSizeRequest request = new GetSizeRequest() {
|
||||
public void done() {
|
||||
// Now that we have the size, put up a dialog to create the watchpoint
|
||||
final int size = getSize();
|
||||
assert size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$
|
||||
WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(),
|
||||
getMemorySpaceManagement());
|
||||
dlg.setExpression(expr);
|
||||
dlg.initializeRange(false, Integer.toString(size));
|
||||
if (dlg.open() == Window.OK) {
|
||||
addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
|
||||
if (isSuccess()) {
|
||||
// Now that we have the size, put up a dialog to create the watchpoint
|
||||
final int size = getSize();
|
||||
assert size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$
|
||||
WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(),
|
||||
getMemorySpaceManagement());
|
||||
dlg.setExpression(expr);
|
||||
dlg.initializeRange(false, Integer.toString(size));
|
||||
if (dlg.open() == Window.OK) {
|
||||
addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setSystem(true);
|
||||
job.schedule();
|
||||
};
|
||||
job.setSystem(true);
|
||||
job.schedule();
|
||||
}
|
||||
else {
|
||||
WorkbenchJob job = new WorkbenchJob("watchpoint error") { //$NON-NLS-1$
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
if (fActivePart != null) {
|
||||
ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "AddWatchpointOnVariableActionDelegate.Error_Dlg_Title" ), ActionMessages.getString( "AddWatchpointOnVariableActionDelegate.No_Element_Size" ), getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setSystem(true);
|
||||
job.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
fVar.getSize(request);
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
|
|||
@Override
|
||||
public void done() {
|
||||
fCallback.setUpdatePending(false);
|
||||
if (!isCanceled()) {
|
||||
if (isSuccess()) {
|
||||
BigInteger address= getAddress();
|
||||
if (targetFrame == 0) {
|
||||
fCallback.updatePC(address);
|
||||
|
@ -269,7 +269,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
|
|||
final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new DisassemblyRequest() {
|
||||
@Override
|
||||
public void done() {
|
||||
if (!isCanceled() && getDisassemblyBlock() != null) {
|
||||
if (isSuccess() && getDisassemblyBlock() != null) {
|
||||
insertDisassembly(startAddress, getDisassemblyBlock(), mixed, showSymbols, showDisassembly);
|
||||
} else {
|
||||
final IStatus status= getStatus();
|
||||
|
@ -381,7 +381,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
|
|||
final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new DisassemblyRequest() {
|
||||
@Override
|
||||
public void done() {
|
||||
if (!isCanceled() && getDisassemblyBlock() != null) {
|
||||
if (isSuccess() && getDisassemblyBlock() != null) {
|
||||
insertDisassembly(null, getDisassemblyBlock(), mixed, showSymbols, showDisassembly);
|
||||
} else {
|
||||
final IStatus status= getStatus();
|
||||
|
|
|
@ -19,9 +19,11 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
|
|||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
/**
|
||||
* Specialization of DSF's VariableVMNode. See
|
||||
|
@ -70,6 +72,7 @@ public class GdbVariableVMNode extends VariableVMNode {
|
|||
if (isSuccess()) {
|
||||
request.setSize(getData().getSize());
|
||||
}
|
||||
request.setStatus(getStatus());
|
||||
request.done();
|
||||
}
|
||||
};
|
||||
|
@ -77,12 +80,14 @@ public class GdbVariableVMNode extends VariableVMNode {
|
|||
expressionService.getExpressionAddressData(exprDmc, drm);
|
||||
}
|
||||
else {
|
||||
request.setStatus(internalError());
|
||||
request.done();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
request.setStatus(internalError());
|
||||
request.done();
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +113,7 @@ public class GdbVariableVMNode extends VariableVMNode {
|
|||
assert getData().getSize() > 0;
|
||||
request.setCanCreate(true);
|
||||
}
|
||||
request.setStatus(getStatus());
|
||||
request.done();
|
||||
}
|
||||
};
|
||||
|
@ -115,17 +121,25 @@ public class GdbVariableVMNode extends VariableVMNode {
|
|||
expressionService.getExpressionAddressData(exprDmc, drm);
|
||||
}
|
||||
else {
|
||||
request.setStatus(internalError());
|
||||
request.done();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
request.setStatus(internalError());
|
||||
request.done();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility method to create an IStatus object for an internal error
|
||||
*/
|
||||
private static Status internalError() {
|
||||
return new Status(Status.ERROR, GdbUIPlugin.getUniqueIdentifier(), Messages.Internal_Error);
|
||||
}
|
||||
/**
|
||||
* Constructor (passthru)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
|
||||
public class Messages extends NLS {
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {}
|
||||
|
||||
public static String Internal_Error;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Internal_Error=Internal Error
|
Loading…
Add table
Reference in a new issue