bugfixes: recalculate executable address after loading breakpoint + iterate over array, not list

This commit is contained in:
fros4943 2009-06-17 13:06:55 +00:00
parent f086c92b40
commit 532c1b6c77
2 changed files with 18 additions and 3 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.mspmote.plugins;
@ -37,6 +37,7 @@ import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Vector; import java.util.Vector;
import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.Watchpoint; import se.sics.cooja.Watchpoint;
@ -50,6 +51,8 @@ import se.sics.mspsim.core.CPUMonitor;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
public class MspBreakpoint implements Watchpoint { public class MspBreakpoint implements Watchpoint {
private static Logger logger = Logger.getLogger(MspBreakpoint.class);
private MspBreakpointContainer breakpoints; private MspBreakpointContainer breakpoints;
private MspMote mspMote; private MspMote mspMote;
@ -205,6 +208,17 @@ public class MspBreakpoint implements Watchpoint {
return false; 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(); createMonitor();
return true; return true;
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; package se.sics.cooja.mspmote.plugins;
@ -193,7 +193,8 @@ public class MspBreakpointContainer implements WatchpointMote {
/* Notify listeners */ /* Notify listeners */
lastTriggeredBreakpoint = b; lastTriggeredBreakpoint = b;
for (ActionListener listener: listeners) { ActionListener[] arr = getWatchpointListeners();
for (ActionListener listener: arr) {
listener.actionPerformed(null); listener.actionPerformed(null);
} }
} }