From 532c1b6c77b91a30f4b12b23659192e1e8ffbb6d Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 17 Jun 2009 13:06:55 +0000 Subject: [PATCH] bugfixes: recalculate executable address after loading breakpoint + iterate over array, not list --- .../cooja/mspmote/plugins/MspBreakpoint.java | 16 +++++++++++++++- .../mspmote/plugins/MspBreakpointContainer.java | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java index 15d8ac13b..d9fba0d5c 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpoint.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspBreakpoint.java,v 1.2 2009/06/16 12:15:15 fros4943 Exp $ + * $Id: MspBreakpoint.java,v 1.3 2009/06/17 13:06:55 fros4943 Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -37,6 +37,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Vector; +import org.apache.log4j.Logger; import org.jdom.Element; import se.sics.cooja.Watchpoint; @@ -50,6 +51,8 @@ import se.sics.mspsim.core.CPUMonitor; * @author Fredrik Osterlind */ public class MspBreakpoint implements Watchpoint { + private static Logger logger = Logger.getLogger(MspBreakpoint.class); + private MspBreakpointContainer breakpoints; private MspMote mspMote; @@ -205,6 +208,17 @@ public class MspBreakpoint implements Watchpoint { return false; } + /* TODO Save source code line */ + + if (codeFile != null && lineNr != null) { + /* Update executable address */ + address = mspMote.getBreakpointsContainer().getExecutableAddressOf(codeFile, lineNr); + if (address == null) { + logger.fatal("Could not restore breakpoint, did source code change?"); + address = 0; + } + } + createMonitor(); return true; } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpointContainer.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpointContainer.java index 46c853007..d04834e7c 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpointContainer.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspBreakpointContainer.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspBreakpointContainer.java,v 1.1 2009/06/11 10:05:28 fros4943 Exp $ + * $Id: MspBreakpointContainer.java,v 1.2 2009/06/17 13:06:55 fros4943 Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -193,7 +193,8 @@ public class MspBreakpointContainer implements WatchpointMote { /* Notify listeners */ lastTriggeredBreakpoint = b; - for (ActionListener listener: listeners) { + ActionListener[] arr = getWatchpointListeners(); + for (ActionListener listener: arr) { listener.actionPerformed(null); } }