206 + " seconds, looking for '" + promptPattern + "', in " + lines + " lines");
207 }
208
209 public List<String> command(JdbCommand cmd) {
210 if (!jdb.isAlive()) {
211 if (cmd.allowExit) {
212 // return remaining output
213 return outputHandler.reset();
214 }
215 throw new RuntimeException("Attempt to send command '" + cmd.cmd + "' to terminated jdb");
216 }
217
218 log("> " + cmd.cmd);
219
220 inputWriter.println(cmd.cmd);
221
222 if (inputWriter.checkError()) {
223 throw new RuntimeException("Unexpected IO error while writing command '" + cmd.cmd + "' to jdb stdin stream");
224 }
225
226 return waitForPrompt(1, cmd.allowExit);
227 }
228
229 public List<String> command(String cmd) {
230 return command(new JdbCommand(cmd));
231 }
232
233 // sends "cont" command up to maxTimes until debuggee exit
234 public void contToExit(int maxTimes) {
235 boolean exited = false;
236 JdbCommand cont = JdbCommand.cont().allowExit();
237 for (int i = 0; i < maxTimes && jdb.isAlive(); i++) {
238 String reply = command(cont).stream().collect(Collectors.joining(lineSeparator));
239 if (reply.contains(APPLICATION_EXIT)) {
240 exited = true;
241 break;
242 }
243 }
244 if (!exited && jdb.isAlive()) {
245 throw new RuntimeException("Debuggee did not exit after " + maxTimes + " <cont> commands");
246 }
|
206 + " seconds, looking for '" + promptPattern + "', in " + lines + " lines");
207 }
208
209 public List<String> command(JdbCommand cmd) {
210 if (!jdb.isAlive()) {
211 if (cmd.allowExit) {
212 // return remaining output
213 return outputHandler.reset();
214 }
215 throw new RuntimeException("Attempt to send command '" + cmd.cmd + "' to terminated jdb");
216 }
217
218 log("> " + cmd.cmd);
219
220 inputWriter.println(cmd.cmd);
221
222 if (inputWriter.checkError()) {
223 throw new RuntimeException("Unexpected IO error while writing command '" + cmd.cmd + "' to jdb stdin stream");
224 }
225
226 return cmd.replyIsSimplePrompt ? waitForSimplePrompt(1, cmd.allowExit) :
227 waitForPrompt(1, cmd.allowExit);
228 }
229
230 public List<String> command(String cmd) {
231 return command(new JdbCommand(cmd));
232 }
233
234 // sends "cont" command up to maxTimes until debuggee exit
235 public void contToExit(int maxTimes) {
236 boolean exited = false;
237 JdbCommand cont = JdbCommand.cont().allowExit();
238 for (int i = 0; i < maxTimes && jdb.isAlive(); i++) {
239 String reply = command(cont).stream().collect(Collectors.joining(lineSeparator));
240 if (reply.contains(APPLICATION_EXIT)) {
241 exited = true;
242 break;
243 }
244 }
245 if (!exited && jdb.isAlive()) {
246 throw new RuntimeException("Debuggee did not exit after " + maxTimes + " <cont> commands");
247 }
|