97 private Map<String, ThreadData> threadData = new HashMap<>();
98
99 private Pattern threadRegexp = Pattern.compile("^(.+)\\[\\d+\\].*");
100 private Pattern lineRegexp = Pattern.compile("^(\\d+)\\b.*", Pattern.MULTILINE);
101
102 // returns the 1st group of the pattern.
103 private String parse(Pattern p, String input) {
104 Matcher m = p.matcher(input);
105 if (!m.find()) {
106 throw new RuntimeException("Input '" + input + "' does not matches '" + p.pattern() + "'");
107 }
108 return m.group(1);
109 }
110
111 private void next() {
112 List<String> reply = jdb.command(JdbCommand.next());
113 /*
114 * Each "next" produces something like ("Breakpoint hit" line only if the line has BP)
115 * Step completed:
116 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(), line=74 bci=12
117 * 74 ++count2; // @2 breakpoint
118 * <empty line>
119 * jj2[1]
120 */
121 // detect thread from the last line
122 String lastLine = reply.get(reply.size() - 1);
123 String threadName = parse(threadRegexp, lastLine);
124 String wholeReply = reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
125 int lineNum = Integer.parseInt(parse(lineRegexp, wholeReply));
126
127 System.out.println("got: thread=" + threadName + ", line=" + lineNum);
128
129 ThreadData data = threadData.get(threadName);
130 if (data == null) {
131 data = new ThreadData();
132 threadData.put(threadName, data);
133 }
134 processThreadData(threadName, lineNum, data);
135 }
136
137 private void processThreadData(String threadName, int lineNum, ThreadData data) {
|
97 private Map<String, ThreadData> threadData = new HashMap<>();
98
99 private Pattern threadRegexp = Pattern.compile("^(.+)\\[\\d+\\].*");
100 private Pattern lineRegexp = Pattern.compile("^(\\d+)\\b.*", Pattern.MULTILINE);
101
102 // returns the 1st group of the pattern.
103 private String parse(Pattern p, String input) {
104 Matcher m = p.matcher(input);
105 if (!m.find()) {
106 throw new RuntimeException("Input '" + input + "' does not matches '" + p.pattern() + "'");
107 }
108 return m.group(1);
109 }
110
111 private void next() {
112 List<String> reply = jdb.command(JdbCommand.next());
113 /*
114 * Each "next" produces something like ("Breakpoint hit" line only if the line has BP)
115 * Step completed:
116 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(), line=74 bci=12
117 * 74 ++count2; // @ 2 breakpoint
118 * <empty line>
119 * jj2[1]
120 */
121 // detect thread from the last line
122 String lastLine = reply.get(reply.size() - 1);
123 String threadName = parse(threadRegexp, lastLine);
124 String wholeReply = reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
125 int lineNum = Integer.parseInt(parse(lineRegexp, wholeReply));
126
127 System.out.println("got: thread=" + threadName + ", line=" + lineNum);
128
129 ThreadData data = threadData.get(threadName);
130 if (data == null) {
131 data = new ThreadData();
132 threadData.put(threadName, data);
133 }
134 processThreadData(threadName, lineNum, data);
135 }
136
137 private void processThreadData(String threadName, int lineNum, ThreadData data) {
|