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 (-15 / +21 lines)
Lines 374-390 Link Here
374
    /**
374
    /**
375
     *  A map of thread id to thread group id.  We use this to find out to which threadGroup a thread belongs.
375
     *  A map of thread id to thread group id.  We use this to find out to which threadGroup a thread belongs.
376
     */
376
     */
377
    private Map<String, String> fThreadToGroupMap = new HashMap<String, String>();
377
    protected Map<String, String> fThreadToGroupMap = new HashMap<String, String>();
378
378
379
    private IGDBControl fCommandControl;
379
    protected IGDBControl fCommandControl;
380
    private IGDBBackend fBackend;
380
    protected IGDBBackend fBackend;
381
    private CommandFactory fCommandFactory;
381
    protected CommandFactory fCommandFactory;
382
382
383
    // A cache for commands about the threadGroups
383
    // A cache for commands about the threadGroups
384
	private CommandCache fContainerCommandCache;
384
    protected CommandCache fContainerCommandCache;
385
385
386
	//A cache for commands about the threads
386
	//A cache for commands about the threads
387
	private CommandCache fThreadCommandCache;
387
    protected CommandCache fThreadCommandCache;
388
	
388
	
389
	// A temporary cache to avoid using -list-thread-groups --available more than once at the same time.
389
	// A temporary cache to avoid using -list-thread-groups --available more than once at the same time.
390
	// We cannot cache this command because it lists all available processes, which can
390
	// We cannot cache this command because it lists all available processes, which can
Lines 392-398 Link Here
392
	// the same time.  This cache will help us avoid that.  The idea is that we cache the command,
392
	// the same time.  This cache will help us avoid that.  The idea is that we cache the command,
393
	// but as soon as it returns, we clear the cache.  So the cache will only trigger for those 
393
	// but as soon as it returns, we clear the cache.  So the cache will only trigger for those 
394
	// overlapping situations.
394
	// overlapping situations.
395
	private CommandCache fListThreadGroupsAvailableCache;
395
    protected CommandCache fListThreadGroupsAvailableCache;
396
396
397
    // A map of process id to process names.  A name is fetched whenever we start
397
    // A map of process id to process names.  A name is fetched whenever we start
398
	// debugging a process, and removed when we stop.
398
	// debugging a process, and removed when we stop.
Lines 401-407 Link Here
401
	// This map also serves as a list of processes we are currently debugging.
401
	// This map also serves as a list of processes we are currently debugging.
402
	// This is important because we cannot always ask GDB for the list, since it may
402
	// This is important because we cannot always ask GDB for the list, since it may
403
	// be running at the time.  Bug 303503
403
	// be running at the time.  Bug 303503
404
    private Map<String, String> fDebuggedProcessesAndNames = new HashMap<String, String>();
404
    protected Map<String, String> fDebuggedProcessesAndNames = new HashMap<String, String>();
405
	
405
	
406
    private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
406
    private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
407
407
Lines 463-478 Link Here
463
        fCommandControl.addEventListener(this);
463
        fCommandControl.addEventListener(this);
464
464
465
		// Register this service.
465
		// Register this service.
466
        registerProcService();
467
        
468
		requestMonitor.done();
469
	}
470
471
	// Register this service. New procservices needs to override this method
472
	protected void registerProcService(){
466
		register(new String[] { IProcesses.class.getName(),
473
		register(new String[] { IProcesses.class.getName(),
467
				IMIProcesses.class.getName(),
474
				IMIProcesses.class.getName(),
468
				IGDBProcesses.class.getName(),
475
				IGDBProcesses.class.getName(),
469
				GDBProcesses_7_0.class.getName() },
476
				GDBProcesses_7_0.class.getName() },
470
				new Hashtable<String, String>());
477
				new Hashtable<String, String>());
471
        
472
		requestMonitor.done();
473
	}
478
	}
