From 8fd51cd8894bdf65e39e2b980865982bd24ed327 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Wed, 9 May 2012 13:04:35 +0200 Subject: [PATCH] bugfix: breakpoints should only trigger once updated watchpointmote method to return executable address, not wrapped in an object --- .../mspsim/src/se/sics/cooja/mspmote/MspMote.java | 14 ++++++++++---- .../src/se/sics/cooja/mspmote/plugins/CodeUI.java | 10 +++++++--- tools/cooja/java/se/sics/cooja/WatchpointMote.java | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java index 2b8789e00..f1882e164 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java @@ -573,9 +573,9 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc return false; } - public Integer getExecutableAddressOf(File file, int lineNr) { + public int getExecutableAddressOf(File file, int lineNr) { if (file == null || lineNr < 0 || debuggingInfo == null) { - return null; + return -1; } /* Match file */ @@ -589,7 +589,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc } } if (lineTable == null) { - return null; + return -1; } /* Match line number */ @@ -603,10 +603,16 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc } } - return null; + return -1; } + private long lastBreakpointCycles = -1; public void signalBreakpointTrigger(MspBreakpoint b) { + if (lastBreakpointCycles == myCpu.cycles) { + return; + } + + lastBreakpointCycles = myCpu.cycles; if (b.stopsSimulation() && getSimulation().isRunning()) { /* Stop simulation immediately */ stopNextInstruction(); diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/CodeUI.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/CodeUI.java index 50faff24c..3e711a769 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/CodeUI.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/CodeUI.java @@ -35,6 +35,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Point; +import java.awt.Rectangle; import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -165,9 +166,9 @@ public class CodeUI extends JPanel { /* Configure breakpoint menu options */ /* XXX TODO We should ask for the file specified in the firmware, not * the actual file on disk. */ - Integer address = + int address = CodeUI.this.mote.getExecutableAddressOf(displayedFile, line); - if (address == null) { + if (address < 0) { return; } final int start = codeEditorLines.get(line); @@ -328,7 +329,10 @@ public class CodeUI extends JPanel { SwingUtilities.invokeLater(new Runnable() { public void run() { try { - codeEditor.scrollRectToVisible(codeEditor.modelToView(start)); + Rectangle r = codeEditor.modelToView(start); + if (r != null) { + codeEditor.scrollRectToVisible(codeEditor.modelToView(start)); + } } catch (BadLocationException e) { } } diff --git a/tools/cooja/java/se/sics/cooja/WatchpointMote.java b/tools/cooja/java/se/sics/cooja/WatchpointMote.java index ba5886213..0d2185eb6 100644 --- a/tools/cooja/java/se/sics/cooja/WatchpointMote.java +++ b/tools/cooja/java/se/sics/cooja/WatchpointMote.java @@ -70,6 +70,6 @@ public interface WatchpointMote extends Mote { public boolean breakpointExists(int address); public boolean breakpointExists(File file, int lineNr); - public Integer getExecutableAddressOf(File file, int lineNr); + public int getExecutableAddressOf(File file, int lineNr); }