You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2008-01-26 00:26:57
|
Revision: 86 http://mspsim.svn.sourceforge.net/mspsim/?rev=86&view=rev Author: joxe Date: 2008-01-25 16:26:43 -0800 (Fri, 25 Jan 2008) Log Message: ----------- added duty-cycle diagram Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/ui/ControlUI.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-01-24 23:15:41 UTC (rev 85) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-01-26 00:26:43 UTC (rev 86) @@ -18,7 +18,9 @@ import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; +import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.util.OperatingModeStatistics; import se.sics.mspsim.util.StackMonitor; @SuppressWarnings("serial") @@ -26,9 +28,9 @@ private TimeSeriesCollection dataset; - public DataChart(String title) { + public DataChart(String title, String yaxis) { DateAxis domain = new DateAxis("Time"); - NumberAxis range = new NumberAxis("Bytes"); + NumberAxis range = new NumberAxis(yaxis); XYPlot xyplot = new XYPlot(); xyplot.setDomainAxis(domain); xyplot.setRangeAxis(range); @@ -38,11 +40,15 @@ DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); + renderer.setSeriesPaint(2, Color.blue); + renderer.setSeriesPaint(3, Color.black); // renderer.setBaseStroke( // new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) // ); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); + renderer.setSeriesShapesVisible(2, false); + renderer.setSeriesShapesVisible(3, false); xyplot.setRenderer(renderer); domain.setAutoRange(true); @@ -74,12 +80,38 @@ StackMonitor sm = new StackMonitor(cpu); DataSourceSampler dss = new DataSourceSampler(); TimeSeries ts = new TimeSeries("Max Stack", Millisecond.class); - ts.setMaximumItemAge(30000); + ts.setMaximumItemCount(200); addTimeSeries(ts); dss.addDataSource(sm.getMaxSource(), ts); ts = new TimeSeries("Stack", Millisecond.class); - ts.setMaximumItemAge(30000); + ts.setMaximumItemCount(200); addTimeSeries(ts); dss.addDataSource(sm.getSource(), ts); } + + public void setupChipFrame(OperatingModeStatistics oms) { + openFrame("Duty-Cycle Monitor"); + DataSourceSampler dss = new DataSourceSampler(); + dss.setInterval(50); + TimeSeries ts = new TimeSeries("LEDS", Millisecond.class); + ts.setMaximumItemCount(200); + addTimeSeries(ts); + dss.addDataSource(oms.getMultiDataSource("Tmote Sky"), ts); + + ts = new TimeSeries("Listen", Millisecond.class); + ts.setMaximumItemCount(200); + addTimeSeries(ts); + dss.addDataSource(oms.getDataSource("CC2420", CC2420.MODE_RX_ON), ts); + + ts = new TimeSeries("Transmit", Millisecond.class); + ts.setMaximumItemCount(200); + addTimeSeries(ts); + dss.addDataSource(oms.getDataSource("CC2420", CC2420.MODE_TXRX_ON), ts); + + ts = new TimeSeries("CPU", Millisecond.class); + ts.setMaximumItemCount(200); + addTimeSeries(ts); + dss.addDataSource(oms.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE), ts); + + } } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 23:15:41 UTC (rev 85) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-26 00:26:43 UTC (rev 86) @@ -51,6 +51,7 @@ import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; +import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; @@ -140,6 +141,8 @@ stats = new OperatingModeStatistics(cpu); stats.addMonitor(this); + stats.addMonitor(radio); + stats.addMonitor(cpu); } public void setButton(boolean hi) { @@ -163,7 +166,7 @@ redLed = (data & RED_LED) == 0; blueLed = (data & BLUE_LED) == 0; greenLed = (data & GREEN_LED) == 0; - int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0); + int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0); if (mode != newMode) { mode = newMode; modeChanged(mode); @@ -225,6 +228,11 @@ cpu.getDisAsm().setMap(map); } + + // A HACK!!! + DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); + dataChart.setupChipFrame(node.stats); + cpu.cpuloop(); } Modified: mspsim/se/sics/mspsim/ui/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 23:15:41 UTC (rev 85) +++ mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-26 00:26:43 UTC (rev 86) @@ -84,7 +84,7 @@ this.stackUI = new StackUI(cpu); - DataChart test = new DataChart("Stack Monitor"); + DataChart test = new DataChart("Stack Monitor", "Bytes"); test.setupStackFrame(cpu); stackWindow = new JFrame("Stack"); Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-01-24 23:15:41 UTC (rev 85) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-01-26 00:26:43 UTC (rev 86) @@ -43,6 +43,9 @@ import java.util.HashMap; import java.util.Iterator; +import org.jfree.chart.renderer.category.StatisticalBarRenderer; +import org.jfree.data.statistics.Statistics; + import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.OperatingModeListener; @@ -62,15 +65,14 @@ public void addMonitor(Chip chip) { chip.addOperatingModeListener(this); + StatEntry entry = new StatEntry(chip.getName(), chip.getModeMax()); + statistics.put(chip.getName(), entry); } public void modeChanged(Chip source, int mode) { StatEntry entry = statistics.get(source.getName()); - if (entry == null) { - entry = new StatEntry(source.getName(), source.getModeMax()); - statistics.put(source.getName(), entry); - } - entry.updateStat(mode, cpu.cycles); + if (entry != null) + entry.updateStat(mode, cpu.cycles); } public void printStat() { @@ -80,7 +82,78 @@ } } + public DataSource getDataSource(String chip, int mode) { + StatEntry se = statistics.get(chip); + if (se != null) { + return new StatDataSource(se, mode); + } + return null; + } + + public DataSource getMultiDataSource(String chip) { + StatEntry se = statistics.get(chip); + if (se != null) { + return new StatMultiDataSource(se); + } + return null; + } + private class StatDataSource implements DataSource { + + private StatEntry entry; + private int mode; + private long lastCycles; + private long lastValue; + + public StatDataSource(StatEntry entry, int mode) { + this.entry = entry; + this.mode = mode; + lastCycles = cpu.cycles; + } + + // returns percentage since last call... + public int getValue() { + long diff = cpu.cycles - lastCycles; + if (diff == 0) return 0; + long val = entry.getValue(mode, cpu.cycles); + long valDiff = val - lastValue; + lastValue = val; + lastCycles = cpu.cycles; + return (int) (100 * valDiff / diff); + } + } + + private class StatMultiDataSource implements DataSource{ + + private StatEntry entry; + private long lastCycles; + private long[] lastValue; + + public StatMultiDataSource(StatEntry entry) { + this.entry = entry; + lastCycles = cpu.cycles; + lastValue = new long[entry.elapsed.length]; + } + + // returns percentage since last call... + public int getValue() { + long diff = cpu.cycles - lastCycles; + if (diff == 0) return 0; + + long valDiff = 0; + // Assume that 0 means "off" + for (int i = 1; i < lastValue.length; i++) { + // Just sum them - later a multiplicator array might be useful... + long val = entry.getValue(i, cpu.cycles); + valDiff += (val - lastValue[i]); + lastValue[i] = val; + } + lastCycles = cpu.cycles; + return (int) (100 * valDiff / diff); + } + } + + private class StatEntry { String key; long startTime; @@ -92,6 +165,13 @@ elapsed = new long[max + 1]; } + long getValue(int mode, long cycles) { + if (mode == this.mode) { + return elapsed[mode] + (cycles - startTime); + } + return elapsed[mode]; + } + void updateStat(int mode, long cycles) { if (this.mode != -1) { elapsed[this.mode] += cycles - startTime; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 23:16:26
|
Revision: 85 http://mspsim.svn.sourceforge.net/mspsim/?rev=85&view=rev Author: joxe Date: 2008-01-24 15:15:41 -0800 (Thu, 24 Jan 2008) Log Message: ----------- minor fixes in new stack chart. Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-01-24 23:05:15 UTC (rev 84) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-01-24 23:15:41 UTC (rev 85) @@ -28,19 +28,21 @@ public DataChart(String title) { DateAxis domain = new DateAxis("Time"); - NumberAxis range = new NumberAxis("Memory"); + NumberAxis range = new NumberAxis("Bytes"); XYPlot xyplot = new XYPlot(); xyplot.setDomainAxis(domain); xyplot.setRangeAxis(range); // xyplot.setBackgroundPaint(Color.black); xyplot.setDataset(dataset = new TimeSeriesCollection()); - XYItemRenderer renderer = new DefaultXYItemRenderer(); + DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); // renderer.setBaseStroke( // new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) // ); + renderer.setSeriesShapesVisible(0, false); + renderer.setSeriesShapesVisible(1, false); xyplot.setRenderer(renderer); domain.setAutoRange(true); @@ -61,7 +63,7 @@ } public void openFrame(String name) { - JFrame jw = new JFrame("name"); + JFrame jw = new JFrame(name); jw.add(this); jw.setBounds(100, 100, 400, 200); jw.setVisible(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 23:06:09
|
Revision: 84 http://mspsim.svn.sourceforge.net/mspsim/?rev=84&view=rev Author: joxe Date: 2008-01-24 15:05:15 -0800 (Thu, 24 Jan 2008) Log Message: ----------- added new stack chart based on jfreechart. Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/ui/ControlUI.java Added Paths: ----------- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java mspsim/se/sics/mspsim/util/StackMonitor.java Added: mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java (rev 0) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-01-24 23:05:15 UTC (rev 84) @@ -0,0 +1,83 @@ +package se.sics.mspsim.extutil.jfreechart; + +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; + +import javax.swing.JFrame; +import javax.swing.JPanel; + +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; + +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.util.StackMonitor; + +@SuppressWarnings("serial") +public class DataChart extends JPanel { + + private TimeSeriesCollection dataset; + + public DataChart(String title) { + DateAxis domain = new DateAxis("Time"); + NumberAxis range = new NumberAxis("Memory"); + XYPlot xyplot = new XYPlot(); + xyplot.setDomainAxis(domain); + xyplot.setRangeAxis(range); + // xyplot.setBackgroundPaint(Color.black); + xyplot.setDataset(dataset = new TimeSeriesCollection()); + + XYItemRenderer renderer = new DefaultXYItemRenderer(); + renderer.setSeriesPaint(0, Color.red); + renderer.setSeriesPaint(1, Color.green); +// renderer.setBaseStroke( +// new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) +// ); + xyplot.setRenderer(renderer); + + domain.setAutoRange(true); + domain.setLowerMargin(0.0); + domain.setUpperMargin(0.0); + + domain.setTickLabelsVisible(true); + range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + JFreeChart chart = new JFreeChart(title, + JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); + ChartPanel chartPanel = new ChartPanel(chart); + setLayout(new BorderLayout()); + add(chartPanel, BorderLayout.CENTER); + } + + public void addTimeSeries(TimeSeries ts) { + dataset.addSeries(ts); + } + + public void openFrame(String name) { + JFrame jw = new JFrame("name"); + jw.add(this); + jw.setBounds(100, 100, 400, 200); + jw.setVisible(true); + } + + public void setupStackFrame(MSP430 cpu) { + openFrame("Stack Monitor"); + StackMonitor sm = new StackMonitor(cpu); + DataSourceSampler dss = new DataSourceSampler(); + TimeSeries ts = new TimeSeries("Max Stack", Millisecond.class); + ts.setMaximumItemAge(30000); + addTimeSeries(ts); + dss.addDataSource(sm.getMaxSource(), ts); + ts = new TimeSeries("Stack", Millisecond.class); + ts.setMaximumItemAge(30000); + addTimeSeries(ts); + dss.addDataSource(sm.getSource(), ts); + } +} Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-01-24 19:45:13 UTC (rev 83) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-01-24 23:05:15 UTC (rev 84) @@ -27,30 +27,32 @@ private int interval = 100; private Timer timer; - private ArrayList<DataSource> sources = new ArrayList<DataSource>(); + private ArrayList<TimeSource> sources = new ArrayList<TimeSource>(); - private TimeSeries test; - private TimeSeries test2; - private TimeSeriesCollection dataset; +// private TimeSeries test; +// private TimeSeries test2; +// private TimeSeriesCollection dataset; public DataSourceSampler() { timer = new Timer(interval, this); - test = new TimeSeries("Data", Millisecond.class); - test.setMaximumItemAge(30000); - test2 = new TimeSeries("Data 2", Millisecond.class); - test2.setMaximumItemAge(30000); -// test2.setMaximumItemCount(30000); - dataset = new TimeSeriesCollection(); - dataset.addSeries(test); - dataset.addSeries(test2); +// test = new TimeSeries("Data", Millisecond.class); +// test.setMaximumItemAge(30000); +// test2 = new TimeSeries("Data 2", Millisecond.class); +// test2.setMaximumItemAge(30000); +//// test2.setMaximumItemCount(30000); +// dataset = new TimeSeriesCollection(); +// dataset.addSeries(test); +// dataset.addSeries(test2); timer.start(); } - public void addDataSource(DataSource source) { - sources.add(source); + public TimeSource addDataSource(DataSource source, TimeSeries ts) { + TimeSource times = new TimeSource(source, ts); + sources.add(times); + return times; } - public void removeDataSource(DataSource source) { + public void removeDataSource(TimeSource source) { sources.remove(source); } @@ -61,14 +63,14 @@ private void sampleAll() { if (sources.size() > 0) { - DataSource[] srcs = (DataSource[]) sources.toArray(new DataSource[0]); + TimeSource[] srcs = (TimeSource[]) sources.toArray(new TimeSource[0]); for (int i = 0; i < srcs.length; i++) { - int val = srcs[i].getValue(); - + srcs[i].update(); } } - test.add(new Millisecond(), Math.random() * 100); - test2.add(new Millisecond(), Math.random() * 100); + +// test.add(new Millisecond(), Math.random() * 100); +// test2.add(new Millisecond(), Math.random() * 100); } public void actionPerformed(ActionEvent arg0) { @@ -76,39 +78,55 @@ } - public static void main(String[] args) { - DataSourceSampler samp = new DataSourceSampler(); - DateAxis domain = new DateAxis("Time"); - NumberAxis range = new NumberAxis("Memory"); - XYPlot xyplot = new XYPlot(); - xyplot.setDataset(samp.dataset); - xyplot.setDomainAxis(domain); - xyplot.setRangeAxis(range); - xyplot.setBackgroundPaint(Color.black); +// public static void main(String[] args) { +// DataSourceSampler samp = new DataSourceSampler(); +// DateAxis domain = new DateAxis("Time"); +// NumberAxis range = new NumberAxis("Memory"); +// XYPlot xyplot = new XYPlot(); +// xyplot.setDataset(samp.dataset); +// xyplot.setDomainAxis(domain); +// xyplot.setRangeAxis(range); +// xyplot.setBackgroundPaint(Color.black); +// +// XYItemRenderer renderer = new DefaultXYItemRenderer(); +// renderer.setSeriesPaint(0, Color.red); +// renderer.setSeriesPaint(1, Color.green); +// renderer.setBaseStroke( +// new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) +// ); +// xyplot.setRenderer(renderer); +// +// domain.setAutoRange(true); +// domain.setLowerMargin(0.0); +// domain.setUpperMargin(0.0); +// domain.setTickLabelsVisible(true); +// range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); +// JFreeChart chart = new JFreeChart( +// "Memory Usage", +// JFreeChart.DEFAULT_TITLE_FONT, +// xyplot,true); +// ChartPanel chartPanel = new ChartPanel(chart); +// JFrame jw = new JFrame("test"); +// jw.add(chartPanel); +// jw.setBounds(100, 100, 400, 200); +// jw.setVisible(true); +// +// } + + class TimeSource { + + private DataSource dataSource; + private TimeSeries timeSeries; + + TimeSource(DataSource ds, TimeSeries ts) { + dataSource = ds; + timeSeries = ts; + } - XYItemRenderer renderer = new DefaultXYItemRenderer(); - renderer.setSeriesPaint(0, Color.red); - renderer.setSeriesPaint(1, Color.green); - renderer.setBaseStroke( - new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) - ); - xyplot.setRenderer(renderer); + public void update() { + timeSeries.add(new Millisecond(), dataSource.getValue()); + } - domain.setAutoRange(true); - domain.setLowerMargin(0.0); - domain.setUpperMargin(0.0); - domain.setTickLabelsVisible(true); - range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); - JFreeChart chart = new JFreeChart( - "Memory Usage", - JFreeChart.DEFAULT_TITLE_FONT, - xyplot,true); - ChartPanel chartPanel = new ChartPanel(chart); - JFrame jw = new JFrame("test"); - jw.add(chartPanel); - jw.setBounds(100, 100, 400, 200); - jw.setVisible(true); - } } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 19:45:13 UTC (rev 83) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 23:05:15 UTC (rev 84) @@ -219,7 +219,7 @@ ControlUI control = new ControlUI(cpu, elf); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); control.setSourceViewer(sourceViewer); - + if (args.length > 1) { MapTable map = new MapTable(args[1]); cpu.getDisAsm().setMap(map); Modified: mspsim/se/sics/mspsim/ui/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 19:45:13 UTC (rev 83) +++ mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 23:05:15 UTC (rev 84) @@ -54,6 +54,7 @@ import javax.swing.KeyStroke; import se.sics.mspsim.core.*; +import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.util.DebugInfo; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.StackUI; @@ -82,6 +83,10 @@ this.cpu = cpu; this.stackUI = new StackUI(cpu); + + DataChart test = new DataChart("Stack Monitor"); + test.setupStackFrame(cpu); + stackWindow = new JFrame("Stack"); stackWindow.add(this.stackUI); WindowUtils.restoreWindowBounds("StackUI", stackWindow); Added: mspsim/se/sics/mspsim/util/StackMonitor.java =================================================================== --- mspsim/se/sics/mspsim/util/StackMonitor.java (rev 0) +++ mspsim/se/sics/mspsim/util/StackMonitor.java 2008-01-24 23:05:15 UTC (rev 84) @@ -0,0 +1,82 @@ +package se.sics.mspsim.util; + +import se.sics.mspsim.core.CPUMonitor; +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.core.MSP430Constants; + +public class StackMonitor implements CPUMonitor { + + private MSP430 cpu; + private int heapStartAddress; + private int stackStartAddress; + + private int stackMin = 0; + private int stackMax = 0; + private int stack = 0; + + private DataSource maxDataSource = new DataSource() { + public int getValue() { + int tmp = stackMax; + stackMax = stack; + return tmp; + } + }; + + private DataSource minDataSource = new DataSource() { + public int getValue() { + int tmp = stackMin; + stackMin = stack; + return tmp; + } + }; + + private DataSource dataSource = new DataSource() { + public int getValue() { + return stack; + } + }; + + public StackMonitor(MSP430 cpu) { + this.cpu = cpu; + this.cpu.setRegisterWriteMonitor(MSP430.SP, this); + + if (cpu.getDisAsm() != null) { + MapTable mapTable = cpu.getDisAsm().getMap(); + if (mapTable != null) { + this.heapStartAddress = mapTable.heapStartAddress; + this.stackStartAddress = mapTable.stackStartAddress; + } + } + } + + public int getStackStart() { + return stackStartAddress; + } + + public int getHeapStart() { + return heapStartAddress; + } + + + public DataSource getMaxSource() { + return maxDataSource; + } + + public DataSource getMinSource() { + return minDataSource; + } + + public DataSource getSource() { + return dataSource; + } + + public void cpuAction(int type, int adr, int data) { + stack = ((stackStartAddress - data) + 0xffff) % 0xffff; + if (stack > stackMax) { + stackMax = stack; + } + if (stack < stackMin) { + stackMin = stack; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 19:52:52
|
Revision: 83 http://mspsim.svn.sourceforge.net/mspsim/?rev=83&view=rev Author: joxe Date: 2008-01-24 11:45:13 -0800 (Thu, 24 Jan 2008) Log Message: ----------- fixed test of TimeSeries to work with 10 updates per sec. Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-01-24 19:26:52 UTC (rev 82) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-01-24 19:45:13 UTC (rev 83) @@ -25,20 +25,25 @@ public class DataSourceSampler implements ActionListener { - private int interval = 1000; + private int interval = 100; private Timer timer; private ArrayList<DataSource> sources = new ArrayList<DataSource>(); private TimeSeries test; + private TimeSeries test2; private TimeSeriesCollection dataset; public DataSourceSampler() { timer = new Timer(interval, this); test = new TimeSeries("Data", Millisecond.class); - test.setMaximumItemCount(30000); + test.setMaximumItemAge(30000); + test2 = new TimeSeries("Data 2", Millisecond.class); + test2.setMaximumItemAge(30000); +// test2.setMaximumItemCount(30000); dataset = new TimeSeriesCollection(); dataset.addSeries(test); -// timer.start(); + dataset.addSeries(test2); + timer.start(); } public void addDataSource(DataSource source) { @@ -62,11 +67,11 @@ } } - test.add(new Millisecond(), Math.random()); + test.add(new Millisecond(), Math.random() * 100); + test2.add(new Millisecond(), Math.random() * 100); } public void actionPerformed(ActionEvent arg0) { - System.out.println("Scheduled for sampling..."); sampleAll(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 19:30:24
|
Revision: 82 http://mspsim.svn.sourceforge.net/mspsim/?rev=82&view=rev Author: joxe Date: 2008-01-24 11:26:52 -0800 (Thu, 24 Jan 2008) Log Message: ----------- Added datasource and jfreechart test. Added Paths: ----------- mspsim/se/sics/mspsim/extutil/jfreechart/ mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java mspsim/se/sics/mspsim/util/DataSource.java Added: mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java (rev 0) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-01-24 19:26:52 UTC (rev 82) @@ -0,0 +1,109 @@ +package se.sics.mspsim.extutil.jfreechart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +import javax.swing.JFrame; +import javax.swing.JWindow; +import javax.swing.Timer; + +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; + +import se.sics.mspsim.util.DataSource; + +public class DataSourceSampler implements ActionListener { + + private int interval = 1000; + private Timer timer; + private ArrayList<DataSource> sources = new ArrayList<DataSource>(); + + private TimeSeries test; + private TimeSeriesCollection dataset; + + public DataSourceSampler() { + timer = new Timer(interval, this); + test = new TimeSeries("Data", Millisecond.class); + test.setMaximumItemCount(30000); + dataset = new TimeSeriesCollection(); + dataset.addSeries(test); +// timer.start(); + } + + public void addDataSource(DataSource source) { + sources.add(source); + } + + public void removeDataSource(DataSource source) { + sources.remove(source); + } + + public void setInterval(int intMsek) { + interval = intMsek; + timer.setDelay(interval); + } + + private void sampleAll() { + if (sources.size() > 0) { + DataSource[] srcs = (DataSource[]) sources.toArray(new DataSource[0]); + for (int i = 0; i < srcs.length; i++) { + int val = srcs[i].getValue(); + + } + } + test.add(new Millisecond(), Math.random()); + } + + public void actionPerformed(ActionEvent arg0) { + System.out.println("Scheduled for sampling..."); + sampleAll(); + } + + + public static void main(String[] args) { + DataSourceSampler samp = new DataSourceSampler(); + DateAxis domain = new DateAxis("Time"); + NumberAxis range = new NumberAxis("Memory"); + XYPlot xyplot = new XYPlot(); + xyplot.setDataset(samp.dataset); + xyplot.setDomainAxis(domain); + xyplot.setRangeAxis(range); + xyplot.setBackgroundPaint(Color.black); + + XYItemRenderer renderer = new DefaultXYItemRenderer(); + renderer.setSeriesPaint(0, Color.red); + renderer.setSeriesPaint(1, Color.green); + renderer.setBaseStroke( + new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) + ); + xyplot.setRenderer(renderer); + + domain.setAutoRange(true); + domain.setLowerMargin(0.0); + domain.setUpperMargin(0.0); + domain.setTickLabelsVisible(true); + range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + JFreeChart chart = new JFreeChart( + "Memory Usage", + JFreeChart.DEFAULT_TITLE_FONT, + xyplot,true); + ChartPanel chartPanel = new ChartPanel(chart); + JFrame jw = new JFrame("test"); + jw.add(chartPanel); + jw.setBounds(100, 100, 400, 200); + jw.setVisible(true); + + } + +} Added: mspsim/se/sics/mspsim/util/DataSource.java =================================================================== --- mspsim/se/sics/mspsim/util/DataSource.java (rev 0) +++ mspsim/se/sics/mspsim/util/DataSource.java 2008-01-24 19:26:52 UTC (rev 82) @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * ----------------------------------------------------------------- + * + * DataSource + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ +package se.sics.mspsim.util; + +public interface DataSource { + public int getValue(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 18:54:29
|
Revision: 81 http://mspsim.svn.sourceforge.net/mspsim/?rev=81&view=rev Author: joxe Date: 2008-01-24 10:48:06 -0800 (Thu, 24 Jan 2008) Log Message: ----------- added operating mode profiling. Modified Paths: -------------- mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/BasicClockModule.java mspsim/se/sics/mspsim/core/IOPort.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Multiplier.java mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Added Paths: ----------- mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/OperatingModeListener.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2008-01-24 18:48:06 UTC (rev 81) @@ -145,4 +145,8 @@ } } } + + public int getModeMax() { + return 0; + } } Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-01-24 18:48:06 UTC (rev 81) @@ -43,7 +43,7 @@ import se.sics.mspsim.core.*; import se.sics.mspsim.util.Utils; -public class CC2420 implements USARTListener { +public class CC2420 extends Chip implements USARTListener { public static final boolean DEBUG = true; @@ -120,6 +120,11 @@ public static final int RAM_PANID = 0x168; public static final int RAM_SHORTADDR = 0x16A; + public static final int MODE_TXRX_OFF = 0x00; + public static final int MODE_RX_ON = 0x01; + public static final int MODE_TXRX_ON = 0x02; + public static final int MODE_MAX = MODE_TXRX_ON; + // when reading registrers this flag is set! public static final int FLAG_READ = 0x40; @@ -144,6 +149,8 @@ private int status = ST_XOSC16M_STABLE; + private int mode = MODE_TXRX_OFF; + private int[] registers = new int[64]; // More than needed... private int[] memory = new int[512]; @@ -169,9 +176,10 @@ public void dataReceived(USART source, int data) { if (chipSelect) { - System.out.println("CC2420 byte received: " + Utils.hex8(data) + - '\'' + (char) data + '\'' + - " CS: " + chipSelect + " state: " + state); + if (DEBUG) + System.out.println("CC2420 byte received: " + Utils.hex8(data) + + '\'' + (char) data + '\'' + + " CS: " + chipSelect + " state: " + state); switch(state) { case WAITING: state = WRITE_REGISTER; @@ -209,8 +217,9 @@ source.byteReceived(registers[address] & 0xff); // set the low bits registers[address] = registers[address] & 0xff00 | data; - System.out.println("CC2420: wrote to " + Utils.hex8(address) + " = " - + registers[address]); + if (DEBUG) + System.out.println("CC2420: wrote to " + Utils.hex8(address) + " = " + + registers[address]); } break; case READ_REGISTER: @@ -218,8 +227,9 @@ source.byteReceived(registers[address] >> 8); } else { source.byteReceived(registers[address] & 0xff); - System.out.println("CC2420: read from " + Utils.hex8(address) + " = " - + registers[address]); + if (DEBUG) + System.out.println("CC2420: read from " + Utils.hex8(address) + " = " + + registers[address]); } break; case READ_RXFIFO: @@ -238,16 +248,17 @@ if (pos == 0) { address = address | (data << 1) & 0x180; ramRead = (data & 0x20) != 0; - System.out.println("CC2420: Address: " + Utils.hex16(address) + - " read: " + ramRead); + if (DEBUG) + System.out.println("CC2420: Address: " + Utils.hex16(address) + + " read: " + ramRead); pos++; } else { if (!ramRead) { memory[address++] = data; - if (address == RAM_PANID + 2) { - System.out.println("CC2420: Pan ID set to: 0x" + - Utils.hex8(memory[RAM_PANID]) + - Utils.hex8(memory[RAM_PANID + 1])); + if (DEBUG && address == RAM_PANID + 2) { + System.out.println("CC2420: Pan ID set to: 0x" + + Utils.hex8(memory[RAM_PANID]) + + Utils.hex8(memory[RAM_PANID + 1])); } } } @@ -258,20 +269,38 @@ // Needs to get information about when it is possible to write // next data... - private void strobe(int data) { // Resets, on/off of different things... - System.out.println("CC2420: Strobe on: " + Utils.hex8(data)); + if (DEBUG) + System.out.println("CC2420: Strobe on: " + Utils.hex8(data)); switch (data) { case REG_SRXON: System.out.println("CC2420: Strobe RX-ON!!!"); + setMode(MODE_RX_ON); break; + case REG_SRFOFF: + System.out.println("CC2420: Strobe RXTX-OFF!!!"); + setMode(MODE_TXRX_OFF); + break; + case REG_STXON: + System.out.println("CC2420: Strobe TXON!"); + setMode(MODE_TXRX_ON); + break; + case REG_STXONCCA: + System.out.println("CC2420: Strobe TXONCCA!"); + setMode(MODE_TXRX_ON); + break; case REG_SFLUSHRX: flushRX(); break; } } + + private void setMode(int mode) { + this.mode = mode; + modeChanged(mode); + } public void setChipSelect(boolean select) { @@ -310,8 +339,8 @@ } public void setIncomingPacket(int[] packet) { - int adr = RAM_RXFIFO; - memory[adr++] = packet.length + 2; + int adr = RAM_RXFIFO; + memory[adr++] = packet.length + 2; for (int i = 0, n = packet.length; i < n; i++) { memory[adr++] = packet[i] & 0xff; } @@ -326,8 +355,9 @@ } private void flushRX() { - if (DEBUG) System.out.println("Flushing RX! was: " + rxPacket + " len = " + - rxLen); + if (DEBUG) + System.out.println("Flushing RX! was: " + rxPacket + " len = " + + rxLen); rxPacket = false; rxCursor = 0; rxLen = 0; @@ -341,5 +371,14 @@ public void setCCA(boolean cca) { ccaPort.setPinState(ccaPin, cca ? 1 : 0); } + + public String getName() { + return "CC2420"; + } + public int getModeMax() { + return MODE_MAX; + } + + } // CC2420 Modified: mspsim/se/sics/mspsim/core/BasicClockModule.java =================================================================== --- mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-01-24 18:48:06 UTC (rev 81) @@ -162,4 +162,8 @@ public void interruptServiced() { } + + public int getModeMax() { + return 0; + } } Added: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java (rev 0) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-01-24 18:48:06 UTC (rev 81) @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * Chip + * + * Author : Joakim Eriksson + * Created : 17 jan 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.core; +import java.util.ArrayList; +import java.util.Iterator; + +/** + * @author Joakim + * + */ +public abstract class Chip { + + private ArrayList<OperatingModeListener> omListeners; + + public void addOperatingModeListener(OperatingModeListener listener) { + if (omListeners == null) + omListeners = new ArrayList<OperatingModeListener>(); + omListeners.add(listener); + } + + public void removeOperatinModeListener(OperatingModeListener listener) { + if (omListeners != null) + omListeners.remove(listener); + } + + protected void modeChanged(int mode) { + if (omListeners != null) { + for (Iterator<OperatingModeListener> iterator = omListeners.iterator(); iterator.hasNext();) { + OperatingModeListener type = iterator.next(); + type.modeChanged(this, mode); + } + } + } + + public abstract String getName(); + public abstract int getModeMax(); +} Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/IOPort.java 2008-01-24 18:48:06 UTC (rev 81) @@ -71,7 +71,7 @@ public static final int IE = 5; public static final int ISEL = 6; - // One listener per port maximum (now at leat) + // One listener per port maximum (now at least) private PortListener listener; /** @@ -203,4 +203,9 @@ cpu.flagInterrupt(interrupt, this, interruptFlag > 0); } + // TODO: Should override this + public int getModeMax() { + return 0; + } + } Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2008-01-24 18:48:06 UTC (rev 81) @@ -41,8 +41,11 @@ package se.sics.mspsim.core; -public abstract class IOUnit { +import java.util.ArrayList; +import java.util.Iterator; +public abstract class IOUnit extends Chip { + int[] memory; int offset; @@ -53,7 +56,7 @@ public void reset() { } - + public boolean needsTick() { return true; } @@ -82,8 +85,6 @@ // read a value from the IO unit public abstract int read(int address, boolean word, long cycles); - public abstract String getName(); - // We should add "Interrupt serviced..." to indicate that its latest // Interrupt was serviced... public abstract void interruptServiced(); Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-01-24 18:48:06 UTC (rev 81) @@ -64,7 +64,7 @@ private DisAsm disAsm; private MapTable map; private Profiler profiler; - + /** * Creates a new <code>MSP430</code> instance. * Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-01-24 18:48:06 UTC (rev 81) @@ -45,7 +45,7 @@ /** * The CPU of the MSP430 */ -public class MSP430Core implements MSP430Constants { +public class MSP430Core extends Chip implements MSP430Constants { public static final boolean DEBUG = false; public static final boolean debugInterrupts = false; @@ -54,6 +54,14 @@ public static final int MAX_MEM = 64*1024; public static final int INTERNAL_IO_SIZE = 5; public static final int PORTS = 6; + + public static final int MODE_ACTIVE = 0; + public static final int MODE_LPM0 = 1; + public static final int MODE_LPM1 = 2; + public static final int MODE_LPM2 = 3; + public static final int MODE_LPM3 = 4; + public static final int MODE_LPM4 = 5; + private static final int MODE_MAX = MODE_LPM4; // 16 registers of which some are "special" - PC, SP, etc. public int[] reg = new int[16]; @@ -247,6 +255,24 @@ if (cpuOff != oldCpuOff) { // System.out.println("LPM CPUOff: " + cpuOff + " cycles: " + cycles); } + if (cpuOff) { + boolean scg0 = (value & SCG0) == SCG0; + boolean scg1 = (value & SCG1) == SCG1; + boolean oscoff = (value & OSCOFF) == OSCOFF; + if (oscoff && scg1 && scg0) { + modeChanged(MODE_LPM4); + } else if (scg1 && scg0){ + modeChanged(MODE_LPM3); + } else if (scg1) { + modeChanged(MODE_LPM2); + } else if (scg0) { + modeChanged(MODE_LPM1); + } else { + modeChanged(MODE_LPM0); + } + } else { + modeChanged(MODE_ACTIVE); + } } } @@ -965,4 +991,12 @@ cpuCycles += cycles - startCycles; return true; } + + public String getName() { + return "MSP430 Core"; + } + + public int getModeMax() { + return MODE_MAX; + } } Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2008-01-24 18:48:06 UTC (rev 81) @@ -116,5 +116,9 @@ public void interruptServiced() { } + public int getModeMax() { + return 0; + } + } Added: mspsim/se/sics/mspsim/core/OperatingModeListener.java =================================================================== --- mspsim/se/sics/mspsim/core/OperatingModeListener.java (rev 0) +++ mspsim/se/sics/mspsim/core/OperatingModeListener.java 2008-01-24 18:48:06 UTC (rev 81) @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * OperatingModeListener - allow listening on IOUnits operating mode. + * + * Author : Joakim Eriksson + * Created : 17 jan 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.core; + +/** + * @author Joakim + * + */ +public interface OperatingModeListener { + public void modeChanged(Chip source, int mode); +} Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-01-24 18:48:06 UTC (rev 81) @@ -151,4 +151,8 @@ public String getName() { return "SpecialFunctionRegister, SFR"; } + + public int getModeMax() { + return 0; + } } // SFR Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-01-24 18:48:06 UTC (rev 81) @@ -629,4 +629,8 @@ System.out.println("interrupt Serviced..."); } } + + public int getModeMax() { + return 0; + } } Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/core/USART.java 2008-01-24 18:48:06 UTC (rev 81) @@ -308,4 +308,8 @@ } } + public int getModeMax() { + return 0; + } + } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 18:48:06 UTC (rev 81) @@ -43,6 +43,7 @@ import java.io.IOException; import se.sics.mspsim.chip.CC2420; +import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430; @@ -54,14 +55,20 @@ import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; +import se.sics.mspsim.util.OperatingModeStatistics; /** * Emulation of Sky Mote */ -public class SkyNode implements PortListener, USARTListener { +public class SkyNode extends Chip implements PortListener, USARTListener { public static final boolean DEBUG = false; + public static final int MODE_LEDS_OFF = 0; + public static final int MODE_LEDS_1 = 1; + public static final int MODE_LEDS_2 = 2; + public static final int MODE_LEDS_3 = 3; + public static final int MODE_MAX = MODE_LEDS_3; // Port 2. public static final int BUTTON_PIN = 7; @@ -81,7 +88,7 @@ private CC2420 radio; private ExtFlash flash; - + public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; @@ -89,7 +96,10 @@ public boolean redLed; public boolean blueLed; public boolean greenLed; + private int mode = MODE_LEDS_OFF; + private OperatingModeStatistics stats; + public SkyGui gui; /** * Creates a new <code>SkyNode</code> instance. @@ -127,6 +137,9 @@ ((IOPort) port4).setPortListener(this); } } + + stats = new OperatingModeStatistics(cpu); + stats.addMonitor(this); } public void setButton(boolean hi) { @@ -150,6 +163,14 @@ redLed = (data & RED_LED) == 0; blueLed = (data & BLUE_LED) == 0; greenLed = (data & GREEN_LED) == 0; + int newMode = (redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0); + if (mode != newMode) { + mode = newMode; + modeChanged(mode); + } + // TODO: put this somewhere else!!! + //stats.printStat(); + if (gui != null) { gui.repaint(); } @@ -203,6 +224,15 @@ MapTable map = new MapTable(args[1]); cpu.getDisAsm().setMap(map); } + cpu.cpuloop(); } + + public int getModeMax() { + return MODE_MAX; + } + + public String getName() { + return "Tmote Sky"; + } } Added: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java (rev 0) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-01-24 18:48:06 UTC (rev 81) @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * OperatingModeStatistics + * + * Author : Joakim Eriksson + * Created : 17 jan 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.util; + +import java.util.HashMap; +import java.util.Iterator; + +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.OperatingModeListener; + +/** + * @author Joakim + * + */ +public class OperatingModeStatistics implements OperatingModeListener { + + private MSP430Core cpu; + private HashMap<String, StatEntry> statistics = new HashMap<String, StatEntry>(); + + public OperatingModeStatistics(MSP430Core cpu) { + this.cpu = cpu; + } + + public void addMonitor(Chip chip) { + chip.addOperatingModeListener(this); + } + + public void modeChanged(Chip source, int mode) { + StatEntry entry = statistics.get(source.getName()); + if (entry == null) { + entry = new StatEntry(source.getName(), source.getModeMax()); + statistics.put(source.getName(), entry); + } + entry.updateStat(mode, cpu.cycles); + } + + public void printStat() { + for (Iterator<StatEntry> iterator = statistics.values().iterator(); iterator.hasNext();) { + StatEntry entry = iterator.next(); + entry.printStat(); + } + } + + + private class StatEntry { + String key; + long startTime; + int mode = -1; + long[] elapsed; + + StatEntry(String key, int max) { + this.key = key; + elapsed = new long[max + 1]; + } + + void updateStat(int mode, long cycles) { + if (this.mode != -1) { + elapsed[this.mode] += cycles - startTime; + } + this.mode = mode; + startTime = cycles; + } + + void printStat() { + System.out.println("Stat for: " + key); + for (int i = 0; i < elapsed.length; i++) { + System.out.println("" + (i + 1) + " = " + elapsed[i]); + } + } + } + +} Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2008-01-24 17:58:34 UTC (rev 80) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2008-01-24 18:48:06 UTC (rev 81) @@ -91,16 +91,16 @@ public void clearProfile() { if (profileData != null) { CallEntry[] entries = - profileData.values().toArray(new CallEntry[0]); + profileData.values().toArray(new CallEntry[0]); for (int i = 0, n = entries.length; i < n; i++) { - entries[i].cycles = 0; - entries[i].calls = 0; + entries[i].cycles = 0; + entries[i].calls = 0; } for (int i = 0, n = callStack.length; i < n; i++) { - CallEntry e = callStack[i]; - if (e != null) { - e.calls = -1; - } + CallEntry e = callStack[i]; + if (e != null) { + e.calls = -1; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-01-24 18:04:04
|
Revision: 80 http://mspsim.svn.sourceforge.net/mspsim/?rev=80&view=rev Author: nifi Date: 2008-01-24 09:58:34 -0800 (Thu, 24 Jan 2008) Log Message: ----------- added ui package Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2008-01-24 13:40:29 UTC (rev 79) +++ mspsim/Makefile 2008-01-24 17:58:34 UTC (rev 80) @@ -64,7 +64,7 @@ BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware -PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util chip extutil/highlight} +PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky ui util chip extutil/highlight} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 13:43:39
|
Revision: 79 http://mspsim.svn.sourceforge.net/mspsim/?rev=79&view=rev Author: joxe Date: 2008-01-24 05:40:29 -0800 (Thu, 24 Jan 2008) Log Message: ----------- moved some more UI related files into the ui package. Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java mspsim/se/sics/mspsim/platform/sky/SkyGui.java mspsim/se/sics/mspsim/ui/ControlUI.java Added Paths: ----------- mspsim/se/sics/mspsim/ui/SerialMon.java mspsim/se/sics/mspsim/ui/SourceViewer.java mspsim/se/sics/mspsim/ui/WindowUtils.java Removed Paths: ------------- mspsim/se/sics/mspsim/util/SerialMon.java mspsim/se/sics/mspsim/util/SourceViewer.java mspsim/se/sics/mspsim/util/WindowUtils.java Modified: mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java =================================================================== --- mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/extutil/highlight/HighlightSourceViewer.java 2008-01-24 13:40:29 UTC (rev 79) @@ -52,8 +52,8 @@ import javax.swing.JScrollPane; import javax.swing.SwingUtilities; -import se.sics.mspsim.util.SourceViewer; -import se.sics.mspsim.util.WindowUtils; +import se.sics.mspsim.ui.SourceViewer; +import se.sics.mspsim.ui.WindowUtils; /** * Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-01-24 13:40:29 UTC (rev 79) @@ -54,8 +54,8 @@ import se.sics.mspsim.chip.Beeper; import se.sics.mspsim.core.*; -import se.sics.mspsim.util.SerialMon; -import se.sics.mspsim.util.WindowUtils; +import se.sics.mspsim.ui.SerialMon; +import se.sics.mspsim.ui.WindowUtils; public class ESBGui extends JComponent implements KeyListener, MouseMotionListener, Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2008-01-24 13:40:29 UTC (rev 79) @@ -52,8 +52,8 @@ import javax.swing.JFrame; import se.sics.mspsim.core.*; -import se.sics.mspsim.util.SerialMon; -import se.sics.mspsim.util.WindowUtils; +import se.sics.mspsim.ui.SerialMon; +import se.sics.mspsim.ui.WindowUtils; public class SkyGui extends JComponent implements KeyListener { Modified: mspsim/se/sics/mspsim/ui/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 13:40:29 UTC (rev 79) @@ -56,9 +56,7 @@ import se.sics.mspsim.core.*; import se.sics.mspsim.util.DebugInfo; import se.sics.mspsim.util.ELF; -import se.sics.mspsim.util.SourceViewer; import se.sics.mspsim.util.StackUI; -import se.sics.mspsim.util.WindowUtils; public class ControlUI extends JPanel implements ActionListener { Copied: mspsim/se/sics/mspsim/ui/SerialMon.java (from rev 74, mspsim/se/sics/mspsim/util/SerialMon.java) =================================================================== --- mspsim/se/sics/mspsim/ui/SerialMon.java (rev 0) +++ mspsim/se/sics/mspsim/ui/SerialMon.java 2008-01-24 13:40:29 UTC (rev 79) @@ -0,0 +1,152 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: SerialMon.java,v 1.4 2007/10/21 22:19:07 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * SerialMon + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 22:19:07 $ + * $Revision: 1.4 $ + */ + +package se.sics.mspsim.ui; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +import se.sics.mspsim.core.*; + +public class SerialMon implements KeyListener, USARTListener { + + private static final String PREFIX = " > "; + + private String name; + private JFrame window; + private USART usart; + private JTextArea textArea; + private JLabel statusLabel; + private String text = "*** Serial mon for ESB/MSPsim ***\n"; + + private int lines = 1; + private boolean isUpdatePending = false; + private StringBuilder keyBuffer = new StringBuilder(); + + public SerialMon(USART usart, String name) { + this.name = name; + this.usart = usart; + window = new JFrame(name); +// window.setBounds(100, 100, 400,340); + window.add(new JScrollPane(textArea = new JTextArea(20, 40), + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), + BorderLayout.CENTER); + textArea.setText(text); + textArea.setEditable(false); + statusLabel = new JLabel(PREFIX); + keyBuffer.append(PREFIX); + statusLabel.setOpaque(true); + statusLabel.setBackground(Color.lightGray); + window.add(statusLabel, BorderLayout.SOUTH); + String key = "usart." + name; + WindowUtils.restoreWindowBounds(key, window); + WindowUtils.addSaveOnShutdown(key, window); + window.setVisible(true); + + textArea.addKeyListener(this); + } + + public void saveWindowBounds() { + WindowUtils.saveWindowBounds("usart." + name, window); + } + + public void dataReceived(USART source, int data) { + if (data == '\n') { + if (lines >= 60) { + int index = text.indexOf('\n'); + text = text.substring(index + 1); + } else { + lines++; + } + } + text += (char)data; + + // Collapse several immediate updates + if (!isUpdatePending) { + isUpdatePending = true; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + isUpdatePending = false; + + final String newText = text; + textArea.setText(newText); + textArea.setCaretPosition(newText.length()); + textArea.repaint(); + } + }); + } + } + + + // ------------------------------------------------------------------- + // KeyListener + // ------------------------------------------------------------------- + + public void keyPressed(KeyEvent key) { + } + + public void keyReleased(KeyEvent key) { + } + + public void keyTyped(KeyEvent key) { + char c = key.getKeyChar(); + // Send it to the usart! + usart.byteReceived(c & 0xff); + + // Visualize the input + if (c == '\n') { + statusLabel.setText(PREFIX); + keyBuffer = new StringBuilder(); + keyBuffer.append(PREFIX); + } else { + keyBuffer.append(c); + statusLabel.setText(keyBuffer.toString()); + } + } + +} Copied: mspsim/se/sics/mspsim/ui/SourceViewer.java (from rev 74, mspsim/se/sics/mspsim/util/SourceViewer.java) =================================================================== --- mspsim/se/sics/mspsim/ui/SourceViewer.java (rev 0) +++ mspsim/se/sics/mspsim/ui/SourceViewer.java 2008-01-24 13:40:29 UTC (rev 79) @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * + * ----------------------------------------------------------------- + * + * Source Viewer + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 22:02:22 $ + * $Revision: 1.4 $ + */ + +package se.sics.mspsim.ui; + + +public interface SourceViewer { + + public boolean isVisible(); + public void viewFile(String path, String file); + public void viewLine(int line); + +} Copied: mspsim/se/sics/mspsim/ui/WindowUtils.java (from rev 74, mspsim/se/sics/mspsim/util/WindowUtils.java) =================================================================== --- mspsim/se/sics/mspsim/ui/WindowUtils.java (rev 0) +++ mspsim/se/sics/mspsim/ui/WindowUtils.java 2008-01-24 13:40:29 UTC (rev 79) @@ -0,0 +1,213 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: WindowUtils.java,v 1.2 2007/10/21 20:50:26 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * WindowUtils + * + * Author : Joakim Eriksson, Niclas Finne, Fredrik \xD6sterlind + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 20:50:26 $ + * $Revision: 1.2 $ + */ + +package se.sics.mspsim.ui; +import java.awt.Window; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.prefs.Preferences; + +public class WindowUtils { + + private static Preferences prefs = + Preferences.userNodeForPackage(WindowUtils.class); + + private static Hashtable<Window,CloseListener> closeTable; + private static Hashtable<Window,String> exitTable; + + private WindowUtils() { + } + + public static void saveWindowBounds(String key, Window window) { + putWindowBounds(key, window); + try { + prefs.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void putWindowBounds(String key, Window window) { + prefs.put("window." + key + ".bounds", getBounds(window)); + } + + public static void restoreWindowBounds(String key, Window window) { + setBounds(window, prefs.get("window." + key + ".bounds", null)); + } + + private static String getBounds(Window window) { + return "" + window.getX() + + ',' + window.getY() + + ',' + window.getWidth() + + ',' + window.getHeight(); + } + + private static void setBounds(Window window, String bounds) { + String[] b; + if ((bounds != null) + && ((b = bounds.split(",")) != null) + && b.length == 4) { + try { + window.setBounds(Integer.parseInt(b[0]), + Integer.parseInt(b[1]), + Integer.parseInt(b[2]), + Integer.parseInt(b[3])); + } catch (Exception e) { + e.printStackTrace(); + window.pack(); + } + } else { + window.pack(); + } + } + + public static void clearState() { + try { + prefs.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public synchronized static void addSaveOnClose(String key, Window window) { + if (closeTable == null) { + closeTable = new Hashtable<Window,CloseListener>(); + } + if (closeTable.get(window) == null) { + CloseListener c = new CloseListener(key); + window.addWindowListener(c); + closeTable.put(window, c); + } + } + + public synchronized static void removeSaveOnClose(Window window) { + if (closeTable != null) { + CloseListener c = closeTable.remove(window); + if (c != null) { + window.removeWindowListener(c); + } + } + } + + public synchronized static void addSaveOnShutdown(String key, Window window) { + if (exitTable == null) { + exitTable = new Hashtable<Window,String>(); + Runtime.getRuntime().addShutdownHook(new ShutdownHandler()); + } + exitTable.put(window, key); + } + + public synchronized static void removeSaveOnShutdown(Window window) { + if (exitTable != null) { + exitTable.remove(window); + } + } + + + + // ------------------------------------------------------------------- + // Main + // ------------------------------------------------------------------- + + public static void main(String[] args) { + if (args.length != 1 || !args[0].equals("-clearState")) { + System.err.println("Usage: WindowUtils -clearState"); + System.exit(1); + } + clearState(); + } + + + // ------------------------------------------------------------------- + // CloseListener + // ------------------------------------------------------------------- + + private static class CloseListener extends WindowAdapter { + + private String key; + + public CloseListener(String key) { + this.key = key; + } + + public void windowClosing(WindowEvent e) { + Window source = (Window) e.getSource(); + saveWindowBounds(key, source); + source.removeWindowListener(this); + closeTable.remove(source); + } + + } + + + // ------------------------------------------------------------------- + // Shutdown handler + // ------------------------------------------------------------------- + + private static class ShutdownHandler extends Thread { + + public ShutdownHandler() { + super("WindowUtils-Shutdown"); + } + + public void run() { + Hashtable<Window,String> table = exitTable; + if (table != null && table.size() > 0) { + exitTable = null; + + Enumeration<Window> e = table.keys(); + while(e.hasMoreElements()) { + Window w = e.nextElement(); + putWindowBounds(table.get(w), w); + } + try { + prefs.flush(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + + } + +} // WindowUtils Deleted: mspsim/se/sics/mspsim/util/SerialMon.java =================================================================== --- mspsim/se/sics/mspsim/util/SerialMon.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/util/SerialMon.java 2008-01-24 13:40:29 UTC (rev 79) @@ -1,152 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: SerialMon.java,v 1.4 2007/10/21 22:19:07 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * SerialMon - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 22:19:07 $ - * $Revision: 1.4 $ - */ - -package se.sics.mspsim.util; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.SwingUtilities; - -import se.sics.mspsim.core.*; - -public class SerialMon implements KeyListener, USARTListener { - - private static final String PREFIX = " > "; - - private String name; - private JFrame window; - private USART usart; - private JTextArea textArea; - private JLabel statusLabel; - private String text = "*** Serial mon for ESB/MSPsim ***\n"; - - private int lines = 1; - private boolean isUpdatePending = false; - private StringBuilder keyBuffer = new StringBuilder(); - - public SerialMon(USART usart, String name) { - this.name = name; - this.usart = usart; - window = new JFrame(name); -// window.setBounds(100, 100, 400,340); - window.add(new JScrollPane(textArea = new JTextArea(20, 40), - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), - BorderLayout.CENTER); - textArea.setText(text); - textArea.setEditable(false); - statusLabel = new JLabel(PREFIX); - keyBuffer.append(PREFIX); - statusLabel.setOpaque(true); - statusLabel.setBackground(Color.lightGray); - window.add(statusLabel, BorderLayout.SOUTH); - String key = "usart." + name; - WindowUtils.restoreWindowBounds(key, window); - WindowUtils.addSaveOnShutdown(key, window); - window.setVisible(true); - - textArea.addKeyListener(this); - } - - public void saveWindowBounds() { - WindowUtils.saveWindowBounds("usart." + name, window); - } - - public void dataReceived(USART source, int data) { - if (data == '\n') { - if (lines >= 60) { - int index = text.indexOf('\n'); - text = text.substring(index + 1); - } else { - lines++; - } - } - text += (char)data; - - // Collapse several immediate updates - if (!isUpdatePending) { - isUpdatePending = true; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - isUpdatePending = false; - - final String newText = text; - textArea.setText(newText); - textArea.setCaretPosition(newText.length()); - textArea.repaint(); - } - }); - } - } - - - // ------------------------------------------------------------------- - // KeyListener - // ------------------------------------------------------------------- - - public void keyPressed(KeyEvent key) { - } - - public void keyReleased(KeyEvent key) { - } - - public void keyTyped(KeyEvent key) { - char c = key.getKeyChar(); - // Send it to the usart! - usart.byteReceived(c & 0xff); - - // Visualize the input - if (c == '\n') { - statusLabel.setText(PREFIX); - keyBuffer = new StringBuilder(); - keyBuffer.append(PREFIX); - } else { - keyBuffer.append(c); - statusLabel.setText(keyBuffer.toString()); - } - } - -} Deleted: mspsim/se/sics/mspsim/util/SourceViewer.java =================================================================== --- mspsim/se/sics/mspsim/util/SourceViewer.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/util/SourceViewer.java 2008-01-24 13:40:29 UTC (rev 79) @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * - * ----------------------------------------------------------------- - * - * Source Viewer - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 22:02:22 $ - * $Revision: 1.4 $ - */ - -package se.sics.mspsim.util; - - -public interface SourceViewer { - - public boolean isVisible(); - public void viewFile(String path, String file); - public void viewLine(int line); - -} Deleted: mspsim/se/sics/mspsim/util/WindowUtils.java =================================================================== --- mspsim/se/sics/mspsim/util/WindowUtils.java 2008-01-24 13:12:18 UTC (rev 78) +++ mspsim/se/sics/mspsim/util/WindowUtils.java 2008-01-24 13:40:29 UTC (rev 79) @@ -1,213 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: WindowUtils.java,v 1.2 2007/10/21 20:50:26 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * WindowUtils - * - * Author : Joakim Eriksson, Niclas Finne, Fredrik \xD6sterlind - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 20:50:26 $ - * $Revision: 1.2 $ - */ - -package se.sics.mspsim.util; -import java.awt.Window; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.prefs.Preferences; - -public class WindowUtils { - - private static Preferences prefs = - Preferences.userNodeForPackage(WindowUtils.class); - - private static Hashtable<Window,CloseListener> closeTable; - private static Hashtable<Window,String> exitTable; - - private WindowUtils() { - } - - public static void saveWindowBounds(String key, Window window) { - putWindowBounds(key, window); - try { - prefs.flush(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void putWindowBounds(String key, Window window) { - prefs.put("window." + key + ".bounds", getBounds(window)); - } - - public static void restoreWindowBounds(String key, Window window) { - setBounds(window, prefs.get("window." + key + ".bounds", null)); - } - - private static String getBounds(Window window) { - return "" + window.getX() - + ',' + window.getY() - + ',' + window.getWidth() - + ',' + window.getHeight(); - } - - private static void setBounds(Window window, String bounds) { - String[] b; - if ((bounds != null) - && ((b = bounds.split(",")) != null) - && b.length == 4) { - try { - window.setBounds(Integer.parseInt(b[0]), - Integer.parseInt(b[1]), - Integer.parseInt(b[2]), - Integer.parseInt(b[3])); - } catch (Exception e) { - e.printStackTrace(); - window.pack(); - } - } else { - window.pack(); - } - } - - public static void clearState() { - try { - prefs.clear(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public synchronized static void addSaveOnClose(String key, Window window) { - if (closeTable == null) { - closeTable = new Hashtable<Window,CloseListener>(); - } - if (closeTable.get(window) == null) { - CloseListener c = new CloseListener(key); - window.addWindowListener(c); - closeTable.put(window, c); - } - } - - public synchronized static void removeSaveOnClose(Window window) { - if (closeTable != null) { - CloseListener c = closeTable.remove(window); - if (c != null) { - window.removeWindowListener(c); - } - } - } - - public synchronized static void addSaveOnShutdown(String key, Window window) { - if (exitTable == null) { - exitTable = new Hashtable<Window,String>(); - Runtime.getRuntime().addShutdownHook(new ShutdownHandler()); - } - exitTable.put(window, key); - } - - public synchronized static void removeSaveOnShutdown(Window window) { - if (exitTable != null) { - exitTable.remove(window); - } - } - - - - // ------------------------------------------------------------------- - // Main - // ------------------------------------------------------------------- - - public static void main(String[] args) { - if (args.length != 1 || !args[0].equals("-clearState")) { - System.err.println("Usage: WindowUtils -clearState"); - System.exit(1); - } - clearState(); - } - - - // ------------------------------------------------------------------- - // CloseListener - // ------------------------------------------------------------------- - - private static class CloseListener extends WindowAdapter { - - private String key; - - public CloseListener(String key) { - this.key = key; - } - - public void windowClosing(WindowEvent e) { - Window source = (Window) e.getSource(); - saveWindowBounds(key, source); - source.removeWindowListener(this); - closeTable.remove(source); - } - - } - - - // ------------------------------------------------------------------- - // Shutdown handler - // ------------------------------------------------------------------- - - private static class ShutdownHandler extends Thread { - - public ShutdownHandler() { - super("WindowUtils-Shutdown"); - } - - public void run() { - Hashtable<Window,String> table = exitTable; - if (table != null && table.size() > 0) { - exitTable = null; - - Enumeration<Window> e = table.keys(); - while(e.hasMoreElements()) { - Window w = e.nextElement(); - putWindowBounds(table.get(w), w); - } - try { - prefs.flush(); - } catch (Exception e2) { - e2.printStackTrace(); - } - } - } - - } - -} // WindowUtils This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-24 13:15:20
|
Revision: 78 http://mspsim.svn.sourceforge.net/mspsim/?rev=78&view=rev Author: joxe Date: 2008-01-24 05:12:18 -0800 (Thu, 24 Jan 2008) Log Message: ----------- Moved UI related files into package ui. Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Added Paths: ----------- mspsim/se/sics/mspsim/ui/ mspsim/se/sics/mspsim/ui/ControlUI.java mspsim/se/sics/mspsim/ui/DebugUI.java Removed Paths: ------------- mspsim/se/sics/mspsim/util/ControlUI.java mspsim/se/sics/mspsim/util/DebugUI.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-01-14 14:06:28 UTC (rev 77) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-01-24 13:12:18 UTC (rev 78) @@ -43,6 +43,7 @@ import java.io.IOException; import se.sics.mspsim.core.*; +import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.util.*; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; public class ESBNode implements PortListener { Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-14 14:06:28 UTC (rev 77) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-24 13:12:18 UTC (rev 78) @@ -50,7 +50,7 @@ import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; -import se.sics.mspsim.util.ControlUI; +import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; Copied: mspsim/se/sics/mspsim/ui/ControlUI.java (from rev 76, mspsim/se/sics/mspsim/util/ControlUI.java) =================================================================== --- mspsim/se/sics/mspsim/ui/ControlUI.java (rev 0) +++ mspsim/se/sics/mspsim/ui/ControlUI.java 2008-01-24 13:12:18 UTC (rev 78) @@ -0,0 +1,222 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: ControlUI.java,v 1.4 2007/10/21 22:19:07 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * ControlUI + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 22:19:07 $ + * $Revision: 1.4 $ + */ + +package se.sics.mspsim.ui; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.KeyStroke; + +import se.sics.mspsim.core.*; +import se.sics.mspsim.util.DebugInfo; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.SourceViewer; +import se.sics.mspsim.util.StackUI; +import se.sics.mspsim.util.WindowUtils; + +public class ControlUI extends JPanel implements ActionListener { + + private static final String TITLE = "MSPSim monitor"; + + private JFrame window; + private MSP430 cpu; + private DebugUI dui; + private JFrame stackWindow; + private StackUI stackUI; + + private ELF elfData; + private SourceViewer sourceViewer; + + private Action stepAction; + + public ControlUI(MSP430 cpu) { + this(cpu, null); + } + + public ControlUI(MSP430 cpu, ELF elf) { + super(new GridLayout(0, 1)); + this.cpu = cpu; + + this.stackUI = new StackUI(cpu); + stackWindow = new JFrame("Stack"); + stackWindow.add(this.stackUI); + WindowUtils.restoreWindowBounds("StackUI", stackWindow); + WindowUtils.addSaveOnShutdown("StackUI", stackWindow); + stackWindow.setVisible(true); + + window = new JFrame(TITLE); +// window.setSize(320,240); + window.setLayout(new BorderLayout()); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + window.add(this, BorderLayout.WEST); + window.add(dui = new DebugUI(cpu), BorderLayout.CENTER); + + createButton("Debug On"); + createButton("Stop"); + stepAction = new AbstractAction("Single Step") { + public void actionPerformed(ActionEvent e) { + ControlUI.this.cpu.step(); + dui.updateRegs(); + dui.repaint(); + if (elfData != null && sourceViewer != null + && sourceViewer.isVisible()) { + int pc = ControlUI.this.cpu.readRegister(MSP430Constants.PC); + DebugInfo dbg = elfData.getDebugInfo(pc); + if (dbg != null) { + if (ControlUI.this.cpu.getDebug()) { + System.out.println("looking up $" + Integer.toString(pc, 16) + + " => " + dbg.getFile() + ':' + + dbg.getLine()); + } + sourceViewer.viewFile(dbg.getPath(), dbg.getFile()); + sourceViewer.viewLine(dbg.getLine()); + } + } + } + }; + stepAction.putValue(Action.MNEMONIC_KEY, + new Integer(KeyEvent.VK_S)); + stepAction.setEnabled(false); + + JButton stepButton = new JButton(stepAction); + add(stepButton); + createButton("Stack Trace"); + + if (elf != null) { + createButton("Show Source"); + } + createButton("Profile Dump"); + + // Setup standard actions + stepButton.getInputMap(WHEN_IN_FOCUSED_WINDOW) + .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), + "cpuStep"); + stepButton.getActionMap().put("cpuStep", stepAction); + + WindowUtils.restoreWindowBounds("ControlUI", window); + WindowUtils.addSaveOnShutdown("ControlUI", window); + window.setVisible(true); + elfData = elf; + } + + public void setSourceViewer(SourceViewer viewer) { + sourceViewer = viewer; + } + + + private JButton createButton(String text) { + JButton jb = new JButton(text); + jb.addActionListener(this); + add(jb); + return jb; + } + + private void updateCPUPercent() { + window.setTitle(TITLE + " CPU On: " + cpu.getCPUPercent() + "%"); + } + + public void actionPerformed(ActionEvent ae) { + String cmd = ae.getActionCommand(); + updateCPUPercent(); + if ("Debug On".equals(cmd)) { + cpu.setDebug(true); + ((JButton) ae.getSource()).setText("Debug Off"); + + } else if ("Debug Off".equals(cmd)) { + cpu.setDebug(false); + ((JButton) ae.getSource()).setText("Debug On"); + + } else if ("Run".equals(cmd)) { + new Thread(new Runnable() { + public void run() { + cpu.cpuloop(); + }}).start(); + ((JButton) ae.getSource()).setText("Stop"); + stepAction.setEnabled(false); + + } else if ("Stop".equals(cmd)) { + cpu.stop(); + ((JButton) ae.getSource()).setText("Run"); + stepAction.setEnabled(true); + + } else if ("Profile Dump".equals(cmd)) { + if (cpu.getProfiler() != null) { + cpu.getProfiler().printProfile(); + } else { + System.out.println("*** No profiler available"); + } + // } else if ("Single Step".equals(cmd)) { + // cpu.step(); +// dui.repaint(); + } else if ("Show Source".equals(cmd)) { + int pc = cpu.readRegister(cpu.PC); + if (elfData != null) { + DebugInfo dbg = elfData.getDebugInfo(pc); + if (dbg != null) { + if (cpu.getDebug()) { + System.out.println("looking up $" + Integer.toString(pc, 16) + + " => " + dbg.getFile() + ':' + dbg.getLine()); + } + if (sourceViewer != null) { + sourceViewer.viewFile(dbg.getPath(), dbg.getFile()); + sourceViewer.viewLine(dbg.getLine()); + } else { + System.out.println("File: " + dbg.getFile()); + System.out.println("LineNr: " + dbg.getLine()); + } + } + } + } else if ("Stack Trace".equals(cmd)) { + cpu.getProfiler().printStackTrace(); + } + dui.updateRegs(); + } + +} Copied: mspsim/se/sics/mspsim/ui/DebugUI.java (from rev 74, mspsim/se/sics/mspsim/util/DebugUI.java) =================================================================== --- mspsim/se/sics/mspsim/ui/DebugUI.java (rev 0) +++ mspsim/se/sics/mspsim/ui/DebugUI.java 2008-01-24 13:12:18 UTC (rev 78) @@ -0,0 +1,215 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: DebugUI.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * DebugUI + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.ui; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import javax.swing.AbstractListModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; + +import se.sics.mspsim.core.*; +import se.sics.mspsim.util.Utils; + +public class DebugUI extends JPanel { + + private JList disList; + private JLabel[] regsLabel; + private MSP430 cpu; + private DbgListModel listModel; + private int currentAddress = 0; + + private DisAsm disAsm; + + /** + * Creates a new <code>DebugUI</code> instance. + * + */ + public DebugUI(MSP430 cpu) { + this(cpu, true); + } + + public DebugUI(MSP430 cpu, boolean showRegs) { + super(new BorderLayout()); + this.cpu = cpu; + disAsm = cpu.getDisAsm(); + + disList = new JList(listModel = new DbgListModel()); + disList.setFont(new Font("courier", 0, 12)); + disList.setCellRenderer(new MyCellRenderer()); + add(disList, BorderLayout.CENTER); + + if (showRegs) { + JPanel regs = new JPanel(new GridLayout(2,8,4,0)); + regsLabel = new JLabel[16]; + for (int i = 0, n = 16; i < n; i++) { + regs.add(regsLabel[i] = new JLabel("$0000")); + } + add(regs, BorderLayout.SOUTH); + updateRegs(); + } + } + + public void updateRegs() { + if (regsLabel != null) { + for (int i = 0, n = 16; i < n; i++) { + regsLabel[i].setText("$" + Utils.hex16(cpu.reg[i])); + } + } + repaint(); + } + + private class DbgListModel extends AbstractListModel { + int startPos = -1; + int endPos = -1; + final int size = 21; + + DbgInstruction[] instructions = new DbgInstruction[size]; + + // 64K Dbg instructions... + private DbgInstruction[] instrs = new DbgInstruction[0x10000]; + + public void setCurrentAddress(int address) { + startPos = address; + } + + // ------------------------------------------------------------------- + // ListAPI + // ------------------------------------------------------------------- + + public int getSize() { + return size; + } + + private void checkPC() { + int pc = cpu.reg[cpu.PC]; + if (pc < startPos || pc > endPos) { + startPos = pc; + // recalulate index!!! with PC at the top of the "page" + int currentPos = pc; + DbgInstruction inst; + for (int i = 0, n = size; i < n; i++) { + if (cpu.getExecCount(currentPos) != 0 || true) { + inst = disAsm.getDbgInstruction(currentPos, cpu); + inst.setPos(currentPos); + currentPos += inst.getSize(); + } else { + inst = new DbgInstruction(); + inst.setASMLine(" " + Utils.hex16(currentPos) + " " + + Utils.hex8(cpu.memory[currentPos]) + " " + + Utils.hex8(cpu.memory[currentPos + 1]) + + " .word " + Utils.hex8(cpu.memory[currentPos]) + + Utils.hex8(cpu.memory[currentPos + 1])); + inst.setPos(currentPos); + currentPos += 2; + } + instructions[i] = inst; + } + endPos = currentPos; + } + } + + // Should cache the current 20 (or size) instructions to get a faster + // version of this... + // And have a call to "update" instead... + public Object getElementAt(int index) { + checkPC(); + return instructions[index]; + } + } + + class MyCellRenderer extends JLabel implements ListCellRenderer { + + public MyCellRenderer() { + setOpaque(true); + } + + public Component getListCellRendererComponent( + JList list, + Object value, // value to display + int index, // cell index + boolean isSelected, // is the cell selected + boolean cellHasFocus) // the list and the cell have the focus + { + String s; + int pos = 0; + if (value == null) { + s = "---"; + } else { + if (value instanceof DbgInstruction) { + DbgInstruction i = (DbgInstruction) value; + s = i.getASMLine(false); + if (i.getFunction() != null) { + s += "; " + i.getFunction(); + } + pos = i.getPos(); + if (cpu.hasBreakpoint(pos)) { + s = "*B " + s; + } else { + s = " " + s; + } + } else { + s = value.toString(); + } + } + setText(s); + if (pos == cpu.reg[cpu.PC]) { + setBackground(Color.green); + } else { + if (isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + } + setEnabled(list.isEnabled()); + setFont(list.getFont()); + return this; + } + } +} Deleted: mspsim/se/sics/mspsim/util/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/util/ControlUI.java 2008-01-14 14:06:28 UTC (rev 77) +++ mspsim/se/sics/mspsim/util/ControlUI.java 2008-01-24 13:12:18 UTC (rev 78) @@ -1,217 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: ControlUI.java,v 1.4 2007/10/21 22:19:07 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * ControlUI - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 22:19:07 $ - * $Revision: 1.4 $ - */ - -package se.sics.mspsim.util; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.KeyStroke; - -import se.sics.mspsim.core.*; - -public class ControlUI extends JPanel implements ActionListener { - - private static final String TITLE = "MSPSim monitor"; - - private JFrame window; - private MSP430 cpu; - private DebugUI dui; - private JFrame stackWindow; - private StackUI stackUI; - - private ELF elfData; - private SourceViewer sourceViewer; - - private Action stepAction; - - public ControlUI(MSP430 cpu) { - this(cpu, null); - } - - public ControlUI(MSP430 cpu, ELF elf) { - super(new GridLayout(0, 1)); - this.cpu = cpu; - - this.stackUI = new StackUI(cpu); - stackWindow = new JFrame("Stack"); - stackWindow.add(this.stackUI); - WindowUtils.restoreWindowBounds("StackUI", stackWindow); - WindowUtils.addSaveOnShutdown("StackUI", stackWindow); - stackWindow.setVisible(true); - - window = new JFrame(TITLE); -// window.setSize(320,240); - window.setLayout(new BorderLayout()); - window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - window.add(this, BorderLayout.WEST); - window.add(dui = new DebugUI(cpu), BorderLayout.CENTER); - - createButton("Debug On"); - createButton("Stop"); - stepAction = new AbstractAction("Single Step") { - public void actionPerformed(ActionEvent e) { - ControlUI.this.cpu.step(); - dui.updateRegs(); - dui.repaint(); - if (elfData != null && sourceViewer != null - && sourceViewer.isVisible()) { - int pc = ControlUI.this.cpu.readRegister(MSP430Constants.PC); - DebugInfo dbg = elfData.getDebugInfo(pc); - if (dbg != null) { - if (ControlUI.this.cpu.getDebug()) { - System.out.println("looking up $" + Integer.toString(pc, 16) + - " => " + dbg.getFile() + ':' + - dbg.getLine()); - } - sourceViewer.viewFile(dbg.getPath(), dbg.getFile()); - sourceViewer.viewLine(dbg.getLine()); - } - } - } - }; - stepAction.putValue(Action.MNEMONIC_KEY, - new Integer(KeyEvent.VK_S)); - stepAction.setEnabled(false); - - JButton stepButton = new JButton(stepAction); - add(stepButton); - createButton("Stack Trace"); - - if (elf != null) { - createButton("Show Source"); - } - createButton("Profile Dump"); - - // Setup standard actions - stepButton.getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), - "cpuStep"); - stepButton.getActionMap().put("cpuStep", stepAction); - - WindowUtils.restoreWindowBounds("ControlUI", window); - WindowUtils.addSaveOnShutdown("ControlUI", window); - window.setVisible(true); - elfData = elf; - } - - public void setSourceViewer(SourceViewer viewer) { - sourceViewer = viewer; - } - - - private JButton createButton(String text) { - JButton jb = new JButton(text); - jb.addActionListener(this); - add(jb); - return jb; - } - - private void updateCPUPercent() { - window.setTitle(TITLE + " CPU On: " + cpu.getCPUPercent() + "%"); - } - - public void actionPerformed(ActionEvent ae) { - String cmd = ae.getActionCommand(); - updateCPUPercent(); - if ("Debug On".equals(cmd)) { - cpu.setDebug(true); - ((JButton) ae.getSource()).setText("Debug Off"); - - } else if ("Debug Off".equals(cmd)) { - cpu.setDebug(false); - ((JButton) ae.getSource()).setText("Debug On"); - - } else if ("Run".equals(cmd)) { - new Thread(new Runnable() { - public void run() { - cpu.cpuloop(); - }}).start(); - ((JButton) ae.getSource()).setText("Stop"); - stepAction.setEnabled(false); - - } else if ("Stop".equals(cmd)) { - cpu.stop(); - ((JButton) ae.getSource()).setText("Run"); - stepAction.setEnabled(true); - - } else if ("Profile Dump".equals(cmd)) { - if (cpu.getProfiler() != null) { - cpu.getProfiler().printProfile(); - } else { - System.out.println("*** No profiler available"); - } - // } else if ("Single Step".equals(cmd)) { - // cpu.step(); -// dui.repaint(); - } else if ("Show Source".equals(cmd)) { - int pc = cpu.readRegister(cpu.PC); - if (elfData != null) { - DebugInfo dbg = elfData.getDebugInfo(pc); - if (dbg != null) { - if (cpu.getDebug()) { - System.out.println("looking up $" + Integer.toString(pc, 16) + - " => " + dbg.getFile() + ':' + dbg.getLine()); - } - if (sourceViewer != null) { - sourceViewer.viewFile(dbg.getPath(), dbg.getFile()); - sourceViewer.viewLine(dbg.getLine()); - } else { - System.out.println("File: " + dbg.getFile()); - System.out.println("LineNr: " + dbg.getLine()); - } - } - } - } else if ("Stack Trace".equals(cmd)) { - cpu.getProfiler().printStackTrace(); - } - dui.updateRegs(); - } - -} Deleted: mspsim/se/sics/mspsim/util/DebugUI.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugUI.java 2008-01-14 14:06:28 UTC (rev 77) +++ mspsim/se/sics/mspsim/util/DebugUI.java 2008-01-24 13:12:18 UTC (rev 78) @@ -1,214 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: DebugUI.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * DebugUI - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ - -package se.sics.mspsim.util; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.GridLayout; -import javax.swing.AbstractListModel; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.ListCellRenderer; - -import se.sics.mspsim.core.*; - -public class DebugUI extends JPanel { - - private JList disList; - private JLabel[] regsLabel; - private MSP430 cpu; - private DbgListModel listModel; - private int currentAddress = 0; - - private DisAsm disAsm; - - /** - * Creates a new <code>DebugUI</code> instance. - * - */ - public DebugUI(MSP430 cpu) { - this(cpu, true); - } - - public DebugUI(MSP430 cpu, boolean showRegs) { - super(new BorderLayout()); - this.cpu = cpu; - disAsm = cpu.getDisAsm(); - - disList = new JList(listModel = new DbgListModel()); - disList.setFont(new Font("courier", 0, 12)); - disList.setCellRenderer(new MyCellRenderer()); - add(disList, BorderLayout.CENTER); - - if (showRegs) { - JPanel regs = new JPanel(new GridLayout(2,8,4,0)); - regsLabel = new JLabel[16]; - for (int i = 0, n = 16; i < n; i++) { - regs.add(regsLabel[i] = new JLabel("$0000")); - } - add(regs, BorderLayout.SOUTH); - updateRegs(); - } - } - - public void updateRegs() { - if (regsLabel != null) { - for (int i = 0, n = 16; i < n; i++) { - regsLabel[i].setText("$" + Utils.hex16(cpu.reg[i])); - } - } - repaint(); - } - - private class DbgListModel extends AbstractListModel { - int startPos = -1; - int endPos = -1; - final int size = 21; - - DbgInstruction[] instructions = new DbgInstruction[size]; - - // 64K Dbg instructions... - private DbgInstruction[] instrs = new DbgInstruction[0x10000]; - - public void setCurrentAddress(int address) { - startPos = address; - } - - // ------------------------------------------------------------------- - // ListAPI - // ------------------------------------------------------------------- - - public int getSize() { - return size; - } - - private void checkPC() { - int pc = cpu.reg[cpu.PC]; - if (pc < startPos || pc > endPos) { - startPos = pc; - // recalulate index!!! with PC at the top of the "page" - int currentPos = pc; - DbgInstruction inst; - for (int i = 0, n = size; i < n; i++) { - if (cpu.getExecCount(currentPos) != 0 || true) { - inst = disAsm.getDbgInstruction(currentPos, cpu); - inst.setPos(currentPos); - currentPos += inst.getSize(); - } else { - inst = new DbgInstruction(); - inst.setASMLine(" " + Utils.hex16(currentPos) + " " + - Utils.hex8(cpu.memory[currentPos]) + " " + - Utils.hex8(cpu.memory[currentPos + 1]) + - " .word " + Utils.hex8(cpu.memory[currentPos]) + - Utils.hex8(cpu.memory[currentPos + 1])); - inst.setPos(currentPos); - currentPos += 2; - } - instructions[i] = inst; - } - endPos = currentPos; - } - } - - // Should cache the current 20 (or size) instructions to get a faster - // version of this... - // And have a call to "update" instead... - public Object getElementAt(int index) { - checkPC(); - return instructions[index]; - } - } - - class MyCellRenderer extends JLabel implements ListCellRenderer { - - public MyCellRenderer() { - setOpaque(true); - } - - public Component getListCellRendererComponent( - JList list, - Object value, // value to display - int index, // cell index - boolean isSelected, // is the cell selected - boolean cellHasFocus) // the list and the cell have the focus - { - String s; - int pos = 0; - if (value == null) { - s = "---"; - } else { - if (value instanceof DbgInstruction) { - DbgInstruction i = (DbgInstruction) value; - s = i.getASMLine(false); - if (i.getFunction() != null) { - s += "; " + i.getFunction(); - } - pos = i.getPos(); - if (cpu.hasBreakpoint(pos)) { - s = "*B " + s; - } else { - s = " " + s; - } - } else { - s = value.toString(); - } - } - setText(s); - if (pos == cpu.reg[cpu.PC]) { - setBackground(Color.green); - } else { - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - } - setEnabled(list.isEnabled()); - setFont(list.getFont()); - return this; - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-14 15:03:07
|
Revision: 76 http://mspsim.svn.sourceforge.net/mspsim/?rev=76&view=rev Author: joxe Date: 2008-01-14 05:51:08 -0800 (Mon, 14 Jan 2008) Log Message: ----------- Added MapTable/MapEntry for better symbol information and changed profile API to use MapEntry instead of function names Modified Paths: -------------- mspsim/se/sics/mspsim/core/DisAsm.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/Profiler.java mspsim/se/sics/mspsim/util/ControlUI.java mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Added Paths: ----------- mspsim/se/sics/mspsim/util/MapEntry.java mspsim/se/sics/mspsim/util/MapTable.java Modified: mspsim/se/sics/mspsim/core/DisAsm.java =================================================================== --- mspsim/se/sics/mspsim/core/DisAsm.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/core/DisAsm.java 2008-01-14 13:51:08 UTC (rev 76) @@ -43,6 +43,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; +import se.sics.mspsim.util.MapTable; import se.sics.mspsim.util.Utils; public class DisAsm implements MSP430Constants { @@ -388,7 +389,7 @@ dbg.setRegs(regs); dbg.setInstruction(instruction, size); if (map != null) { - dbg.setFunction(map.getFunction(startPC)); + dbg.setFunction(map.getFunctionName(startPC)); } if (!step) { Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-01-14 13:51:08 UTC (rev 76) @@ -120,9 +120,9 @@ if (profiler != null) { if ((instruction & 0xff80) == CALL) { /* The profiling should only be made on actual cpuCycles */ - String function = map.getFunction(reg[PC]); + MapEntry function = map.getEntry(reg[PC]); if (function == null) { - function = "fkn at $" + Utils.hex16(reg[PC]); + function = getFunction(map, reg[PC]); } profiler.profileCall(function, cpuCycles); } else if (instruction == RETURN) { @@ -181,9 +181,9 @@ if (profiler != null) { if ((instruction & 0xff80) == CALL) { /* The profiling should only be made on actual cpuCycles */ - String function = map.getFunction(reg[PC]); + MapEntry function = map.getEntry(reg[PC]); if (function == null) { - function = "fkn at $" + Utils.hex16(reg[PC]); + function = getFunction(map, reg[PC]); } profiler.profileCall(function, cpuCycles); } else if (instruction == RETURN) { @@ -193,8 +193,15 @@ } return cycles; +} + + private MapEntry getFunction(MapTable map, int address) { + MapEntry function = new MapEntry(MapEntry.TYPE.function, address, + "fkn at $" + Utils.hex16(address), null, true); + map.setEntry(function); + return function; } - + public void stop() { running = false; } Modified: mspsim/se/sics/mspsim/core/Profiler.java =================================================================== --- mspsim/se/sics/mspsim/core/Profiler.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/core/Profiler.java 2008-01-14 13:51:08 UTC (rev 76) @@ -40,18 +40,19 @@ */ package se.sics.mspsim.core; -import java.util.Arrays; -import java.util.Hashtable; +import se.sics.mspsim.util.MapEntry; -import se.sics.mspsim.util.Utils; - public interface Profiler { - public void profileCall(String function, long cycles); + public void setCPU(MSP430Core cpu); + + public void profileCall(MapEntry entry, long cycles); public void profileReturn(long cycles); public void clearProfile(); public void printProfile(); + public void printStackTrace(); + } Modified: mspsim/se/sics/mspsim/util/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/util/ControlUI.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/util/ControlUI.java 2008-01-14 13:51:08 UTC (rev 76) @@ -95,7 +95,6 @@ createButton("Debug On"); createButton("Stop"); - stepAction = new AbstractAction("Single Step") { public void actionPerformed(ActionEvent e) { ControlUI.this.cpu.step(); @@ -123,6 +122,7 @@ JButton stepButton = new JButton(stepAction); add(stepButton); + createButton("Stack Trace"); if (elf != null) { createButton("Show Source"); @@ -208,6 +208,8 @@ } } } + } else if ("Stack Trace".equals(cmd)) { + cpu.getProfiler().printStackTrace(); } dui.updateRegs(); } Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-01-14 13:51:08 UTC (rev 76) @@ -309,16 +309,17 @@ if (sAddr > 0 && sAddr < 0x10000) { String symbolName = sn; - if (bind == ELFSection.SYMBIND_LOCAL) { - symbolName += " (" + currentFile + ')'; - } +// if (bind == ELFSection.SYMBIND_LOCAL) { +// symbolName += " (" + currentFile + ')'; +// } if ("_end".equals(symbolName)) { map.setHeapStart(sAddr); } else if ("__stack".equals(symbolName)){ map.setStackStart(sAddr); } - map.setFunctionName(sAddr, symbolName); + map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, currentFile, + bind == ELFSection.SYMBIND_LOCAL)); } addr += symTable.entSize; } Added: mspsim/se/sics/mspsim/util/MapEntry.java =================================================================== --- mspsim/se/sics/mspsim/util/MapEntry.java (rev 0) +++ mspsim/se/sics/mspsim/util/MapEntry.java 2008-01-14 13:51:08 UTC (rev 76) @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id $ + * + * ----------------------------------------------------------------- + * + * MapEntry + * + * Author : Joakim Eriksson + * Created : Jan 14 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; + +public class MapEntry { + + public static enum TYPE {function, variable} + + private TYPE type; + private int address; + private String name; + private String file; + private boolean isLocal; + + public MapEntry(TYPE type, int address, String name, String file, boolean isLocal) { + this.type = type; + this.address = address; + this.name = name; + this.file = file; + this.isLocal = isLocal; + } + + public TYPE getType() { + return type; + } + + public int getAddress() { + return address; + } + + public String getName() { + return name; + } + + public String getFile() { + return file; + } + + public boolean isLocal() { + return isLocal; + } + + public String getInfo() { + StringBuilder sb = new StringBuilder(); + sb.append(name); + if (file != null) { + sb.append(" ("); + if (isLocal) sb.append("local in "); + sb.append(file).append(')'); + } else if (isLocal) { + sb.append(" (local)"); + } + return sb.toString(); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('$').append(Utils.hex16(address)).append(' ').append(type).append(' ').append(name); + if (file != null) { + sb.append(" ("); + if (isLocal) sb.append("local in "); + sb.append(file).append(')'); + } else if (isLocal) { + sb.append(" (local)"); + } + return sb.toString(); + } +} Property changes on: mspsim/se/sics/mspsim/util/MapEntry.java ___________________________________________________________________ Name: svn:executable + * Added: mspsim/se/sics/mspsim/util/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/util/MapTable.java (rev 0) +++ mspsim/se/sics/mspsim/util/MapTable.java 2008-01-14 13:51:08 UTC (rev 76) @@ -0,0 +1,174 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: MapTable.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * MapTable + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + + +/** + * The map reader reads the map file with memory map and + * other information about the binary/firmware to load into the + * node. + * + * Format of the map file must be: + * .text WS Adress WS Size WS file + * WS Adress WS function_name + * WS Adress WS function_name + * ... + */ +public class MapTable { + + private enum Mode {NONE,CODE,DATA,BSS}; + private Mode mode; + + public int heapStartAddress = -1; + public int stackStartAddress = -1; + + private MapEntry[] entries; + + public MapTable() { + } + + public MapTable(String file) throws IOException { + loadMap(file); + } + + /** + * <code>parseMapLine</code> + * parses a line of a map file! + * @param line a <code>String</code> value + */ + public void parseMapLine(String line) { + String parts[] = line.split("\\s+"); + if (line.startsWith(".text")) { + mode = Mode.CODE; + System.out.println("CODE Mode"); + } else if (line.startsWith(".bss")) { + mode = Mode.BSS; + System.out.println("BSS Mode!"); + } else if (line.startsWith(".data")) { + mode = Mode.DATA; + System.out.println("Data Mode!"); + } else if (line.startsWith(" .text")) { + if (parts.length > 3) { + // System.out.println("Code " + parts[2] + " Name:" + parts[4]); + } + } else if (mode == Mode.CODE && line.startsWith(" ")) { + if (parts.length > 2) { + // Scrap 0x and parse as hex! + int val = Integer.parseInt(parts[1].substring(2), 16); + System.out.println("Function: " + parts[2] + " at " + + Utils.hex16(val)); + // Add the file part later some time... + // After the demo... + setEntry(new MapEntry(MapEntry.TYPE.function, val, parts[2], null, false)); + } + + } else if (line.contains(" _end = .") && parts.length > 2) { + heapStartAddress = Integer.parseInt(parts[1].substring(2), 16); + + } else if (line.contains("PROVIDE (__stack") && parts.length > 2) { + stackStartAddress = Integer.parseInt(parts[1].substring(2), 16); + } + } + + public void loadMap(String file) throws IOException { + FileInputStream fInput = new FileInputStream(file); + BufferedReader bInput = new BufferedReader(new InputStreamReader(fInput)); + String line; + while ((line = bInput.readLine()) != null) { + parseMapLine(line); + } + bInput.close(); + fInput.close(); + } + + public String getFunctionName(int address) { + if (entries != null && entries[address] != null) { + return entries[address].getName(); + } else { + return null; + } + } + + public MapEntry getEntry(int address) { + if (entries != null) + return entries[address]; + return null; + } + + // Should be any symbol... not just function... + public void setFunctionName(int address, String name) { + setEntry(new MapEntry(MapEntry.TYPE.function, address, name, null, false)); + } + + public void setEntry(MapEntry entry) { + if (entries == null) + entries = new MapEntry[0x10000]; + entries[entry.getAddress()] = entry; + } + + // Really slow way to find a specific function address!!!! + // Either reimplement this or cache in hashtable... + public int getFunctionAddress(String function) { + for (int i = 0, n = entries.length; i < n; i++) { + if (function.equals(entries[i])) { + return i; + } + } + return -1; + } + + public void setStackStart(int start) { + stackStartAddress = start; + } + + public void setHeapStart(int start) { + heapStartAddress = start; + } + + public static void main(String[] args) throws IOException { + new MapTable(args[0]); + } +} Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2008-01-14 13:41:29 UTC (rev 75) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2008-01-14 13:51:08 UTC (rev 76) @@ -40,6 +40,7 @@ */ package se.sics.mspsim.util; +import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.Profiler; import java.util.Arrays; import java.util.Hashtable; @@ -47,27 +48,32 @@ public class SimpleProfiler implements Profiler { - private Hashtable<String,CallEntry> profileData; + private Hashtable<MapEntry,CallEntry> profileData; private CallEntry[] callStack; private int cSP = 0; + private MSP430Core cpu; public SimpleProfiler() { - profileData = new Hashtable<String,CallEntry>(); + profileData = new Hashtable<MapEntry, CallEntry>(); callStack = new CallEntry[2048]; } - public void profileCall(String function, long cycles) { -// System.out.println("Call at: " + Utils.hex16(reg[PC])); + public void setCPU(MSP430Core cpu) { + this.cpu = cpu; + } + + public void profileCall(MapEntry entry, long cycles) { +// System.out.println("Call at: " + Utils.hex16(reg[PC])); if (callStack[cSP] == null) { callStack[cSP] = new CallEntry(); } - callStack[cSP].function = function; + callStack[cSP].function = entry; callStack[cSP].calls = 0; callStack[cSP++].cycles = cycles; } public void profileReturn(long cycles) { - String fkn = callStack[--cSP].function; + MapEntry fkn = callStack[--cSP].function; // System.out.println("Profiler: return / call stack: " + cSP + ", " + fkn); long elapsed = cycles - callStack[cSP].cycles; @@ -114,8 +120,8 @@ String cyclesS = "" + entries[i].cycles; String callS = "" + c; String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); - System.out.print(entries[i].function); - printSpace(56 - entries[i].function.length() - avgS.length()); + System.out.print(entries[i].function.getName()); + printSpace(56 - entries[i].function.getName().length() - avgS.length()); System.out.print(avgS); System.out.print(' '); printSpace(8 - callS.length()); @@ -133,17 +139,22 @@ } } - private static class CallEntry implements Comparable { - String function; + public void printStackTrace() { + System.out.println("Stack Trace: number of calls: " + cSP); + for (int i = 0; i < cSP; i++) { + System.out.println(" " + callStack[cSP - i - 1].function.getInfo()); + } + } + + private static class CallEntry implements Comparable<CallEntry> { + MapEntry function; long cycles; int calls; - public int compareTo(Object o) { - if (o instanceof CallEntry) { - long diff = ((CallEntry)o).cycles - cycles; - if (diff > 0) return 1; - if (diff < 0) return -1; - } + public int compareTo(CallEntry o) { + long diff = o.cycles - cycles; + if (diff > 0) return 1; + if (diff < 0) return -1; return 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-01-14 15:02:43
|
Revision: 75 http://mspsim.svn.sourceforge.net/mspsim/?rev=75&view=rev Author: joxe Date: 2008-01-14 05:41:29 -0800 (Mon, 14 Jan 2008) Log Message: ----------- minor cleanup Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-12-10 15:34:32 UTC (rev 74) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-01-14 13:41:29 UTC (rev 75) @@ -43,10 +43,17 @@ import java.io.IOException; import se.sics.mspsim.chip.CC2420; -import se.sics.mspsim.core.*; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.IOUnit; +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.core.PortListener; +import se.sics.mspsim.core.USART; +import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; -import se.sics.mspsim.util.*; -import java.io.File; +import se.sics.mspsim.util.ControlUI; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.IHexReader; +import se.sics.mspsim.util.MapTable; /** * Emulation of Sky Mote @@ -129,16 +136,15 @@ public boolean getDebug() { return cpu.getDebug(); } + public void setDebug(boolean debug) { cpu.setDebug(debug); } - public MSP430 getCPU() { return cpu; } - public void portWrite(IOPort source, int data) { if (source == port5) { redLed = (data & RED_LED) == 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-01-14 15:00:21
|
Revision: 77 http://mspsim.svn.sourceforge.net/mspsim/?rev=77&view=rev Author: nifi Date: 2008-01-14 06:06:28 -0800 (Mon, 14 Jan 2008) Log Message: ----------- removed due to new MapTable for MapEntries Removed Paths: ------------- mspsim/se/sics/mspsim/core/MapTable.java Deleted: mspsim/se/sics/mspsim/core/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/core/MapTable.java 2008-01-14 13:51:08 UTC (rev 76) +++ mspsim/se/sics/mspsim/core/MapTable.java 2008-01-14 14:06:28 UTC (rev 77) @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: MapTable.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * MapTable - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ - -package se.sics.mspsim.core; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; - -import se.sics.mspsim.util.Utils; - -/** - * The map reader reads the map file with memory map and - * other information about the binary/firmware to load into the - * node. - * - * Format of the map file must be: - * .text WS Adress WS Size WS file - * WS Adress WS function_name - * WS Adress WS function_name - * ... - */ -public class MapTable { - - private enum Mode {NONE,CODE,DATA,BSS}; - private Mode mode; - - public String[] functionNames; - - public int heapStartAddress = -1; - public int stackStartAddress = -1; - - public MapTable() { - } - - public MapTable(String file) throws IOException { - loadMap(file); - } - - /** - * <code>parseMapLine</code> - * parses a line of a map file! - * @param line a <code>String</code> value - */ - public void parseMapLine(String line) { - String parts[] = line.split("\\s+"); - if (line.startsWith(".text")) { - mode = Mode.CODE; - System.out.println("CODE Mode"); - } else if (line.startsWith(".bss")) { - mode = Mode.BSS; - System.out.println("BSS Mode!"); - } else if (line.startsWith(".data")) { - mode = Mode.DATA; - System.out.println("Data Mode!"); - } else if (line.startsWith(" .text")) { - if (parts.length > 3) { - // System.out.println("Code " + parts[2] + " Name:" + parts[4]); - } - } else if (mode == Mode.CODE && line.startsWith(" ")) { - if (parts.length > 2) { - // Scrap 0x and parse as hex! - int val = Integer.parseInt(parts[1].substring(2), 16); - System.out.println("Function: " + parts[2] + " at " + - Utils.hex16(val)); - // Add the file part later some time... - // After the demo... - functionNames[val] = parts[2]; // + " " + currentFile; - } - - } else if (line.contains(" _end = .") && parts.length > 2) { - heapStartAddress = Integer.parseInt(parts[1].substring(2), 16); - - } else if (line.contains("PROVIDE (__stack") && parts.length > 2) { - stackStartAddress = Integer.parseInt(parts[1].substring(2), 16); - } - } - - public void loadMap(String file) throws IOException { - FileInputStream fInput = new FileInputStream(file); - BufferedReader bInput = new BufferedReader(new InputStreamReader(fInput)); - String line; - // Allocate stringpointers... -- should it be like this??? - functionNames = new String[0x10000]; - while ((line = bInput.readLine()) != null) { - parseMapLine(line); - } - bInput.close(); - fInput.close(); - } - - // For fast access??? - public String[] getFunctionArray() { - return functionNames; - } - - public String getFunction(int address) { - if (functionNames[address] != null) { - return functionNames[address]; - } else { - return null; - } - } - - // Should be any symbol... not just function... - public void setFunctionName(int address, String name) { - if (functionNames == null) - functionNames = new String[0x10000]; - functionNames[address] = name; - } - - // Really slow way to find a specific function address!!!! - // Either reimplement this or cache in hashtable... - public int getFunctionAddress(String function) { - for (int i = 0, n = functionNames.length; i < n; i++) { - if (function.equals(functionNames[i])) { - return i; - } - } - return -1; - } - - public void setStackStart(int start) { - stackStartAddress = start; - } - - public void setHeapStart(int start) { - heapStartAddress = start; - } - - public static void main(String[] args) throws IOException { - new MapTable(args[0]); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-12-10 15:34:34
|
Revision: 74 http://mspsim.svn.sourceforge.net/mspsim/?rev=74&view=rev Author: nifi Date: 2007-12-10 07:34:32 -0800 (Mon, 10 Dec 2007) Log Message: ----------- set stack start address and heap start address Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2007-12-10 15:33:57 UTC (rev 73) +++ mspsim/se/sics/mspsim/util/ELF.java 2007-12-10 15:34:32 UTC (rev 74) @@ -306,11 +306,18 @@ System.out.println("Found symbol: " + sn + " at " + Integer.toString(sAddr, 16) + " bind: " + bind + " type: " + type + " size: " + size); + if (sAddr > 0 && sAddr < 0x10000) { String symbolName = sn; if (bind == ELFSection.SYMBIND_LOCAL) { symbolName += " (" + currentFile + ')'; } + if ("_end".equals(symbolName)) { + map.setHeapStart(sAddr); + } else if ("__stack".equals(symbolName)){ + map.setStackStart(sAddr); + } + map.setFunctionName(sAddr, symbolName); } addr += symTable.entSize; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-12-10 15:33:59
|
Revision: 73 http://mspsim.svn.sourceforge.net/mspsim/?rev=73&view=rev Author: nifi Date: 2007-12-10 07:33:57 -0800 (Mon, 10 Dec 2007) Log Message: ----------- added setStackStart()/setHeapStart() Modified Paths: -------------- mspsim/se/sics/mspsim/core/MapTable.java Modified: mspsim/se/sics/mspsim/core/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/core/MapTable.java 2007-12-10 12:27:23 UTC (rev 72) +++ mspsim/se/sics/mspsim/core/MapTable.java 2007-12-10 15:33:57 UTC (rev 73) @@ -158,6 +158,14 @@ return -1; } + public void setStackStart(int start) { + stackStartAddress = start; + } + + public void setHeapStart(int start) { + heapStartAddress = start; + } + public static void main(String[] args) throws IOException { new MapTable(args[0]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-10 12:27:24
|
Revision: 72 http://mspsim.svn.sourceforge.net/mspsim/?rev=72&view=rev Author: joxe Date: 2007-12-10 04:27:23 -0800 (Mon, 10 Dec 2007) Log Message: ----------- fixed esb to also show source Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBNode.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2007-12-10 10:37:24 UTC (rev 71) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2007-12-10 12:27:23 UTC (rev 72) @@ -44,7 +44,7 @@ import se.sics.mspsim.core.*; import se.sics.mspsim.util.*; - +import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; public class ESBNode implements PortListener { public static final boolean DEBUG = false; @@ -137,7 +137,7 @@ final MSP430 cpu = new MSP430(0); // Monitor execution cpu.setMonitorExec(true); - + ELF elf = null; int[] memory = cpu.getMemory(); if (args[0].endsWith("ihex")) { @@ -145,7 +145,7 @@ IHexReader reader = new IHexReader(); reader.readFile(memory, args[0]); } else { - ELF elf = ELF.readELF(args[0]); + elf = ELF.readELF(args[0]); elf.loadPrograms(memory); MapTable map = elf.getMap(); cpu.getDisAsm().setMap(map); @@ -155,7 +155,9 @@ cpu.reset(); ESBNode node = new ESBNode(cpu); node.gui = new ESBGui(node); - ControlUI control = new ControlUI(cpu); + ControlUI control = new ControlUI(cpu, elf); + HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); + control.setSourceViewer(sourceViewer); if (args.length > 1) { MapTable map = new MapTable(args[1]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-10 10:45:34
|
Revision: 71 http://mspsim.svn.sourceforge.net/mspsim/?rev=71&view=rev Author: joxe Date: 2007-12-10 02:37:24 -0800 (Mon, 10 Dec 2007) Log Message: ----------- updated esb image Modified Paths: -------------- mspsim/images/esb.jpg Modified: mspsim/images/esb.jpg =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-12-10 10:17:06
|
Revision: 70 http://mspsim.svn.sourceforge.net/mspsim/?rev=70&view=rev Author: nifi Date: 2007-12-10 02:16:51 -0800 (Mon, 10 Dec 2007) Log Message: ----------- bug fix Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-12-07 10:24:30 UTC (rev 69) +++ mspsim/Makefile 2007-12-10 10:16:51 UTC (rev 70) @@ -56,8 +56,8 @@ ESBFIRMWARE = firmware/esb/sensor-demo.firmware SKYFIRMWARE = firmware/sky/blink.firmware else -ESBFIRMWARE = $FIRMWAREFILE -SKYFIRMWARE = $FIRMWAREFILE +ESBFIRMWARE = ${FIRMWAREFILE} +SKYFIRMWARE = ${FIRMWAREFILE} endif CPUTEST := tests/cputest.firmware This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-07 10:24:43
|
Revision: 69 http://mspsim.svn.sourceforge.net/mspsim/?rev=69&view=rev Author: joxe Date: 2007-12-07 02:24:30 -0800 (Fri, 07 Dec 2007) Log Message: ----------- minor fixe to DebugUI - register update while single stepping Modified Paths: -------------- mspsim/se/sics/mspsim/util/ControlUI.java mspsim/se/sics/mspsim/util/DebugUI.java Modified: mspsim/se/sics/mspsim/util/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/util/ControlUI.java 2007-12-07 10:16:32 UTC (rev 68) +++ mspsim/se/sics/mspsim/util/ControlUI.java 2007-12-07 10:24:30 UTC (rev 69) @@ -99,6 +99,7 @@ stepAction = new AbstractAction("Single Step") { public void actionPerformed(ActionEvent e) { ControlUI.this.cpu.step(); + dui.updateRegs(); dui.repaint(); if (elfData != null && sourceViewer != null && sourceViewer.isVisible()) { Modified: mspsim/se/sics/mspsim/util/DebugUI.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugUI.java 2007-12-07 10:16:32 UTC (rev 68) +++ mspsim/se/sics/mspsim/util/DebugUI.java 2007-12-07 10:24:30 UTC (rev 69) @@ -98,6 +98,7 @@ regsLabel[i].setText("$" + Utils.hex16(cpu.reg[i])); } } + repaint(); } private class DbgListModel extends AbstractListModel { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-07 10:16:35
|
Revision: 68 http://mspsim.svn.sourceforge.net/mspsim/?rev=68&view=rev Author: joxe Date: 2007-12-07 02:16:32 -0800 (Fri, 07 Dec 2007) Log Message: ----------- Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-12-07 10:15:39 UTC (rev 67) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-12-07 10:16:32 UTC (rev 68) @@ -191,7 +191,6 @@ node.gui = new SkyGui(node); ControlUI control = new ControlUI(cpu, elf); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); - sourceViewer.addSearchPath(new File("e:/work/contiki-2.x/examples/sky/")); control.setSourceViewer(sourceViewer); if (args.length > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-07 10:15:43
|
Revision: 67 http://mspsim.svn.sourceforge.net/mspsim/?rev=67&view=rev Author: joxe Date: 2007-12-07 02:15:39 -0800 (Fri, 07 Dec 2007) Log Message: ----------- added changelog Modified Paths: -------------- mspsim/Makefile mspsim/se/sics/mspsim/platform/sky/SkyNode.java Added Paths: ----------- mspsim/CHANGE_LOG.txt Added: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt (rev 0) +++ mspsim/CHANGE_LOG.txt 2007-12-07 10:15:39 UTC (rev 67) @@ -0,0 +1,12 @@ + +0.81 - ELF Stabs, source debugging (2007-12-07) +Changes: +- support for ELF debug information (stab section) +- possible to convert address into linenumber and file +- simple source-level viewer that shows current execution position + (and updates during single stepping) - with highlighting for C. +- support for LPM/CPUOFF which stops instruction emulation when in + LPM modes +- refactored profiling into separate classes + +0.8 - Initial release (2007-11-26) Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-12-07 08:56:27 UTC (rev 66) +++ mspsim/Makefile 2007-12-07 10:15:39 UTC (rev 67) @@ -62,7 +62,7 @@ CPUTEST := tests/cputest.firmware -BINARY := README.txt license.txt images/*.jpg firmware/*/*.firmware +BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util chip extutil/highlight} Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-12-07 08:56:27 UTC (rev 66) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-12-07 10:15:39 UTC (rev 67) @@ -46,6 +46,7 @@ import se.sics.mspsim.core.*; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; import se.sics.mspsim.util.*; +import java.io.File; /** * Emulation of Sky Mote @@ -190,6 +191,7 @@ node.gui = new SkyGui(node); ControlUI control = new ControlUI(cpu, elf); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); + sourceViewer.addSearchPath(new File("e:/work/contiki-2.x/examples/sky/")); control.setSourceViewer(sourceViewer); if (args.length > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-07 08:56:28
|
Revision: 66 http://mspsim.svn.sourceforge.net/mspsim/?rev=66&view=rev Author: joxe Date: 2007-12-07 00:56:27 -0800 (Fri, 07 Dec 2007) Log Message: ----------- fixed comment colors Modified Paths: -------------- mspsim/se/sics/mspsim/extutil/highlight/SyntaxHighlighter.java Modified: mspsim/se/sics/mspsim/extutil/highlight/SyntaxHighlighter.java =================================================================== --- mspsim/se/sics/mspsim/extutil/highlight/SyntaxHighlighter.java 2007-12-06 23:42:32 UTC (rev 65) +++ mspsim/se/sics/mspsim/extutil/highlight/SyntaxHighlighter.java 2007-12-07 08:56:27 UTC (rev 66) @@ -121,7 +121,7 @@ changeStyle(WORD, Color.black); changeStyle(NUMBER, Color.black); changeStyle(PUNCTUATION, Color.blue); - changeStyle(COMMENT, Color.red, Font.ITALIC); + changeStyle(COMMENT, new Color(178,34,34), Font.ITALIC); changeStyle(START_COMMENT, new Color(178,34,34), Font.ITALIC); changeStyle(MID_COMMENT, new Color(178,34,34), Font.ITALIC); changeStyle(END_COMMENT, new Color(178,34,34), Font.ITALIC); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-06 23:42:35
|
Revision: 65 http://mspsim.svn.sourceforge.net/mspsim/?rev=65&view=rev Author: joxe Date: 2007-12-06 15:42:32 -0800 (Thu, 06 Dec 2007) Log Message: ----------- added profiling while single-stepping Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-12-06 23:35:08 UTC (rev 64) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-12-06 23:42:32 UTC (rev 65) @@ -164,16 +164,32 @@ int ctr = 0; - while (!emulateOP() && ctr++ < 10000) { + boolean emuOP = false; + while (!(emuOP = emulateOP()) && ctr++ < 10000) { /* Stuck in LPM - hopefully not more than 10000 times*/ } - if ((instCtr % 10000007) == 0 && !debug) { - printCPUSpeed(reg[PC]); - } + if (emuOP) { + if ((instCtr % 10000007) == 0 && !debug) { + printCPUSpeed(reg[PC]); + } - if (execCounter != null) { - execCounter[reg[PC]]++; + if (execCounter != null) { + execCounter[reg[PC]]++; + } + + if (profiler != null) { + if ((instruction & 0xff80) == CALL) { + /* The profiling should only be made on actual cpuCycles */ + String function = map.getFunction(reg[PC]); + if (function == null) { + function = "fkn at $" + Utils.hex16(reg[PC]); + } + profiler.profileCall(function, cpuCycles); + } else if (instruction == RETURN) { + profiler.profileReturn(cpuCycles); + } + } } return cycles; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-12-06 23:35:13
|
Revision: 64 http://mspsim.svn.sourceforge.net/mspsim/?rev=64&view=rev Author: nifi Date: 2007-12-06 15:35:08 -0800 (Thu, 06 Dec 2007) Log Message: ----------- made debug output depend on DEBUG flag Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELFDebug.java Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2007-12-06 23:28:32 UTC (rev 63) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2007-12-06 23:35:08 UTC (rev 64) @@ -106,9 +106,11 @@ } } else { /* requires sorted order of all file entries in stab section */ - System.out.println("FILE: Already passed address..." + - currentPath + " " + - currentFile + " " + currentFunction); + if (DEBUG) { + System.out.println("FILE: Already passed address..." + + currentPath + " " + + currentFile + " " + currentFunction); + } return null; } break; @@ -135,7 +137,9 @@ currentFunction = stab.data; lastAddress = stab.value; } else { - System.out.println("FUN: Already passed address..."); + if (DEBUG) { + System.out.println("FUN: Already passed address..."); + } return null; } break; @@ -144,7 +148,7 @@ return null; } - private class Stab { + private static class Stab { String data; int type; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-12-06 23:28:36
|
Revision: 63 http://mspsim.svn.sourceforge.net/mspsim/?rev=63&view=rev Author: nifi Date: 2007-12-06 15:28:32 -0800 (Thu, 06 Dec 2007) Log Message: ----------- added isVisible Modified Paths: -------------- mspsim/se/sics/mspsim/util/SourceViewer.java Modified: mspsim/se/sics/mspsim/util/SourceViewer.java =================================================================== --- mspsim/se/sics/mspsim/util/SourceViewer.java 2007-12-06 23:25:03 UTC (rev 62) +++ mspsim/se/sics/mspsim/util/SourceViewer.java 2007-12-06 23:28:32 UTC (rev 63) @@ -43,6 +43,7 @@ public interface SourceViewer { + public boolean isVisible(); public void viewFile(String path, String file); public void viewLine(int line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-06 23:25:10
|
Revision: 62 http://mspsim.svn.sourceforge.net/mspsim/?rev=62&view=rev Author: joxe Date: 2007-12-06 15:25:03 -0800 (Thu, 06 Dec 2007) Log Message: ----------- fixed single stepping and assembly output Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/util/DebugUI.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-12-06 23:20:49 UTC (rev 61) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-12-06 23:25:03 UTC (rev 62) @@ -162,7 +162,12 @@ } } - instCtr++; + + int ctr = 0; + while (!emulateOP() && ctr++ < 10000) { + /* Stuck in LPM - hopefully not more than 10000 times*/ + } + if ((instCtr % 10000007) == 0 && !debug) { printCPUSpeed(reg[PC]); } @@ -171,7 +176,6 @@ execCounter[reg[PC]]++; } - emulateOP(); return cycles; } Modified: mspsim/se/sics/mspsim/util/DebugUI.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugUI.java 2007-12-06 23:20:49 UTC (rev 61) +++ mspsim/se/sics/mspsim/util/DebugUI.java 2007-12-06 23:25:03 UTC (rev 62) @@ -130,7 +130,7 @@ int currentPos = pc; DbgInstruction inst; for (int i = 0, n = size; i < n; i++) { - if (cpu.getExecCount(currentPos) != 0) { + if (cpu.getExecCount(currentPos) != 0 || true) { inst = disAsm.getDbgInstruction(currentPos, cpu); inst.setPos(currentPos); currentPos += inst.getSize(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |