mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 05:40:45 +00:00
AS3 debugger start halt fix
AS2 debugger - offsets fix, functions fix
This commit is contained in:
@@ -39,7 +39,9 @@ import com.jpexs.debugger.flash.messages.in.InVersion;
|
||||
import com.jpexs.debugger.flash.messages.out.OutGetBreakReason;
|
||||
import com.jpexs.debugger.flash.messages.out.OutGetSwd;
|
||||
import com.jpexs.debugger.flash.messages.out.OutGetSwf;
|
||||
import com.jpexs.debugger.flash.messages.out.OutPlay;
|
||||
import com.jpexs.debugger.flash.messages.out.OutProcessedTag;
|
||||
import com.jpexs.debugger.flash.messages.out.OutRewind;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import java.io.IOException;
|
||||
@@ -86,10 +88,16 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
private String breakScriptName = null;
|
||||
|
||||
public int getBreakIp() {
|
||||
if (!isPaused()) {
|
||||
return -1;
|
||||
}
|
||||
return breakIp;
|
||||
}
|
||||
|
||||
public String getBreakScriptName() {
|
||||
if (!isPaused()) {
|
||||
return "-";
|
||||
}
|
||||
return breakScriptName;
|
||||
}
|
||||
|
||||
@@ -532,18 +540,18 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "paused");
|
||||
}
|
||||
|
||||
String newBreakScriptName = "unknown";
|
||||
if (modulePaths.containsKey(message.file)) {
|
||||
newBreakScriptName = modulePaths.get(message.file);
|
||||
} else {
|
||||
Logger.getLogger(DebuggerCommands.class.getName()).log(Level.SEVERE, "Invalid file: " + message.file);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
breakInfo = con.getMessage(InBreakAtExt.class);
|
||||
breakReason = con.sendMessage(new OutGetBreakReason(con), InBreakReason.class);
|
||||
|
||||
String newBreakScriptName = "unknown";
|
||||
if (modulePaths.containsKey(message.file)) {
|
||||
newBreakScriptName = modulePaths.get(message.file);
|
||||
} else if (breakReason.reason != InBreakReason.REASON_SCRIPT_LOADED) {
|
||||
Logger.getLogger(DebuggerCommands.class.getName()).log(Level.SEVERE, "Invalid file: " + 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];
|
||||
|
||||
@@ -593,6 +601,8 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
|
||||
if (!isAS3) {
|
||||
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINER, "End of connect - sending continue");
|
||||
con.writeMessage(new OutRewind(con));
|
||||
con.writeMessage(new OutPlay(con));
|
||||
commands.sendContinue();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFBundle;
|
||||
import com.jpexs.decompiler.flash.SWFCompression;
|
||||
import com.jpexs.decompiler.flash.SWFSourceInfo;
|
||||
import com.jpexs.decompiler.flash.SearchMode;
|
||||
import com.jpexs.decompiler.flash.SwfOpenException;
|
||||
@@ -179,7 +180,9 @@ public class Main {
|
||||
|
||||
runProcess = null;
|
||||
}
|
||||
mainFrame.getPanel().clearDebuggerColors();
|
||||
if (mainFrame != null && mainFrame.getPanel() != null) {
|
||||
mainFrame.getPanel().clearDebuggerColors();
|
||||
}
|
||||
if (runProcessDebug) {
|
||||
Main.getDebugHandler().disconnect();
|
||||
}
|
||||
@@ -310,6 +313,22 @@ public class Main {
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
|
||||
swf.saveTo(fos);
|
||||
}
|
||||
|
||||
if (swf.isAS3() && Configuration.autoOpenLoadedSWFs.get()) {
|
||||
SWF instrSWF = null;
|
||||
try (FileInputStream fis = new FileInputStream(tempFile)) {
|
||||
instrSWF = new SWF(fis, false, false);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainFrameMenu.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
if (instrSWF != null) {
|
||||
DebuggerTools.injectDebugLoader(instrSWF);
|
||||
instrSWF.enableDebugging(true, new File("."));
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
|
||||
instrSWF.saveTo(fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
return;
|
||||
|
||||
@@ -351,26 +370,34 @@ public class Main {
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fTempFile))) {
|
||||
swf.saveTo(fos);
|
||||
}
|
||||
//Inject Loader
|
||||
SWF instrSWF = null;
|
||||
try (FileInputStream fis = new FileInputStream(fTempFile)) {
|
||||
instrSWF = new SWF(fis, false, false);
|
||||
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainFrameMenu.class
|
||||
.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(MainFrameMenu.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
if (instrSWF != null) {
|
||||
if (instrSWF.isAS3()) {
|
||||
instrSWF.enableDebugging(true, new File("."));
|
||||
} else {
|
||||
instrSWF.enableDebugging(false, new File("."));
|
||||
File swdFile = new File(fTempFile.getAbsolutePath().replace(".swf", ".swd"));
|
||||
instrSWF.generateSwdFile(swdFile, getPackBreakPoints(true));
|
||||
if (instrSWF.isAS3() && Configuration.autoOpenLoadedSWFs.get()) {
|
||||
DebuggerTools.injectDebugLoader(instrSWF);
|
||||
}
|
||||
instrSWF.enableDebugging(true, new File("."));
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fTempFile))) {
|
||||
instrSWF.saveTo(fos);
|
||||
}
|
||||
if (!instrSWF.isAS3()) {
|
||||
//Read again, because line file offsets changed with adding debug tags
|
||||
//TODO: handle somehow without rereading?
|
||||
instrSWF = null;
|
||||
try (FileInputStream fis = new FileInputStream(fTempFile)) {
|
||||
instrSWF = new SWF(fis, false, false);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(MainFrameMenu.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
if (instrSWF != null) {
|
||||
File swdFile = new File(fTempFile.getAbsolutePath().replace(".swf", ".swd"));
|
||||
instrSWF.generateSwdFile(swdFile, getPackBreakPoints(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user