1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 284286: Missing action to exit trace visualization mode.

This commit is contained in:
Marc Khouzam 2010-05-20 15:26:17 +00:00
parent d40ae2e41d
commit 75a65c4f96
14 changed files with 229 additions and 38 deletions

View file

@ -25,6 +25,8 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceStatusDMData;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceVariableDMData;
@ -111,6 +113,21 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
}
}
private final class ActionExitVisualizationModeDetails extends Action {
public ActionExitVisualizationModeDetails() {
setText(TracepointsMessages.TraceControlView_action_exit_visualization_mode);
setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Exit_Visualization));
}
@Override
public void run() {
asyncExec(new Runnable() {
public void run() {
exitVisualizationMode();
updateActionEnablement();
}});
}
}
private ISelectionListener fDebugViewListener;
private String fDebugSessionId;
private DsfServicesTracker fServicesTracker;
@ -119,8 +136,11 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
private StyledText fStatusText;
protected Action fActionRefreshView;
protected Action fOpenTraceVarDetails;
protected Action fActionExitVisualization;
private boolean fTracingSupported;
private boolean fTraceVisualization;
public TraceControlView() {
}
@ -176,6 +196,10 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
fOpenTraceVarDetails = new ActionOpenTraceVarDetails();
manager.add(fOpenTraceVarDetails);
// Create the action to exit visualization mode
fActionExitVisualization = new ActionExitVisualizationModeDetails();
manager.add(fActionExitVisualization);
bars.updateActionBars();
updateActionEnablement();
}
@ -242,7 +266,38 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
return EMPTY_STRING;
}
protected void exitVisualizationMode() {
if (fDebugSessionId == null || getSession() == null) {
return;
}
final ITraceTargetDMContext ctx = DMContexts.getAncestorOfType(fTargetContext, ITraceTargetDMContext.class);
if (ctx == null) {
return;
}
Query<Object> query = new Query<Object>() {
@Override
protected void execute(DataRequestMonitor<Object> rm) {
final IGDBTraceControl traceControl = getService(IGDBTraceControl.class);
if (traceControl != null) {
ITraceRecordDMContext emptyDmc = traceControl.createTraceRecordContext(ctx, -1);
traceControl.selectTraceRecord(emptyDmc, rm);
} else {
rm.setData(null);
rm.done();
}
}
};
try {
getSession().getExecutor().execute(query);
query.get();
} catch (InterruptedException exc) {
} catch (ExecutionException exc) {
}
}
protected void updateDebugContext() {
IAdaptable debugContext = DebugUITools.getDebugContext();
if (debugContext instanceof IDMVMContext) {
@ -322,12 +377,17 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
}
protected void updateActionEnablement() {
enableActions(fTracingSupported);
}
protected void enableActions(boolean enabled) {
fOpenTraceVarDetails.setEnabled(enabled);
fActionRefreshView.setEnabled(enabled);
fOpenTraceVarDetails.setEnabled(fTracingSupported);
fActionRefreshView.setEnabled(fTracingSupported);
// This hack is to avoid adding an API late in the release.
// For the next release, we should have a proper call to know if
// we can stop visualization or not
if (fStatusText != null && fStatusText.getText().toLowerCase().indexOf("off-line") != -1) { //$NON-NLS-1$
fActionExitVisualization.setEnabled(false);
} else {
fActionExitVisualization.setEnabled(fTraceVisualization);
}
}
private void asyncExec(Runnable runnable) {
@ -361,6 +421,15 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
updateContent();
}
@DsfServiceEventHandler
public void handleEvent(ITraceRecordSelectedChangedDMEvent event) {
if (event.isVisualizationModeEnabled()) {
fTraceVisualization = true;
} else {
fTraceVisualization = false;
}
updateContent();
}
/*
* Since something suspended, might as well refresh our status
* to show the latest.
@ -480,14 +549,14 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde
}
FailedTraceVariableCreationException e =
new FailedTraceVariableCreationException(message);
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Backend error", e));
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Backend error", e)); //$NON-NLS-1$
rm.done();
};
});
} else {
FailedTraceVariableCreationException e =
new FailedTraceVariableCreationException(TracepointsMessages.TraceControlView_trace_variable_tracing_unavailable);
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Tracing unavailable", e));
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Tracing unavailable", e)); //$NON-NLS-1$
rm.done();
}
}

View file

@ -36,6 +36,8 @@ public class TracepointImageRegistry extends AbstractImageRegistry {
public static final String ICON_Refresh_enabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/elcl16"}, "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String ICON_Refresh_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/dlcl16"}, "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String ICON_Trace_Variables = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "tracevariables.gif"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String ICON_Exit_Visualization = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "stop_visual_trace.gif"); //$NON-NLS-1$ //$NON-NLS-2$
private static TracepointImageRegistry INSTANCE= new TracepointImageRegistry(GdbUIPlugin.getDefault());
TracepointImageRegistry(Plugin plugin) {

View file

@ -17,8 +17,6 @@ import org.eclipse.osgi.util.NLS;
*/
public final class TracepointsMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.dsf.gdb.internal.ui.tracepoints.TracepointsMessages";//$NON-NLS-1$
private TracepointsMessages() {
// Do not instantiate
}
@ -38,8 +36,9 @@ public final class TracepointsMessages extends NLS {
public static String TraceControlView_trace_variable_details_value_label;
public static String TraceControlView_create_variable_error;
public static String TraceControlView_create_variable_empty_name_error;
public static String TraceControlView_action_exit_visualization_mode;
static {
NLS.initializeMessages(BUNDLE_NAME, TracepointsMessages.class);
NLS.initializeMessages(TracepointsMessages.class.getName(), TracepointsMessages.class);
}
}

View file

@ -23,4 +23,5 @@ TraceControlView_trace_variable_details_create_button=Create
TraceControlView_trace_variable_details_name_label=Name:
TraceControlView_trace_variable_details_value_label=Value:
TraceControlView_create_variable_error=Error creating trace variable
TraceControlView_create_variable_empty_name_error=Cannot create variable with empty name
TraceControlView_create_variable_empty_name_error=Cannot create variable with empty name
TraceControlView_action_exit_visualization_mode=Exit Visualization Mode

View file

@ -22,11 +22,11 @@ import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
@ -607,9 +607,14 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
*/
@DsfServiceEventHandler
public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
// We have started looking at trace records. We can no longer
// do run control operations.
fRunControlOperationsEnabled = false;
if (e.isVisualizationModeEnabled()) {
// We have started looking at trace records. We can no longer
// do run control operations.
fRunControlOperationsEnabled = false;
} else {
// We stopped looking at trace data and gone back to debugger mode
fRunControlOperationsEnabled = true;
}
}
/** @since 2.0 */

