blob: d36b71a20d826c1990f5480f27a47ba7ae703a54 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. 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:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.internal.tcf.cdt.ui;
import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
import org.eclipse.cdt.debug.core.model.ITargetProperties;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
* Integrates the TCF model with the "Instruction Stepping Mode" button from CDT.
*/
@SuppressWarnings("deprecation")
public class TCFSteppingModeTarget implements ISteppingModeTarget, ITargetProperties {
private final Preferences fPreferences;
private final TCFModel fModel;
public TCFSteppingModeTarget(TCFModel model) {
fPreferences= new Preferences();
fPreferences.setDefault(PREF_INSTRUCTION_STEPPING_MODE, model.isInstructionSteppingEnabled());
fModel = model;
}
public void addPropertyChangeListener(IPropertyChangeListener listener) {
fPreferences.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(IPropertyChangeListener listener) {
fPreferences.removePropertyChangeListener(listener);
}
public boolean supportsInstructionStepping() {
return true;
}
public void enableInstructionStepping(boolean enabled) {
fPreferences.setValue(PREF_INSTRUCTION_STEPPING_MODE, enabled);
fModel.setInstructionSteppingEnabled(enabled);
// switch to disassembly or source
forceSourceDisplay(DebugUITools.getDebugContext());
}
private void forceSourceDisplay(IAdaptable debugContext) {
ISourceDisplay sourceDisplay = (ISourceDisplay) debugContext.getAdapter(ISourceDisplay.class);
if (sourceDisplay != null) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
sourceDisplay.displaySource(debugContext, page, true);
}
}
}
}
public boolean isInstructionSteppingEnabled() {
return fPreferences.getBoolean(PREF_INSTRUCTION_STEPPING_MODE);
}
}
|