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

Collapse All | Expand All

(-)RxThread.java (-1 / +33 lines)
Lines 20-25 Link Here
20
import java.util.LinkedList;
20
import java.util.LinkedList;
21
import java.util.List;
21
import java.util.List;
22
import java.util.StringTokenizer;
22
import java.util.StringTokenizer;
23
import java.util.regex.Matcher;
24
import java.util.regex.Pattern;
23
25
24
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
26
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
25
import org.eclipse.cdt.debug.mi.core.command.Command;
27
import org.eclipse.cdt.debug.mi.core.command.Command;
Lines 61-71 Link Here
61
import org.eclipse.cdt.debug.mi.core.output.MIStreamRecord;
63
import org.eclipse.cdt.debug.mi.core.output.MIStreamRecord;
62
import org.eclipse.cdt.debug.mi.core.output.MITargetStreamOutput;
64
import org.eclipse.cdt.debug.mi.core.output.MITargetStreamOutput;
63
import org.eclipse.cdt.debug.mi.core.output.MIValue;
65
import org.eclipse.cdt.debug.mi.core.output.MIValue;
66
import org.eclipse.core.runtime.Platform;
64
67
65
/**
68
/**
66
 * Receiving thread of gdb response output.
69
 * Receiving thread of gdb response output.
67
 */
70
 */
68
public class RxThread extends Thread {
71
public class RxThread extends Thread {
72
	private static final String MI_OUTPUT_REGEX =
73
		"(.*?)([0-9]*(\\*(stopped|running)|=(thread|library)-|" +
74
		"\\^(done|running|connected|error|exit)).*|[~@&]\".*\"|\\(gdb\\))"; //$NON-NLS-1$
75
76
	private final Pattern fMiOutputPattern = Pattern.compile(MI_OUTPUT_REGEX);
69
77
70
	final MISession session;
78
	final MISession session;
71
	LinkedList<MIStreamRecord> fStreamRecords = new LinkedList<MIStreamRecord>();
79
	LinkedList<MIStreamRecord> fStreamRecords = new LinkedList<MIStreamRecord>();
Lines 84-89 Link Here
84
	 * search for the corresponding token in rxQueue for the ResultRecord.
92
	 * search for the corresponding token in rxQueue for the ResultRecord.
85
	 */
93
	 */
86
	public void run() {
94
	public void run() {
95
		final boolean win32 = Platform.getOS().equals(Platform.OS_WIN32);
87
		BufferedReader reader = new BufferedReader(new InputStreamReader(session.getChannelInputStream()));
96
		BufferedReader reader = new BufferedReader(new InputStreamReader(session.getChannelInputStream()));
88
		try {
97
		try {
89
			String line;
98
			String line;
Lines 97-103 Link Here
97
					session.writeToConsole(line + "\n"); //$NON-NLS-1$
106
					session.writeToConsole(line + "\n"); //$NON-NLS-1$
98
107
99
				setPrompt(line);
108
				setPrompt(line);
100
				processMIOutput(line + "\n"); //$NON-NLS-1$
109
				if (win32) {
110
					String[] lines = splitMIOutput(line);
111
					for (int i = 0; i < lines.length; i++) {
112
						processMIOutput(lines[i] + "\n"); //$NON-NLS-1$
113
					}
114
				} else {
115
					processMIOutput(line + "\n"); //$NON-NLS-1$
116
				}
101
			}
117
			}
102
		} catch (IOException e) {
118
		} catch (IOException e) {
103
			//e.printStackTrace();
119
			//e.printStackTrace();
Lines 160-165 Link Here
160
		return fEnableConsole;
176
		return fEnableConsole;
161
	}
177
	}
162
178
179
	private String[] splitMIOutput(String line) {
180
		Matcher matcher = fMiOutputPattern.matcher(line);
181
		if (matcher.matches() && (matcher.groupCount() >= 3)) {
182
			String targetGroup = matcher.group(1);
183
			String miGroup = matcher.group(2);
184
			if (targetGroup.length() > 0) {
185
				return new String[] {targetGroup, miGroup};
186
			} else {
187
				return new String[] {miGroup};
188
			}
189
		} else {
190
			// Line does not match pattern, return it as a whole.
191
			return new String[] {line};
192
		}
193
	}
194
163
	/**
195
	/**
164
	 * Search for the command in the RxQueue, set the MIOutput
196
	 * Search for the command in the RxQueue, set the MIOutput
165
	 * and notify() the other end.
197
	 * and notify() the other end.

Return to bug 356085