Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 237306 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java (-2 / +8 lines)
Lines 649-655 Link Here
649
    	rm.done();
649
    	rm.done();
650
    }
650
    }
651
    
651
    
652
    private boolean doIsDebuggerAttachSupported() {
652
    /**
653
	 * @since 4.0
654
	 */
655
    protected boolean doIsDebuggerAttachSupported() {
653
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
656
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
654
    	if (backend != null) {
657
    	if (backend != null) {
655
    		return backend.getIsAttachSession();
658
    		return backend.getIsAttachSession();
Lines 689-695 Link Here
689
	    }
692
	    }
690
	}
693
	}
691
694
692
    private boolean doCanDetachDebuggerFromProcess() {
695
    /**
696
	 * @since 4.0
697
	 */
698
    protected boolean doCanDetachDebuggerFromProcess() {
693
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
699
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
694
    	if (backend != null) {
700
    	if (backend != null) {
695
    		return backend.getIsAttachSession() && fCommandControl.isConnected();
701
    		return backend.getIsAttachSession() && fCommandControl.isConnected();
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (+132 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Ericsson - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.service;
12
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
15
import org.eclipse.cdt.dsf.datamodel.DMContexts;
16
import org.eclipse.cdt.dsf.datamodel.IDMContext;
17
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
18
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
19
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
20
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
21
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
22
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
23
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
24
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
25
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
26
import org.eclipse.cdt.dsf.service.DsfSession;
27
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.core.runtime.Status;
29
30
/**
31
 * @since 4.0
32
 */
33
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
34
35
    private CommandFactory fCommandFactory;
36
    private IGDBControl fCommandControl;
37
    
38
	public GDBProcesses_7_2(DsfSession session) {
39
		super(session);
40
	}
41
42
	@Override
43
	public void initialize(final RequestMonitor requestMonitor) {
44
		super.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
45
			@Override
46
			protected void handleSuccess() {
47
				doInitialize(requestMonitor);
48
			}
49
		});
50
	}
51
52
	/**
53
	 * This method initializes this service after our superclass's initialize()
54
	 * method succeeds.
55
	 * 
56
	 * @param requestMonitor
57
	 *            The call-back object to notify when this service's
58
	 *            initialization is done.
59
	 */
60
	private void doInitialize(RequestMonitor requestMonitor) {
61
		fCommandControl = getServicesTracker().getService(IGDBControl.class);
62
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
63
        requestMonitor.done();
64
	}
65
66
	@Override
67
	public void shutdown(RequestMonitor requestMonitor) {
68
		super.shutdown(requestMonitor);
69
	}
70
71
	@Override
72
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
73
		if (procCtx instanceof IMIProcessDMContext) {
74
	    	if (!doIsDebuggerAttachSupported()) {
75
	            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
76
	            rm.done();    		
77
	    		return;
78
	    	}
79
	    	
80
	    	ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, ICommandControlDMContext.class);
81
	        fCommandControl.queueCommand(
82
	        		fCommandFactory.createMIAddInferior(controlDmc),
83
	        		new DataRequestMonitor<MIAddInferiorInfo>(getExecutor(), rm) {
84
	        			@Override
85
	        			protected void handleSuccess() {
86
	        				final String groupId = getData().getGroupId();
87
	        				if (groupId == null || groupId.trim().length() == 0) {
88
     				           rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid gdb group id.", null)); //$NON-NLS-1$
89
    				           rm.done();
90
    				           return;
91
        					}
92
	        				
93
	        				final IMIContainerDMContext containerDmc = createContainerContext(procCtx, groupId);
94
	        				fCommandControl.queueCommand(
95
	        						fCommandFactory.createMITargetAttach(containerDmc, ((IMIProcessDMContext)procCtx).getProcId()),
96
	        						new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
97
	        							@Override
98
	        							protected void handleSuccess() {
99
	        								rm.setData(containerDmc);
100
	        								rm.done();
101
	        							}
102
	        						});
103
	        			}
104
	        		});
105
	    } else {
106
            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
107
            rm.done();
108
	    }
109
	}
110
	
111
	@Override
112
    public void detachDebuggerFromProcess(IDMContext dmc, final RequestMonitor rm) {
113
    	
114
		IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class);
