Fixed AS1/2 - debugger - rewinding playback to apply breakpoints

This commit is contained in:
Jindra Petřík
2021-12-08 19:04:53 +01:00
parent 985311c87f
commit 61561c6e72
2 changed files with 20 additions and 7 deletions

View File

@@ -518,6 +518,8 @@ public class DebuggerHandler implements DebugConnectionListener {
}
Main.getMainFrame().getPanel().updateMenu();
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
//enlog(DebuggerConnection.class);
//enlog(DebuggerCommands.class);
@@ -611,9 +613,9 @@ public class DebuggerHandler implements DebugConnectionListener {
commands.setGetterTimeout(1500);
commands.setSetterTimeout(5000);
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
con.isAS3 = isAS3;
//Widelines - only AS3, it hangs in AS1/2 and SWD does not support UI32 lines
if (isAS3) {
con.wideLines = commands.getOption("wide_line_player", "false").equals("true");
@@ -663,9 +665,6 @@ public class DebuggerHandler implements DebugConnectionListener {
}
}
synchronized (this) {
connected = true;
}
con.addMessageListener(new DebugMessageListener<InAskBreakpoints>() {
@Override
public void message(InAskBreakpoints message) {
@@ -697,17 +696,19 @@ public class DebuggerHandler implements DebugConnectionListener {
breakInfo = con.getMessage(InBreakAtExt.class, DebuggerConnection.PREF_RESPONSE_TIMEOUT);
breakReason = con.sendMessageWithTimeout(new OutGetBreakReason(con), InBreakReason.class);
int reasonInt = breakReason == null ? 0 : breakReason.reason;
String newBreakScriptName = "unknown";
if (modulePaths.containsKey(message.file)) {
newBreakScriptName = modulePaths.get(message.file);
} else if (breakReason.reason != InBreakReason.REASON_SCRIPT_LOADED) {
} else if (reasonInt != InBreakReason.REASON_SCRIPT_LOADED) {
Logger.getLogger(DebuggerCommands.class.getName()).log(Level.SEVERE, "Invalid file: {0}", message.file);
return;
}
final String[] reasonNames = new String[]{"unknown", "breakpoint", "watch", "fault", "stopRequest", "step", "halt", "scriptLoaded"};
String reason = breakReason.reason < reasonNames.length ? reasonNames[breakReason.reason] : reasonNames[0];
String reason = reasonInt < reasonNames.length ? reasonNames[reasonInt] : reasonNames[0];
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "break at {0}:{1}, reason: {2}", new Object[]{newBreakScriptName, message.line, reason});
@@ -717,7 +718,7 @@ public class DebuggerHandler implements DebugConnectionListener {
breakIp = message.line;
}
if (breakReason.reason == InBreakReason.REASON_SCRIPT_LOADED) {
if (reasonInt == InBreakReason.REASON_SCRIPT_LOADED) {
if (!Configuration.debugHalt.get()) {
commands.sendContinue();
return;
@@ -744,6 +745,17 @@ public class DebuggerHandler implements DebugConnectionListener {
}
});
synchronized (this) {
connected = true;
}
if (!isAS3) {
try {
commands.getConnection().writeMessage(new OutRewind(commands.getConnection()));
} catch (IOException ex) {
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
for (ConnectionListener l : clisteners) {
l.connected();
}