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 (-1 / +1 lines)
Lines 649-655 Link Here
649
    	rm.done();
649
    	rm.done();
650
    }
650
    }
651
    
651
    
652
    private boolean doIsDebuggerAttachSupported() {
652
    protected boolean doIsDebuggerAttachSupported() {
653
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
653
    	IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
654
    	if (backend != null) {
654
    	if (backend != null) {
655
    		return backend.getIsAttachSession();
655
    		return backend.getIsAttachSession();
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (+108 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
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
31
32
    private CommandFactory fCommandFactory;
33
    private IGDBControl fCommandControl;
34
    
35
	public GDBProcesses_7_2(DsfSession session) {
36
		super(session);
37
	}
38
39
	@Override
40
	public void initialize(final RequestMonitor requestMonitor) {
41
		super.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
42
			@Override
43
			protected void handleSuccess() {
44
				doInitialize(requestMonitor);
45
			}
46
		});
47
	}
48
49
	/**
50
	 * This method initializes this service after our superclass's initialize()
51
	 * method succeeds.
52
	 * 
53
	 * @param requestMonitor
54
	 *            The call-back object to notify when this service's
55
	 *            initialization is done.
56
	 */
57
	private void doInitialize(RequestMonitor requestMonitor) {
58
		fCommandControl = getServicesTracker().getService(IGDBControl.class);
59
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
60
        requestMonitor.done();
61
	}
62
63
	@Override
64
	public void shutdown(RequestMonitor requestMonitor) {
65
		super.shutdown(requestMonitor);
66
	}
67
68
	@Override
69
    public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) {
70
		if (procCtx instanceof IMIProcessDMContext) {
71
	    	if (!doIsDebuggerAttachSupported()) {
72
	            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$
73
	            rm.done();    		
74
	    		return;
75
	    	}
76
	    	
77
	    	ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, ICommandControlDMContext.class);
78
	        fCommandControl.queueCommand(
79
	        		fCommandFactory.createMIAddInferior(controlDmc),
80
	        		new DataRequestMonitor<MIAddInferiorInfo>(getExecutor(), rm) {
81
	        			@Override
82
	        			protected void handleSuccess() {
83
	        				final String groupId = getData().getGroupId();
84
	        				if (groupId == null || groupId.trim().length() == 0) {
85
     				           rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid gdb group id.", null)); //$NON-NLS-1$
86
    				           rm.done();
87
    				           return;
88
        					}
89
	        				
90
	        				final IMIContainerDMContext containerDmc = createContainerContext(procCtx, groupId);
91
	        				fCommandControl.queueCommand(
92
	        						fCommandFactory.createMITargetAttach(containerDmc, ((IMIProcessDMContext)procCtx).getProcId()),
93
	        						new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
94
	        							@Override
95
	        							protected void handleSuccess() {
96
	        								rm.setData(containerDmc);
97
	        								rm.done();
98
	        							}
99
	        						});
100
	        			}
101
	        		});
102
	    } else {
103
            rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
104
            rm.done();
105
	    }
106
	}
107
}
108
(-)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 (+5 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-672 Link Here
667
		return new MITargetAttach(ctx, groupId);
668
		return new MITargetAttach(ctx, groupId);
668
	}
669
	}
669
670
671
	public ICommand<MIInfo> createMITargetAttach(IMIContainerDMContext ctx, String groupId) {
672
		return new MITargetAttach(ctx, groupId);
673
	}
674
670
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
675
	public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
671
		return new MITargetDetach(ctx, groupId);
676
		return new MITargetDetach(ctx, groupId);
672
	}
677
	}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java (-1 / +6 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
	public MITargetAttach(IMIContainerDMContext ctx, String pid) {
31
		super(ctx, "-target-attach", new String[] {"--thread-group", ctx.getGroupId()}, new String[] {pid}); //$NON-NLS-1$ //$NON-NLS-2$
32
	}
28
}
33
}

Return to bug 237306