115
116
    	if (containerDmc != null) {
117
        	if (!doCanDetachDebuggerFromProcess()) {
118
                rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Detach not supported.", null)); //$NON-NLS-1$
119
                rm.done();
120
                return;
121
        	}
122
123
        	fCommandControl.queueCommand(
124
        			fCommandFactory.createMITargetDetach(containerDmc),
125
    				new DataRequestMonitor<MIInfo>(getExecutor(), rm));
126
    	} else {
127
            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); //$NON-NLS-1$
128
            rm.done();
129
	    }
130
	}
131
}
132
(-)src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java (+3 lines)
Lines 139-144 Link Here
139
		
139
		
140
	@Override
140
	@Override
141
	protected IProcesses createProcessesService(DsfSession session) {
141
	protected IProcesses createProcessesService(DsfSession session) {
142
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) {
143
			return new GDBProcesses_7_2(session);
144
		}
142
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
145
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
143
			return new GDBProcesses_7_1(session);
146
			return new GDBProcesses_7_1(session);
144
		}
147
		}
(-)src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java (+15 lines)
Lines 27-32 Link Here
27
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
27
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
28
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
28
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
29
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
29
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceTargetDMContext;
30
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
30
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
31
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
31
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIAttach;
32
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIAttach;
32
import org.eclipse.cdt.dsf.mi.service.command.commands.CLICatch;
33
import org.eclipse.cdt.dsf.mi.service.command.commands.CLICatch;
Lines 667-676 Link Here
667
		return new MITargetAttach(ctx, groupId);
668
		return new MITargetAttach(ctx, groupId);
668
	}
669
	}
669
670
671
	/**
672
	 * @since 4.0
673
	 */
674
	public ICommand<MIInfo> createMITargetAttach(IMIContainerDMContext ctx, String groupId) {
675
		return new MITargetAttach(ctx, groupId);
676
	}
677
670
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
678
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
671
		return new MITargetDetach(ctx, groupId);
679
		return new MITargetDetach(ctx, groupId);
672
	}
680
	}
673
681
682
	/**
683
	 * @since 4.0
684
	 */
685
	public ICommand<MIInfo> createMITargetDetach(IMIContainerDMContext ctx) {
686
		return new MITargetDetach(ctx);
687
	}
688
674
    public ICommand<MIInfo> createMITargetSelect(IDMContext ctx, String[] params) {
689
    public ICommand<MIInfo> createMITargetSelect(IDMContext ctx, String[] params) {
675
        return new MITargetSelect(ctx, params);
690
        return new MITargetSelect(ctx, params);
676
    }
691
    }
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Ericsson and others.
2
 * Copyright (c) 2008, 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
12
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
16
16
/**
17
/**
Lines 25-28 Link Here
25
	public MITargetAttach(ICommandControlDMContext ctx, String groupId) {
26
	public MITargetAttach(ICommandControlDMContext ctx, String groupId) {
26
		super(ctx, "-target-attach", new String[] {groupId}); //$NON-NLS-1$
27
		super(ctx, "-target-attach", new String[] {groupId}); //$NON-NLS-1$
27
	}
28
	}
29
	
30
	/**
31
	 * @since 4.0
32
	 */
33
	public MITargetAttach(IMIContainerDMContext ctx, String pid) {
34
		super(ctx, "-target-attach", new String[] {"--thread-group", ctx.getGroupId()}, new String[] {pid}); //$NON-NLS-1$ //$NON-NLS-2$
35
	}
28
}
36
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetDetach.java (+8 lines)
Lines 11-16 Link Here
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
12
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
16
16
/**
17
/**
Lines 25-28 Link Here
25
	public MITargetDetach(ICommandControlDMContext ctx, String groupId) {
26
	public MITargetDetach(ICommandControlDMContext ctx, String groupId) {
26
		super(ctx, "-target-detach", new String[] {groupId}); //$NON-NLS-1$
27
		super(ctx, "-target-detach", new String[] {groupId}); //$NON-NLS-1$
27
	}
28
	}
29
	
30
	/**
31
	 * @since 4.0
32
	 */
33
	public MITargetDetach(IMIContainerDMContext ctx) {
34
		super(ctx, "-target-detach", new String[] {"--thread-group", ctx.getGroupId()}); //$NON-NLS-1$ //$NON-NLS-2$
35
	}
28
}
36
}

Return to bug 237306