474
479
475
476
	/**
480
	/**
477
	 * This method shuts down this service. It unregisters the service, stops
481
	 * This method shuts down this service. It unregisters the service, stops
478
	 * receiving service events, and calls the superclass shutdown() method to
482
	 * receiving service events, and calls the superclass shutdown() method to
Lines 573-581 Link Here
573
			} else {
577
			} else {
574
				name = fDebuggedProcessesAndNames.get(id);
578
				name = fDebuggedProcessesAndNames.get(id);
575
				if (name == null) {
579
				if (name == null) {
580
					name = "New Inferior"; //$NON-NLS-1$
581
					id = "null";
576
					// We don't have the name in our map.  Should not happen.
582
					// We don't have the name in our map.  Should not happen.
577
					name = "Unknown name"; //$NON-NLS-1$
583
					//name = "Unknown name"; //$NON-NLS-1$
578
					assert false : "Don't have entry for process ID: " + id; //$NON-NLS-1$
584
					//assert false : "Don't have entry for process ID: " + id; //$NON-NLS-1$
579
				} else if (name.length() == 0) {
585
				} else if (name.length() == 0) {
580
					// Probably will not happen, but just in case...use the
586
					// Probably will not happen, but just in case...use the
581
					// binary file name (absolute path)
587
					// binary file name (absolute path)
Lines 761-767 Link Here
761
		}
767
		}
762
	}
768
	}
763
769
764
	private IExecutionDMContext[] makeExecutionDMCs(IContainerDMContext containerDmc, MIThread[] threadInfos) {
770
	protected IExecutionDMContext[] makeExecutionDMCs(IContainerDMContext containerDmc, MIThread[] threadInfos) {
765
		final IProcessDMContext procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
771
		final IProcessDMContext procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
766
772
767
		if (threadInfos.length == 0) {
773
		if (threadInfos.length == 0) {
Lines 784-790 Link Here
784
		}
790
		}
785
	}
791
	}
786
792
787
	private IMIContainerDMContext[] makeContainerDMCs(ICommandControlDMContext controlDmc, IThreadGroupInfo[] groups) {
793
	protected IMIContainerDMContext[] makeContainerDMCs(ICommandControlDMContext controlDmc, IThreadGroupInfo[] groups) {
788
		// This is a workaround for post-mortem tracing because the early GDB release
794
		// This is a workaround for post-mortem tracing because the early GDB release
789
		// does not report a process when we do -list-thread-group
795
		// does not report a process when we do -list-thread-group
790
		// GDB 7.2 will properly report the process so this
796
		// GDB 7.2 will properly report the process so this
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_1.java (+173 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE-BTE 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
 *     TUBITAK-UEKAE-BTE - GDB_7_1 support 
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.service;
13
14
import java.util.Hashtable;
15
import java.util.Map;
16
17
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
18
import org.eclipse.cdt.dsf.datamodel.DMContexts;
19
import org.eclipse.cdt.dsf.datamodel.IDMContext;
20
import org.eclipse.cdt.dsf.debug.service.IProcesses;
21
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
22
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
23
import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext;
24
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
25
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
26
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoInferiorsInfo;
27
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
28
import org.eclipse.cdt.dsf.mi.service.command.output.MIListThreadGroupsInfo;
29
import org.eclipse.cdt.dsf.service.DsfSession;
30
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.Status;
32
33
public class GDBProcesses_7_1 extends GDBProcesses_7_0 {
34
35
	public GDBProcesses_7_1(DsfSession session) {
36
		super(session);
37
		// TODO Auto-generated constructor stub
38
	}
39
	
40
	
41
	@Override
42
	protected void registerProcService() {
43
		register(new String[] { IProcesses.class.getName(),
44
				IMIProcesses.class.getName(),
45
				IGDBProcesses.class.getName(),
46
				GDBProcesses_7_1.class.getName() },
47
				new Hashtable<String, String>());
48
	}
49
	
50
	public boolean doIsRunNewProcessSupported() {
51
		return true;
52
	}
53
	
54
	@Override
55
	public void isRunNewProcessSupported(IDMContext dmc,
56
			DataRequestMonitor<Boolean> rm) {
57
		rm.setData(true);
58
		rm.done();
59
	}
60
	
61
	@Override
62
	public void runNewProcess(IDMContext dmc, String file,
63
			Map<String, Object> attributes,
64
			DataRequestMonitor<IProcessDMContext> rm) {
65
		final DataRequestMonitor<IProcessDMContext> requestMonitor = rm;
66
67
		if (dmc instanceof GDBControlDMContext) {
68
						
69
			if ( !doIsRunNewProcessSupported() ) {
70
				requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Multi-process debug not supported.", null)); //$NON-NLS-1$
71
				requestMonitor.done();    		
72
	    		return;
73
	    	}
74
	    	
75
	    	final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
76
			fCommandControl.queueCommand(
77
					fCommandFactory.createCLIAddInferior( controlDmc ),
78
					new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {			
79
						@Override
80
						protected void handleSuccess() {
81
							IMIProcesses procService = getServicesTracker().getService(IMIProcesses.class);
82
		                    if (procService != null) {
83
		                    	IProcessDMContext procDmc = procService.createProcessContext(controlDmc, null);
84
		                    	IMIContainerDMContext containerDmc = createContainerContext(procDmc, null);
85
		                    	getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties());
86
		                    	requestMonitor.setData(procDmc);
87
		                    }
88
		                    
89
		                    requestMonitor.done();
90
						}
91
					});   
92
93
	    } else {
94
	    	requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
95
	    	requestMonitor.done();
96
	    }
97
		
98
	}
99
100
	/*
101
	 * Selects active inferior  
102
	 * Every process has an address space . Besides one address space may have multiple processes
103
	 * This is not supported now!!!
104
	 */
