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 269838 | Differences between
and this patch

Collapse All | Expand All

(-)mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java (+5 lines)
Lines 15-20 Link Here
15
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
15
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
16
import org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary;
16
import org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary;
17
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
17
import org.eclipse.cdt.debug.mi.core.command.factories.StandardCommandFactory;
18
import org.eclipse.cdt.debug.mi.core.command.CLIInfoThreads;
18
19
19
public class StandardMacOSCommandFactory extends StandardCommandFactory {
20
public class StandardMacOSCommandFactory extends StandardCommandFactory {
20
21
Lines 44-47 Link Here
44
		return new MIInfoSharedLibrary(getMIVersion());
45
		return new MIInfoSharedLibrary(getMIVersion());
45
	}
46
	}
46
47
48
	public CLIInfoThreads createCLIInfoThreads() {
49
		return new MacOSCLIInfoThreads();
50
	}
51
47
}
52
}
(-)mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOsCLIInfoThreadsInfo.java (+66 lines)
Added Link Here
1
package org.eclipse.cdt.debug.mi.core.command.factories.macos;
2
3
import java.util.Arrays;
4
5
import org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo;
6
import org.eclipse.cdt.debug.mi.core.output.MIConst;
7
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
8
import org.eclipse.cdt.debug.mi.core.output.MIResult;
9
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
10
import org.eclipse.cdt.debug.mi.core.output.MITuple;
11
import org.eclipse.cdt.debug.mi.core.output.MIValue;
12
13
/**
14
 * This class actually parses -thread-list-ids and converts it to the
15
 * CLIInfoThreadsInfo 'format'
16
 */
17
class MacOsCLIInfoThreadsInfo extends CLIInfoThreadsInfo {
18
19
	public MacOsCLIInfoThreadsInfo(MIOutput out) {
20
		super(out);
21
	}
22
23
	protected void parse() {
24
		if (isDone()) {
25
			MIOutput out = getMIOutput();
26
			MIResultRecord rr = out.getMIResultRecord();
27
			if (rr != null) {
28
				MIResult[] results = rr.getMIResults();
29
				for (int i = 0; i < results.length; i++) {
30
					String var = results[i].getVariable();
31
					if (var.equals("thread-ids")) { //$NON-NLS-1$
32
						MIValue val = results[i].getMIValue();
33
						if (val instanceof MITuple) {
34
							parseThreadIds((MITuple) val);
35
						}
36
					}
37
				}
38
			}
39
		}
40
		if (threadIds == null) {
41
			threadIds = new int[0];
42
		}
43
		Arrays.sort(threadIds);
44
		if (threadIds.length > 0) {
45
			currentThreadId = threadIds[0];
46
		}
47
	}
48
49
	void parseThreadIds(MITuple tuple) {
50
		MIResult[] results = tuple.getMIResults();
51
		threadIds = new int[results.length];
52
		for (int i = 0; i < results.length; i++) {
53
			String var = results[i].getVariable();
54
			if (var.equals("thread-id")) { //$NON-NLS-1$
55
				MIValue value = results[i].getMIValue();
56
				if (value instanceof MIConst) {
57
					String str = ((MIConst) value).getCString();
58
					try {
59
						threadIds[i] = Integer.parseInt(str.trim());
60
					} catch (NumberFormatException e) {
61
					}
62
				}
63
			}
64
		}
65
	}
66
}
(-)mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoThreads.java (+39 lines)
Added Link Here
1
package org.eclipse.cdt.debug.mi.core.command.factories.macos;
2
3
import org.eclipse.cdt.debug.mi.core.MIException;
4
import org.eclipse.cdt.debug.mi.core.command.CLIInfoThreads;
5
import org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo;
6
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
7
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
8
9
class MacOSCLIInfoThreads extends CLIInfoThreads {
10
	public MacOSCLIInfoThreads() {
11
		super();
12
		// with apple-gdb, we use -thread-list-ids as a replacement for info
13
		// threads
14
		setOperation("-thread-list-ids"); //$NON-NLS-1$
15
	}
16
17
	// MI doesn't work with a space between the token and the
18
	// operation, so we override CLICommmand's toString
19
	public String toString() {
20
		return getToken() + getOperation() + "\n"; //$NON-NLS-1$
21
	}
22
23
	public MIInfo getMIInfo() throws MIException {
24
		MIInfo info = null;
25
		MIOutput out = getMIOutput();
26
		if (out != null) {
27
			info = new MacOsCLIInfoThreadsInfo(out);
28
			if (info.isError()) {
29
				throwMIException(info, out);
30
			}
31
		}
32
		return info;
33
	}
34
35
	public CLIInfoThreadsInfo getMIInfoThreadsInfo() throws MIException {
36
		return (CLIInfoThreadsInfo) getMIInfo();
37
	}
38
39
}

Return to bug 269838