Added: AS1/2 Debugging - _global variable accessible

Added: AS Debugging - Variables with flag DontEnumerate are hidden by default (can be changed in Advanced Settings)
This commit is contained in:
Jindra Petřík
2025-08-24 06:18:27 +02:00
parent f15e154906
commit de2b174165
7 changed files with 56 additions and 7 deletions

View File

@@ -24,6 +24,9 @@ All notable changes to this project will be documented in this file.
Limitation: It's not available on Mac x86-64 platform
- [#2519] AS1/2 Direct editation + P-code - better handling of "too large"
error messages - highlight actual problematic structure
- AS1/2 Debugging - _global variable accessible
- AS Debugging - Variables with flag DontEnumerate are hidden by default
(can be changed in Advanced Settings)
### Fixed
- [#2474] Gotos incorrectly decompiled

View File

@@ -1158,6 +1158,10 @@ public final class Configuration {
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
public static ConfigurationItem<Boolean> autoDeobfuscateIdentifiers = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
public static ConfigurationItem<Boolean> showVarsWithDontEnumerateFlag = null;
private static Map<String, String> configurationDescriptions = new LinkedHashMap<>();
private static Map<String, String> configurationTitles = new LinkedHashMap<>();

View File

@@ -39,6 +39,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
@@ -501,15 +502,27 @@ public class DebugPanel extends JPanel {
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;
}
safeSetTreeModel(debugRegistersTable, new ABCPanel.VariablesTableModel(debugRegistersTable, f.registers));
List<Variable> locals = new ArrayList<>();
if (root != null) {
locals.add(root);
Map<String, Long> placedObjects = Main.getDebugHandler().getPlacedObjects();
for (String poName : placedObjects.keySet()) {
String realName = poName;
if ("/".equals(realName)) {
realName = "_root";
} else if (realName.startsWith("/")) {
continue;
}
Variable placedVar = Main.getDebugHandler().getVariable(0, realName, false, false).parent;
if (placedVar != null) {
locals.add(placedVar);
}
}
safeSetTreeModel(debugRegistersTable, new ABCPanel.VariablesTableModel(debugRegistersTable, f.registers));
locals.addAll(f.arguments);
locals.addAll(f.variables);

View File

@@ -34,6 +34,7 @@ import com.jpexs.debugger.flash.messages.in.InErrorException;
import com.jpexs.debugger.flash.messages.in.InFrame;
import com.jpexs.debugger.flash.messages.in.InGetVariable;
import com.jpexs.debugger.flash.messages.in.InNumScript;
import com.jpexs.debugger.flash.messages.in.InPlaceObject;
import com.jpexs.debugger.flash.messages.in.InProcessTag;
import com.jpexs.debugger.flash.messages.in.InScript;
import com.jpexs.debugger.flash.messages.in.InSetBreakpoint;
@@ -45,6 +46,7 @@ import com.jpexs.debugger.flash.messages.out.OutGetBreakReason;
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.debugger.flash.messages.out.OutStopDebug;
import com.jpexs.debugger.flash.messages.out.OutSwfInfo;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
@@ -53,6 +55,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -111,6 +114,8 @@ public class DebuggerHandler implements DebugConnectionListener {
private List<Integer> stackLines = new ArrayList<>();
private List<SWF> debuggedSwfs = new ArrayList<>();
private Map<String, Long> placedObjects = new LinkedHashMap<>();
public static class ActionScriptException extends Exception {
@@ -723,6 +728,8 @@ public class DebuggerHandler implements DebugConnectionListener {
moduleToTraitIndex.clear();
moduleToMethodIndex.clear();
moduleToSwfIndex.clear();
placedObjects.clear();
con.addMessageListener(new DebugMessageListener<InScript>() {
@Override
@@ -835,6 +842,14 @@ public class DebuggerHandler implements DebugConnectionListener {
con.dropMessage(t);
}
});
con.addMessageListener(new DebugMessageListener<InPlaceObject>() {
@Override
public void message(InPlaceObject t) {
placedObjects.put(t.path, t.objId);
con.dropMessage(t);
}
});
InSetBreakpoint isb = con.getMessage(InSetBreakpoint.class);
synchronized (this) {
@@ -1156,4 +1171,8 @@ public class DebuggerHandler implements DebugConnectionListener {
}
return null;
}
public Map<String, Long> getPlacedObjects() {
return new LinkedHashMap<>(placedObjects);
}
}

View File

@@ -400,6 +400,10 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
Variable curTrait = null;
for (int i = 0; i < igv.childs.size(); i++) {
if (!Configuration.showVarsWithDontEnumerateFlag.get() && (igv.childs.get(i).flags & VariableFlags.DONT_ENUMERATE) > 0) {
continue;
}
if (!isTraits(igv.childs.get(i))) {
Long parentObjectId = varToObjectId(varInsideGetter);
childs.add(new VariableNode(path, level + 1, igv.childs.get(i), parentObjectId, curTrait));

View File

@@ -636,3 +636,6 @@ config.description.showHeapStatusWidget = Displays used memory widget in the tit
config.name.autoDeobfuscateIdentifiers = Deobfuscate identifiers
config.description.autoDeobfuscateIdentifiers = Obfuscated names that are not valid identifiers will be printed as _SafeStr_XX, _SafeCls_XX or _SafePkg_XX.
config.name.showVarsWithDontEnumerateFlag = Debugger - show vars with DontEnumerate flag
config.description.showVarsWithDontEnumerateFlag = While debugging ActionScript, show also variables with special DontEnumerate flag, which are internal to flash. It is recommended to hide them as they are usually not relevant.

View File

@@ -636,3 +636,6 @@ config.description.showHeapStatusWidget = Zobraz\u00ed widget s pou\u017eitou pa
config.name.autoDeobfuscateIdentifiers = Deobfuskovat idenfitik\u00e1tory
config.description.autoDeobfuscateIdentifiers = Obfuskovan\u00e9 n\u00e1zvy kter\u00e9 nejsou platn\u00fdmi identifik\u00e1tory budou zobrazeny ve form\u00e1tu _SafeStr_XX.
config.name.showVarsWithDontEnumerateFlag = Lad\u011bn\u00ed - zobrazit prom\u011bnn\u00e9 s p\u0159\u00edznakem DontEnumerate
config.description.showVarsWithDontEnumerateFlag = B\u011bhem lad\u011bn\u00ed ActionScriptu zobrazit tak\u00e9 prom\u011bnn\u00e9 se speci\u00e1ln\u00edm p\u0159\u00edznakem DontEnumerate, kter\u00fd je intern\u00ed pro flash. Je doporu\u010deno tyto polo\u017eky skr\u00fdt, jeliko\u017e jsou obvykle nerelevantn\u00ed.