105
	public void selectActiveInferior(IDMContext dmc, int inferiorNo ,
106
			DataRequestMonitor<IProcessDMContext> rm) {
107
		final DataRequestMonitor<IProcessDMContext> requestMonitor = rm;
108
109
		if (dmc instanceof GDBControlDMContext) {
110
						
111
			if ( !doIsRunNewProcessSupported() ) {
112
				requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Multi-process debug not supported.", null)); //$NON-NLS-1$
113
				requestMonitor.done();    		
114
	    		return;
115
	    	}
116
	    	
117
	    	final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
118
			fCommandControl.queueCommand(
119
					fCommandFactory.createCLISelectInferior( controlDmc , inferiorNo ),
120
					new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {			
121
						@Override
122
						protected void handleSuccess() {
123
							System.out.println("Active inferior changed");
124
		                    requestMonitor.done();
125
						}
126
					});
127
128
	    } else {
129
	    	requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$
130
	    	requestMonitor.done();
131
	    }
132
		
133
	}
134
	
135
	@Override
136
	public void getProcessesBeingDebugged(final IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) {
137
		final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class);
138
		final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class);
139
		if (containerDmc != null) {
140
			fThreadCommandCache.execute(
141
					fCommandFactory.createMIListThreadGroups(controlDmc, containerDmc.getGroupId()),
142
					new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), rm) {
143
						@Override
144
						protected void handleSuccess() {
145
							rm.setData(makeExecutionDMCs(containerDmc, getData().getThreadInfo().getThreadList()));
146
							rm.done();
147
						}
148
					});
149
		} else {
150
			fContainerCommandCache.execute(
151
					fCommandFactory.createCLIInfoInferiors(controlDmc,null),
152
					new DataRequestMonitor<CLIInfoInferiorsInfo>(getExecutor(), rm) {
153
						@Override
154
						protected void handleSuccess() {
155
							rm.setData(makeContainerDMCs(controlDmc, getData().getGroupList()));
156
							rm.done();
157
						}
158
						@Override
159
						protected void handleFailure() {
160
							// If the target is not available, generate the list ourselves
161
							IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fDebuggedProcessesAndNames.size()];
162
							int i = 0;
163
							for (String groupId : fDebuggedProcessesAndNames.keySet()) {
164
								IProcessDMContext processDmc = createProcessContext(controlDmc, groupId);
165
								containerDmcs[i++] = createContainerContext(processDmc, groupId);
166
							}
167
							rm.setData(containerDmcs);
168
							rm.done();
169
						}
170
					});
171
		}
172
	}
173
}
(-)src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java (-1 / +4 lines)
Lines 45-50 Link Here
45
	// This should eventually be "7.0" once GDB 7.0 is released
45
	// This should eventually be "7.0" once GDB 7.0 is released
46
	private static final String GDB_7_0_VERSION = "6.8.50.20090218"; //$NON-NLS-1$	
46
	private static final String GDB_7_0_VERSION = "6.8.50.20090218"; //$NON-NLS-1$	
47
	private static final String GDB_7_2_VERSION = "7.1.50"; //$NON-NLS-1$
47
	private static final String GDB_7_2_VERSION = "7.1.50"; //$NON-NLS-1$
48
	private static final String GDB_7_1_VERSION = "7.1"; //$NON-NLS-1$
48
	
49
	
49
	private final String fVersion;
50
	private final String fVersion;
50
	
51
	
Lines 133-139 Link Here
133
		
134
		
134
	@Override
135
	@Override
135
	protected IProcesses createProcessesService(DsfSession session) {
136
	protected IProcesses createProcessesService(DsfSession session) {
136
		if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
137
		if (GDB_7_1_VERSION.compareTo(fVersion) <= 0) {
138
			return new GDBProcesses_7_1(session);
139
		}else if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
137
			return new GDBProcesses_7_0(session);
140
			return new GDBProcesses_7_0(session);
138
		}
141
		}
139
		return new GDBProcesses(session);
