diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f0bc741..3d0623fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. - Apply unpacker menu on binary data - Harman unpacker for binary data - Multilevel binary data unpacking is possible +- [#2131] AS1/2 Debugger - show _root variable ### Fixed - [#2021], [#2000] Caret position in editors when using tabs and / or unicode @@ -47,6 +48,8 @@ All notable changes to this project will be documented in this file. - Linenumbers are visible even if debug markers are used - Marker of stack frames not properly cleared - Retain AS3 script selection in the tree after its editation and saving whole SWF +- [#2131] AS1/2 Debugger - Breakpoint handling - incorrect script names +- [#2131] Debugger - Correct walking variables tree ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class @@ -3304,6 +3307,7 @@ Major version of SWF to XML export changed to 2. [#2123]: https://www.free-decompiler.com/flash/issues/2123 [#2119]: https://www.free-decompiler.com/flash/issues/2119 [#2129]: https://www.free-decompiler.com/flash/issues/2129 +[#2131]: https://www.free-decompiler.com/flash/issues/2131 [#2021]: https://www.free-decompiler.com/flash/issues/2021 [#2000]: https://www.free-decompiler.com/flash/issues/2000 [#2116]: https://www.free-decompiler.com/flash/issues/2116 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index c4c4152f9..2385fa1f4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -2315,7 +2315,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } Map asmsToExport = new LinkedHashMap<>(); for (TreeItem treeItem : getFirstLevelASMNodes(null)) { - getASMs(exportFileNames, treeItem, nodesToExport, exportAll, asmsToExport, File.separator + getASMPath(exportFileNames, treeItem)); + getASMs(exportFileNames, treeItem, nodesToExport, exportAll, asmsToExport, + File.separator + getASMPath(true, treeItem), + File.separator + getASMPath(false, treeItem) + ); } if (exportAll) { if (exportFileNames) { @@ -2327,48 +2330,67 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { return asmsToExport; } - private void getASMs(boolean exportFileNames, TreeItem treeItem, List nodesToExport, boolean exportAll, Map asmsToExport, String path) { + private void getASMs(boolean exportFileNames, TreeItem treeItem, List nodesToExport, boolean exportAll, Map asmsToExport, String pathExportFilenames, String pathNoExportFilenames) { TreeItem realItem = treeItem instanceof TagScript ? ((TagScript) treeItem).getTag() : treeItem; boolean exportNode = nodesToExport.contains(treeItem) || nodesToExport.contains(realItem); if (realItem instanceof ASMSource && (exportAll || exportNode)) { - String npath = path; - String exPath = path; + String pathNoExportFilenames2 = pathNoExportFilenames; + String pathExportFilenames2 = pathExportFilenames; + String path = exportFileNames ? pathExportFilenames : pathNoExportFilenames; + int ppos = 1; - while (asmsToExport.containsKey(npath)) { + while (asmsToExport.containsKey(path)) { ppos++; - npath = path + (exportFileNames ? "[" + ppos + "]" : "_" + ppos); - exPath = path + "[" + ppos + "]"; + pathNoExportFilenames2 = pathNoExportFilenames + "_" + ppos; + pathExportFilenames2 = pathExportFilenames + "[" + ppos + "]"; + path = exportFileNames ? pathExportFilenames2 : pathNoExportFilenames2; } - ((ASMSource) realItem).setScriptName(exPath); - asmsToExport.put(npath, (ASMSource) realItem); + ((ASMSource) realItem).setScriptName(pathNoExportFilenames2); + ((ASMSource) realItem).setExportedScriptName(pathExportFilenames2); + asmsToExport.put(path, (ASMSource) realItem); } if (treeItem instanceof TagScript) { TagScript tagScript = (TagScript) treeItem; for (TreeItem subItem : tagScript.getFrames()) { - getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, + pathExportFilenames + File.separator + getASMPath(true, subItem), + pathNoExportFilenames + File.separator + getASMPath(false, subItem) + ); } } else if (treeItem instanceof FrameScript) { FrameScript frameScript = (FrameScript) treeItem; Frame parentFrame = frameScript.getFrame(); for (TreeItem subItem : parentFrame.actionContainers) { - getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, + pathExportFilenames + File.separator + getASMPath(true, subItem), + pathNoExportFilenames + File.separator + getASMPath(false, subItem) + ); } for (TreeItem subItem : parentFrame.actions) { - getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, + pathExportFilenames + File.separator + getASMPath(true, subItem), + pathNoExportFilenames + File.separator + getASMPath(false, subItem) + ); } } else if (treeItem instanceof AS2Package) { AS2Package as2Package = (AS2Package) treeItem; for (TreeItem subItem : as2Package.subPackages.values()) { if ((subItem instanceof AS2Package) && ((AS2Package) subItem).isDefaultPackage()) { - getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path); + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, pathExportFilenames, pathNoExportFilenames); } else { - getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, + pathExportFilenames + File.separator + getASMPath(true, subItem), + pathNoExportFilenames + File.separator + getASMPath(false, subItem) + ); } } for (TreeItem subItem : as2Package.scripts.values()) { - getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem)); + getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, + pathExportFilenames + File.separator + getASMPath(true, subItem), + pathNoExportFilenames + File.separator + getASMPath(false, subItem) + ); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 63d2891f0..e636b1c24 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -61,6 +61,9 @@ public class DoActionTag extends Tag implements ASMSource { @Internal private String scriptName = "-"; + + @Internal + private String exportedScriptName = "-"; @Override public String getScriptName() { @@ -258,4 +261,14 @@ public class DoActionTag extends Tag implements ASMSource { return new ArrayList<>(); } } + + @Override + public String getExportedScriptName() { + return exportedScriptName; + } + + @Override + public void setExportedScriptName(String scriptName) { + this.exportedScriptName = scriptName; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index d9b5ed21e..56345e635 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -68,6 +68,9 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { @Internal private String scriptName = "-"; + + @Internal + private String exportedScriptName = "-"; @Override public String getScriptName() { @@ -291,4 +294,14 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { return new ArrayList<>(); } } + + @Override + public String getExportedScriptName() { + return exportedScriptName; + } + + @Override + public void setExportedScriptName(String scriptName) { + this.exportedScriptName = scriptName; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index ca448298e..e03fbf4c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -123,4 +123,8 @@ public interface ASMSource extends Exportable, HasSwfAndTag { public String getScriptName(); public void setScriptName(String scriptName); + + public String getExportedScriptName(); + + public void setExportedScriptName(String scriptName); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonAction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonAction.java index ba78689da..7f0828544 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonAction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonAction.java @@ -45,6 +45,8 @@ public class ButtonAction implements ASMSource { List listeners = new ArrayList<>(); private String scriptName = "-"; + + private String exportedScriptName = "-"; private final DefineButtonTag buttonTag; @@ -227,4 +229,14 @@ public class ButtonAction implements ASMSource { return new ArrayList<>(); } } + + @Override + public String getExportedScriptName() { + return exportedScriptName; + } + + @Override + public void setExportedScriptName(String scriptName) { + this.exportedScriptName = scriptName; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index b4e2a9c8a..638cb4109 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -55,6 +55,8 @@ public class BUTTONCONDACTION implements ASMSource, Serializable, HasSwfAndTag { private Tag tag; private String scriptName = "-"; + + private String exportedScriptName = "-"; @Override public String getScriptName() { @@ -382,4 +384,14 @@ public class BUTTONCONDACTION implements ASMSource, Serializable, HasSwfAndTag { return new ArrayList<>(); } } + + @Override + public String getExportedScriptName() { + return exportedScriptName; + } + + @Override + public void setExportedScriptName(String scriptName) { + this.exportedScriptName = scriptName; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index 31f3f317c..00eff73f0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -50,6 +50,7 @@ import java.util.List; public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag { private String scriptName = "-"; + private String exportedScriptName = "-"; private CLIPACTIONS parentClipActions; @Override @@ -371,4 +372,14 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag { return new ArrayList<>(); } } + + @Override + public String getExportedScriptName() { + return exportedScriptName; + } + + @Override + public void setExportedScriptName(String scriptName) { + this.exportedScriptName = scriptName; + } } diff --git a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java index a2323e1dc..39599c272 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java @@ -21,6 +21,7 @@ import com.jpexs.debugger.flash.messages.in.InBreakAtExt; import com.jpexs.debugger.flash.messages.in.InConstantPool; import com.jpexs.debugger.flash.messages.in.InFrame; import com.jpexs.debugger.flash.messages.in.InGetVariable; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.DebuggerHandler.BreakListener; import com.jpexs.decompiler.flash.gui.abc.ABCPanel; @@ -504,15 +505,26 @@ public class DebugPanel extends JPanel { SelectedTab oldSel = selectedTab; localsTable = null; + SWF swf = Main.getMainFrame().getPanel().getCurrentSwf(); + if (swf == null) { + return; + } + boolean as3 = swf.isAS3(); InFrame f = Main.getDebugHandler().getFrame(); if (f != null) { - + Variable root = null; + if (!as3) { + root = Main.getDebugHandler().getVariable(0, "_root", false, false).parent; + } List regVarIds = new ArrayList<>(); for (int i = 0; i < f.registers.size(); i++) { regVarIds.add(0L); } safeSetTreeModel(debugRegistersTable, new ABCPanel.VariablesTableModel(debugRegistersTable, f.registers, regVarIds)); List locals = new ArrayList<>(); + if (root != null) { + locals.add(root); + } locals.addAll(f.arguments); locals.addAll(f.variables); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index c79fe3b74..9a5dfab3f 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -359,15 +359,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener 0) { @@ -440,6 +440,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener { - setEditorText("-", "; " + AppStrings.translate("work.disassembling") + " - " + phase + " " + percent + "%...", "text/flasm"); + setEditorText("-", "-", "; " + AppStrings.translate("work.disassembling") + " - " + phase + " " + percent + "%...", "text/flasm"); }); } } @@ -533,9 +533,9 @@ public class ActionPanel extends JPanel implements SearchListener { - setEditorText(asm.getScriptName(), "; " + AppStrings.translate("work.disassembling") + "...", "text/flasm"); + setEditorText(asm.getScriptName(), asm.getExportedScriptName(), "; " + AppStrings.translate("work.disassembling") + "...", "text/flasm"); if (decompileNeeded) { - setDecompiledText("-", "// " + AppStrings.translate("work.waitingfordissasembly") + "..."); + setDecompiledText("-", "-", "// " + AppStrings.translate("work.waitingfordissasembly") + "..."); } }); @@ -547,7 +547,7 @@ public class ActionPanel extends JPanel implements SearchListener { - setDecompiledText("-", "// " + AppStrings.translate("work.decompiling") + "..."); + setDecompiledText("-", "-", "// " + AppStrings.translate("work.decompiling") + "..."); }); HighlightedText htext = SWF.getCached(asm, innerActions); @@ -571,10 +571,10 @@ public class ActionPanel extends JPanel implements SearchListener bkptLines = Main.getScriptBreakPoints(scriptName, false); + Set bkptLines = Main.getScriptBreakPoints(breakPointScriptName, false); for (int line : bkptLines) { - if (Main.isBreakPointValid(scriptName, line)) { + if (Main.isBreakPointValid(breakPointScriptName, line)) { addColorMarker(line + firstLineOffset(), BREAKPOINT_MARKER); } else { addColorMarker(line + firstLineOffset(), INVALID_BREAKPOINT_MARKER); } } - int ip = Main.getIp(scriptName); + int ip = Main.getIp(breakPointScriptName); String ipPath = Main.getIpClass(); - if (ip > 0 && ipPath != null && ipPath.equals(scriptName)) { + if (ip > 0 && ipPath != null && ipPath.equals(breakPointScriptName)) { addColorMarker(ip + firstLineOffset(), IP_MARKER); } List stackLines = Main.getStackLines(); @@ -137,7 +140,7 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP for (int i = 1; i < stackClasses.size(); i++) { String cls = stackClasses.get(i); int line = stackLines.get(i); - if (cls.equals(scriptName)) { + if (cls.equals(breakPointScriptName)) { addColorMarker(line + firstLineOffset(), STACK_MARKER); } } @@ -153,6 +156,10 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP return scriptName; } + public String getBreakPointScriptName() { + return breakPointScriptName; + } + @Override public void paintLineMarker(Graphics g, int line, int x, int lineY, int textY, int lineHeight, boolean currentLine, int maxLines) {