diff --git a/libsrc/debugswf/com/jpexs/decompiler/flash/debugger/DebugConnection.as b/libsrc/debugswf/com/jpexs/decompiler/flash/debugger/DebugConnection.as index 46b25b6dc..e0fb8ff87 100644 --- a/libsrc/debugswf/com/jpexs/decompiler/flash/debugger/DebugConnection.as +++ b/libsrc/debugswf/com/jpexs/decompiler/flash/debugger/DebugConnection.as @@ -11,7 +11,6 @@ private static var s:Socket; private static var q = []; - private static var first:Boolean = true; private static var inited:Boolean = false; private static var name:String; private static var failed:Boolean = false; @@ -34,12 +33,16 @@ public static const MSG_DUMP_BYTEARRAY = 3; public static const MSG_REQUEST_BYTEARRAY = 4; public static const MSG_LOADER_URL_INFO = 5; - public static const MSG_LOADER_MODIFY_BYTES = 6; + public static const MSG_LOADER_MODIFY_BYTES = 6; + + private static var connected:Boolean = false; + + public static const SHOW_TRACE = false; private static function sendQueue(){ + if (SHOW_TRACE) trace("debugswf: client " + name + " sending queue"); var qo = q; q = []; - sendHeader(); for each(var m in qo){ writeMsg(m.data,m.type); } @@ -103,25 +106,30 @@ if(inited){ return; } + if (SHOW_TRACE) trace("debugswf: initing client " + sname); name = sname; inited = true; try { - s = new Socket(); + s = new Socket(); s.addEventListener(Event.CONNECT, onSocketConnect); s.addEventListener(ProgressEvent.SOCKET_DATA, onSocketData); var port:int = 0; - port = 123456; + port = 123456; + if (SHOW_TRACE) trace("debugswf: connecting client " + sname + " to localhost:" + port) ; s.connect("localhost",port); inited = true; } catch (e:SecurityError) { - trace("Debugger helper failed to connect to localhost"); + if (SHOW_TRACE) trace("Debugger helper failed to connect to localhost"); failed = true; } } private static function onSocketConnect(event:Event):void { - sendQueue(); + if (SHOW_TRACE) trace("debugswf: client " + name + " connected"); + sendHeader(); + connected = true; + sendQueue(); } @@ -150,8 +158,10 @@ } else { ba.position = pos; } + if (SHOW_TRACE) trace("debugswf: client " + name + " received bytearray of " + ba.length + " bytes"); var onComplete = fillByteArraysEvents.pop(); if (onComplete != null) { + if (SHOW_TRACE) trace("debugswf: client " + name + " calling onComplete"); onComplete.call(onComplete); } } @@ -200,15 +210,11 @@ } private static function sendHeader() { - if (!first) { - return; - } if (!s.connected) { return; } writeStringNull("debug.version.major="+DEBUG_VERSION_MAJOR+";debug.version.minor="+DEBUG_VERSION_MINOR); writeString(name); - first = false; } public static function writeMsg(msg,msgType=0){ @@ -216,7 +222,9 @@ return; } if(!inited) { - initClient(""); + var max:int = 100000; + var randomInt:int = Math.floor(Math.random() * (max + 1)); + initClient("rand" + randomInt); } if ((msg is ByteArray) && msgType == MSG_DUMP_BYTEARRAY) { var ba2:ByteArray = new ByteArray(); @@ -224,9 +232,9 @@ msg = ba2; } - if(s.connected){ - sendHeader(); - s.writeByte(msgType); + if(connected) { + if (SHOW_TRACE) trace("debugswf: client " + name +" sending msg " + msgType); + s.writeByte(msgType); switch(msgType){ case MSG_STRING: writeString(msg); @@ -242,6 +250,7 @@ break; case MSG_REQUEST_BYTEARRAY: fillByteArrays.push(msg); + fillByteArraysEvents.push(null); break; case MSG_LOADER_MODIFY_BYTES: writeString(msg["url"]); @@ -251,7 +260,9 @@ break; } s.flush(); + if (SHOW_TRACE) trace("debugswf: client " + name +" msg " + msgType + " sent"); }else{ + if (SHOW_TRACE) trace("debugswf: client " + name +" pushing msg " + msgType + " to queue"); q.push({type:msgType,data:msg}); } } diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner.swf b/libsrc/ffdec_lib/testdata/debug_inner/inner.swf index 0a7bf764f..050b03ad6 100644 Binary files a/libsrc/ffdec_lib/testdata/debug_inner/inner.swf and b/libsrc/ffdec_lib/testdata/debug_inner/inner.swf differ diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.old b/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.old index 3fb908ad7..ec4ea7bee 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.old +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.old @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\inner\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\inner\src\InnerMain.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner\src\InnerMain.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.xml b/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.xml index 3fb908ad7..ec4ea7bee 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.xml +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner/obj/InnerSWFConfig.xml @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\inner\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\inner\src\InnerMain.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner\src\InnerMain.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner/src/InnerMain.as b/libsrc/ffdec_lib/testdata/debug_inner/inner/src/InnerMain.as index 710cb6b23..028dc8a01 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner/src/InnerMain.as +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner/src/InnerMain.as @@ -2,6 +2,8 @@ package { import flash.display.Sprite; import flash.events.Event; + import flash.text.TextField; + import flash.text.TextFormat; public class InnerMain extends Sprite { @@ -13,10 +15,24 @@ package else addEventListener(Event.ADDED_TO_STAGE, init); } - private function init(e:Event = null):void + private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); - // entry point + + var textField:TextField = new TextField(); + + textField.text = "Main inner1."; + + var textFormat:TextFormat = new TextFormat(); + textFormat.size = 24; + textFormat.color = 0x000000; + textField.setTextFormat(textFormat); + textField.width = 200; + + addChild(textField); + + textField.x = 50; + textField.y = 125; } } diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner/src/MyInnerClass.as b/libsrc/ffdec_lib/testdata/debug_inner/inner/src/MyInnerClass.as index b90f7d2ad..7e78e7891 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner/src/MyInnerClass.as +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner/src/MyInnerClass.as @@ -43,14 +43,17 @@ package var byteArray:ByteArray = new binaryData2Class() as ByteArray; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete); + //trace("loading innerSwf 2"); loader.loadBytes(byteArray); } private function onLoaderComplete(event:Event):void { var loaderInfo:LoaderInfo = event.target as LoaderInfo; var className:String = "MyInnerClass2"; + //trace("getting definition of " + className); var LoadedClass:Class = loaderInfo.applicationDomain.getDefinition(className) as Class; var instance:* = new LoadedClass(); + //trace("calling innerSwf 2 instance"); instance.run(root); } diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2.swf b/libsrc/ffdec_lib/testdata/debug_inner/inner2.swf index da6ab5aef..b9d6125fd 100644 Binary files a/libsrc/ffdec_lib/testdata/debug_inner/inner2.swf and b/libsrc/ffdec_lib/testdata/debug_inner/inner2.swf differ diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2/InnerSWF2.as3proj b/libsrc/ffdec_lib/testdata/debug_inner/inner2/InnerSWF2.as3proj index 2bf448b4c..e8b2f5171 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner2/InnerSWF2.as3proj +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner2/InnerSWF2.as3proj @@ -4,7 +4,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.old b/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.old index a1eafadb6..90a9f4d03 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.old +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.old @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\inner2\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner2\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\inner2\src\Main.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner2\src\InnerMain2.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.xml b/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.xml index a1eafadb6..90a9f4d03 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.xml +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner2/obj/InnerSWF2Config.xml @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\inner2\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner2\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\inner2\src\Main.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\inner2\src\InnerMain2.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/InnerMain2.as b/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/InnerMain2.as new file mode 100644 index 000000000..3abc54c2c --- /dev/null +++ b/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/InnerMain2.as @@ -0,0 +1,40 @@ +package +{ + import flash.display.Sprite; + import flash.events.Event; + import flash.text.TextField; + import flash.text.TextFormat; + + public class InnerMain2 extends Sprite + { + MyInnerClass2; + + public function InnerMain2() + { + if (stage) init(); + else addEventListener(Event.ADDED_TO_STAGE, init); + } + + private function init(e:Event = null):void + { + removeEventListener(Event.ADDED_TO_STAGE, init); + + var textField:TextField = new TextField(); + + textField.text = "Main inner2."; + + var textFormat:TextFormat = new TextFormat(); + textFormat.size = 24; + textFormat.color = 0x000000; + textField.setTextFormat(textFormat); + textField.width = 200; + + addChild(textField); + + textField.x = 50; + textField.y = 100; + } + + } + +} \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/Main.as b/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/Main.as deleted file mode 100644 index 1e9bfa3ff..000000000 --- a/libsrc/ffdec_lib/testdata/debug_inner/inner2/src/Main.as +++ /dev/null @@ -1,24 +0,0 @@ -package -{ - import flash.display.Sprite; - import flash.events.Event; - - public class Main extends Sprite - { - MyInnerClass2; - - public function Main() - { - if (stage) init(); - else addEventListener(Event.ADDED_TO_STAGE, init); - } - - private function init(e:Event = null):void - { - removeEventListener(Event.ADDED_TO_STAGE, init); - // entry point - } - - } - -} \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/debug_inner/outer.swf b/libsrc/ffdec_lib/testdata/debug_inner/outer.swf index 4902490c2..90a6d467a 100644 Binary files a/libsrc/ffdec_lib/testdata/debug_inner/outer.swf and b/libsrc/ffdec_lib/testdata/debug_inner/outer.swf differ diff --git a/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.old b/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.old index 3c1960d44..a147a267c 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.old +++ b/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.old @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\outer\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\outer\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\outer\src\Main.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\outer\src\Main.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.xml b/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.xml index 3c1960d44..a147a267c 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.xml +++ b/libsrc/ffdec_lib/testdata/debug_inner/outer/obj/OuterSwfConfig.xml @@ -16,7 +16,7 @@ CONFIG::timeStamp - '04.08.2024' + '05.08.2024' CONFIG::air @@ -32,12 +32,12 @@ true - C:\FlashRelated\test_debugger\inner_debug\outer\src + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\outer\src C:\Program Files (x86)\FlashDevelop\Library\AS3\classes - C:\FlashRelated\test_debugger\inner_debug\outer\src\Main.as + C:\Dropbox\Programovani\JavaSE\FFDec\libsrc\ffdec_lib\testdata\debug_inner\outer\src\Main.as #FFFFFF 30 diff --git a/libsrc/ffdec_lib/testdata/debug_inner/outer/src/Main.as b/libsrc/ffdec_lib/testdata/debug_inner/outer/src/Main.as index d4bb99cfe..39bd24e7e 100644 --- a/libsrc/ffdec_lib/testdata/debug_inner/outer/src/Main.as +++ b/libsrc/ffdec_lib/testdata/debug_inner/outer/src/Main.as @@ -28,14 +28,17 @@ package var byteArray:ByteArray = new binaryDataClass() as ByteArray; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete); + //trace("loading innerSwf 1"); loader.loadBytes(byteArray); } private function onLoaderComplete(event:Event):void { var loaderInfo:LoaderInfo = event.target as LoaderInfo; var className:String = "MyInnerClass"; + //trace("getting definition of " + className); var LoadedClass:Class = loaderInfo.applicationDomain.getDefinition(className) as Class; var instance:* = new LoadedClass(); + //trace("calling innerSwf 1 instance"); instance.run(this); } diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index 7aa0df343..9d8fbb388 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -79,7 +79,7 @@ public class DebuggerHandler implements DebugConnectionListener { private DebuggerCommands commands = null; - private List swfs = new ArrayList<>(); + //private List swfs = new ArrayList<>(); private boolean paused = true; @@ -396,6 +396,32 @@ public class DebuggerHandler implements DebugConnectionListener { } invalidBreakPointMap.get(swf).get(scriptName).add(line); } + + private synchronized void markBreakPointConfirmed(SWF swf, String scriptName, int line) { + if (!confirmedPointMap.containsKey(swf)) { + confirmedPointMap.put(swf, new HashMap<>()); + } + if (!confirmedPointMap.get(swf).containsKey(scriptName)) { + confirmedPointMap.get(swf).put(scriptName, new TreeSet<>()); + } + confirmedPointMap.get(swf).get(scriptName).add(line); + } + + private synchronized void markBreakPointValid(SWF swf, String scriptName, int line) { + if (!invalidBreakPointMap.containsKey(swf)) { + return; + } + if (!invalidBreakPointMap.get(swf).containsKey(scriptName)) { + return; + } + invalidBreakPointMap.get(swf).get(scriptName).remove(line); + if (invalidBreakPointMap.get(swf).get(scriptName).isEmpty()) { + invalidBreakPointMap.get(swf).remove(scriptName); + } + if (invalidBreakPointMap.get(swf).isEmpty()) { + invalidBreakPointMap.remove(swf); + } + } private InFrame frame; @@ -562,10 +588,7 @@ public class DebuggerHandler implements DebugConnectionListener { } } - public List getSwfs() { - return swfs; - } - + public void disconnect() { frame = null; pool = null; @@ -673,7 +696,6 @@ public class DebuggerHandler implements DebugConnectionListener { } }); - swfs.clear(); swfIndicesCommited.clear(); swfIndicesNewToSwfHash.clear(); @@ -759,11 +781,12 @@ public class DebuggerHandler implements DebugConnectionListener { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.WARNING, "SWF with hash {0} not found", swfHash); } else { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "adding {0} to debugSwfs", swfIndex); + swfIndicesCommited.add(swfIndex); debuggedSwfs.add(swf); } } else { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "Swf index already commited"); - } + } } con.dropMessage(sc); } @@ -804,8 +827,7 @@ public class DebuggerHandler implements DebugConnectionListener { con.addMessageListener(new DebugMessageListener() { @Override public void message(InSwfInfo t) { - for (InSwfInfo.SwfInfo s : t.swfInfos) { - swfs.add(s); + /*for (InSwfInfo.SwfInfo s : t.swfInfos) { View.execInEventDispatch(new Runnable() { @Override public void run() { @@ -817,7 +839,7 @@ public class DebuggerHandler implements DebugConnectionListener { } } }); - } + }*/ con.dropMessage(t); } }); @@ -845,13 +867,7 @@ public class DebuggerHandler implements DebugConnectionListener { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.INFO, "Breakpoint {0}:{1} submitted successfully", new Object[]{sname, isb.lines.get(i)}); } } - - con.addMessageListener(new DebugMessageListener() { - @Override - public void message(InAskBreakpoints message) { - - } - }); + con.addMessageListener(new DebugMessageListener() { @Override public void message(InContinue msg) { @@ -864,6 +880,7 @@ public class DebuggerHandler implements DebugConnectionListener { } } }); + con.addMessageListener(new DebugMessageListener() { @Override public void message(InBreakAt message) { @@ -897,18 +914,20 @@ public class DebuggerHandler implements DebugConnectionListener { Logger.getLogger(DebuggerCommands.class.getName()).log(Level.SEVERE, "Invalid file: {0}", message.file); //return; } - - - for (int i = 0; i < debuggedSwfs.size(); i++) { - swfIndicesCommited.add(i); - } + final String[] reasonNames = new String[]{"unknown", "breakpoint", "watch", "fault", "stopRequest", "step", "halt", "scriptLoaded"}; 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}); - - sendBreakPoints(); + + try { + sendBreakPoints(); + } catch (IOException ex) { + //ignore + Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "send breakpoints exception: " + ex.getMessage()); + } + synchronized (DebuggerHandler.this) { breakScriptName = newBreakScriptName; breakIp = message.line; @@ -1030,7 +1049,8 @@ public class DebuggerHandler implements DebugConnectionListener { } if (toAddBPointMap.containsKey(debuggedSwf)) { - for (String scriptName : toAddBPointMap.get(debuggedSwf).keySet()) { + Set toAddScripts = new HashSet<>(toAddBPointMap.get(debuggedSwf).keySet()); + for (String scriptName : toAddScripts) { if (scriptName.startsWith("#PCODE") != Main.isDebugPCode()) { continue; } @@ -1038,16 +1058,19 @@ public class DebuggerHandler implements DebugConnectionListener { int file = moduleIdOf(hash + ":" + scriptName); Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINEST, "module = {0}", file); if (file > -1) { - for (int line : toAddBPointMap.get(debuggedSwf).get(scriptName)) { + Set lines = new HashSet<>(toAddBPointMap.get(debuggedSwf).get(scriptName)); + for (int line : lines) { if (commands.addBreakPoint(file, line)) { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.INFO, "Breakpoint {0}:{1} submitted successfully", new Object[]{scriptName, line}); - if (!confirmedPointMap.containsKey(debuggedSwf)) { - confirmedPointMap.put(debuggedSwf, new HashMap<>()); + markBreakPointConfirmed(debuggedSwf, scriptName, line); + markBreakPointValid(debuggedSwf, scriptName, line); + toAddBPointMap.get(debuggedSwf).get(scriptName).remove(line); + if (toAddBPointMap.get(debuggedSwf).get(scriptName).isEmpty()) { + toAddBPointMap.get(debuggedSwf).remove(scriptName); } - if (!confirmedPointMap.get(debuggedSwf).containsKey(scriptName)) { - confirmedPointMap.get(debuggedSwf).put(scriptName, new TreeSet<>()); + if (toAddBPointMap.get(debuggedSwf).isEmpty()) { + toAddBPointMap.remove(debuggedSwf); } - confirmedPointMap.get(debuggedSwf).get(scriptName).add(line); } else { Logger.getLogger(DebuggerHandler.class.getName()).log(Level.INFO, "Breakpoint {0}:{1} unable to submit", new Object[]{scriptName, line}); markBreakPointInvalid(debuggedSwf, scriptName, line); @@ -1058,13 +1081,7 @@ public class DebuggerHandler implements DebugConnectionListener { markBreakPointInvalid(debuggedSwf, scriptName, line); } } - } - Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINEST, "clearing toAddBps of {0}", hash); - toAddBPointMap.get(debuggedSwf).clear(); - - if (toAddBPointMap.get(debuggedSwf).isEmpty()) { - toAddBPointMap.remove(debuggedSwf); - } + } } } } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 1e09911ab..7891e1428 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -476,9 +476,9 @@ public class Main { try { File fTempFile = new File(instrSWF.getFile()); instrSWF.enableDebugging(true, new File("."), true, doPCode, swfHash); - FileOutputStream fos = new FileOutputStream(fTempFile); - instrSWF.saveTo(fos); - fos.close(); + try (FileOutputStream fos = 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? @@ -550,7 +550,7 @@ public class Main { String url = it.getUrl(); File importedFile = new File(origFile.getParentFile(), url); if (importedFile.exists()) { - File newTempFile = createTempFileInDir(tempFilesDir, "~ffdec_run_import_", ".swf"); + File newTempFile = createTempFileInDir(tempFilesDir, "~ffdec_run_import_", ".swf"); it.setUrl("./" + newTempFile.getName()); byte[] impData = Helper.readFile(importedFile.getAbsolutePath()); Helper.writeFile(newTempFile.getAbsolutePath(), impData); @@ -2503,15 +2503,18 @@ public class Main { try(FileOutputStream fos = new FileOutputStream(tempFile)) { fos.write(inputData); } + Logger.getLogger(Main.class.getName()).log(Level.FINE, "preparing for load: {0}", hash); prepareSwf("loaded_" + hash, runningPreparation, tempFile, mainSWF.getFile() == null ? null : new File(mainSWF.getFile()), tempRunDir, runTempFiles); byte outputData[] = Helper.readFileEx(tempFile.getAbsolutePath()); tempFile.delete(); + Logger.getLogger(Main.class.getName()).log(Level.FINE, "calling datamodified"); modifiedListener.dataModified(outputData); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } + Logger.getLogger(Main.class.getName()).log(Level.FINE, "finished opened method"); } }; diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java index e66d73fa4..845a6440d 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java @@ -350,18 +350,22 @@ public class Debugger { } } catch (IOException ex) { + logger.log(Level.FINER, "IOException in injected debugger thread: {0}", ex.getMessage()); //ignore } try { s.close(); } catch (IOException ex) { + logger.log(Level.FINER, "Socked close exception in injected debugger thread: {0}", ex.getMessage()); //ignore } finished = true; active = false; + logger.log(Level.FINER, "Calling onFinish"); for (DebugListener l : listeners) { l.onFinish(clientName); } + logger.log(Level.FINER, "Injected debugger finished"); } } diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/debug.swf b/src/com/jpexs/decompiler/flash/gui/debugger/debug.swf index 55095b233..63a2cb31b 100644 Binary files a/src/com/jpexs/decompiler/flash/gui/debugger/debug.swf and b/src/com/jpexs/decompiler/flash/gui/debugger/debug.swf differ