Debugging in the browser, improved

This commit is contained in:
Jindra Petřík
2026-02-14 18:58:41 +01:00
parent 8032b2e39b
commit d5b9d54314
12 changed files with 1674 additions and 1308 deletions
@@ -197,16 +197,16 @@ public class BreakpointListDialog extends AppDialog {
defaultTableModel.addColumn(translate("breakpoint.line"));
defaultTableModel.addColumn(translate("breakpoint.status"));
Map<String, Set<Integer>> breakpoints = Main.getDebugHandler().getAllBreakPoints(swf, false);
Map<String, Set<Integer>> breakpoints = Main.getDebugHandler().getAllSessionsBreakPoints(swf);
List<Breakpoint> newBreakpointList = new ArrayList<>();
for (String scriptName : breakpoints.keySet()) {
for (int line : breakpoints.get(scriptName)) {
newBreakpointList.add(new Breakpoint(scriptName, line));
String status = "unknown";
if (Main.getDebugHandler().isBreakpointInvalid(swf, scriptName, line)) {
if (Main.getCurrentDebugSession().isBreakpointInvalid(swf, scriptName, line)) {
status = "invalid";
} else if (Main.getDebugHandler().isBreakpointConfirmed(swf, scriptName, line)) {
} else if (Main.getCurrentDebugSession().isBreakpointConfirmed(swf, scriptName, line)) {
status = "confirmed";
}
defaultTableModel.addRow(new Object[]{scriptName, line, translate("breakpoint.status." + status)});
@@ -36,6 +36,7 @@ import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -89,6 +90,8 @@ public class DebugPanel extends JPanel {
private boolean loading = false;
public ABCPanel.VariablesTableModel localsTable;
private WeakReference<DebuggerSession> currentSessionRef = null;
public static enum SelectedTab {
@@ -140,7 +143,7 @@ public class DebugPanel extends JPanel {
}
private void logAdd(String message) {
private void logAdd(DebuggerSession session, String message) {
boolean wasEmpty = logLength == 0;
String add = message + "\r\n";
logLength += add.length();
@@ -151,7 +154,7 @@ public class DebugPanel extends JPanel {
//ignore
}
if (wasEmpty) {
refresh();
refresh(session);
}
}
@@ -177,6 +180,15 @@ public class DebugPanel extends JPanel {
}
private void dopop(MouseEvent e) {
if (currentSessionRef == null) {
return;
}
DebuggerSession session = currentSessionRef.get();
if (session == null) {
return;
}
if (debugLocalsTable.getSelectedRow() == -1) {
return;
}
@@ -241,8 +253,8 @@ public class DebugPanel extends JPanel {
}*/
//Variant using comma separated bytes, pretty fast
try {
Variable debugConnectionClass = Main.getDebugHandler().getVariable(0, Main.currentDebuggerPackage + "::DebugConnection", false, false).parent;
String dataStr = (String) Main.getDebugHandler().callMethod(debugConnectionClass, "readCommaSeparatedFromByteArray", Arrays.asList(v)).variables.get(0).value;
Variable debugConnectionClass = session.getVariable(0, Main.currentDebuggerPackage + "::DebugConnection", false, false).parent;
String dataStr = (String) session.callMethod(debugConnectionClass, "readCommaSeparatedFromByteArray", Arrays.asList(v)).variables.get(0).value;
String[] parts = dataStr.split(",");
byte[] data = new byte[parts.length];
for (int i = 0; i < parts.length; i++) {
@@ -313,9 +325,9 @@ public class DebugPanel extends JPanel {
splitter = ",";
}
String dataStr = sb.toString();
Variable debugConnectionClass = Main.getDebugHandler().getVariable(0, Main.currentDebuggerPackage + "::DebugConnection", false, false).parent;
Variable debugConnectionClass = session.getVariable(0, Main.currentDebuggerPackage + "::DebugConnection", false, false).parent;
try {
Main.getDebugHandler().callMethod(debugConnectionClass, "writeCommaSeparatedToByteArray", Arrays.asList(dataStr, v));
session.callMethod(debugConnectionClass, "writeCommaSeparatedToByteArray", Arrays.asList(dataStr, v));
} catch (DebuggerHandler.ActionScriptException ex) {
Logger.getLogger(DebugPanel.class.getName()).log(Level.SEVERE, "Error exporting ByteArray", ex);
}
@@ -334,19 +346,19 @@ public class DebugPanel extends JPanel {
JMenu addWatchMenu = new JMenu(AppStrings.translate("debug.watch.add").replace("%name%", v.name));
JMenuItem watchReadMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.read"));
watchReadMenuItem.addActionListener((ActionEvent e1) -> {
if (!Main.addWatch(v, watchParentId, true, false)) {
if (!Main.addWatch(session, v, watchParentId, true, false)) {
ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
});
JMenuItem watchWriteMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.write"));
watchWriteMenuItem.addActionListener((ActionEvent e1) -> {
if (!Main.addWatch(v, watchParentId, false, true)) {
if (!Main.addWatch(session, v, watchParentId, false, true)) {
ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
});
JMenuItem watchReadWriteMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.readwrite"));
watchReadWriteMenuItem.addActionListener((ActionEvent e1) -> {
if (!Main.addWatch(v, watchParentId, true, true)) {
if (!Main.addWatch(session, v, watchParentId, true, true)) {
ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
});
@@ -376,41 +388,41 @@ public class DebugPanel extends JPanel {
Main.getDebugHandler().addTraceListener(new DebuggerHandler.TraceListener() {
@Override
public void trace(String... val) {
public void trace(DebuggerSession session, String... val) {
for (String s : val) {
logAdd("trace: " + s);
logAdd(session, "trace: " + s);
}
}
});
Main.getDebugHandler().addErrorListener(new DebuggerHandler.ErrorListener() {
@Override
public void errorException(String message, Variable thrownVar) {
logAdd("unhandled exception: " + message);
public void errorException(DebuggerSession session, String message, Variable thrownVar) {
logAdd(session, "unhandled exception: " + message);
selectedTab = tabTypes.get(tabTypes.size() - 1);
refresh();
refresh(session);
}
});
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
}
@Override
public void disconnected() {
refresh();
public void disconnected(DebuggerSession session) {
refresh(session);
}
});
Main.getDebugHandler().addFrameChangeListener(frameChangeListener = new DebuggerHandler.FrameChangeListener() {
@Override
public void frameChanged() {
public void frameChanged(DebuggerSession session) {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
refresh();
refresh(session);
}
});
}
@@ -419,17 +431,17 @@ public class DebugPanel extends JPanel {
Main.getDebugHandler().addBreakListener(breakListener = new DebuggerHandler.BreakListener() {
@Override
public void doContinue() {
public void doContinue(DebuggerSession session) {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
refresh();
refresh(session);
}
});
}
@Override
public void breakAt(String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
public void breakAt(DebuggerSession session, String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
}
});
@@ -484,8 +496,9 @@ public class DebugPanel extends JPanel {
}
return v.getMembers(this);
}*/
public void refresh() {
public void refresh(DebuggerSession session) {
currentSessionRef = session == null ? null : new WeakReference<>(session);
View.execInEventDispatch(new Runnable() {
@Override
@@ -495,19 +508,14 @@ public class DebugPanel extends JPanel {
SelectedTab oldSel = selectedTab;
localsTable = null;
SWF swf = Main.getDebuggedSWF();
if (swf == null) {
return;
}
boolean as3 = swf.isAS3();
InFrame f = Main.getDebugHandler().getFrame();
InFrame f = session == null ? null : session.getFrame();
if (f != null) {
List<Variable> locals = new ArrayList<>();
Map<String, Long> placedObjects = Main.getDebugHandler().getPlacedObjects();
Map<String, Long> placedObjects = session.getPlacedObjects();
for (String poName : placedObjects.keySet()) {
String realName = poName;
if ("/".equals(realName)) {
@@ -515,7 +523,7 @@ public class DebugPanel extends JPanel {
} else if (realName.startsWith("/")) {
continue;
}
Variable placedVar = Main.getDebugHandler().getVariable(0, realName, false, false).parent;
Variable placedVar = session.getVariable(0, realName, false, false).parent;
if (placedVar != null) {
locals.add(placedVar);
}
@@ -540,26 +548,26 @@ public class DebugPanel extends JPanel {
TreeModelListener refreshListener = new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
Main.getDebugHandler().refreshFrame();
refresh();
session.refreshFrame();
refresh(session);
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
Main.getDebugHandler().refreshFrame();
refresh();
session.refreshFrame();
refresh(session);
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
Main.getDebugHandler().refreshFrame();
refresh();
session.refreshFrame();
refresh(session);
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
Main.getDebugHandler().refreshFrame();
refresh();
session.refreshFrame();
refresh(session);
}
};
debugLocalsTable.getTreeTableModel().addTreeModelListener(refreshListener);
@@ -569,7 +577,7 @@ public class DebugPanel extends JPanel {
debugLocalsTable.setTreeModel(new ABCPanel.VariablesTableModel(debugLocalsTable, new ArrayList<>()));
debugScopeTable.setTreeModel(new ABCPanel.VariablesTableModel(debugScopeTable, new ArrayList<>()));
}
InConstantPool cpool = Main.getDebugHandler().getConstantPool();
InConstantPool cpool = session == null ? null : session.getConstantPool();
if (cpool != null) {
Object[][] data2 = new Object[cpool.vars.size()][2];
for (int i = 0; i < cpool.vars.size(); i++) {
@@ -635,7 +643,7 @@ public class DebugPanel extends JPanel {
public void actionPerformed(ActionEvent e) {
traceLogTextarea.setText("");
logLength = 0;
refresh();
refresh(session);
}
});
JPanel butPanel = new JPanel(new FlowLayout());
@@ -23,6 +23,7 @@ import java.awt.Component;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.ref.WeakReference;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
@@ -46,35 +47,40 @@ public class DebugStackPanel extends JPanel {
private int[] classIndices = new int[0];
private int[] methodIndices = new int[0];
private int[] traitIndices = new int[0];
private WeakReference<DebuggerSession> currentSessionRef = null;
public DebugStackPanel() {
stackTable = new JTable();
Main.getDebugHandler().addFrameChangeListener(new DebuggerHandler.FrameChangeListener() {
@Override
public void frameChanged() {
depth = Main.getDebugHandler().getDepth();
refresh();
public void frameChanged(DebuggerSession session) {
if (session == null) {
refresh(null);
return;
}
depth = session.getDepth();
refresh(session);
}
});
Main.getDebugHandler().addBreakListener(new DebuggerHandler.BreakListener() {
@Override
public void breakAt(String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
public void breakAt(DebuggerSession session, String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
}
@Override
public void doContinue() {
public void doContinue(DebuggerSession session) {
clear();
}
});
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
}
@Override
public void disconnected() {
public void disconnected(DebuggerSession session) {
clear();
}
});
@@ -96,7 +102,13 @@ public class DebugStackPanel extends JPanel {
SWF swf = swfHash == null ? Main.getRunningSWF() : Main.getSwfByHash(swfHash);
Main.getMainFrame().getPanel().gotoScriptLine(swf,
scriptName, line, classIndices[row], traitIndices[row], methodIndices[row], Main.isDebugPCode());
Main.getDebugHandler().setDepth(row);
DebuggerSession session = null;
if (currentSessionRef != null) {
session = currentSessionRef.get();
}
if (session != null) {
session.setDepth(row);
}
}
}
}
@@ -112,8 +124,12 @@ public class DebugStackPanel extends JPanel {
return active;
}
public void refresh() {
InBreakAtExt info = Main.getDebugHandler().getBreakInfo();
public void refresh(DebuggerSession session) {
if (session == null) {
clear();
return;
}
InBreakAtExt info = session.getBreakInfo();
if (info == null) {
clear();
return;
@@ -126,7 +142,7 @@ public class DebugStackPanel extends JPanel {
int[] newTraitIndices = new int[info.files.size()];
for (int i = 0; i < info.files.size(); i++) {
int f = info.files.get(i);
String moduleName = Main.getDebugHandler().moduleToString(f);
String moduleName = session.moduleToString(f);
String swfHash = null;
if (moduleName.contains(":")) {
swfHash = moduleName.substring(0, moduleName.indexOf(":"));
@@ -137,11 +153,11 @@ public class DebugStackPanel extends JPanel {
data[i][1] = moduleName;
data[i][2] = info.lines.get(i);
data[i][3] = info.stacks.get(i);
Integer newClassIndex = Main.getDebugHandler().moduleToClassIndex(f);
Integer newClassIndex = session.moduleToClassIndex(f);
newClassIndices[i] = newClassIndex == null ? -1 : newClassIndex;
Integer newMethodIndex = Main.getDebugHandler().moduleToMethodIndex(f);
Integer newMethodIndex = session.moduleToMethodIndex(f);
newMethodIndices[i] = newMethodIndex == null ? -1 : newMethodIndex;
Integer newTraitIndex = Main.getDebugHandler().moduleToTraitIndex(f);
Integer newTraitIndex = session.moduleToTraitIndex(f);
;
newTraitIndices[i] = newTraitIndex == null ? -1 : newTraitIndex;
}
@@ -184,6 +200,7 @@ public class DebugStackPanel extends JPanel {
repaint();
}
});
currentSessionRef = new WeakReference<>(session);
}
public int getDepth() {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+207 -118
View File
@@ -105,6 +105,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.Proxy;
@@ -231,49 +232,60 @@ public class Main {
public static String currentDebuggerPackage = null;
private static SWF runningSWF = null;
private static SWF debuggedSWF = null;
private static String preparedHashSha256 = null;
private static SwfPreparation runningPreparation = null;
private static boolean loggingFileLoaded = false;
private static boolean debugListening = false;
public static SWF getDebuggedSWF() {
return debuggedSWF;
}
public static void findDebuggedSwf(String hashSha256) {
System.err.println("Searching for hash " + hashSha256 + "...");
public static void setDebuggedSWF(SWF swf) {
debuggedSWF = swf;
}
/**
* Searches opened swfs for swf with sha256 hash of its decompressed form
*
* @param hashSha256 Hex sha 256
* @return SWF or null if not found
*/
public static SWF findOpenedSwfByHash(String hashSha256) {
Logger.getLogger(Main.class.getName()).log(Level.FINE, "Searching for hash {0}...", hashSha256);
for (SWF swf : mainFrame.getPanel().getAllSwfs()) {
System.err.println("Checking " + swf +" with hash " + swf.getHashSha256());
Logger.getLogger(Main.class.getName()).log(Level.FINE, "Checking {0} with hash {1}", new Object[]{swf.toString(), swf.getHashSha256()});
if (Objects.equals(hashSha256, swf.getHashSha256())) {
Main.debuggedSWF = swf;
System.err.println("RECEIVED SWF FOUND");
return;
Logger.getLogger(Main.class.getName()).log(Level.FINE, "RECEIVED SWF FOUND");
return swf;
}
}
if (preparedHashSha256 != null && hashSha256.equals(preparedHashSha256)) {
System.err.println("RECEIVED SWF IS ONE THAT WAS PREPARED FOR RUN...");
Main.debuggedSWF = runningSWF;
return;
Logger.getLogger(Main.class.getName()).log(Level.FINE, "RECEIVED SWF IS ONE THAT WAS PREPARED FOR RUN...");
return runningSWF;
}
System.err.println("RECEIVED SWF IS NOT ANY OF OURS");
Main.debuggedSWF = null;
Logger.getLogger(Main.class.getName()).log(Level.FINE, "RECEIVED SWF IS NOT ANY OF OURS");
return null;
}
public static SWF getRunningSWF() {
//System.err.println("debuggedSWF: " + (debuggedSWF == null ? "NOT SET" : debuggedSWF));
//return runningSWF;
return debuggedSWF;
//return debuggedSWF;
DebuggerSession session = getCurrentDebugSession();
if (session != null) {
return session.getDebuggedSwfs().get(0);
}
return null;
}
public static WatchService getWatcher() {
@@ -331,12 +343,16 @@ public class Main {
mainFrame.getPanel().clearDebuggerColors();
}
if (runProcessDebug) {
Main.getDebugHandler().disconnect();
Main.getDebugHandler().terminateAllSessions();
}
}
public static synchronized boolean isDebugPaused() {
return (runProcess != null && runProcessDebug || !flashDebugger.isStopped()) && getDebugHandler().isPaused();
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return false;
}
return (runProcess != null && runProcessDebug || !flashDebugger.isStopped()) && session.isPaused();
}
public static synchronized boolean isDebugRunning() {
@@ -348,60 +364,60 @@ public class Main {
}
public static synchronized boolean isDebugConnected() {
return getDebugHandler().isConnected();
return getDebugHandler().isAnySessionConnected();
}
public static synchronized boolean isRunning() {
return runProcess != null && !runProcessDebug;
}
public static synchronized void debugExportByteArray(Variable v, OutputStream os) throws IOException {
public static synchronized void debugExportByteArray(DebuggerSession session, Variable v, OutputStream os) throws IOException {
try {
long objectId = 0L;
if ((v.vType == VariableType.OBJECT || v.vType == VariableType.MOVIECLIP)) {
objectId = (Long) v.value;
}
Object oldPos = getDebugHandler().getVariable(objectId, "position", false, true).parent.value;
getDebugHandler().setVariable(objectId, "position", VariableType.NUMBER, 0);
int length = (int) (double) (Double) getDebugHandler().getVariable(objectId, "length", false, true).parent.value;
Object oldPos = session.getVariable(objectId, "position", false, true).parent.value;
session.setVariable(objectId, "position", VariableType.NUMBER, 0);
int length = (int) (double) (Double) session.getVariable(objectId, "length", false, true).parent.value;
for (int i = 0; i < length; i++) {
int b = (int) (double) (Double) getDebugHandler().callFunction(false, "readByte", v, new ArrayList<>()).variables.get(0).value;
int b = (int) (double) (Double) session.callFunction(false, "readByte", v, new ArrayList<>()).variables.get(0).value;
os.write(b);
}
getDebugHandler().setVariable(objectId, "position", VariableType.NUMBER, oldPos);
session.setVariable(objectId, "position", VariableType.NUMBER, oldPos);
} catch (DebuggerHandler.ActionScriptException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static synchronized void debugImportByteArray(Variable v, InputStream is) throws IOException {
public static synchronized void debugImportByteArray(DebuggerSession session, Variable v, InputStream is) throws IOException {
try {
long objectId = 0L;
if ((v.vType == VariableType.OBJECT || v.vType == VariableType.MOVIECLIP)) {
objectId = (Long) v.value;
}
Double oldPos = (Double) getDebugHandler().getVariable(objectId, "position", false, true).parent.value;
getDebugHandler().setVariable(objectId, "length", VariableType.NUMBER, 0);
getDebugHandler().setVariable(objectId, "position", VariableType.NUMBER, 0);
Double oldPos = (Double) session.getVariable(objectId, "position", false, true).parent.value;
session.setVariable(objectId, "length", VariableType.NUMBER, 0);
session.setVariable(objectId, "position", VariableType.NUMBER, 0);
int length = 0;
int b;
while ((b = is.read()) > -1) {
getDebugHandler().callFunction(false, "writeByte", v, Arrays.asList((Double) (double) b));
session.callFunction(false, "writeByte", v, Arrays.asList((Double) (double) b));
length++;
}
if (oldPos > length) {
oldPos = (Double) (double) length;
}
getDebugHandler().setVariable(objectId, "position", VariableType.NUMBER, oldPos);
session.setVariable(objectId, "position", VariableType.NUMBER, oldPos);
} catch (DebuggerHandler.ActionScriptException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static synchronized boolean addWatch(Variable v, long v_id, boolean watchRead, boolean watchWrite) {
DebuggerCommands.Watch w = getDebugHandler().addWatch(v, v_id, watchRead, watchWrite);
public static synchronized boolean addWatch(DebuggerSession session, Variable v, long v_id, boolean watchRead, boolean watchWrite) {
DebuggerCommands.Watch w = session.addWatch(v, v_id, watchRead, watchWrite);
return w != null;
}
@@ -591,9 +607,9 @@ public class Main {
});
startWork(AppStrings.translate("work.generating_swd"), swfPrepareWorker, true);
if (doPCode) {
instrSWF.generatePCodeSwdFile(swdFile, getPackBreakPoints(true, swfHash), swfHash);
instrSWF.generatePCodeSwdFile(swdFile, getAllSessionPackBreakPoints(swfHash), swfHash);
} else {
instrSWF.generateSwdFile(swdFile, getPackBreakPoints(true, swfHash), swfHash);
instrSWF.generateSwdFile(swdFile, getAllSessionPackBreakPoints(swfHash), swfHash);
}
tempFiles.add(swdFile);
}
@@ -647,12 +663,12 @@ public class Main {
try (FileOutputStream fos = new FileOutputStream(toPrepareFile)) {
instrSWF.saveTo(fos);
}
if ("main".equals(swfHash)) {
if ("main".equals(swfHash)) {
preparedHashSha256 = instrSWF.getHashSha256();
}
}
}
}
}
public static void prepareForDebug(SWF swf, File fTempFile, File tempRunDir, List<File> tempFiles, boolean doPCode) throws IOException, InterruptedException {
SWF swfToSave = swf;
if (swf.gfx) {
@@ -661,9 +677,9 @@ public class Main {
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fTempFile))) {
swfToSave.saveTo(fos, false, swf.gfx);
}
prepareSwf("main", new SwfDebugPrepare(doPCode), fTempFile, swf.getFile() == null ? null : new File(swf.getFile()), tempRunDir, tempFiles);
prepareSwf("main", new SwfDebugPrepare(doPCode), fTempFile, swf.getFile() == null ? null : new File(swf.getFile()), tempRunDir, tempFiles);
}
private static File createTempFileInDir(File tempFilesDir, String prefix, String suffix) throws IOException {
if (tempFilesDir == null || !tempFilesDir.isDirectory()) {
return File.createTempFile(prefix, suffix);
@@ -847,10 +863,10 @@ public class Main {
Main.startWork(AppStrings.translate("work.debugging.start") + "...", null, true);
Main.startDebugger();
Main.startWork(AppStrings.translate("work.debugging.listening"), null);
mainFrame.getMenu().hilightPath("/debugging");
mainFrame.getMenu().hilightPath("/debugging");
}
public static void runDebug(SWF swf, final boolean doPCode) {
public static void runDebug(SWF swf, final boolean doPCode) {
String flashVars = ""; //key=val&key2=val2
String playerLocation = Configuration.playerDebugLocation.get();
if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) {
@@ -861,7 +877,7 @@ public class Main {
if (swf == null) {
return;
}
debugHandler.setMainDebuggedSwf(swf);
//debugHandler.setMainDebuggedSwf(swf); ???
File tempRunDir = swf.getFile() == null ? null : new File(swf.getFile()).getParentFile();
File tempFile = null;
@@ -930,61 +946,121 @@ public class Main {
}
public static synchronized int getIp(Object pack) {
return getDebugHandler().getBreakIp();
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return -1;
}
return session.getBreakIp();
}
public static synchronized String getIpClass() {
return getDebugHandler().getBreakScriptName();
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return null;
}
return session.getBreakScriptName();
}
public static synchronized List<Integer> getStackLines() {
return getDebugHandler().getStackLines();
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return new ArrayList<>();
}
return session.getStackLines();
}
public static synchronized List<String> getStackClasses() {
return getDebugHandler().getStackScripts();
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return new ArrayList<>();
}
return session.getStackScripts();
}
public static synchronized boolean isBreakPointValid(String scriptName, int line) {
DebuggerSession session = getCurrentDebugSession();
if (session == null) {
return true;
}
SWF swf = getMainFrame().getPanel().getCurrentSwf();
return !getDebugHandler().isBreakpointInvalid(swf, scriptName, line);
return !session.isBreakpointInvalid(swf, scriptName, line);
}
public static synchronized void addBreakPoint(String scriptName, int line) {
public static synchronized void addBreakPoint(DebuggerSession session, String scriptName, int line) {
SWF swf = getMainFrame().getPanel().getCurrentSwf();
getDebugHandler().addBreakPoint(swf, scriptName, line);
session.addBreakPoint(swf, scriptName, line);
}
public static synchronized void removeBreakPoint(String scriptName, int line) {
public static synchronized void removeBreakPoint(DebuggerSession session, String scriptName, int line) {
SWF swf = getMainFrame().getPanel().getCurrentSwf();
getDebugHandler().removeBreakPoint(swf, scriptName, line);
session.removeBreakPoint(swf, scriptName, line);
}
public static synchronized boolean toggleBreakPoint(String scriptName, int line) {
SWF swf = getMainFrame().getPanel().getCurrentSwf();
if (getDebugHandler().isBreakpointToAdd(swf, scriptName, line) || getDebugHandler().isBreakpointConfirmed(swf, scriptName, line) || getDebugHandler().isBreakpointInvalid(swf, scriptName, line)) {
Map<String, Set<Integer>> breakPoints = getDebugHandler().getAllSessionsBreakPoints(swf);
if (breakPoints.containsKey(scriptName) && breakPoints.get(scriptName).contains(line)) {
getDebugHandler().removeBreakPoint(swf, scriptName, line);
return false;
} else {
getDebugHandler().addBreakPoint(swf, scriptName, line);
return true;
}
getDebugHandler().addBreakPoint(swf, scriptName, line);
return true;
/*if (session.isBreakpointToAdd(swf, scriptName, line) || session.isBreakpointConfirmed(swf, scriptName, line) || session.isBreakpointInvalid(swf, scriptName, line)) {
session.removeBreakPoint(swf, scriptName, line);
return false;
} else {
session.addBreakPoint(swf, scriptName, line);
return true;
}*/
}
public static synchronized Map<String, Set<Integer>> getPackBreakPoints(boolean validOnly, String swfHash) {
public static synchronized Map<String, Set<Integer>> getAllSessionPackBreakPoints(String swfHash) {
SWF swf = Main.getSwfByHash(swfHash);
return getDebugHandler().getAllBreakPoints(swf, validOnly);
return getDebugHandler().getAllSessionsBreakPoints(swf);
}
public static synchronized Set<Integer> getScriptBreakPoints(String pack, boolean onlyValid) {
public static synchronized Map<String, Set<Integer>> getPackBreakPoints(DebuggerSession session, boolean validOnly, String swfHash) {
SWF swf = Main.getSwfByHash(swfHash);
return session.getAllBreakPoints(swf, validOnly);
}
public static synchronized Set<Integer> getScriptBreakPoints(String pack) {
SWF swf = getMainFrame().getPanel().getCurrentSwf();
return getDebugHandler().getBreakPoints(swf, pack, onlyValid);
return getDebugHandler().getAllSessionsScriptBreakPoints(swf, pack);
}
public static DebuggerHandler getDebugHandler() {
return debugHandler;
}
public static DebuggerSession getCurrentDebugSession() {
if (mainFrame == null) {
return null;
}
if (mainFrame.getPanel() == null) {
return null;
}
SWF currentSwf = mainFrame.getPanel().getCurrentSwf();
if (currentSwf == null) {
return null;
}
return getDebugHandler().getSessionContainingSwf(currentSwf);
}
public static void updateSession() {
DebuggerSession session = getCurrentDebugSession();
for (DebuggerHandler.FrameChangeListener l : getDebugHandler().getFrameChangeListeners()) {
l.frameChanged(session);
}
if (getDebugHandler().getNumberOfPausedSessions() > 0) {
mainFrame.getPanel().showDebugStackFrame();
}
}
public static void ensureMainFrame() {
if (mainFrame == null) {
synchronized (Main.class) {
@@ -1027,8 +1103,8 @@ public class Main {
loadFromMemoryFrame.setVisible(true);
}
public static void setVariable(long parentId, String varName, int valueType, Object value) {
getDebugHandler().setVariable(parentId, varName, valueType, value);
public static void setVariable(DebuggerSession session, long parentId, String varName, int valueType, Object value) {
session.setVariable(parentId, varName, valueType, value);
}
public static void setSubLimiter(boolean value) {
@@ -1100,7 +1176,7 @@ public class Main {
public static void startWork(final String name, final int percent, final CancellableWorker worker, boolean force) {
working = true;
long nowTime = System.currentTimeMillis();
if (mainFrame != null && nowTime < lastTimeStartWork + 1000) {
if (!force && mainFrame != null && nowTime < lastTimeStartWork + 1000) {
mainFrame.getPanel().setWorkStatusHidden(name, worker);
return;
}
@@ -1117,7 +1193,7 @@ public class Main {
if (loadingDialog != null) {
loadingDialog.setDetail(name);
loadingDialog.setPercent(percent);
}
}
});
if (CommandLineArgumentParser.isCommandLineMode()) {
System.out.println(name);
@@ -1470,7 +1546,7 @@ public class Main {
}
};
fc.addChoosableFileFilter(swtFilter);
FileFilter gfxFilter = new FileFilter() {
@Override
public boolean accept(File f) {
@@ -1767,7 +1843,7 @@ public class Main {
private final OpenableOpened executeAfterOpen;
private final int[] reloadIndices;
private final boolean loadSession;
public OpenFileWorker(OpenableSourceInfo sourceInfo, boolean loadSession) {
@@ -1891,6 +1967,14 @@ public class Main {
}
}
}
List<String> breakpointsList = conf.getCustomDataAsList(CustomConfigurationKeys.KEY_BREAKPOINTS);
for (String breakpoint : breakpointsList) {
if (breakpoint.matches("^.*:[0-9]+$")) {
int line = Integer.parseInt(breakpoint.substring(breakpoint.lastIndexOf(":") + 1));
String scriptName = breakpoint.substring(0, breakpoint.lastIndexOf(":"));
getDebugHandler().addBreakPoint(swf, scriptName, line);
}
}
}
}
}
@@ -1901,7 +1985,7 @@ public class Main {
View.execInEventDispatch(() -> {
if (mainFrame == null) {
ensureMainFrame();
Main.startWork(AppStrings.translate("work.creatingwindow") + "...", null);
Main.startWork(AppStrings.translate("work.creatingwindow") + "...", null);
}
loadingDialog.setVisible(false);
@@ -1926,14 +2010,6 @@ public class Main {
if (swfCustomConf != null) {
resourcesPathStr = swfCustomConf.getCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_RESOURCES, resourcesPathStr);
tagListPathStr = swfCustomConf.getCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_TAGLIST, null);
List<String> breakpointsList = swfCustomConf.getCustomDataAsList(CustomConfigurationKeys.KEY_BREAKPOINTS);
for (String breakpoint : breakpointsList) {
if (breakpoint.matches("^.*:[0-9]+$")) {
int line = Integer.parseInt(breakpoint.substring(breakpoint.lastIndexOf(":") + 1));
String scriptName = breakpoint.substring(0, breakpoint.lastIndexOf(":"));
getDebugHandler().addBreakPoint(fswf, scriptName, line);
}
}
}
if (loadSession) {
@@ -1954,7 +2030,7 @@ public class Main {
mainFrame.getPanel().tagListTree.setSelectionPath(tp);
}
} else {
mainFrame.getPanel().tagListTree.setSelectionPathString(tagListPathStr);
mainFrame.getPanel().tagListTree.setSelectionPathString(tagListPathStr);
}
} else {
mainFrame.getPanel().tagTree.setExpandPathString(resourcesPathStr);
@@ -2108,7 +2184,7 @@ public class Main {
executeAfterOpen.run();
}
}
}, loadSession
}, loadSession
);
return openResult;
} catch (IOException ex) {
@@ -2139,7 +2215,7 @@ public class Main {
return openFile(new OpenableSourceInfo[]{sourceInfo}, executeAfterOpen, new int[]{reloadIndex}, loadSession);
}
public static OpenFileResult openFile(OpenableSourceInfo[] newSourceInfos) {
View.checkAccess();
@@ -2298,7 +2374,7 @@ public class Main {
}
fc.setSelectedFile(fc.getCurrentDirectory().toPath().resolve(fileTitle).toFile());
}
FileFilter swcFilter = new FileFilter() {
@Override
public boolean accept(File f) {
@@ -2312,31 +2388,31 @@ public class Main {
}
};
fc.setFileFilter(swcFilter);
if (fc.showSaveDialog(getDefaultMessagesComponent()) != JFileChooser.APPROVE_OPTION) {
if (fc.showSaveDialog(getDefaultMessagesComponent()) != JFileChooser.APPROVE_OPTION) {
return false;
}
File file = Helper.fixDialogFile(fc.getSelectedFile());
String fileName = file.getAbsolutePath();
if (!fileName.toLowerCase(Locale.ENGLISH).endsWith(".swc")) {
fileName += ".swc";
}
}
SwfToSwcExporter exporter = new SwfToSwcExporter();
try {
exporter.exportSwf(swf, new File(fileName), false);
} catch (IOException iex) {
ViewMessages.showMessageDialog(getDefaultMessagesComponent(), iex.getMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (InterruptedException ex) {
} catch (InterruptedException ex) {
return false;
}
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
return true;
}
public static boolean saveFileDialog(Openable openable, final SaveFileMode mode) {
String ext = ".swf";
@@ -2387,7 +2463,7 @@ public class Main {
return AppStrings.translate("filter.swt");
}
};
FileFilter gfxFilter = new FileFilter() {
@Override
public boolean accept(File f) {
@@ -2492,14 +2568,14 @@ public class Main {
} else if (openable instanceof SWF) {
SWF swf = (SWF) openable;
if (swf.getFile() != null && swf.getFile().toLowerCase(Locale.ENGLISH).endsWith(".swt")) {
fc.setFileFilter(swtFilter);
fc.setFileFilter(swtFilter);
fc.addChoosableFileFilter(swfFilter);
} else {
fc.setFileFilter(swfFilter);
fc.setFileFilter(swfFilter);
fc.addChoosableFileFilter(swtFilter);
}
fc.addChoosableFileFilter(gfxFilter);
} else if (openable instanceof ABC) {
fc.setFileFilter(abcFilter);
}
@@ -2523,7 +2599,7 @@ public class Main {
}
((SWF) openable).gfx = true;
}
if (selFilter == swtFilter) {
if (!fileName.toLowerCase(Locale.ENGLISH).endsWith(".swt")) {
fileName += ".swt";
@@ -2662,7 +2738,7 @@ public class Main {
}
};
fc.addChoosableFileFilter(swtFilter);
FileFilter swcFilter = new FileFilter() {
@Override
public boolean accept(File f) {
@@ -2805,7 +2881,7 @@ public class Main {
initUiLang();
initLookAndFeel();
View.execInEventDispatch(() -> {
ErrorLogFrame.createNewInstance();
@@ -2976,13 +3052,15 @@ public class Main {
flashDebugger = new Debugger();
debugHandler = new DebuggerHandler();
debugHandler.addBreakListener(new DebuggerHandler.BreakListener() {
@Override
public void doContinue() {
public void doContinue(DebuggerSession session) {
mainFrame.getPanel().clearDebuggerColors();
mainFrame.getMenu().updateComponents();
}
@Override
public void breakAt(String scriptName, int line, final int classIndex, final int traitIndex, final int methodIndex) {
public void breakAt(DebuggerSession session, String scriptName, int line, final int classIndex, final int traitIndex, final int methodIndex) {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
@@ -2992,7 +3070,17 @@ public class Main {
hash = scriptName.substring(0, scriptName.indexOf(":"));
scriptNameNoHash = scriptName.substring(scriptName.indexOf(":") + 1);
}
SWF swf = Main.getSwfByHash(hash);
SWF swf = "main".equals(hash) ? session.getDebuggedSwfs().get(0) : Main.getSwfByHash(hash);
Logger.getLogger(Main.class.getName()).log(Level.FINE, "Break. Current session: {0}, New break session: {1}", new Object[]{Main.getCurrentDebugSession(), session});
if (
Main.getDebugHandler().getNumberOfPausedSessions() > 1
&& Main.getCurrentDebugSession() != session
) {
Logger.getLogger(Main.class.getName()).log(Level.INFO, "Another SWF ({0}) has reached breakpoint meanwhile", swf.toString());
mainFrame.getPanel().refreshBreakPoints();
return;
}
mainFrame.getPanel().gotoScriptLine(swf, scriptNameNoHash, line, classIndex, traitIndex, methodIndex, Main.isDebugPCode());
}
});
@@ -3000,12 +3088,12 @@ public class Main {
});
debugHandler.addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
Main.mainFrame.getMenu().updateComponents();
}
@Override
public void disconnected() {
public void disconnected(DebuggerSession session) {
if (Main.mainFrame != null) {
Main.mainFrame.getMenu().updateComponents();
}
@@ -3028,10 +3116,11 @@ public class Main {
}
public static void startDebugger() {
flashDebugger.startDebugger();
flashDebugger.startDebugger();
}
public static void stopDebugger() {
getDebugHandler().terminateAllSessions();
flashDebugger.stopDebugger();
}
@@ -3288,7 +3377,7 @@ public class Main {
AppStrings.updateLanguage();
Helper.decompilationErrorAdd = AppStrings.translate(Configuration.autoDeobfuscate.get() ? "deobfuscation.comment.failed" : "deobfuscation.comment.tryenable");
ResourceBundle advancedSettingsBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(AdvancedSettingsDialog.class));
Set<String> configurationNames = Configuration.getConfigurationFields(false, true).keySet();
Map<String, String> titles = new LinkedHashMap<>();
@@ -3298,7 +3387,7 @@ public class Main {
titles.put(name, advancedSettingsBundle.getString("config.name." + name));
}
if (advancedSettingsBundle.containsKey("config.description." + name)) {
descriptions.put(name, advancedSettingsBundle.getString("config.description." + name));
descriptions.put(name, advancedSettingsBundle.getString("config.description." + name));
}
}
Configuration.setConfigurationDescriptions(descriptions);
@@ -3358,11 +3447,11 @@ public class Main {
*/
public static void main(String[] args) throws IOException {
decodeLaunch5jArgs(args);
preInitLogging();
preInitLogging();
setSessionLoaded(false);
System.setProperty("sun.io.serialization.extendedDebugInfo", "true");
System.setProperty("sun.io.serialization.extendedDebugInfo", "true");
clearTemp();
try {
@@ -3638,17 +3727,17 @@ public class Main {
if (!showStable && !showNightly) {
return false;
}
String stableTagName = "version" + ApplicationInfo.version_major + "." + ApplicationInfo.version_minor + "." + ApplicationInfo.version_release;
String ignoreVersion = "-";
String currentTagName;
if (ApplicationInfo.nightly) {
currentTagName = "nightly" + ApplicationInfo.version_build;
} else {
currentTagName = stableTagName;
}
if (!showNightly) {
//prereleases are not shown as latest, when checking latest nightly, this is useless
JsonValue latestVersionInfoJson = urlGetJson(ApplicationInfo.GITHUB_RELEASES_LATEST_URL);
@@ -3799,7 +3888,7 @@ public class Main {
}
}
}
public static void initLogging(boolean debug) {
if (loggingFileLoaded) {
return;
@@ -1756,11 +1756,11 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean pauseActionPerformed(ActionEvent evt) {
try {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
DebuggerCommands cmd = Main.getCurrentDebugSession().getCommands();
//TODO
} catch (IOException ex) {
Main.getDebugHandler().disconnect();
Main.getCurrentDebugSession().disconnect();
//ignore
}
return true;
@@ -1770,13 +1770,13 @@ public abstract class MainFrameMenu implements MenuBuilder {
try {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
DebuggerCommands cmd = Main.getCurrentDebugSession().getCommands();
mainFrame.getPanel().clearDebuggerColors();
Main.startWork(AppStrings.translate("work.debugging") + "...", null);
cmd.stepOver();
} catch (IOException ex) {
Main.getDebugHandler().disconnect();
Main.getCurrentDebugSession().disconnect();
//ignore
}
return true;
@@ -1784,13 +1784,13 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean stepIntoActionPerformed(ActionEvent evt) {
try {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
DebuggerCommands cmd = Main.getCurrentDebugSession().getCommands();
mainFrame.getPanel().clearDebuggerColors();
Main.startWork(AppStrings.translate("work.debugging") + "...", null);
cmd.stepInto();
} catch (IOException ex) {
Main.getDebugHandler().disconnect();
Main.getCurrentDebugSession().disconnect();
//ignore
}
@@ -1799,12 +1799,12 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean stepOutActionPerformed(ActionEvent evt) {
try {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
DebuggerCommands cmd = Main.getCurrentDebugSession().getCommands();
mainFrame.getPanel().clearDebuggerColors();
Main.startWork(AppStrings.translate("work.debugging") + "...", null);
cmd.stepOut();
} catch (IOException ex) {
Main.getDebugHandler().disconnect();
Main.getCurrentDebugSession().disconnect();
//ignore
}
@@ -1813,12 +1813,12 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean continueActionPerformed(ActionEvent evt) {
try {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
DebuggerCommands cmd = Main.getCurrentDebugSession().getCommands();
mainFrame.getPanel().clearDebuggerColors();
Main.startWork(AppStrings.translate("work.debugging") + "...", null);
cmd.sendContinue();
} catch (IOException ex) {
Main.getDebugHandler().disconnect();
Main.getCurrentDebugSession().disconnect();
//ignore
}
@@ -451,6 +451,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
private boolean loadingScrollPosEnabled = true;
private static final DataFlavor TREE_FILE_FLAVOR = new DataFlavor(TreeFileFlavor.class, "TreeFile");
private boolean editingStatusSet = false;
public synchronized void setLoadingScrollPosEnabled(boolean loadingScrollPosEnabled) {
this.loadingScrollPosEnabled = loadingScrollPosEnabled;
@@ -972,11 +974,15 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
public void setEditingStatus() {
editingStatusSet = true;
statusPanel.setStatus(translate(Configuration.autoSaveTagModifications.get() ? "status.editing.autosave" : "status.editing"));
}
public void clearEditingStatus() {
statusPanel.setStatus("");
if (editingStatusSet) {
statusPanel.setStatus("");
editingStatusSet = false;
}
}
public void setWorkStatus(String s, CancellableWorker worker) {
@@ -1116,7 +1122,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
debugStackPanel = new DebugStackPanel();
Main.getDebugHandler().addBreakListener(new DebuggerHandler.BreakListener() {
@Override
public void breakAt(String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
public void breakAt(DebuggerSession session, String scriptName, int line, int classIndex, int traitIndex, int methodIndex) {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
@@ -1126,23 +1132,25 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
@Override
public void doContinue() {
public void doContinue(DebuggerSession session) {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
showDetail(DETAILCARDEMPTYPANEL);
if (Main.getDebugHandler().getNumberOfPausedSessions() == 0) {
showDetail(DETAILCARDEMPTYPANEL);
}
}
});
}
});
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
}
@Override
public void disconnected() {
public void disconnected(DebuggerSession session) {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
@@ -1628,6 +1636,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
private void updateUi(final Openable openable) {
View.checkAccess();
Main.updateSession();
SWF swf = null;
if (openable instanceof SWF) {
swf = (SWF) openable;
@@ -1646,7 +1655,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (!abcFound) {
getABCPanel().setAbc(abcList.get(0).getABC());
}
}
}
}
mainMenu.updateComponents(openable);
@@ -5766,7 +5775,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
private void valueChanged(Object source, TreePath selectedPath) {
TreeItem treeItem = selectedPath == null ? null : (TreeItem) selectedPath.getLastPathComponent();
Main.updateSession();
if (treeItem == null) {
updateUi(null);
reload(false);
@@ -6360,7 +6370,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (openable instanceof SWF) {
SwfSpecificCustomConfiguration swfCustomConf = Configuration.getOrCreateSwfSpecificCustomConfiguration(openable.getShortPathTitle());
SWF swf = (SWF) openable;
Map<String, Set<Integer>> breakpoints = Main.getDebugHandler().getAllBreakPoints(swf, false);
Map<String, Set<Integer>> breakpoints = Main.getDebugHandler().getAllSessionsBreakPoints(swf);
List<String> breakpointList = new ArrayList<>();
for (String scriptName : breakpoints.keySet()) {
for (int line : breakpoints.get(scriptName)) {
@@ -7053,4 +7063,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public EasyPanel getEasyPanel() {
return easyPanel;
}
public void showDebugStackFrame() {
showDetail(DETAILCARDDEBUGSTACKFRAME);
}
}
@@ -56,6 +56,7 @@ import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.DebugPanel;
import com.jpexs.decompiler.flash.gui.DebuggerHandler;
import com.jpexs.decompiler.flash.gui.DebuggerSession;
import com.jpexs.decompiler.flash.gui.FasterScrollPane;
import com.jpexs.decompiler.flash.gui.HeaderLabel;
import com.jpexs.decompiler.flash.gui.Main;
@@ -388,9 +389,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
if (parentObjectId == 0 && objectId != 0L && isAS3) {
igv = Main.getDebugHandler().getVariable(objectId, "", true, useGetter);
igv = Main.getCurrentDebugSession().getVariable(objectId, "", true, useGetter);
} else {
igv = Main.getDebugHandler().getVariable(parentObjectId, var.name, true, useGetter);
igv = Main.getCurrentDebugSession().getVariable(parentObjectId, var.name, true, useGetter);
}
//current var is getter function - set it to value really got
@@ -782,7 +783,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
default:
return;
}
Main.getDebugHandler().setVariable(((VariableNode) node).parentObjectId, ((VariableNode) node).var.name, valType, symb.value);
Main.getCurrentDebugSession().setVariable(((VariableNode) node).parentObjectId, ((VariableNode) node).var.name, valType, symb.value);
//((VariableNode) node).refresh();
Object[] path = new Object[((VariableNode) node).path.size()];
for (int i = 0; i < path.length; i++) {
@@ -1422,13 +1423,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
decButtonsPan.setVisible(false);
}
@Override
public void disconnected() {
decButtonsPan.setVisible(true);
public void disconnected(DebuggerSession session) {
if (!Main.getDebugHandler().isAnySessionConnected()) {
decButtonsPan.setVisible(true);
}
}
});
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.DebuggerHandler;
import com.jpexs.decompiler.flash.gui.DebuggerSession;
import com.jpexs.decompiler.flash.gui.HeaderLabel;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.decompiler.flash.gui.MainPanel;
@@ -146,7 +147,7 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
conListener = new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
synchronized (DetailPanel.this) {
debugRunning = true;
if (buttonsPanel != null) {
@@ -156,7 +157,10 @@ public class DetailPanel extends JPanel implements TagEditorPanel {
}
@Override
public void disconnected() {
public void disconnected(DebuggerSession session) {
if (Main.getDebugHandler().isAnySessionConnected()) {
return;
}
synchronized (DetailPanel.this) {
debugRunning = false;
@@ -43,6 +43,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.DebugPanel;
import com.jpexs.decompiler.flash.gui.DebuggerHandler;
import com.jpexs.decompiler.flash.gui.DebuggerSession;
import com.jpexs.decompiler.flash.gui.DocsPanel;
import com.jpexs.decompiler.flash.gui.FasterScrollPane;
import com.jpexs.decompiler.flash.gui.GraphDialog;
@@ -1065,12 +1066,15 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
//decPanel.add(searchPanel, BorderLayout.NORTH);
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
@Override
public void connected() {
public void connected(DebuggerSession session) {
decButtonsPan.setVisible(false);
}
@Override
public void disconnected() {
public void disconnected(DebuggerSession session) {
if (Main.getDebugHandler().isAnySessionConnected()) {
return;
}
decButtonsPan.setVisible(true);
}
});
@@ -126,7 +126,7 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
return;
}
Set<Integer> bkptLines = Main.getScriptBreakPoints(breakPointScriptName, false);
Set<Integer> bkptLines = Main.getScriptBreakPoints(breakPointScriptName);
for (int line : bkptLines) {
if (Main.isBreakPointValid(breakPointScriptName, line)) {