< prev index next >

test/jdk/com/sun/jdi/lib/jdb/Jdb.java

Print this page

        

*** 148,161 **** # 5) ^main[89] > @ # # i.e., the > prompt comes out AFTER the prompt we we need to wait for. */ // compile regexp once ! private final String promptPattern = "[a-zA-Z0-9_-][a-zA-Z0-9_-]*\\[[1-9][0-9]*\\] [ >]*$"; ! private final Pattern promptRegexp = Pattern.compile(promptPattern); public List<String> waitForPrompt(int lines, boolean allowExit) { ! return waitForPrompt(lines, allowExit, promptRegexp); } // jdb prompt when debuggee is not started and is not suspended after breakpoint private static final String SIMPLE_PROMPT = "> "; public List<String> waitForSimplePrompt(int lines, boolean allowExit) { --- 148,162 ---- # 5) ^main[89] > @ # # i.e., the > prompt comes out AFTER the prompt we we need to wait for. */ // compile regexp once ! private final static String promptPattern = "[a-zA-Z0-9_-][a-zA-Z0-9_-]*\\[[1-9][0-9]*\\] [ >]*$"; ! final static Pattern PROMPT_REGEXP = Pattern.compile(promptPattern); ! public List<String> waitForPrompt(int lines, boolean allowExit) { ! return waitForPrompt(lines, allowExit, PROMPT_REGEXP); } // jdb prompt when debuggee is not started and is not suspended after breakpoint private static final String SIMPLE_PROMPT = "> "; public List<String> waitForSimplePrompt(int lines, boolean allowExit) {
*** 181,211 **** // if something appeared in the jdb output, reset the timeout startTime = System.currentTimeMillis(); } } List<String> reply = outputHandler.get(); ! for (String line: reply.subList(Math.max(0, reply.size() - lines), reply.size())) { if (promptRegexp.matcher(line).find()) { logJdb(reply); return outputHandler.reset(); } } if (!jdb.isAlive()) { // ensure we get the whole output reply = outputHandler.reset(); logJdb(reply); if (!allowExit) { throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000) ! + " seconds, looking for '" + promptPattern + "', in " + lines + " lines"); } return reply; } } // timeout logJdb(outputHandler.get()); throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000) ! + " seconds, looking for '" + promptPattern + "', in " + lines + " lines"); } public List<String> command(JdbCommand cmd) { if (!jdb.isAlive()) { if (cmd.allowExit) { --- 182,220 ---- // if something appeared in the jdb output, reset the timeout startTime = System.currentTimeMillis(); } } List<String> reply = outputHandler.get(); ! if ((promptRegexp.flags() & Pattern.MULTILINE) > 0) { ! String replyString = reply.stream().collect(Collectors.joining(lineSeparator)); ! if (promptRegexp.matcher(replyString).find()) { ! logJdb(reply); ! return outputHandler.reset(); ! } ! } else { ! for (String line : reply.subList(Math.max(0, reply.size() - lines), reply.size())) { if (promptRegexp.matcher(line).find()) { logJdb(reply); return outputHandler.reset(); } } + } if (!jdb.isAlive()) { // ensure we get the whole output reply = outputHandler.reset(); logJdb(reply); if (!allowExit) { throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000) ! + " seconds, looking for '" + promptRegexp.pattern() + "', in " + lines + " lines"); } return reply; } } // timeout logJdb(outputHandler.get()); throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000) ! + " seconds, looking for '" + promptRegexp.pattern() + "', in " + lines + " lines"); } public List<String> command(JdbCommand cmd) { if (!jdb.isAlive()) { if (cmd.allowExit) {
*** 221,231 **** if (inputWriter.checkError()) { throw new RuntimeException("Unexpected IO error while writing command '" + cmd.cmd + "' to jdb stdin stream"); } ! return waitForPrompt(1, cmd.allowExit); } public List<String> command(String cmd) { return command(new JdbCommand(cmd)); } --- 230,240 ---- if (inputWriter.checkError()) { throw new RuntimeException("Unexpected IO error while writing command '" + cmd.cmd + "' to jdb stdin stream"); } ! return waitForPrompt(1, cmd.allowExit, cmd.waitForPattern); } public List<String> command(String cmd) { return command(new JdbCommand(cmd)); }
< prev index next >