View file

@ -319,9 +319,16 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
public static class TraceRecordSelectedChangedEvent extends AbstractDMEvent<ITraceRecordDMContext>
implements ITraceRecordSelectedChangedDMEvent {
final boolean fVisualModeEnabled;
public TraceRecordSelectedChangedEvent(ITraceRecordDMContext context) {
super(context);
fVisualModeEnabled = !(context instanceof InvalidTraceRecordDMContext);
}
public boolean isVisualizationModeEnabled() {
return fVisualModeEnabled;
}
}
private CommandCache fTraceCache;
@ -838,8 +845,16 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
if (context instanceof MITraceRecordDMContext) {
ITraceTargetDMContext targetDmc = DMContexts.getAncestorOfType(context, ITraceTargetDMContext.class);
final int reference = ((MITraceRecordDMContext)context).getReference();
if (reference < 0) {
// This is how we indicate that we want to exit visualization mode
// We should have a specific call in the IGDBTraceControl interface to do this.
stopVisualizingTraceData(targetDmc, rm);
return;
}
fConnection.queueCommand(
fCommandFactory.createMITraceFind(targetDmc, ((MITraceRecordDMContext)context).getReference()),
fCommandFactory.createMITraceFindFrameNumber(targetDmc, reference),
new DataRequestMonitor<MITraceFindInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
@ -935,7 +950,37 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
}
}
private void stopVisualizingTraceData(final ITraceTargetDMContext context, final RequestMonitor rm) {
if (fIsTracingCurrentlySupported == false) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Tracing not supported", null)); //$NON-NLS-1$
rm.done();
return;
}
if (fBackend.getSessionType() == SessionType.CORE) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Cannot stop visualizing for a post mortem session", null)); //$NON-NLS-1$
rm.done();
return;
}
fConnection.queueCommand(
fCommandFactory.createMITraceFindNone(context),
new DataRequestMonitor<MITraceFindInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
assert getData().isFound() == false;
fCurrentRecordDmc = null;
// This event will indicate to the other services that we are no longer visualizing trace data.
ITraceRecordDMContext invalidDmc = new InvalidTraceRecordDMContext(getSession(), context);
getSession().dispatchEvent(new TraceRecordSelectedChangedEvent(invalidDmc), getProperties());
rm.done();
return;
}
});
}
public void getTraceRecordData(ITraceRecordDMContext context, DataRequestMonitor<ITraceRecordDMData> rm) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not implemented.", null)); //$NON-NLS-1$
rm.done();

View file