142
		return new GDBProcesses(session);
(-)src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java (+16 lines)
Lines 39-44 Link Here
39
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread;
39
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread;
40
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
40
import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
41
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
41
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIUnsetEnv;
42
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIInfoInferior;
43
import org.eclipse.cdt.dsf.mi.service.command.commands.CLISelectActivateInferior;
44
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIAddInferior;
42
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter;
45
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter;
43
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCommands;
46
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCommands;
44
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCondition;
47
import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCondition;
Lines 130-135 Link Here
130
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo;
133
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo;
131
import org.eclipse.cdt.dsf.mi.service.command.output.CLIThreadInfo;
134
import org.eclipse.cdt.dsf.mi.service.command.output.CLIThreadInfo;
132
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
135
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
136
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoInferiorsInfo;
133
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
137
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
134
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
138
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
135
import org.eclipse.cdt.dsf.mi.service.command.output.MIDataDisassembleInfo;
139
import org.eclipse.cdt.dsf.mi.service.command.output.MIDataDisassembleInfo;
Lines 182-187 Link Here
182
		return new CLIAttach(ctx, pid);
186
		return new CLIAttach(ctx, pid);
183
	}
187
	}
184
188
189
	public ICommand<MIInfo> createCLIAddInferior(ICommandControlDMContext ctx) {
190
		return new CLIAddInferior(ctx);
191
	}
192
	
185
	public ICommand<CLICatchInfo> createCLICatch(IBreakpointsTargetDMContext ctx, String event, String[] args) {
193
	public ICommand<CLICatchInfo> createCLICatch(IBreakpointsTargetDMContext ctx, String event, String[] args) {
186
		return new CLICatch(ctx, event, args);
194
		return new CLICatch(ctx, event, args);
187
	}
195
	}
Lines 218-223 Link Here
218
		return new CLIRecord(ctx, enable);
226
		return new CLIRecord(ctx, enable);
219
	}
227
	}
220
228
229
	public ICommand<MIInfo> createCLISelectInferior(ICommandControlDMContext ctx , int inferiorNo) {
230
		return new CLISelectActivateInferior(ctx,inferiorNo);
231
	}
232
	
233
	public ICommand<CLIInfoInferiorsInfo> createCLIInfoInferiors(ICommandControlDMContext ctx, String groupId) {
234
		return new CLIInfoInferior(ctx);//TODO    MIListThreadGroups(ctx, groupId);
235
	}
236
	
221
	public ICommand<MIInfo> createCLISource(ICommandControlDMContext ctx, String file) {
237
	public ICommand<MIInfo> createCLISource(ICommandControlDMContext ctx, String file) {
222
		return new CLISource(ctx, file);
238
		return new CLISource(ctx, file);
223
	}
239
	}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIAddInferior.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE-BTE 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
 *     TUBITAK-UEKAE-BTE - GDB_7_1 support 
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
16
/**
17
 * This command adds a new - null inferior
18
 * TODO Native interface may change.
19
 */
