This commit is contained in:
Jindra Petřík
2015-11-15 22:03:04 +01:00
parent 575d988ed4
commit 27fbe7d18f
7 changed files with 172 additions and 66 deletions
@@ -21,8 +21,10 @@ import com.jpexs.debugger.flash.DebugMessageListener;
import com.jpexs.debugger.flash.Debugger;
import com.jpexs.debugger.flash.DebuggerCommands;
import com.jpexs.debugger.flash.DebuggerConnection;
import com.jpexs.debugger.flash.InDebuggerMessage;
import com.jpexs.debugger.flash.messages.in.InAskBreakpoints;
import com.jpexs.debugger.flash.messages.in.InBreakAt;
import com.jpexs.debugger.flash.messages.in.InContinue;
import com.jpexs.debugger.flash.messages.in.InNumScript;
import com.jpexs.debugger.flash.messages.in.InScript;
import com.jpexs.debugger.flash.messages.in.InSwfInfo;
@@ -45,6 +47,11 @@ public class DebuggerHandler implements DebugConnectionListener {
private boolean connected = false;
private DebuggerCommands commands = null;
private List<InSwfInfo.SwfInfo> swfs = new ArrayList<>();
private boolean paused = true;
public synchronized boolean isPaused() {
return paused;
}
public List<InSwfInfo.SwfInfo> getSwfs() {
return swfs;
@@ -61,6 +68,12 @@ public class DebuggerHandler implements DebugConnectionListener {
@Override
public void connected(DebuggerConnection con) {
synchronized (DebuggerHandler.this) {
paused = true;
}
Main.getMainFrame().getPanel().updateMenu();
Level level = Level.FINER;
Logger rootLog = Logger.getLogger(Debugger.class.getName());
@@ -103,10 +116,24 @@ public class DebuggerHandler implements DebugConnectionListener {
}
con.getMessage(InAskBreakpoints.class);
con.addMessageListener(new DebugMessageListener<InContinue>() {
@Override
public void message(InContinue msg) {
synchronized (DebuggerHandler.this) {
paused = false;
}
Main.getMainFrame().getPanel().updateMenu();
}
});
con.addMessageListener(new DebugMessageListener<InBreakAt>() {
@Override
public void message(InBreakAt message) {
synchronized (DebuggerHandler.this) {
paused = true;
}
Main.getMainFrame().getPanel().updateMenu();
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.INFO, "break at {0}:{1}", new Object[]{moduleNames.get(message.file), message.line});
if (!modulePaths.containsKey(message.file)) {
return;
@@ -116,7 +143,7 @@ public class DebuggerHandler implements DebugConnectionListener {
//dc.sendContinue();
}
});
commands.sendContinue();
//commands.sendContinue();
connected = true;
}
}
@@ -645,6 +645,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
boolean isRunning = isRunning();
boolean isDebugRunning = isDebugRunning();
boolean isRunningOrDebugging = isRunning || isDebugRunning;
boolean isDebugPaused = isDebugPaused();
boolean swfSelected = swf != null;
boolean isWorking = Main.isWorking();
@@ -704,17 +705,17 @@ public abstract class MainFrameMenu implements MenuBuilder {
setMenuEnabled("_/about", !isWorking);
setMenuEnabled("/help/about", !isWorking);
setMenuEnabled("/execution/start/run", !isRunningOrDebugging);
setMenuEnabled("/execution/start/run", swfSelected && !isRunningOrDebugging);
setMenuEnabled("/execution/start/debug", !isRunningOrDebugging);
setMenuEnabled("/execution/start/stop", isRunningOrDebugging);
setMenuEnabled("/execution/debug", isDebugRunning);
setMenuEnabled("/execution/debug/pause", isDebugRunning);
setMenuEnabled("/execution/debug/stepOver", isDebugRunning);
setMenuEnabled("/execution/debug/stepInto", isDebugRunning);
setMenuEnabled("/execution/debug/stepOut", isDebugRunning);
setMenuEnabled("/execution/debug/continue", isDebugRunning);
setMenuEnabled("/execution/debug/stack", isDebugRunning);
setMenuEnabled("/execution/debug/watch", isDebugRunning);
//setMenuEnabled("/execution/debug/pause", isDebugRunning);
setMenuEnabled("/execution/debug/stepOver", isDebugPaused);
setMenuEnabled("/execution/debug/stepInto", isDebugPaused);
setMenuEnabled("/execution/debug/stepOut", isDebugPaused);
setMenuEnabled("/execution/debug/continue", isDebugPaused);
setMenuEnabled("/execution/debug/stack", isDebugPaused);
setMenuEnabled("/execution/debug/watch", isDebugPaused);
}
@@ -819,7 +820,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
finishMenu("/execution/start");
addMenuItem("/execution/debug", translate("menu.execution.debug"), null, null, 0, null, false);
addMenuItem("/execution/debug/pause", translate("menu.execution.debug.pause"), "pause32", this::pauseActionPerformed, PRIORITY_TOP, null, true);
//addMenuItem("/execution/debug/pause", translate("menu.execution.debug.pause"), "pause32", this::pauseActionPerformed, PRIORITY_TOP, null, true);
addMenuItem("/execution/debug/continue", translate("menu.execution.debug.continue"), "continue32", this::continueActionPerformed, PRIORITY_TOP, null, true);
addMenuItem("/execution/debug/stepOver", translate("menu.execution.debug.stepOver"), "stepover32", this::stepOverActionPerformed, PRIORITY_MEDIUM, null, true);
addMenuItem("/execution/debug/stepInto", translate("menu.execution.debug.stepInto"), "stepinto32", this::stepIntoActionPerformed, PRIORITY_MEDIUM, null, true);
@@ -1074,8 +1075,13 @@ public abstract class MainFrameMenu implements MenuBuilder {
private Process runProcess;
private boolean runProcessDebug;
private File runTempFile;
public synchronized boolean isDebugPaused() {
return runProcess != null && runProcessDebug && Main.getDebugHandler().isPaused();
}
public synchronized boolean isDebugRunning() {
return runProcess != null && runProcessDebug;
}
@@ -1084,16 +1090,13 @@ public abstract class MainFrameMenu implements MenuBuilder {
return runProcess != null && !runProcessDebug;
}
private synchronized void setProcess(Process p) {
this.runProcess = p;
}
private synchronized void freeRun() {
if (runTempFile != null) {
runTempFile.delete();
runTempFile = null;
}
runProcess = null;
mainFrame.getPanel().clearDebuggerColors();
}
private void runPlayer(String exePath, String file, String flashVars) {
@@ -1239,6 +1242,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean stepOverActionPerformed(ActionEvent evt) {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
if (cmd != null) {
mainFrame.getPanel().clearDebuggerColors();
cmd.stepOver();
}
return true;
@@ -1247,6 +1251,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean stepIntoActionPerformed(ActionEvent evt) {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
if (cmd != null) {
mainFrame.getPanel().clearDebuggerColors();
cmd.stepInto();
}
return true;
@@ -1255,6 +1260,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean stepOutActionPerformed(ActionEvent evt) {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
if (cmd != null) {
mainFrame.getPanel().clearDebuggerColors();
cmd.stepOut();
}
return true;
@@ -1263,7 +1269,8 @@ public abstract class MainFrameMenu implements MenuBuilder {
public boolean continueActionPerformed(ActionEvent evt) {
DebuggerCommands cmd = Main.getDebugHandler().getCommands();
if (cmd != null) {
cmd.stepContinue();
mainFrame.getPanel().clearDebuggerColors();
cmd.sendContinue();
}
return true;
}
@@ -342,6 +342,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
}
public void updateMenu() {
mainMenu.updateComponents();
}
private static void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) {
tabbedPane.add(tab);
@@ -1530,14 +1534,15 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void gotoClassLine(SWF swf, String cls, int line) {
gotoClass(swf, cls);
if (abcPanel != null) {
abcPanel.decompiledTextArea.selectLine(line);
abcPanel.decompiledTextArea.gotoLine(line);
}
}
public void debuggerBreakAt(SWF swf, String cls, int line) {
gotoClassLine(swf, cls, line);
if (abcPanel != null) {
abcPanel.decompiledTextArea.setLineColor(line, Color.green);
abcPanel.decompiledTextArea.setLineColor(line - 1, Color.green);
}
}
@@ -1663,7 +1668,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
new CancellableWorker<Void>() {
@Override
protected Void doInBackground() throws Exception {
List<TextTag> textResult = null;
List<TextTag> textResult;
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
textSearchPanel.setOptions(ignoreCase, regexp);
textResult = searchText(txt, ignoreCase, regexp, swf);
@@ -2494,19 +2499,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
public boolean alignText(TextTag textTag, TextAlign textAlign) {
if (textTag.alignText(textAlign)) {
return true;
}
return false;
return (textTag.alignText(textAlign));
}
public boolean translateText(TextTag textTag, int diff) {
if (textTag.translateText(diff)) {
return true;
}
return false;
return textTag.translateText(diff);
}
public boolean previousTag() {
@@ -2807,6 +2804,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
}
public void clearDebuggerColors() {
if (abcPanel != null) {
abcPanel.decompiledTextArea.clearLineColors();
}
}
private void stopFlashPlayer() {
if (flashPanel != null) {
if (!flashPanel.isStopped()) {
@@ -3040,7 +3043,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
ABCPanel abcPanel = getABCPanel();
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
abcPanel.setAbc(scriptLeaf.abc);
abcPanel.decompiledTextArea.setScript(scriptLeaf);
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
abcPanel.decompiledTextArea.setNoTrait();
return null;
}
@@ -200,6 +200,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
}
public void setAbc(ABC abc) {
if (abc == this.abc) {
return;
}
this.abc = abc;
setDecompiledEditMode(false);
navigator.setAbc(abc);
@@ -654,7 +657,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
public void updateSearchPos(ABCPanelSearchResult item) {
ScriptPack pack = item.getScriptPack();
setAbc(pack.abc);
decompiledTextArea.setScript(pack);
decompiledTextArea.setScript(pack, false);
hilightScript(pack);
decompiledTextArea.setCaretPosition(0);
@@ -639,7 +639,10 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
script = null;
}
public void setScript(ScriptPack scriptLeaf) {
public void setScript(ScriptPack scriptLeaf, boolean force) {
if (!force && this.script == scriptLeaf) {
return;
}
abcPanel.scriptNameLabel.setText(scriptLeaf.getClassPath().toString());
int scriptIndex = scriptLeaf.scriptIndex;
ScriptInfo script = null;
@@ -688,7 +691,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
int ci = classIndex;
SWF.uncache(script);
if (script != null && getABC() != null) {
setScript(script);
setScript(script, true);
}
setNoTrait();
setClassIndex(ci);
@@ -69,11 +69,17 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
private Map<Integer, Color> lineColors = new HashMap<>();
public void clearLineColors() {
lineColors.clear();
repaint();
}
public void setLineColor(int line, Color color) {
lineColors.remove(line);
if (color != null) {
lineColors.put(line, color);
}
repaint();
}
public int getLine() {