@ -56,7 +56,9 @@ public interface IGDBTraceControl extends IDsfService {
}
public interface ITracingStartedDMEvent extends IDMEvent<ITraceTargetDMContext> {}
public interface ITracingStoppedDMEvent extends IDMEvent<ITraceTargetDMContext> {}
public interface ITraceRecordSelectedChangedDMEvent extends IDMEvent<ITraceRecordDMContext> {}
public interface ITraceRecordSelectedChangedDMEvent extends IDMEvent<ITraceRecordDMContext> {
boolean isVisualizationModeEnabled();
}
/**
* Returns whether tracing can be started on the specified trace target

View file

@ -611,12 +611,18 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
/** @since 3.0 */
@DsfServiceEventHandler
public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
// Once we start looking at trace frames, we should not use
// the --thread or --frame options because GDB does not handle
// it well, there are no actual threads running.
// We only need to do this once, but it won't hurt to do it
// every time.
setUseThreadAndFrameOptions(false);
if (e.isVisualizationModeEnabled()) {
// Once we start looking at trace frames, we should not use
// the --thread or --frame options because GDB does not handle
// it well, there are no actual threads running.
// We only need to do this once, but it won't hurt to do it
// every time.
setUseThreadAndFrameOptions(false);
} else {
// We stopped looking at trace frames, so we can start
// using --thread and --frame again
setUseThreadAndFrameOptions(true);
}
}
public static class InitializationShutdownStep extends Sequence.Step {

View file

@ -1030,9 +1030,11 @@ public class MIExpressions extends AbstractDsfService implements IExpressions2,
/** @since 3.0 */
@DsfServiceEventHandler
public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
// Once we start looking at a trace record, we remain in
// trace visualization mode.
fTraceVisualization = true;
if (e.isVisualizationModeEnabled()) {
fTraceVisualization = true;
} else {
fTraceVisualization = false;
}
}
/**

View file

@ -1004,10 +1004,14 @@ public class MIStack extends AbstractDsfService
/** @since 3.0 */
@DsfServiceEventHandler
public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
// Once we start looking at a trace record, we remain in
// trace visualization mode.
fTraceVisualization = true;
if (e.isVisualizationModeEnabled()) {
fTraceVisualization = true;
} else {
fTraceVisualization = false;
fCachedStoppedEvent = null;
}
}
/**
* {@inheritDoc}
* @since 1.1

View file

@ -108,6 +108,8 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIThreadListIds;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIThreadSelect;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceDefineVariable;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceFind;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceFindFrameNumber;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceFindNone;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceListVariables;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceSave;
import org.eclipse.cdt.dsf.mi.service.command.commands.MITraceStart;
@ -682,10 +684,16 @@ public class CommandFactory {
public ICommand<MIInfo> createMITraceDefineVariable(ITraceTargetDMContext ctx, String varName, String varValue) {
return new MITraceDefineVariable(ctx, varName, varValue);
}
public ICommand<MITraceFindInfo> createMITraceFind(ITraceTargetDMContext ctx, int frameReference) {
return new MITraceFind(ctx, frameReference);
}
public ICommand<MITraceFindInfo> createMITraceFind(ITraceTargetDMContext ctx, String[] params) {
return new MITraceFind(ctx, params);
}
public ICommand<MITraceFindInfo> createMITraceFindFrameNumber(ITraceTargetDMContext ctx, int frameReference) {
return new MITraceFindFrameNumber(ctx, frameReference);
}
public ICommand<MITraceFindInfo> createMITraceFindNone(ITraceTargetDMContext ctx) {
return new MITraceFindNone(ctx);
}
public ICommand<MITraceListVariablesInfo> createMITraceListVariables(ITraceTargetDMContext ctx) {
return new MITraceListVariables(ctx);

View file

@ -51,8 +51,8 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MITraceFindInfo;
* @since 3.0
*/
public class MITraceFind extends MICommand<MITraceFindInfo> {
public MITraceFind(ITraceTargetDMContext ctx, int frameReference) {
super(ctx, "-trace-find", null, new String[] { "frame-number", Integer.toString(frameReference) }); //$NON-NLS-1$ //$NON-NLS-2$
public MITraceFind(ITraceTargetDMContext ctx, String[] params) {
super(ctx, "-trace-find", null, params); //$NON-NLS-1$
}
@Override

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2010 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ericsson - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.commands;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
/**
* -trace-find frame-number FRAME
*
* @since 3.0
*/
public class MITraceFindFrameNumber extends MITraceFind {
public MITraceFindFrameNumber(ITraceTargetDMContext ctx, int frameReference) {
super(ctx, new String[] { "frame-number", Integer.toString(frameReference) }); //$NON-NLS-1$
}
}

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2010 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ericsson - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.commands;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
/**
* -trace-find none
*
* @since 3.0
*/
public class MITraceFindNone extends MITraceFind {
public MITraceFindNone(ITraceTargetDMContext ctx) {
super(ctx, new String[] { "none" }); //$NON-NLS-1$
}
}