20
public class CLIAddInferior extends CLICommand<MIInfo> {
21
22
	public CLIAddInferior(ICommandControlDMContext ctx) {
23
		super(ctx, "add-inferior"); //$NON-NLS-1$
24
	}
25
	
26
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIInfoInferior.java (+40 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE-BTE 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
 *     TUBITAK-UEKAE-BTE - GDB_7_1 support 
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoInferiorsInfo;
15
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
16
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
17
18
/**
19
 * This command adds a new - null inferior
20
 * TODO Native interface may change.
21
 */
22
public class CLIInfoInferior extends CLICommand<CLIInfoInferiorsInfo> {
23
24
	public CLIInfoInferior(ICommandControlDMContext ctx) {
25
		super(ctx, "info inferior"); //$NON-NLS-1$
26
	}
27
	
28
	@Override
29
	public CLIInfoInferiorsInfo getResult(MIOutput output) {
30
		return (CLIInfoInferiorsInfo)getMIInfo(output);
31
	}
32
33
	public MIInfo getMIInfo(MIOutput out) {
34
		MIInfo info = null;
35
		if (out != null) {
36
			info = new CLIInfoInferiorsInfo(out);
37
		}
38
		return info;
39
	}
40
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISelectActivateInferior.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE-BTE 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
 *     TUBITAK-UEKAE-BTE - GDB_7_1 support 
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.mi.service.command.commands;
12
13
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
14
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
15
16
/**
17
 * This command adds a new - null inferior
18
 * TODO Native interface may change.
19
 */
20
public class CLISelectActivateInferior extends CLICommand<MIInfo> {
21
22
	public CLISelectActivateInferior(ICommandControlDMContext ctx , int inferiorNo) {
23
		super(ctx, "inferior"+inferiorNo); //$NON-NLS-1$
24
	}
25
	
26
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoInferiorsInfo.java (+125 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 TUBITAK-UEKAE-BTE 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
 *     TUBITAK-UEKAE-BTE - GDB_7_1 support 
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.mi.service.command.output;
13
14
import java.util.Scanner;
15
16
import org.eclipse.cdt.dsf.concurrent.Immutable;
17
import org.eclipse.cdt.dsf.mi.service.command.output.MIListThreadGroupsInfo.IThreadGroupInfo;
18
19
/**
20
 *  (org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoInferiorsInfo) &"info inferior\n"
21
~"  Num  Description       Executable        \n"
22
~"* 1    <null>            /home/onur/runtime-EclipseApplication/helloworks/Debug/helloworks \n"
23
7^done
24
*
25
*
26
*
27
&"info inferiors\n"
28
~"  Num  Description       Executable        \n"
29
~"  2    <null>                              \n"
30
~"* 1    process 1562                        \n"
31
32
*/
33
public class CLIInfoInferiorsInfo extends MIInfo {
34
35
	@Immutable
36
	private static class ThreadGroupInfo implements IThreadGroupInfo {
37
		final String fGroupId;
38
		final String fDescription;
39
		final String fName;
40
		
41
		public ThreadGroupInfo(String id, String executable) {
42
			fGroupId = id;
43
			fDescription = executable;
44
			fName		 = executable;
45
			//fName = parseName(fDescription,fGroupId);
46
		}
47
		/*
48
		private static String parseName(String desc , String groupId) {
49
			String name = "";
50
			if ( desc.equals(" ") || desc.equals(null)){
51
				name = "Inferior" + groupId;
52
			}else{
53
         		// "/usr/sbin/dhcdbd --system"
54
        		name = desc.split("\\s", 2)[0]; //$NON-NLS-1$
55
        	}
56
57
			return name;
58
		}
59
		*/
60
		
61
		public String getGroupId() { return fGroupId; }
62
		public String getPid() { return fGroupId; }
63
64
		public String getName() { return fName;	}
65
66
		public String getDesciption() { return fDescription; }
67
	}
68
	
69
	
70
	private IThreadGroupInfo[] fGroupList;
71
	
72
    public CLIInfoInferiorsInfo(MIOutput out) {
73
        super(out);
74
        parse();
75
	}
76
	
77
	public IThreadGroupInfo[] getGroupList() { return fGroupList; }
78
	
79
  	protected void parse() {
80
		if (isDone()) {
81
			MIOutput out = getMIOutput();
82
			MIOOBRecord[] oobs = out.getMIOOBRecords();
83
			fGroupList = new IThreadGroupInfo[oobs.length - 2];
84
			for (int i = 0; i < oobs.length; i++) {
85
				if (oobs[i] instanceof MIConsoleStreamOutput) {
86
					MIStreamRecord cons = (MIStreamRecord) oobs[i];
87
					String str = cons.getString(); // * 1    <null>
88
					parseGroups(str , i-2);
89
				}
90
			}
91
		}
92
  		if (fGroupList == null) {
93
			fGroupList = new IThreadGroupInfo[0];
94
		}		
95
	}
96
  	public boolean isCurrentThread;
97
	private void parseGroups(String str , int index ) {
98
		if(str.length() > 0 ){
99
			if (str.charAt(2) != 'N') {
100
				Scanner scanner = new Scanner(str);
101
				//TODO Birden fazla bosluk icin
102
				scanner.useDelimiter(" ");
103
				if ( scanner.hasNext() ){
104
					String  currThread	= scanner.next();
105
					if ( currThread.equals("*")){
106
						isCurrentThread = true;
107
					}else{
108
						isCurrentThread = false;
109
					}
110
		    		String 	sGdbId	= scanner.next();
111
		    		String 	sType	= scanner.next();
112
		    		String 	sPid	= scanner.next();
113
		    		String 	sExecutableName	= scanner.next();
114
		    		if(sType.equals(null) || sType.equals(" ") || sType.equals("")){
115
		    			sExecutableName = "Inferior" + sGdbId;
116
		    		}
117
		    			
118
		    		fGroupList[index] = new ThreadGroupInfo(sGdbId, sExecutableName);
119
		    	}
120
		    scanner.close();
121
			}
122
		}
123
	}
124
}
125

Return to bug 237306