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: <ni...@us...> - 2010-09-23 09:13:10
|
Revision: 762 http://mspsim.svn.sourceforge.net/mspsim/?rev=762&view=rev Author: nifi Date: 2010-09-23 09:13:04 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Fixed bugs to support multiple writes Modified Paths: -------------- mspsim/se/sics/mspsim/core/Flash.java Modified: mspsim/se/sics/mspsim/core/Flash.java =================================================================== --- mspsim/se/sics/mspsim/core/Flash.java 2010-09-22 09:51:34 UTC (rev 761) +++ mspsim/se/sics/mspsim/core/Flash.java 2010-09-23 09:13:04 UTC (rev 762) @@ -35,6 +35,8 @@ */ package se.sics.mspsim.core; +import java.util.Arrays; + import se.sics.mspsim.util.Utils; public class Flash extends IOUnit { @@ -54,15 +56,12 @@ private static final int ERASE_SHIFT = 1; private static final int ERASE_MASK = 0x06; - private enum EraseMode { - ERASE_NONE, + /* Erase modes needs to be first due to usage of ordinality */ + private enum WriteMode { + NONE, ERASE_SEGMENT, ERASE_MAIN, - ERASE_ALL - }; - - private enum WriteMode { - WRITE_NONE, + ERASE_ALL, WRITE_SINGLE, WRITE_BLOCK, WRITE_BLOCK_FINISH @@ -112,45 +111,41 @@ private boolean busy; private boolean wait; private boolean blocked_cpu; - private EraseMode current_erase; + + private WriteMode currentWriteMode; + private int blockwriteCount; - private WriteMode current_write_mode; - private int blockwrite_count; - private TimeEvent end_process = new TimeEvent(0) { public void execute(long t) { blocked_cpu = false; - switch(current_erase) { - case ERASE_NONE: + switch(currentWriteMode) { + case NONE: break; case ERASE_SEGMENT: case ERASE_MAIN: case ERASE_ALL: + // Erase flags are automatically cleared after each erase mode = 0; - current_erase = EraseMode.ERASE_NONE; + currentWriteMode = WriteMode.NONE; busy = false; break; - } - - switch(current_write_mode) { - case WRITE_NONE: - break; case WRITE_SINGLE: - mode = 0; busy = false; - current_write_mode = WriteMode.WRITE_NONE; + // WRT flags are NOT automatically cleared +// mode = 0; +// current_write_mode = WriteMode.WRITE_NONE; break; case WRITE_BLOCK: - blockwrite_count++; - if (blockwrite_count == 64) { + blockwriteCount++; + if (blockwriteCount == 64) { // FIXME: What happens if we try to write more than 64 bytes // on real hardware??? logw("Last access in block mode. Forced exit?"); - current_write_mode = WriteMode.WRITE_BLOCK_FINISH; + currentWriteMode = WriteMode.WRITE_BLOCK_FINISH; } /* if (DEBUG) { System.out.println("Write cycle complete, flagged WAIT."); @@ -162,10 +157,10 @@ if (DEBUG) { log("Programming voltage dropped, write mode disabled."); } - current_write_mode = WriteMode.WRITE_NONE; + currentWriteMode = WriteMode.NONE; busy = false; wait = true; - mode = 0; +// mode = 0; break; } } @@ -179,7 +174,10 @@ this.main_range = main_range; this.info_range = info_range; locked = true; - + + Arrays.fill(memory, main_range.start, main_range.end, 0xff); + Arrays.fill(memory, info_range.start, info_range.end, 0xff); + reset(MSP430.RESET_POR); } @@ -265,7 +263,7 @@ } } - switch(current_erase) { + switch(currentWriteMode) { case ERASE_SEGMENT: int a_area_start[] = new int[1]; int a_area_end[] = new int[1]; @@ -282,7 +280,7 @@ memory[i] = 0xff; } waitFlashProcess(SEGMENT_ERASE_TIME); - return; + break; case ERASE_MAIN: if (! main_range.isInRange(address)) { @@ -292,7 +290,7 @@ memory[i] = 0xff; } waitFlashProcess(MASS_ERASE_TIME); - return; + break; case ERASE_ALL: for (int i = main_range.start; i < main_range.end; i++) { @@ -302,42 +300,38 @@ memory[i] = 0xff; } waitFlashProcess(MASS_ERASE_TIME); - return; - } - - switch(current_write_mode) { + break; + case WRITE_SINGLE: case WRITE_BLOCK: - wait = false; - // TODO: Register target block and verify all writes stay in the same - // block. What does the real hardware on random writes?!? - if (blockwrite_count == 0) { - wait_time = BLOCKWRITE_FIRST_TIME; - if (DEBUG) { - log("Flash write in block mode started @" + Utils.hex16(address)); - } - if (addressInFlash(cpu.readRegister(MSP430.PC))) { - logw("Oops. Block write access only allowed when executing from RAM."); - } + if (currentWriteMode == WriteMode.WRITE_BLOCK) { + wait = false; + // TODO: Register target block and verify all writes stay in the same + // block. What does the real hardware on random writes?!? + if (blockwriteCount == 0) { + wait_time = BLOCKWRITE_FIRST_TIME; + if (DEBUG) { + log("Flash write in block mode started @" + Utils.hex16(address)); + } + if (addressInFlash(cpu.readRegister(MSP430.PC))) { + logw("Oops. Block write access only allowed when executing from RAM."); + } + } else { + wait_time = BLOCKWRITE_TIME; + } } else { - wait_time = BLOCKWRITE_TIME; + wait_time = WRITE_TIME; } + /* Flash memory allows clearing bits only */ + memory[address] &= data & 0xff; + if (word) { + memory[address + 1] &= (data >> 8) & 0xff; + } + if (DEBUG) { + log("Writing " + data + " to $" + Utils.hex16(address)); + } + waitFlashProcess(wait_time); break; - - case WRITE_SINGLE: - wait_time = WRITE_TIME; - break; } - - /* Flash memory allows clearing bits only */ - memory[address] &= data & 0xff; - if (word) { - memory[address + 1] &= (data >> 8) & 0xff; - } - - if (wait_time < 0) { - throw new RuntimeException("Wait time not properly initialized"); - } - waitFlashProcess(wait_time); } public void notifyRead(int address) { @@ -346,7 +340,7 @@ return; } if (DEBUG) { - if (wait == false && current_write_mode == WriteMode.WRITE_BLOCK) { + if (wait == false && currentWriteMode == WriteMode.WRITE_BLOCK) { log("Reading flash prohibited. Would read 0x3fff!!!"); log("CPU PC=" + Utils.hex16(cpu.readRegister(MSP430.PC)) + " read address=" + Utils.hex16(address)); @@ -435,15 +429,13 @@ busy = false; wait = true; locked = true; - current_erase = EraseMode.ERASE_NONE; - current_write_mode = WriteMode.WRITE_NONE; - + currentWriteMode = WriteMode.NONE; } - private EraseMode getEraseMode(int regdata) { + private WriteMode getEraseMode(int regdata) { int idx = (regdata & ERASE_MASK) >> ERASE_SHIFT; - for (EraseMode em : EraseMode.values()) { + for (WriteMode em : WriteMode.values()) { if (em.ordinal() == idx) return em; } @@ -451,7 +443,7 @@ } private void triggerErase(int newmode) { - current_erase = getEraseMode(newmode); + currentWriteMode = getEraseMode(newmode); } private void triggerLockFlash() { @@ -463,10 +455,9 @@ } private void triggerAccessViolation(String reason) { - if (DEBUG) - log("Flash access violation: " + reason + - ". PC=" + Utils.hex16(cpu.readRegister(MSP430.PC))); - + logw("Access violation: " + reason + ". PC=$" + + Utils.hex16(cpu.readRegister(MSP430.PC))); + statusreg |= ACCVIFG; if (cpu.getSFR().isIEBitsSet(SFR.IE1, ACCVIE)) { cpu.flagInterrupt(NMI_VECTOR, this, true); @@ -477,22 +468,22 @@ /*if (DEBUG) { System.out.println("Single write triggered"); }*/ - current_write_mode = WriteMode.WRITE_SINGLE; + currentWriteMode = WriteMode.WRITE_SINGLE; } private void triggerBlockWrite() { if (DEBUG) { log("Block write triggered"); } - current_write_mode = WriteMode.WRITE_BLOCK; - blockwrite_count = 0; + currentWriteMode = WriteMode.WRITE_BLOCK; + blockwriteCount = 0; } private void triggerEndBlockWrite() { if (DEBUG) { log("Got end of flash block write"); } - current_write_mode = WriteMode.WRITE_BLOCK_FINISH; + currentWriteMode = WriteMode.WRITE_BLOCK_FINISH; waitFlashProcess(BLOCKWRITE_END_TIME); } @@ -515,12 +506,11 @@ case FCTL1: // access violation while erase/write in progress // exception: block write mode and WAIT==1 - if ((mode & ERASE_MASK) != 0 || (mode & WRT) != 0) { - if (!((mode & BLKWRT) != 0 && wait)) { - triggerAccessViolation( - "FCTL1 write not allowed while erase/write active"); - return; - } +// if ((mode & ERASE_MASK) != 0 || (mode & WRT) != 0) { + if (busy && ((mode & BLKWRT) == 0 || wait == false)) { + // if (!((mode & BLKWRT) != 0 && wait)) { + triggerAccessViolation("FCTL1 write not allowed while erase/write active"); + return; } if ((mode & ERASE_MASK) != (regdata & ERASE_MASK)) { @@ -539,9 +529,9 @@ } else { triggerSingleWrite(); } - mode &= ~WRT; - mode |= regdata & WRT; } + mode &= ~WRT; + mode |= regdata & WRT; } if ((mode & BLKWRT) != 0 && (regdata & BLKWRT) == 0) { @@ -597,7 +587,6 @@ busy = false; wait = true; locked = true; - current_erase = EraseMode.ERASE_NONE; - current_write_mode = WriteMode.WRITE_NONE; + currentWriteMode = WriteMode.NONE; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-09-22 09:51:40
|
Revision: 761 http://mspsim.svn.sourceforge.net/mspsim/?rev=761&view=rev Author: nifi Date: 2010-09-22 09:51:34 +0000 (Wed, 22 Sep 2010) Log Message: ----------- Bug fix: SFR is not available when Flash is setup Modified Paths: -------------- mspsim/se/sics/mspsim/core/Flash.java Modified: mspsim/se/sics/mspsim/core/Flash.java =================================================================== --- mspsim/se/sics/mspsim/core/Flash.java 2010-09-08 17:20:54 UTC (rev 760) +++ mspsim/se/sics/mspsim/core/Flash.java 2010-09-22 09:51:34 UTC (rev 761) @@ -100,7 +100,6 @@ private static final int FN_MASK = 0x3f; private MSP430Core cpu; - private SFR sfr; private FlashRange main_range; private FlashRange info_range; private int[] memory; @@ -179,7 +178,6 @@ this.memory = memory; this.main_range = main_range; this.info_range = info_range; - this.sfr = cpu.getSFR(); locked = true; reset(MSP430.RESET_POR); @@ -470,7 +468,7 @@ ". PC=" + Utils.hex16(cpu.readRegister(MSP430.PC))); statusreg |= ACCVIFG; - if (sfr.isIEBitsSet(SFR.IE1, ACCVIE)) { + if (cpu.getSFR().isIEBitsSet(SFR.IE1, ACCVIE)) { cpu.flagInterrupt(NMI_VECTOR, this, true); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-09-08 17:21:00
|
Revision: 760 http://mspsim.svn.sourceforge.net/mspsim/?rev=760&view=rev Author: joxe Date: 2010-09-08 17:20:54 +0000 (Wed, 08 Sep 2010) Log Message: ----------- fixed bug in timer overflow calculation Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2010-09-08 12:04:03 UTC (rev 759) +++ mspsim/se/sics/mspsim/core/Timer.java 2010-09-08 17:20:54 UTC (rev 760) @@ -385,11 +385,15 @@ /* and can be something else if mode is another... */ // This should be updated whenever clockspeed changes... nextTimerTrigger = (long) (nextTimerTrigger + 0x10000 * cyclesMultiplicator); +// System.out.println("*** scheduling counter trigger..." + nextTimerTrigger + " now = " + t); core.scheduleCycleEvent(this, nextTimerTrigger); + if (lastTIV == 0 && interruptEnable) { lastTIV = memory[tiv] = timerOverflow; core.flagInterrupt(ccr1Vector, Timer.this, true); + } else { +// System.out.println("*** Did not trigger interrupt: " + interruptEnable); } } }; @@ -813,7 +817,10 @@ updateCyclesMultiplicator(); if (DEBUG) System.out.println(getName() + " Counter reset at " + cycles + " cycMul: " + cyclesMultiplicator); - core.scheduleCycleEvent(counterTrigger, (long) ((0x100000 - counter) * cyclesMultiplicator)); + + core.scheduleCycleEvent(counterTrigger, cycles + (long)((0x10000 - counter) * cyclesMultiplicator)); +// System.out.println("(re)Scheduling counter trigger..." + counterTrigger.time + " now = " + cycles + " ctr: " + counter); + } private void setCounter(int newCtr, long cycles) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-09-08 12:04:09
|
Revision: 759 http://mspsim.svn.sourceforge.net/mspsim/?rev=759&view=rev Author: joxe Date: 2010-09-08 12:04:03 +0000 (Wed, 08 Sep 2010) Log Message: ----------- added notification of configuration change for CC2420 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/Chip.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-09-07 07:13:34 UTC (rev 758) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-09-08 12:04:03 UTC (rev 759) @@ -661,6 +661,7 @@ } private void setReg(int address, int data) { + int oldValue = registers[address]; registers[address] = data; switch(address) { case REG_IOCFG0: @@ -682,12 +683,13 @@ autoAck = (data & AUTOACK) != 0; break; case REG_FSCTRL: - if (cl != null) { - updateActiveFrequency(); - cl.changedChannel(activeChannel); - } + if (cl != null) { + updateActiveFrequency(); + cl.changedChannel(activeChannel); + } break; } + configurationChanged(address, oldValue, data); } public void dataReceived(USART source, int data) { Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2010-09-07 07:13:34 UTC (rev 758) +++ mspsim/se/sics/mspsim/core/Chip.java 2010-09-08 12:04:03 UTC (rev 759) @@ -181,7 +181,7 @@ /* Called by subclasses to inform about changes of configuration */ protected void configurationChanged(int parameter, int oldValue, int newValue) { ConfigurationChangeListener[] listeners = ccListeners; - if (listeners != null) { + if (oldValue != newValue && listeners != null) { for (int i = 0, n = listeners.length; i < n; i++) { listeners[i].configurationChanged(this, parameter, oldValue, newValue); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-09-07 07:13:40
|
Revision: 758 http://mspsim.svn.sourceforge.net/mspsim/?rev=758&view=rev Author: joxe Date: 2010-09-07 07:13:34 +0000 (Tue, 07 Sep 2010) Log Message: ----------- added missing java class Added Paths: ----------- mspsim/se/sics/mspsim/core/ConfigurationChangeListener.java Added: mspsim/se/sics/mspsim/core/ConfigurationChangeListener.java =================================================================== --- mspsim/se/sics/mspsim/core/ConfigurationChangeListener.java (rev 0) +++ mspsim/se/sics/mspsim/core/ConfigurationChangeListener.java 2010-09-07 07:13:34 UTC (rev 758) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, 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: StateChangeListener.java 729 2010-07-18 07:00:28Z nifi $ + * + * ----------------------------------------------------------------- + * + * StateChangeListener + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 17 jul 2010 + * Updated : $Date: 2010-07-18 09:00:28 +0200 (Sun, 18 Jul 2010) $ + * $Revision: 729 $ + */ + + +package se.sics.mspsim.core; + +public interface ConfigurationChangeListener { + + public void configurationChanged(Object source, int configurationParam, int oldValue, int newValue); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-09-06 20:29:33
|
Revision: 757 http://mspsim.svn.sourceforge.net/mspsim/?rev=757&view=rev Author: joxe Date: 2010-09-06 20:29:26 +0000 (Mon, 06 Sep 2010) Log Message: ----------- added configuration listener and state listener support for chip and iounit Modified Paths: -------------- mspsim/se/sics/mspsim/chip/AT45DB.java mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/chip/DS2411.java mspsim/se/sics/mspsim/chip/Leds.java mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/chip/MMA7260QT.java mspsim/se/sics/mspsim/chip/SHT11.java mspsim/se/sics/mspsim/chip/TR1001.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/core/USARTListener.java mspsim/se/sics/mspsim/platform/GenericNode.java Modified: mspsim/se/sics/mspsim/chip/AT45DB.java =================================================================== --- mspsim/se/sics/mspsim/chip/AT45DB.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/AT45DB.java 2010-09-06 20:29:26 UTC (rev 757) @@ -166,12 +166,12 @@ if(dummy == 0) { if(DEBUG) log("State " + state + " -> " + next_state); - state = next_state; + setState(next_state); } }else{ if(--dummy == 0) { if(DEBUG) log("State " + state + " -> " + next_state); - state = next_state; + setState(next_state); } } source.byteReceived(0); @@ -211,7 +211,7 @@ if(DEBUG) log("Buffer" + (data == BUFFER1_TO_PAGE_ERASE ? "1" : "2") + " to Page with Erase Command"); pos = 0; - state = READ_ADDRESS; + setState(READ_ADDRESS); next_state = data; dummy = 0; setReady(false); @@ -223,7 +223,7 @@ if(DEBUG) log("Read Buffer Command " + (data == BUFFER1_READ ? "Buffer1" : "Buffer2")); pos = 0; - state = READ_ADDRESS; + setState(READ_ADDRESS); next_state = data; dummy = 1; setReady(false); @@ -235,7 +235,7 @@ if(DEBUG) log("Write Buffer Command " + (data == BUFFER1_WRITE ? "Buffer1" : "Buffer2")); pos = 0; - state = READ_ADDRESS; + setState(READ_ADDRESS); next_state = data; dummy = 0; setReady(false); @@ -247,7 +247,7 @@ if(DEBUG) log("Page To Buffer " + (data == PAGE_TO_BUFFER1 ? "1" : "2") + " Command"); pos = 0; - state = READ_ADDRESS; + setState(READ_ADDRESS); next_state = data; dummy = 0; setReady(false); @@ -256,12 +256,12 @@ case STATUS_REGISTER_READ: if(DEBUG) log("Read status register command. status: " + status); - state = STATUS_REGISTER_READ; + setState(STATUS_REGISTER_READ); source.byteReceived(0); break; default: - logw("WARNING: Command not implemented: " + data); - source.byteReceived(0); + logw("WARNING: Command not implemented: " + data); + source.byteReceived(0); break; } break; @@ -272,6 +272,11 @@ } } + private void setState(int nextState) { + state = nextState; + stateChanged(nextState); + } + private int readBuffer(int num, int address) { //if(DEBUG) { // log("Reading RAM Buffer" + num + " Address: " + Integer.toHexString(address)); @@ -295,7 +300,7 @@ public void setReset(boolean reset) { Reset = reset; if(Reset == true) - state = STATE_RESET; + setState(STATE_RESET); if(DEBUG) { log("Reset: " + Reset); } @@ -322,7 +327,7 @@ break; } - state = STATE_IDLE; + setState(STATE_IDLE); } if(DEBUG) { @@ -362,4 +367,9 @@ public abstract int read(byte[] b) throws IOException; public abstract void write(byte[] b) throws IOException; + /* not yet any meaningful support for getting configuration */ + public int getConfiguration(int param) { + return 0; + } + } // AT45DB Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2010-09-06 20:29:26 UTC (rev 757) @@ -187,15 +187,18 @@ } } - @Override public int getModeMax() { return MODE_MAX; } - @Override public String info() { return "Volume: " + getVolume() + " Beep: " + (beepOn ? "on" : "off") + " Sound Enabled: " + isSoundEnabled; } + /* just return some value */ + public int getConfiguration(int parameter) { + return beepOn ? 1 : 0; + } + } Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-09-06 20:29:26 UTC (rev 757) @@ -523,6 +523,7 @@ if (stateListener != null) { stateListener.newState(stateMachine); } + stateChanged(stateMachine.state); return true; } @@ -1338,5 +1339,10 @@ public void stateChanged(int state) { } + + /* return data in register at the correct position */ + public int getConfiguration(int parameter) { + return registers[parameter]; + } } // CC2420 Modified: mspsim/se/sics/mspsim/chip/DS2411.java =================================================================== --- mspsim/se/sics/mspsim/chip/DS2411.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/DS2411.java 2010-09-06 20:29:26 UTC (rev 757) @@ -78,6 +78,7 @@ case WAIT_FOR_RESET: if (!lastPin) { state = STATE.RESETTING; + stateChanged(state.ordinal()); if (DEBUG) log("Reseting..."); } break; @@ -85,6 +86,7 @@ /* ready! release bus */ sdataPort.setPinState(sdataPin, IOPort.PIN_HI); state = STATE.READY; + stateChanged(state.ordinal()); if (DEBUG) log("Ready!"); readByte = 0; pos = 0; @@ -96,7 +98,8 @@ if (pos == 8) { if (DEBUG) log("Command: " + Utils.hex8(readByte)); handleCommand(readByte); - state = STATE.WAIT_SENDING; + state = STATE.WAIT_SENDING; + stateChanged(state.ordinal()); pos = 0; writePos = 0; writeByte = writeBuf[writePos]; @@ -170,6 +173,7 @@ sdataPort.setPinState(sdataPin, IOPort.PIN_HI); if (!high) { state = STATE.WAIT_FOR_RESET; + stateChanged(state.ordinal()); /* reset if low for at least 480uS - we check after 400uS and resets * then */ if (DEBUG) log("Wait for reset..."); @@ -179,6 +183,7 @@ case RESETTING: if (high) { state = STATE.SIGNAL_READY; + stateChanged(state.ordinal()); if (DEBUG) log("Signal ready"); /* reset done - signal with LOW for a while! */ sdataPort.setPinState(sdataPin, IOPort.PIN_LOW); @@ -196,6 +201,7 @@ case WAIT_SENDING: if (!high) { state = STATE.SENDING; + stateChanged(state.ordinal()); } break; case SENDING: @@ -212,6 +218,7 @@ if (writePos == writeLen) { if (DEBUG) log("write is over => IDLE!!!!"); state = STATE.IDLE; + stateChanged(state.ordinal()); } else { pos = 0; writeByte = writeBuf[writePos]; @@ -229,4 +236,8 @@ macID[4] = m; macID[5] = n; } + + public int getConfiguration(int parameter) { + return 0; + } } Modified: mspsim/se/sics/mspsim/chip/Leds.java =================================================================== --- mspsim/se/sics/mspsim/chip/Leds.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/Leds.java 2010-09-06 20:29:26 UTC (rev 757) @@ -104,14 +104,16 @@ this.stateListeners = (StateChangeListener[]) ArrayUtils.remove(this.stateListeners, l); } - @Override public int getModeMax() { return 0; } - @Override public String info() { return "Leds: " + (ledColors.length <= 8 ? Utils.binary8(leds) : Utils.binary16(leds)); } + public int getConfiguration(int parameter) { + return 0; + } + } Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2010-09-06 20:29:26 UTC (rev 757) @@ -380,4 +380,9 @@ public abstract int readFully(byte[] b) throws IOException; public abstract void write(byte[] b) throws IOException; + /* by default - there is not configuratin to return for m25p80 */ + public int getConfiguration(int param) { + return 0; + } + } // ExtFlash Modified: mspsim/se/sics/mspsim/chip/MMA7260QT.java =================================================================== --- mspsim/se/sics/mspsim/chip/MMA7260QT.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/MMA7260QT.java 2010-09-06 20:29:26 UTC (rev 757) @@ -120,7 +120,6 @@ super.setMode(mode); } - @Override public int getModeMax() { return MODE_NAMES.length; } @@ -131,4 +130,9 @@ + " [x=" + getADCX() + ",y=" + getADCY() + ",z=" + getADCZ() + ']'; } + /* currently just return the gSelect as configuration */ + public int getConfiguration(int parameter) { + return gSelect; + } + } Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-09-06 20:29:26 UTC (rev 757) @@ -279,4 +279,9 @@ return 0; } + /* no configuration for the SHT11 ? */ + public int getConfiguration(int parameter) { + return 0; + } + } Modified: mspsim/se/sics/mspsim/chip/TR1001.java =================================================================== --- mspsim/se/sics/mspsim/chip/TR1001.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/chip/TR1001.java 2010-09-06 20:29:26 UTC (rev 757) @@ -120,4 +120,7 @@ } } + public int getConfiguration(int parameter) { + return 0; + } } Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/core/Chip.java 2010-09-06 20:29:26 UTC (rev 757) @@ -57,10 +57,14 @@ protected final MSP430Core cpu; private OperatingModeListener[] omListeners; + private StateChangeListener[] scListeners; + private ConfigurationChangeListener[] ccListeners; + private EventListener eventListener; protected boolean sendEvents = false; private String[] modeNames = null; private int mode; + private int chipState; protected EmulationLogger logger; private PrintStream log; protected boolean DEBUG = false; @@ -86,6 +90,23 @@ omListeners = (OperatingModeListener[]) ArrayUtils.remove(omListeners, listener); } + public void addStateChangeListener(StateChangeListener listener) { + scListeners = (StateChangeListener[]) ArrayUtils.add(StateChangeListener.class, scListeners, listener); + } + + public void removeStateChangeListener(StateChangeListener listener) { + scListeners = (StateChangeListener[]) ArrayUtils.remove(scListeners, listener); + } + + public void addConfigurationChangeListener(ConfigurationChangeListener listener) { + ccListeners = (ConfigurationChangeListener[]) ArrayUtils.add(ConfigurationChangeListener.class, ccListeners, listener); + } + + public void removeConfigurationChangeListener(ConfigurationChangeListener listener) { + ccListeners = (ConfigurationChangeListener[]) ArrayUtils.remove(ccListeners, listener); + } + + public int getMode() { return mode; } @@ -142,6 +163,35 @@ return -1; } + /* Called by subclasses to inform about changes of state */ + protected void stateChanged(int newState) { + if (chipState != newState) { + int oldState = chipState; + chipState = newState; + /* inform listeners */ + StateChangeListener[] listeners = scListeners; + if (listeners != null) { + for (int i = 0, n = listeners.length; i < n; i++) { + listeners[i].stateChanged(this, oldState, chipState); + } + } + } + } + + /* Called by subclasses to inform about changes of configuration */ + protected void configurationChanged(int parameter, int oldValue, int newValue) { + ConfigurationChangeListener[] listeners = ccListeners; + if (listeners != null) { + for (int i = 0, n = listeners.length; i < n; i++) { + listeners[i].configurationChanged(this, parameter, oldValue, newValue); + } + } + } + + /* interface for getting hold of configuration values - typically mapped to some kind of address */ + public abstract int getConfiguration(int parameter); + + public String getID() { return id; } Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2010-09-06 20:29:26 UTC (rev 757) @@ -43,6 +43,8 @@ import java.io.PrintStream; +import se.sics.mspsim.util.ArrayUtils; + public abstract class IOUnit implements InterruptHandler, Loggable { int[] memory; @@ -51,6 +53,9 @@ protected final String id; protected final String name; + private StateChangeListener[] scListeners; + private int ioState; + protected EmulationLogger logger; private PrintStream log; protected boolean DEBUG = false; @@ -66,6 +71,29 @@ this.offset = offset; } + public void addStateChangeListener(StateChangeListener listener) { + scListeners = (StateChangeListener[]) ArrayUtils.add(StateChangeListener.class, scListeners, listener); + } + + public void removeStateChangeListener(StateChangeListener listener) { + scListeners = (StateChangeListener[]) ArrayUtils.remove(scListeners, listener); + } + + /* Called by subclasses to inform about changes of state */ + protected void stateChanged(int newState) { + if (ioState != newState) { + int oldState = ioState; + ioState = newState; + /* inform listeners */ + StateChangeListener[] listeners = scListeners; + if (listeners != null) { + for (int i = 0, n = listeners.length; i < n; i++) { + listeners[i].stateChanged(this, oldState, ioState); + } + } + } + } + public void reset(int type) { } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-09-06 20:29:26 UTC (rev 757) @@ -1447,4 +1447,8 @@ public int getPC() { return reg[PC]; } + + public int getConfiguration(int parameter) { + return 0; + } } Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/core/USART.java 2010-09-06 20:29:26 UTC (rev 757) @@ -310,9 +310,8 @@ log(" clearing rx interrupt flag " + cpu.getPC() + " byte: " + tmp); } clrBitIFG(urxifg); - if (listener != null) { - listener.stateChanged(USARTListener.RXFLAG_CLEARED); - } + /* This should be changed to a state rather than an "event" */ + stateChanged(USARTListener.RXFLAG_CLEARED); return tmp; } return 0; Modified: mspsim/se/sics/mspsim/core/USARTListener.java =================================================================== --- mspsim/se/sics/mspsim/core/USARTListener.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/core/USARTListener.java 2010-09-06 20:29:26 UTC (rev 757) @@ -44,5 +44,4 @@ public interface USARTListener { public static int RXFLAG_CLEARED = 1; public void dataReceived(USART source, int data); - public void stateChanged(int state); } Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2010-09-04 15:28:53 UTC (rev 756) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2010-09-06 20:29:26 UTC (rev 757) @@ -301,4 +301,7 @@ } } + public int getConfiguration(int param) { + return 0; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-09-04 15:29:00
|
Revision: 756 http://mspsim.svn.sourceforge.net/mspsim/?rev=756&view=rev Author: joxe Date: 2010-09-04 15:28:53 +0000 (Sat, 04 Sep 2010) Log Message: ----------- fixed correct file per symbol Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-08-31 19:28:37 UTC (rev 755) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-09-04 15:28:53 UTC (rev 756) @@ -358,6 +358,12 @@ } public String lookupFile(int address) { + if (debug != null) { + DebugInfo di = debug.getDebugInfo(address); + if (di != null) { + return di.getFile(); + } + } for (int i = 0; i < files.size(); i++) { FileInfo fi = files.get(i); if (address >= fi.start && address <= fi.end) { @@ -392,15 +398,12 @@ if (type == ELFSection.SYMTYPE_NONE && sn != null){ if ("Letext".equals(sn)) { if (currentFile != null) { -// System.out.println("Found file addr for " + currentFile + " : 0x" + -// Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); files.add(new FileInfo(currentFile, currentAddress, sAddr)); currentAddress = sAddr; } } else if (!sn.startsWith("_")) { -// System.out.println("Adding entry: " + sn + " at " + sAddr); - map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, 0, sn, currentFile, - false)); + map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, 0, sn, currentFile, + false)); } } if (type == ELFSection.SYMTYPE_FILE) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-08-31 19:28:43
|
Revision: 755 http://mspsim.svn.sourceforge.net/mspsim/?rev=755&view=rev Author: nifi Date: 2010-08-31 19:28:37 +0000 (Tue, 31 Aug 2010) Log Message: ----------- Somewhat darker led colors Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-08-31 18:27:29 UTC (rev 754) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2010-08-31 19:28:37 UTC (rev 755) @@ -70,7 +70,7 @@ private IOPort port2; private IOPort port5; - private static final int[] LEDS = { 0xff6060, 0xffff00, 0x40ff40 }; + private static final int[] LEDS = { 0xff2020, 0xffff00, 0x40ff40 }; public static final int RED_LED = 0x01; public static final int GREEN_LED = 0x02; public static final int YELLOW_LED = 0x04; Modified: mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java 2010-08-31 18:27:29 UTC (rev 754) +++ mspsim/se/sics/mspsim/platform/jcreate/JCreateNode.java 2010-08-31 19:28:37 UTC (rev 755) @@ -63,8 +63,8 @@ public static final int MODE_MAX = 9; private static final int[] LEDS = { - 0xff6060, 0xff6060, 0xff6060, 0xff6060, - 0xff6060, 0xff6060, 0xff6060, 0xff6060 + 0xff2020, 0xff2020, 0xff2020, 0xff2020, + 0xff2020, 0xff2020, 0xff2020, 0xff2020 }; private Leds leds; Modified: mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java 2010-08-31 18:27:29 UTC (rev 754) +++ mspsim/se/sics/mspsim/platform/sentillausb/SentillaUSBNode.java 2010-08-31 19:28:37 UTC (rev 755) @@ -60,7 +60,7 @@ public static final int MODE_LEDS_2 = 2; public static final int MODE_MAX = MODE_LEDS_2; - private static final int[] LEDS = { 0xff6060, 0x40ff40 }; + private static final int[] LEDS = { 0xff2020, 0x40ff40 }; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-08-31 18:27:29 UTC (rev 754) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2010-08-31 19:28:37 UTC (rev 755) @@ -19,7 +19,7 @@ public static final int SHT11_CLK = 1 << SHT11_CLK_PIN; public static final int SHT11_DATA = 1 << SHT11_DATA_PIN; - private static final int[] LEDS = { 0xff8000, 0x60ff60, 0xa0a0ff }; + private static final int[] LEDS = { 0xff2020, 0x40ff40, 0x4040ff }; public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; public static final int RED_LED = 0x10; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-31 18:27:35
|
Revision: 754 http://mspsim.svn.sourceforge.net/mspsim/?rev=754&view=rev Author: joxe Date: 2010-08-31 18:27:29 +0000 (Tue, 31 Aug 2010) Log Message: ----------- integrated dwarf reader for adding addr2line support in mspsim on mspgcc4 files Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-30 20:49:02 UTC (rev 753) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-31 18:27:29 UTC (rev 754) @@ -41,12 +41,16 @@ import java.util.ArrayList; +import se.sics.mspsim.util.DebugInfo; +import se.sics.mspsim.util.ELFDebug; import se.sics.mspsim.util.Utils; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.ELFSection; -public class DwarfReader { +public class DwarfReader implements ELFDebug { + public boolean DEBUG = false; + /* Operands for lines */ public static final int DW_LNS_EXT = 0; @@ -75,13 +79,24 @@ int addressSize; int segmentSize; } - + + class LineEntry { + int address; + int line; + LineEntry(int line, int adr) { + this.line = line; + address = adr; + } + } /* Line number lookup data */ class LineData { String[] includeDirs; String[] sourceFiles; + LineEntry[] lineEntries; } + ArrayList<LineData> lineInfo = new ArrayList<LineData>(); + /* some state for the line number handling */ private int lineAddress; private int lineFile; @@ -114,6 +129,7 @@ System.out.println("DWARF Line - ELF Section length: " + sec.getSize()); sec.reset(); int endPos = 0; + ArrayList<LineEntry> lineData = new ArrayList(); while (sec.getPosition() < sec.getSize()) { /* here starts the reading of one file's (?) debug info */ int totLen = sec.readElf32(); @@ -145,7 +161,7 @@ // pos = pos + 15 + opcodeBase - 1; // System.out.println("Line pos = " + pos + " sec-pos = " + sec.getPosition()); - System.out.println("Line --- include files ---"); + if (DEBUG) System.out.println("Line --- include files ---"); ArrayList<String> directories = new ArrayList<String>(); directories.add("./"); ArrayList<String> files = new ArrayList<String>(); @@ -156,12 +172,12 @@ while ((c = sec.readElf8()) != 0) { sb.append((char)c); while((c = sec.readElf8()) != 0) sb.append((char) c); - System.out.println("Line: include file: " + sb.toString()); + if (DEBUG) System.out.println("Line: include file: " + sb.toString()); directories.add(sb.toString()); sb.setLength(0); } - System.out.println("Line --- source files ---"); + if (DEBUG) System.out.println("Line --- source files ---"); long dirIndex = 0; long time = 0; long size = 0; @@ -172,8 +188,8 @@ time = sec.readLEB128(); size = sec.readLEB128(); - System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); - files.add(directories.get((int) dirIndex) + sb.toString()); + if (DEBUG) System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); + files.add(directories.get((int) dirIndex) + "/" + sb.toString()); sb.setLength(0); } @@ -196,6 +212,8 @@ if (sec.getPosition() >= endPos) { endSequence = true; } + lineData.clear(); + while(!endSequence) { int ins = sec.readElf8(); System.out.print(Utils.hex8(ins) + " "); @@ -219,13 +237,14 @@ lineAddress = sec.readElf16(); if (len == 5) lineAddress = sec.readElf32(); - System.out.println("Line: Set address to: " + Utils.hex16(lineAddress) + + if (DEBUG) System.out.println("Line: Set address to: " + Utils.hex16(lineAddress) + " (len: " + len + ")"); break; } break; case DW_LNS_copy: /* copy data to matrix... */ + lineData.add(new LineEntry(lineLine, lineAddress)); isBasicBlock = false; break; case DW_LNS_advance_pc: @@ -236,45 +255,73 @@ case DW_LNS_advance_line: long addLine = sec.readLEB128S(); lineLine += addLine; - System.out.println("Line: Increased line to: " + lineLine + + if (DEBUG) System.out.println("Line: Increased line to: " + lineLine + " (incr: " + addLine + ")"); break; case DW_LNS_set_file: lineFile = (int) sec.readLEB128(); - System.out.println("Line: Set file to: " + lineFile); + if (DEBUG) System.out.println("Line: Set file to: " + lineFile); break; case DW_LNS_set_column: lineColumn = (int) sec.readLEB128(); - System.out.println("Line: set column to: " + lineColumn); + if (DEBUG) System.out.println("Line: set column to: " + lineColumn); break; case DW_LNS_negate_stmt: isStatement = !isStatement; - System.out.println("Line: Negated is statement"); + if (DEBUG) System.out.println("Line: Negated is statement"); break; case DW_LNS_set_basic_block: isBasicBlock = true; - System.out.println("Line: Set basic block to true"); + if (DEBUG) System.out.println("Line: Set basic block to true"); break; case DW_LNS_const_add_pc: - System.out.println("Line: Should add const to PC - but how much?"); + System.out.println("Line: *** Should add const to PC - but how much - same as FF??"); break; case DW_LNS_fixed_advance_pc: int incr = sec.readElf16(); lineAddress += incr; - System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); + System.out.println("Line: *** Increased address to: " + Utils.hex16(lineAddress)); break; default: int lineInc = lineBase + ((ins - opcodeBase) % lineRange); int addrInc = (ins - opcodeBase) / lineRange; lineAddress += addrInc * minOpLen; lineLine += lineInc; - System.out.println("Line: *** Special operation => addr: " + + lineData.add(new LineEntry(lineLine, lineAddress)); + isBasicBlock = false; + + if (DEBUG) System.out.println("Line: *** Special operation => addr: " + Utils.hex16(lineAddress) + " Line: " + lineLine + " lineInc: " + lineInc); } } - System.out.println(); - System.out.println("Line - Position " + sec.getPosition() + " totLen: " + totLen); + if (DEBUG) System.out.println("Line - Position " + sec.getPosition() + " totLen: " + totLen); + + if (lineData.size() > 0) { + /* create a block of line-address data that can be used for lookup later.*/ + LineData lineTable = new LineData(); + lineTable.lineEntries = lineData.toArray(new LineEntry[0]); + lineTable.includeDirs = directories.toArray(new String[0]); + lineTable.sourceFiles = files.toArray(new String[0]); + lineInfo.add(lineTable); + } } + + /* Now we have some tables of data where it should be possible to sort out which + * addresses correspond to which lines!? + */ + + + for (int i = 0; i < lineInfo.size(); i++) { + LineData data = lineInfo.get(i); + System.out.println("Compiled file: " + data.sourceFiles[0]); + System.out.println("Start address: " + + Utils.hex16(data.lineEntries[0].address)); + System.out.println("End address: " + + Utils.hex16(data.lineEntries[data.lineEntries.length - 1].address)); + System.out.println("Size: " + + Utils.hex16(data.lineEntries[data.lineEntries.length - 1].address - data.lineEntries[0].address)); + + } } /* DWARF - address ranges information */ @@ -309,5 +356,30 @@ } while (addr != 0 || len != 0); } } while (pos < sec.getSize()); - } + } + + /* Access methods for data... */ + public DebugInfo getDebugInfo(int address) { + for (int i = 0; i < lineInfo.size(); i++) { + LineData data = lineInfo.get(i); + int start = data.lineEntries[0].address; + int end = data.lineEntries[data.lineEntries.length - 1].address; + if (address <= end && address >= start) { + for (int j = 0; j < data.lineEntries.length; j++) { + if (data.lineEntries[j].address >= address) { + return new DebugInfo(data.lineEntries[j].line, ".", data.sourceFiles[0], "* not available"); + } + } + } + } + return null; + } + + public ArrayList<Integer> getExecutableAddresses() { + return null; + } + + public String[] getSourceFiles() { + return null; + } } Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-08-30 20:49:02 UTC (rev 753) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-08-31 18:27:29 UTC (rev 754) @@ -300,6 +300,7 @@ if (readDwarf) { DwarfReader dwarf = new DwarfReader(this); dwarf.read(); + debug = dwarf; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-30 20:49:08
|
Revision: 753 http://mspsim.svn.sourceforge.net/mspsim/?rev=753&view=rev Author: joxe Date: 2010-08-30 20:49:02 +0000 (Mon, 30 Aug 2010) Log Message: ----------- added reading of complete DWARF addr 2 line info Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java mspsim/se/sics/mspsim/debug/StabFunction.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-29 18:36:47 UTC (rev 752) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-30 20:49:02 UTC (rev 753) @@ -41,8 +41,6 @@ import java.util.ArrayList; -import javax.sound.sampled.LineEvent; - import se.sics.mspsim.util.Utils; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.ELFSection; @@ -69,6 +67,7 @@ ELF elfFile; + /* Address ranges */ class Arange { int length; int version; @@ -76,6 +75,12 @@ int addressSize; int segmentSize; } + + /* Line number lookup data */ + class LineData { + String[] includeDirs; + String[] sourceFiles; + } /* some state for the line number handling */ private int lineAddress; @@ -87,7 +92,6 @@ private boolean endSequence = false; private ArrayList<Arange> aranges = new ArrayList<Arange>(); - public DwarfReader(ELF elfFile) { this.elfFile = elfFile; @@ -108,152 +112,169 @@ private void readLines(ELFSection sec) { System.out.println("DWARF Line - ELF Section length: " + sec.getSize()); - int pos = 0; sec.reset(); - int totLen = sec.readElf32(); - int version = sec.readElf16(); - int proLen = sec.readElf32(); - int minOpLen = sec.readElf8(); - - int defaultIsStmt = sec.readElf8(); - int lineBase = sec.readElf8(); - int lineRange = sec.readElf8(); - int opcodeBase = sec.readElf8(); + int endPos = 0; + while (sec.getPosition() < sec.getSize()) { + /* here starts the reading of one file's (?) debug info */ + int totLen = sec.readElf32(); + int version = sec.readElf16(); + int proLen = sec.readElf32(); + int minOpLen = sec.readElf8(); - - System.out.println("Line total length: " + totLen); - System.out.println("Line pro length: " + proLen); - System.out.println("Line version: " + version); + int defaultIsStmt = sec.readElf8(); + int lineBase = sec.readElf8(); + int lineRange = sec.readElf8(); + int opcodeBase = sec.readElf8(); - if (lineBase > 127) { - lineBase = lineBase - 256; - } - System.out.println("Line base : " + lineBase); - System.out.println("Line range : " + lineRange); - System.out.println("Line - Opcode base: " + opcodeBase); - - /* first char of includes (skip opcode lens)... */ - for (int i = 0; i < opcodeBase - 1; i++) { - sec.readElf8(); - } - -// pos = pos + 15 + opcodeBase - 1; -// System.out.println("Line pos = " + pos + " sec-pos = " + sec.getPosition()); - System.out.println("Line --- include files ---"); - ArrayList<String> directories = new ArrayList<String>(); - directories.add("./"); - ArrayList<String> files = new ArrayList<String>(); - StringBuilder sb = new StringBuilder(); - /* if first char is zero => no more include directories... */ - int c; - while ((c = sec.readElf8()) != 0) { - sb.append((char)c); - while((c = sec.readElf8()) != 0) sb.append((char) c); - System.out.println("Line: include file: " + sb.toString()); - directories.add(sb.toString()); - sb.setLength(0); - } + endPos += 4 + totLen; + System.out.println("Line total length: " + totLen + " endPos: " + endPos); + System.out.println("Line pro length: " + proLen); + System.out.println("Line version: " + version); - System.out.println("Line --- source files ---"); - long dirIndex = 0; - long time = 0; - long size = 0; - while ((c = sec.readElf8()) != 0) { - sb.append((char)c); - while((c = sec.readElf8()) != 0) sb.append((char) c); - dirIndex = sec.readLEB128(); - time = sec.readLEB128(); - size = sec.readLEB128(); - - System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); - files.add(directories.get((int) dirIndex) + sb.toString()); - sb.setLength(0); + if (lineBase > 127) { + lineBase = lineBase - 256; + } + System.out.println("Line base : " + lineBase); + System.out.println("Line range : " + lineRange); + System.out.println("Line - Opcode base: " + opcodeBase); + + /* first char of includes (skip opcode lens)... */ + for (int i = 0; i < opcodeBase - 1; i++) { + sec.readElf8(); + } + + // pos = pos + 15 + opcodeBase - 1; + // System.out.println("Line pos = " + pos + " sec-pos = " + sec.getPosition()); + System.out.println("Line --- include files ---"); + ArrayList<String> directories = new ArrayList<String>(); + directories.add("./"); + ArrayList<String> files = new ArrayList<String>(); + StringBuilder sb = new StringBuilder(); + + /* if first char is zero => no more include directories... */ + int c; + while ((c = sec.readElf8()) != 0) { + sb.append((char)c); + while((c = sec.readElf8()) != 0) sb.append((char) c); + System.out.println("Line: include file: " + sb.toString()); + directories.add(sb.toString()); + sb.setLength(0); + } + + System.out.println("Line --- source files ---"); + long dirIndex = 0; + long time = 0; + long size = 0; + while ((c = sec.readElf8()) != 0) { + sb.append((char)c); + while((c = sec.readElf8()) != 0) sb.append((char) c); + dirIndex = sec.readLEB128(); + time = sec.readLEB128(); + size = sec.readLEB128(); + + System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); + files.add(directories.get((int) dirIndex) + sb.toString()); + sb.setLength(0); + } + + /* Now we should have entered the position of the "code" for generating the + * line <=> address table + */ + System.out.println("Line: position: " + sec.getPosition()); + System.out.println("Line: first bytes of the machine: "); + System.out.print("Line: "); + + /* reset the "state" of the state machine (6.2.2 spec) */ + lineAddress = 0; + lineFile = 1; + lineLine = 1; + lineColumn = 0; + endSequence = false; + isStatement = defaultIsStmt != 0; + isBasicBlock = false; + + if (sec.getPosition() >= endPos) { + endSequence = true; + } + while(!endSequence) { + int ins = sec.readElf8(); + System.out.print(Utils.hex8(ins) + " "); + switch(ins) { + case DW_LNS_EXT: + /* extended instruction */ + int len = sec.readElf8(); + int extIns = sec.readElf8(); + switch(extIns) { + case DW_LNE_end_sequence: + endSequence = true; + System.out.println("Line: End sequence executed!!!"); + break; + case DW_LNE_define_file: + System.out.println("Line: Should define a file!!!!"); + break; + case DW_LNE_set_address: + if (len == 2) + lineAddress = sec.readElf8(); + if (len == 3) + lineAddress = sec.readElf16(); + if (len == 5) + lineAddress = sec.readElf32(); + System.out.println("Line: Set address to: " + Utils.hex16(lineAddress) + + " (len: " + len + ")"); + break; + } + break; + case DW_LNS_copy: + /* copy data to matrix... */ + isBasicBlock = false; + break; + case DW_LNS_advance_pc: + long add = sec.readLEB128(); + lineAddress += add * minOpLen; + System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); + break; + case DW_LNS_advance_line: + long addLine = sec.readLEB128S(); + lineLine += addLine; + System.out.println("Line: Increased line to: " + lineLine + + " (incr: " + addLine + ")"); + break; + case DW_LNS_set_file: + lineFile = (int) sec.readLEB128(); + System.out.println("Line: Set file to: " + lineFile); + break; + case DW_LNS_set_column: + lineColumn = (int) sec.readLEB128(); + System.out.println("Line: set column to: " + lineColumn); + break; + case DW_LNS_negate_stmt: + isStatement = !isStatement; + System.out.println("Line: Negated is statement"); + break; + case DW_LNS_set_basic_block: + isBasicBlock = true; + System.out.println("Line: Set basic block to true"); + break; + case DW_LNS_const_add_pc: + System.out.println("Line: Should add const to PC - but how much?"); + break; + case DW_LNS_fixed_advance_pc: + int incr = sec.readElf16(); + lineAddress += incr; + System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); + break; + default: + int lineInc = lineBase + ((ins - opcodeBase) % lineRange); + int addrInc = (ins - opcodeBase) / lineRange; + lineAddress += addrInc * minOpLen; + lineLine += lineInc; + System.out.println("Line: *** Special operation => addr: " + + Utils.hex16(lineAddress) + " Line: " + lineLine + " lineInc: " + lineInc); + } + } + System.out.println(); + System.out.println("Line - Position " + sec.getPosition() + " totLen: " + totLen); } - - /* Now we should have entered the position of the "code" for generating the - * line <=> address table - */ - System.out.println("Line: position: " + sec.getPosition()); - System.out.println("Line: first bytes of the machine: "); - System.out.print("Line: "); - isStatement = defaultIsStmt != 0; - for (int i = 0; i < 100; i++) { - int ins = sec.readElf8(); - System.out.print(Utils.hex8(ins) + " "); - switch(ins) { - case DW_LNS_EXT: - /* extended instruction */ - int len = sec.readElf8(); - int extIns = sec.readElf8(); - switch(extIns) { - case DW_LNE_end_sequence: - endSequence = true; - System.out.println("Line: End sequence executed!!!"); - break; - case DW_LNE_define_file: - System.out.println("Line: Should define a file!!!!"); - break; - case DW_LNE_set_address: - if (len == 2) - lineAddress = sec.readElf8(); - if (len == 3) - lineAddress = sec.readElf16(); - if (len == 5) - lineAddress = sec.readElf32(); - System.out.println("Line: Set address to: " + Utils.hex16(lineAddress) + - " (len: " + len + ")"); - break; - } - break; - case DW_LNS_copy: - /* copy data to matrix... */ - isBasicBlock = false; - break; - case DW_LNS_advance_pc: - long add = sec.readLEB128(); - lineAddress += add * minOpLen; - System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); - break; - case DW_LNS_advance_line: - long addLine = sec.readLEB128S(); - lineLine += addLine; - System.out.println("Line: Increased line to: " + lineLine + - " (incr: " + addLine + ")"); - break; - case DW_LNS_set_file: - lineFile = (int) sec.readLEB128(); - System.out.println("Line: Set file to: " + lineFile); - break; - case DW_LNS_set_column: - lineColumn = (int) sec.readLEB128(); - break; - case DW_LNS_negate_stmt: - isStatement = !isStatement; - System.out.println("Line: Negated is statement"); - break; - case DW_LNS_set_basic_block: - isBasicBlock = true; - System.out.println("Line: Set basic block to true"); - break; - case DW_LNS_const_add_pc: - System.out.println("Line: Should add const to PC - but how much?"); - break; - case DW_LNS_fixed_advance_pc: - int incr = sec.readElf16(); - lineAddress += incr; - System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); - break; - default: - - int lineInc = lineBase + ((ins - opcodeBase) % lineRange); - int addrInc = (ins - opcodeBase) / lineRange; - lineAddress += addrInc * minOpLen; - lineLine += lineInc; - System.out.println("Line: *** Special operation => addr: " + - Utils.hex16(lineAddress) + " Line: " + lineLine + " lineInc: " + lineInc); - } - } - System.out.println(); } /* DWARF - address ranges information */ Modified: mspsim/se/sics/mspsim/debug/StabFunction.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFunction.java 2010-08-29 18:36:47 UTC (rev 752) +++ mspsim/se/sics/mspsim/debug/StabFunction.java 2010-08-30 20:49:02 UTC (rev 753) @@ -1,3 +1,4 @@ + package se.sics.mspsim.debug; import java.util.ArrayList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-29 18:36:54
|
Revision: 752 http://mspsim.svn.sourceforge.net/mspsim/?rev=752&view=rev Author: joxe Date: 2010-08-29 18:36:47 +0000 (Sun, 29 Aug 2010) Log Message: ----------- some refactoring for more generic debugging support Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java mspsim/se/sics/mspsim/debug/StabFile.java mspsim/se/sics/mspsim/debug/StabFunction.java mspsim/se/sics/mspsim/debug/StabType.java mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/ELFDebug.java mspsim/se/sics/mspsim/util/ELFSection.java Added Paths: ----------- mspsim/se/sics/mspsim/debug/StabDebug.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-29 18:36:47 UTC (rev 752) @@ -1,3 +1,42 @@ +/** + * Copyright (c) 2010, 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. + * + * ----------------------------------------------------------------- + * + * DwarfReader + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2010-07-09 23:22:13 +0200 (Fri, 09 Jul 2010) $ + * $Revision: 717 $ + */ + package se.sics.mspsim.debug; import java.util.ArrayList; Added: mspsim/se/sics/mspsim/debug/StabDebug.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabDebug.java (rev 0) +++ mspsim/se/sics/mspsim/debug/StabDebug.java 2010-08-29 18:36:47 UTC (rev 752) @@ -0,0 +1,313 @@ +/** + * 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. + * + * ----------------------------------------------------------------- + * + * StabDebug + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2010-07-09 23:22:13 +0200 (Fri, 09 Jul 2010) $ + * $Revision: 717 $ + */ + +package se.sics.mspsim.debug; +import java.util.ArrayList; + +import se.sics.mspsim.util.DebugInfo; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.ELFDebug; +import se.sics.mspsim.util.ELFSection; +import se.sics.mspsim.util.Utils; + +public class StabDebug implements ELFDebug { + + private Stab[] stabs; + + public static final int N_FUN = 0x24; + public static final int N_STSYM = 0x26; // Data segment file-scope variable; + public static final int N_LCSYM = 0x28; // BSS segment file-scope variable; + public static final int N_REG_PARAM= 0x40; + public static final int N_VAR_PARAM= 0xa0; + public static final int N_SLINE = 0x44; + public static final int N_SO = 0x64; // filename and path + public static final int N_LSYM = 0x80; // stack var, typdef or struct + + public static final boolean DEBUG = false; + + ELFSection dbgStab; + ELFSection dbgStabStr; + + public StabDebug(ELF elf, ELFSection stab, ELFSection stabstr) { + dbgStab = stab; + dbgStabStr = stabstr; + + int len = dbgStab.getSize(); + int count = len / dbgStab.getEntrySize(); + int addr = dbgStab.getOffset(); + + if (DEBUG) { + System.out.println("Number of stabs:" + count); + } + stabs = new Stab[count]; + for (int i = 0, n = count; i < n; i++) { + elf.setPos(addr); + int nI = elf.readElf32(); + String stabData = elf.dbgStabStr.getName(nI); + int type = elf.readElf8(); + int other = elf.readElf8(); + int desc = elf.readElf16(); + int value = elf.readElf32(); + stabs[i] = new Stab(stabData, type, other, desc, value); + + if (DEBUG) { + System.out.println("Stab: " + Utils.hex8(type) + + " '" + stabData + "' o:" + other + + " d:" + desc + " v:" + value); + } + addr += dbgStab.getEntrySize(); + } + // getStabFiles(); + } + + public StabFile[] getStabFiles() { + ArrayList<StabFile> files = new ArrayList<StabFile>(); + StabFile currentFile = null; + for (int i = 0, n = stabs.length; i < n; i++) { + Stab stab = stabs[i]; + switch(stab.type) { + case N_SO: + if (currentFile == null || currentFile.startAddress != stab.value) { + /* end of file ? */ + currentFile = new StabFile(); + files.add(currentFile); + currentFile.startAddress = stab.value; + currentFile.stabIndex = i; + currentFile.handleStabs(stabs); + System.out.println("Found: " + currentFile); + } + break; + } + } + return files.toArray(new StabFile[files.size()]); + } + + + /* Just pick up file + some other things */ + public DebugInfo getDebugInfo(int address) { + String currentPath = null; + String currentFile = null; + String currentFunction = null; + int lastAddress = 0; + int currentLine = 0; + int currentLineAdr = 0; + for (int i = 0, n = stabs.length; i < n; i++) { + Stab stab = stabs[i]; + switch(stab.type) { + case N_SO: + if (stab.value < address) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + lastAddress = stab.value; + currentFunction = null; + } else { + currentFile = stab.data; + lastAddress = stab.value; + currentFunction = null; + } + } else { + /* requires sorted order of all file entries in stab section */ + if (DEBUG) { + System.out.println("FILE: Already passed address..." + + currentPath + " " + + currentFile + " " + currentFunction); + } + return null; + } + break; + case N_SLINE: + if (currentPath != null) { /* only files with path... */ + if (currentLineAdr < address) { + currentLine = stab.desc; + currentLineAdr = lastAddress + stab.value; + if (currentLineAdr >= address) { + // Finished!!! + if (DEBUG) { + System.out.println("File: " + currentPath + " " + currentFile); + System.out.println("Function: " + currentFunction); + System.out.println("Line No: " + currentLine); + } + return new DebugInfo(currentLine, currentPath, currentFile, + currentFunction); + } + } + } + break; + case N_FUN: + if (stab.value < address) { + currentFunction = stab.data; + lastAddress = stab.value; + } else { + if (DEBUG) { + System.out.println("FUN: Already passed address..."); + } + return null; + } + break; + } + } + return null; + } + + public ArrayList<Integer> getExecutableAddresses() { + ArrayList<Integer> allAddresses = new ArrayList<Integer>(); + + int address = Integer.MAX_VALUE; + + String currentPath = null; + String currentFile = null; + String currentFunction = null; + int lastAddress = 0; +// int currentLine = 0; + int currentLineAdr = 0; + for (Stab stab : stabs) { + switch(stab.type) { + case N_SO: + if (stab.value < address) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + currentFunction = null; + } else { + currentFile = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + currentFunction = null; + } + } else { + /* requires sorted order of all file entries in stab section */ + if (DEBUG) { + System.out.println("FILE: Already passed address..." + + currentPath + " " + + currentFile + " " + currentFunction); + } + return allAddresses; + } + break; + case N_SLINE: + if (currentPath != null) { /* only files with path... */ + if (currentLineAdr < address) { +// currentLine = stab.desc; + currentLineAdr = lastAddress + stab.value; + allAddresses.add(new Integer(currentLineAdr)); + /*if (currentLineAdr >= address) { + // Finished!!! + if (DEBUG) { + System.out.println("File: " + currentPath + " " + currentFile); + System.out.println("Function: " + currentFunction); + System.out.println("Line No: " + currentLine); + } + return new DebugInfo(currentLine, currentPath, currentFile, + currentFunction); + }*/ + } + } + break; + case N_FUN: + if (stab.value < address) { + currentFunction = stab.data; + lastAddress = stab.value; + allAddresses.add(new Integer(lastAddress)); + } else { + if (DEBUG) { + System.out.println("FUN: Already passed address..."); + } + return allAddresses; + } + break; + } + } + return allAddresses; +} + + public String[] getSourceFiles() { + String currentPath = null; + String currentFile = null; + ArrayList<String> sourceFiles = new ArrayList<String>(); + + for (Stab stab : stabs) { + if (stab.type == N_SO) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + } else { + currentFile = stab.data; + + if (currentFile != null && currentFile.length() > 0) { + if (currentPath == null) { + sourceFiles.add(currentFile); + } else { + sourceFiles.add(currentPath + currentFile); + } + } + } + } + } + + String[] sourceFilesArray = new String[sourceFiles.size()]; + for (int i=0; i < sourceFilesArray.length; i++) { + sourceFilesArray[i] = sourceFiles.get(i); + } + + return sourceFilesArray; + } + + public static class Stab { + + public String data; + public int type; + public int other; + public int desc; + public int value; + + Stab(String data, int type, int other, int desc, int value) { + this.data = data; + this.type = type; + this.other = other; + this.desc = desc; + this.value = value; + } + + public String toString() { + return "" + Integer.toHexString(type) + " " + data + + " [" + other + "," + desc + "," + value + "]"; + } + } + +} // StabDebug Modified: mspsim/se/sics/mspsim/debug/StabFile.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFile.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/debug/StabFile.java 2010-08-29 18:36:47 UTC (rev 752) @@ -1,3 +1,42 @@ +/** + * Copyright (c) 2010, 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. + * + * ----------------------------------------------------------------- + * + * StabDebug + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2009 + * Updated : $Date: 2010-07-09 23:22:13 +0200 (Fri, 09 Jul 2010) $ + * $Revision: 717 $ + */ + package se.sics.mspsim.debug; import java.util.ArrayList; @@ -2,8 +41,4 @@ import java.util.HashMap; -import java.util.Iterator; +import se.sics.mspsim.debug.StabDebug.Stab; -import se.sics.mspsim.util.ELFDebug; -import se.sics.mspsim.util.Utils; -import se.sics.mspsim.util.ELFDebug.Stab; - public class StabFile { @@ -24,10 +59,10 @@ public void handleStabs(Stab[] stabs) { int i = stabIndex; while(i < stabs.length) { - ELFDebug.Stab stab = stabs[i]; + StabDebug.Stab stab = stabs[i]; System.out.println("Handling stab: " + stab); switch(stab.type) { - case ELFDebug.N_SO: + case StabDebug.N_SO: if (stab.value != startAddress) { return; } @@ -40,10 +75,10 @@ } i++; break; - case ELFDebug.N_FUN: + case StabDebug.N_FUN: i += addFunction(i, stabs); break; - case ELFDebug.N_LSYM: + case StabDebug.N_LSYM: i += addType(i, stabs); break; default: @@ -90,8 +125,8 @@ } private boolean isParam(Stab stab) { - return (stab.type == ELFDebug.N_REG_PARAM || - stab.type == ELFDebug.N_VAR_PARAM); + return (stab.type == StabDebug.N_REG_PARAM || + stab.type == StabDebug.N_VAR_PARAM); } public String toString() { Modified: mspsim/se/sics/mspsim/debug/StabFunction.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFunction.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/debug/StabFunction.java 2010-08-29 18:36:47 UTC (rev 752) @@ -1,10 +1,9 @@ package se.sics.mspsim.debug; import java.util.ArrayList; +import se.sics.mspsim.util.Utils; +import se.sics.mspsim.debug.StabDebug.Stab; -import se.sics.jipv6.util.Utils; -import se.sics.mspsim.util.ELFDebug.Stab; - public class StabFunction { public String name; Modified: mspsim/se/sics/mspsim/debug/StabType.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabType.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/debug/StabType.java 2010-08-29 18:36:47 UTC (rev 752) @@ -1,9 +1,8 @@ package se.sics.mspsim.debug; import java.util.HashMap; +import se.sics.mspsim.debug.StabDebug.Stab; -import se.sics.mspsim.util.ELFDebug.Stab; - public class StabType { String name; Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-08-29 18:36:47 UTC (rev 752) @@ -49,6 +49,7 @@ import java.util.ArrayList; import se.sics.mspsim.debug.DwarfReader; +import se.sics.mspsim.debug.StabDebug; public class ELF { @@ -75,7 +76,7 @@ int shstrndx; byte[] elfData; - int pos = 0; + private int pos = 0; private ELFSection sections[]; private ELFProgram programs[]; @@ -84,13 +85,13 @@ ELFSection strTable; ELFSection symTable; ELFSection dbgStab; - ELFSection dbgStabStr; + public ELFSection dbgStabStr; ELFDebug debug; public ELF(byte[] data) { elfData = data; - pos = 0; + setPos(0); } /* check if the file exists and is an ELF file */ @@ -132,7 +133,7 @@ throw new ELFException("Illegal encoding: " + elfData[EI_ENCODING]); } - pos += 16; + setPos(getPos() + 16); type = readElf16(); machine = readElf16(); version = readElf32(); @@ -171,12 +172,12 @@ sec.type = readElf32(); sec.flags = readElf32(); sec.addr = readElf32(); - sec.offset = readElf32(); + sec.setOffset(readElf32()); sec.size = readElf32(); sec.link = readElf32(); sec.info = readElf32(); sec.addralign = readElf32(); - sec.entSize = readElf32(); + sec.setEntrySize(readElf32()); sec.elf = this; return sec; } @@ -206,21 +207,21 @@ return sections[index]; } - int readElf32() { - int val = readElf32(pos); - pos += 4; + public int readElf32() { + int val = readElf32(getPos()); + setPos(getPos() + 4); return val; } - int readElf16() { - int val = readElf16(pos); - pos += 2; + public int readElf16() { + int val = readElf16(getPos()); + setPos(getPos() + 2); return val; } - int readElf8() { - int val = readElf16(pos); - pos += 1; + public int readElf8() { + int val = readElf16(getPos()); + setPos(getPos() + 1); return val; } @@ -265,7 +266,7 @@ } private void readSections() { - pos = shoff; + setPos(shoff); sections = new ELFSection[shnum]; for (int i = 0, n = shnum; i < n; i++) { @@ -304,7 +305,7 @@ } private void readPrograms() { - pos = phoff; + setPos(phoff); programs = new ELFProgram[phnum]; for (int i = 0, n = phnum; i < n; i++) { programs[i] = readProgramHeader(); @@ -319,7 +320,7 @@ readPrograms(); readSections(); if (dbgStab != null) { - debug = new ELFDebug(this, dbgStab, dbgStabStr); + debug = new StabDebug(this, dbgStab, dbgStabStr); } } @@ -370,15 +371,15 @@ ELFSection name = sections[symTable.link]; int len = symTable.size; - int count = len / symTable.entSize; - int addr = symTable.offset; + int count = len / symTable.getEntrySize(); + int addr = symTable.getOffset(); String currentFile = ""; if (DEBUG) { System.out.println("Number of symbols:" + count); } int currentAddress = 0; for (int i = 0, n = count; i < n; i++) { - pos = addr; + setPos(addr); int nI = readElf32(); String sn = name.getName(nI); int sAddr = readElf32(); @@ -444,7 +445,7 @@ } } - addr += symTable.entSize; + addr += symTable.getEntrySize(); } return map; @@ -480,7 +481,7 @@ } if (".stab".equals(elf.sections[i].getSectionName()) || ".stabstr".equals(elf.sections[i].getSectionName())) { - int adr = elf.sections[i].offset; + int adr = elf.sections[i].getOffset(); if (DEBUG) { System.out.println(" == Section data =="); } @@ -508,7 +509,16 @@ } - class FileInfo { + public void setPos(int pos) { + this.pos = pos; +} + +public int getPos() { + return pos; +} + + +class FileInfo { String name; int start; int end; Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2010-08-29 18:36:47 UTC (rev 752) @@ -40,270 +40,12 @@ package se.sics.mspsim.util; import java.util.ArrayList; -import se.sics.mspsim.debug.StabFile; +public interface ELFDebug { -public class ELFDebug { + public DebugInfo getDebugInfo(int address); - private Stab[] stabs; + public ArrayList<Integer> getExecutableAddresses(); - public static final int N_FUN = 0x24; - public static final int N_STSYM = 0x26; // Data segment file-scope variable; - public static final int N_LCSYM = 0x28; // BSS segment file-scope variable; - public static final int N_REG_PARAM= 0x40; - public static final int N_VAR_PARAM= 0xa0; - public static final int N_SLINE = 0x44; - public static final int N_SO = 0x64; // filename and path - public static final int N_LSYM = 0x80; // stack var, typdef or struct + public String[] getSourceFiles(); - public static final boolean DEBUG = false; - - ELFSection dbgStab; - ELFSection dbgStabStr; - - public ELFDebug(ELF elf, ELFSection stab, ELFSection stabstr) { - dbgStab = stab; - dbgStabStr = stabstr; - - int len = dbgStab.size; - int count = len / dbgStab.entSize; - int addr = dbgStab.offset; - - if (DEBUG) { - System.out.println("Number of stabs:" + count); - } - stabs = new Stab[count]; - for (int i = 0, n = count; i < n; i++) { - elf.pos = addr; - int nI = elf.readElf32(); - String stabData = elf.dbgStabStr.getName(nI); - int type = elf.readElf8(); - int other = elf.readElf8(); - int desc = elf.readElf16(); - int value = elf.readElf32(); - stabs[i] = new Stab(stabData, type, other, desc, value); - - if (DEBUG) { - System.out.println("Stab: " + Utils.hex8(type) + - " '" + stabData + "' o:" + other - + " d:" + desc + " v:" + value); - } - addr += dbgStab.entSize; - } - // getStabFiles(); - } - - public StabFile[] getStabFiles() { - ArrayList<StabFile> files = new ArrayList<StabFile>(); - StabFile currentFile = null; - for (int i = 0, n = stabs.length; i < n; i++) { - Stab stab = stabs[i]; - switch(stab.type) { - case N_SO: - if (currentFile == null || currentFile.startAddress != stab.value) { - /* end of file ? */ - currentFile = new StabFile(); - files.add(currentFile); - currentFile.startAddress = stab.value; - currentFile.stabIndex = i; - currentFile.handleStabs(stabs); - System.out.println("Found: " + currentFile); - } - break; - } - } - return files.toArray(new StabFile[files.size()]); - } - - - /* Just pick up file + some other things */ - public DebugInfo getDebugInfo(int address) { - String currentPath = null; - String currentFile = null; - String currentFunction = null; - int lastAddress = 0; - int currentLine = 0; - int currentLineAdr = 0; - for (int i = 0, n = stabs.length; i < n; i++) { - Stab stab = stabs[i]; - switch(stab.type) { - case N_SO: - if (stab.value < address) { - if (stab.data != null && stab.data.endsWith("/")) { - currentPath = stab.data; - lastAddress = stab.value; - currentFunction = null; - } else { - currentFile = stab.data; - lastAddress = stab.value; - currentFunction = null; - } - } else { - /* requires sorted order of all file entries in stab section */ - if (DEBUG) { - System.out.println("FILE: Already passed address..." + - currentPath + " " + - currentFile + " " + currentFunction); - } - return null; - } - break; - case N_SLINE: - if (currentPath != null) { /* only files with path... */ - if (currentLineAdr < address) { - currentLine = stab.desc; - currentLineAdr = lastAddress + stab.value; - if (currentLineAdr >= address) { - // Finished!!! - if (DEBUG) { - System.out.println("File: " + currentPath + " " + currentFile); - System.out.println("Function: " + currentFunction); - System.out.println("Line No: " + currentLine); - } - return new DebugInfo(currentLine, currentPath, currentFile, - currentFunction); - } - } - } - break; - case N_FUN: - if (stab.value < address) { - currentFunction = stab.data; - lastAddress = stab.value; - } else { - if (DEBUG) { - System.out.println("FUN: Already passed address..."); - } - return null; - } - break; - } - } - return null; - } - - public ArrayList<Integer> getExecutableAddresses() { - ArrayList<Integer> allAddresses = new ArrayList<Integer>(); - - int address = Integer.MAX_VALUE; - - String currentPath = null; - String currentFile = null; - String currentFunction = null; - int lastAddress = 0; -// int currentLine = 0; - int currentLineAdr = 0; - for (Stab stab : stabs) { - switch(stab.type) { - case N_SO: - if (stab.value < address) { - if (stab.data != null && stab.data.endsWith("/")) { - currentPath = stab.data; - lastAddress = stab.value; - allAddresses.add(new Integer(lastAddress)); - currentFunction = null; - } else { - currentFile = stab.data; - lastAddress = stab.value; - allAddresses.add(new Integer(lastAddress)); - currentFunction = null; - } - } else { - /* requires sorted order of all file entries in stab section */ - if (DEBUG) { - System.out.println("FILE: Already passed address..." + - currentPath + " " + - currentFile + " " + currentFunction); - } - return allAddresses; - } - break; - case N_SLINE: - if (currentPath != null) { /* only files with path... */ - if (currentLineAdr < address) { -// currentLine = stab.desc; - currentLineAdr = lastAddress + stab.value; - allAddresses.add(new Integer(currentLineAdr)); - /*if (currentLineAdr >= address) { - // Finished!!! - if (DEBUG) { - System.out.println("File: " + currentPath + " " + currentFile); - System.out.println("Function: " + currentFunction); - System.out.println("Line No: " + currentLine); - } - return new DebugInfo(currentLine, currentPath, currentFile, - currentFunction); - }*/ - } - } - break; - case N_FUN: - if (stab.value < address) { - currentFunction = stab.data; - lastAddress = stab.value; - allAddresses.add(new Integer(lastAddress)); - } else { - if (DEBUG) { - System.out.println("FUN: Already passed address..."); - } - return allAddresses; - } - break; - } - } - return allAddresses; -} - - public String[] getSourceFiles() { - String currentPath = null; - String currentFile = null; - ArrayList<String> sourceFiles = new ArrayList<String>(); - - for (Stab stab : stabs) { - if (stab.type == N_SO) { - if (stab.data != null && stab.data.endsWith("/")) { - currentPath = stab.data; - } else { - currentFile = stab.data; - - if (currentFile != null && currentFile.length() > 0) { - if (currentPath == null) { - sourceFiles.add(currentFile); - } else { - sourceFiles.add(currentPath + currentFile); - } - } - } - } - } - - String[] sourceFilesArray = new String[sourceFiles.size()]; - for (int i=0; i < sourceFilesArray.length; i++) { - sourceFilesArray[i] = sourceFiles.get(i); - } - - return sourceFilesArray; - } - - public static class Stab { - - public String data; - public int type; - public int other; - public int desc; - public int value; - - Stab(String data, int type, int other, int desc, int value) { - this.data = data; - this.type = type; - this.other = other; - this.desc = desc; - this.value = value; - } - - public String toString() { - return "" + Integer.toHexString(type) + " " + data + - " [" + other + "," + desc + "," + value + "]"; - } - } - } // ELFDebug Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-29 18:09:55 UTC (rev 751) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-29 18:36:47 UTC (rev 752) @@ -79,12 +79,12 @@ int type; int flags; int addr; - int offset; + private int offset; int size; int link; int info; int addralign; - int entSize; + private int entrySize; ELF elf; @@ -111,7 +111,7 @@ } public String getName(int i) { - int pos = offset + i; + int pos = getOffset() + i; StringBuffer sb = new StringBuffer(); char c; while ((c = (char) elf.elfData[pos++]) != 0) { @@ -169,15 +169,15 @@ } public int readElf8(int pos) { - return elf.readElf8(pos + offset); + return elf.readElf8(pos + getOffset()); } public int readElf16(int pos) { - return elf.readElf16(pos + offset); + return elf.readElf16(pos + getOffset()); } public int readElf32(int pos) { - return elf.readElf32(pos + offset); + return elf.readElf32(pos + getOffset()); } public int LEB128Size(long val) { @@ -206,10 +206,26 @@ ((type <= TYPE_DYNSYM) ? " " + typeNames[type] : "") + "\nflags: " + Integer.toString(flags, 16) + "\naddr: " + Integer.toString(addr, 16) + - "\noffset: " + Integer.toString(offset, 16) + + "\noffset: " + Integer.toString(getOffset(), 16) + "\nsize: " + Integer.toString(size, 16) + "\nlink: " + Integer.toString(link, 16) + "\ninfo: " + Integer.toString(info, 16); } +public void setEntrySize(int entrySize) { + this.entrySize = entrySize; +} + +public int getEntrySize() { + return entrySize; +} + +public void setOffset(int offset) { + this.offset = offset; +} + +public int getOffset() { + return offset; +} + } // ELFSection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-29 18:10:01
|
Revision: 751 http://mspsim.svn.sourceforge.net/mspsim/?rev=751&view=rev Author: joxe Date: 2010-08-29 18:09:55 +0000 (Sun, 29 Aug 2010) Log Message: ----------- added more basic dwarf 2.0 support Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java mspsim/se/sics/mspsim/util/ELFSection.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-17 12:24:37 UTC (rev 750) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-29 18:09:55 UTC (rev 751) @@ -1,6 +1,9 @@ package se.sics.mspsim.debug; import java.util.ArrayList; + +import javax.sound.sampled.LineEvent; + import se.sics.mspsim.util.Utils; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.ELFSection; @@ -40,6 +43,9 @@ private int lineFile; private int lineLine; private int lineColumn; + private boolean isBasicBlock = false; + private boolean isStatement = false; + private boolean endSequence = false; private ArrayList<Arange> aranges = new ArrayList<Arange>(); @@ -70,7 +76,7 @@ int proLen = sec.readElf32(); int minOpLen = sec.readElf8(); - int isStmt = sec.readElf8(); + int defaultIsStmt = sec.readElf8(); int lineBase = sec.readElf8(); int lineRange = sec.readElf8(); int opcodeBase = sec.readElf8(); @@ -79,6 +85,13 @@ System.out.println("Line total length: " + totLen); System.out.println("Line pro length: " + proLen); System.out.println("Line version: " + version); + + if (lineBase > 127) { + lineBase = lineBase - 256; + } + System.out.println("Line base : " + lineBase); + System.out.println("Line range : " + lineRange); + System.out.println("Line - Opcode base: " + opcodeBase); /* first char of includes (skip opcode lens)... */ for (int i = 0; i < opcodeBase - 1; i++) { @@ -124,17 +137,81 @@ System.out.println("Line: position: " + sec.getPosition()); System.out.println("Line: first bytes of the machine: "); System.out.print("Line: "); - for (int i = 0; i < 20; i++) { + isStatement = defaultIsStmt != 0; + for (int i = 0; i < 100; i++) { int ins = sec.readElf8(); System.out.print(Utils.hex8(ins) + " "); switch(ins) { case DW_LNS_EXT: /* extended instruction */ + int len = sec.readElf8(); + int extIns = sec.readElf8(); + switch(extIns) { + case DW_LNE_end_sequence: + endSequence = true; + System.out.println("Line: End sequence executed!!!"); + break; + case DW_LNE_define_file: + System.out.println("Line: Should define a file!!!!"); + break; + case DW_LNE_set_address: + if (len == 2) + lineAddress = sec.readElf8(); + if (len == 3) + lineAddress = sec.readElf16(); + if (len == 5) + lineAddress = sec.readElf32(); + System.out.println("Line: Set address to: " + Utils.hex16(lineAddress) + + " (len: " + len + ")"); + break; + } break; - case DW_LNS_advance_line: + case DW_LNS_copy: + /* copy data to matrix... */ + isBasicBlock = false; break; case DW_LNS_advance_pc: + long add = sec.readLEB128(); + lineAddress += add * minOpLen; + System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); break; + case DW_LNS_advance_line: + long addLine = sec.readLEB128S(); + lineLine += addLine; + System.out.println("Line: Increased line to: " + lineLine + + " (incr: " + addLine + ")"); + break; + case DW_LNS_set_file: + lineFile = (int) sec.readLEB128(); + System.out.println("Line: Set file to: " + lineFile); + break; + case DW_LNS_set_column: + lineColumn = (int) sec.readLEB128(); + break; + case DW_LNS_negate_stmt: + isStatement = !isStatement; + System.out.println("Line: Negated is statement"); + break; + case DW_LNS_set_basic_block: + isBasicBlock = true; + System.out.println("Line: Set basic block to true"); + break; + case DW_LNS_const_add_pc: + System.out.println("Line: Should add const to PC - but how much?"); + break; + case DW_LNS_fixed_advance_pc: + int incr = sec.readElf16(); + lineAddress += incr; + System.out.println("Line: Increased address to: " + Utils.hex16(lineAddress)); + break; + default: + + int lineInc = lineBase + ((ins - opcodeBase) % lineRange); + int addrInc = (ins - opcodeBase) / lineRange; + lineAddress += addrInc * minOpLen; + lineLine += lineInc; + System.out.println("Line: *** Special operation => addr: " + + Utils.hex16(lineAddress) + " Line: " + lineLine + " lineInc: " + lineInc); } } System.out.println(); Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-17 12:24:37 UTC (rev 750) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-29 18:09:55 UTC (rev 751) @@ -148,7 +148,26 @@ } while ((b & 128) != 0); return val; } - + + public long readLEB128S() { + long val = 0; + /* LSB first always? */ + int b; + int bitPos = 0; + do { + b = readElf8(pos++); + val = val + ((b & 127) << bitPos); + bitPos += 7; + } while ((b & 128) != 0); + long negval = 0x1 << bitPos; + if (b < 0x40) + return val; + else { + System.out.println("Line: read negative : " + val + " negval: " + negval); + return -(negval - val); + } + } + public int readElf8(int pos) { return elf.readElf8(pos + offset); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-17 12:24:44
|
Revision: 750 http://mspsim.svn.sourceforge.net/mspsim/?rev=750&view=rev Author: joxe Date: 2010-08-17 12:24:37 +0000 (Tue, 17 Aug 2010) Log Message: ----------- added elf read methods Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELFSection.java Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-16 14:04:06 UTC (rev 749) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-17 12:24:37 UTC (rev 750) @@ -88,6 +88,8 @@ ELF elf; + int pos = 0; + public String getSectionName() { if (elf.strTable != null) { return elf.strTable.getName(name); @@ -96,6 +98,14 @@ } } + public void reset() { + pos = 0; + } + + public int getPosition() { + return pos; + } + public int getSize() { return size; } @@ -110,6 +120,35 @@ return sb.toString(); } + public int readElf8() { + return readElf8(pos++); + } + + public int readElf16() { + int val = readElf16(pos); + pos += 2; + return val; + } + + public int readElf32() { + int val = readElf32(pos); + pos += 4; + return val; + } + + public long readLEB128() { + long val = 0; + /* LSB first always? */ + int b; + int bitPos = 0; + do { + b = readElf8(pos++); + val = val + ((b & 127) << bitPos); + bitPos += 7; + } while ((b & 128) != 0); + return val; + } + public int readElf8(int pos) { return elf.readElf8(pos + offset); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-16 14:04:12
|
Revision: 749 http://mspsim.svn.sourceforge.net/mspsim/?rev=749&view=rev Author: joxe Date: 2010-08-16 14:04:06 +0000 (Mon, 16 Aug 2010) Log Message: ----------- added more dwarf reading code Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-13 10:16:37 UTC (rev 748) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-16 14:04:06 UTC (rev 749) @@ -1,7 +1,6 @@ package se.sics.mspsim.debug; import java.util.ArrayList; - import se.sics.mspsim.util.Utils; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.ELFSection; @@ -9,6 +8,8 @@ public class DwarfReader { /* Operands for lines */ + public static final int DW_LNS_EXT = 0; + public static final int DW_LNS_copy = 1; public static final int DW_LNS_advance_pc = 2; public static final int DW_LNS_advance_line = 3; @@ -19,6 +20,11 @@ public static final int DW_LNS_const_add_pc = 8; public static final int DW_LNS_fixed_advance_pc = 9; + /* Extended operands (preceded by DW_LNS_EXT + len) */ + public static final int DW_LNE_end_sequence = 1; + public static final int DW_LNE_set_address = 2; + public static final int DW_LNE_define_file = 3; + ELF elfFile; class Arange { @@ -58,16 +64,16 @@ private void readLines(ELFSection sec) { System.out.println("DWARF Line - ELF Section length: " + sec.getSize()); int pos = 0; + sec.reset(); + int totLen = sec.readElf32(); + int version = sec.readElf16(); + int proLen = sec.readElf32(); + int minOpLen = sec.readElf8(); - int totLen = sec.readElf32(pos + 0); - int version = sec.readElf16(pos + 4); - int proLen = sec.readElf32(pos + 6); - int minOpLen = sec.readElf8(pos + 10); - - int isStmt = sec.readElf8(pos + 11); - int lineBase = sec.readElf8(pos + 12); - int lineRange = sec.readElf8(pos + 13); - int opcodeBase = sec.readElf8(pos + 14); + int isStmt = sec.readElf8(); + int lineBase = sec.readElf8(); + int lineRange = sec.readElf8(); + int opcodeBase = sec.readElf8(); System.out.println("Line total length: " + totLen); @@ -75,15 +81,24 @@ System.out.println("Line version: " + version); /* first char of includes (skip opcode lens)... */ - pos = pos + 15 + opcodeBase - 1; + for (int i = 0; i < opcodeBase - 1; i++) { + sec.readElf8(); + } + +// pos = pos + 15 + opcodeBase - 1; +// System.out.println("Line pos = " + pos + " sec-pos = " + sec.getPosition()); System.out.println("Line --- include files ---"); + ArrayList<String> directories = new ArrayList<String>(); + directories.add("./"); + ArrayList<String> files = new ArrayList<String>(); StringBuilder sb = new StringBuilder(); /* if first char is zero => no more include directories... */ int c; - while ((c = sec.readElf8(pos++)) != 0) { + while ((c = sec.readElf8()) != 0) { sb.append((char)c); - while((c = sec.readElf8(pos++)) != 0) sb.append((char) c); + while((c = sec.readElf8()) != 0) sb.append((char) c); System.out.println("Line: include file: " + sb.toString()); + directories.add(sb.toString()); sb.setLength(0); } @@ -91,25 +106,38 @@ long dirIndex = 0; long time = 0; long size = 0; - while ((c = sec.readElf8(pos++)) != 0) { + while ((c = sec.readElf8()) != 0) { sb.append((char)c); - while((c = sec.readElf8(pos++)) != 0) sb.append((char) c); - /* TODO: maybe move pos to the ELF section for easy and safe reading? */ - dirIndex = sec.readLEB128(pos); - pos += sec.LEB128Size(dirIndex); - time = sec.readLEB128(pos); - pos += sec.LEB128Size(time); - size = sec.readLEB128(pos); - pos += sec.LEB128Size(size); + while((c = sec.readElf8()) != 0) sb.append((char) c); + dirIndex = sec.readLEB128(); + time = sec.readLEB128(); + size = sec.readLEB128(); System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); - + files.add(directories.get((int) dirIndex) + sb.toString()); sb.setLength(0); } - - - System.out.println(); + /* Now we should have entered the position of the "code" for generating the + * line <=> address table + */ + System.out.println("Line: position: " + sec.getPosition()); + System.out.println("Line: first bytes of the machine: "); + System.out.print("Line: "); + for (int i = 0; i < 20; i++) { + int ins = sec.readElf8(); + System.out.print(Utils.hex8(ins) + " "); + switch(ins) { + case DW_LNS_EXT: + /* extended instruction */ + break; + case DW_LNS_advance_line: + break; + case DW_LNS_advance_pc: + break; + } + } + System.out.println(); } /* DWARF - address ranges information */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2010-08-13 10:16:43
|
Revision: 748 http://mspsim.svn.sourceforge.net/mspsim/?rev=748&view=rev Author: fros4943 Date: 2010-08-13 10:16:37 +0000 (Fri, 13 Aug 2010) Log Message: ----------- set debug false Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-08-13 10:14:21 UTC (rev 747) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-08-13 10:16:37 UTC (rev 748) @@ -56,7 +56,7 @@ private static final int EI_ENCODING = 5; private static final int[] MAGIC = new int[] {0x7f, 'E', 'L', 'F'}; - public static final boolean DEBUG = true;//false; + public static final boolean DEBUG = false; boolean encMSB = true; @@ -282,7 +282,9 @@ /* Find sections */ for (int i = 0, n = shnum; i < n; i++) { String name = sections[i].getSectionName(); - System.out.println("ELF-Section: " + name); + if (DEBUG) { + System.out.println("ELF-Section: " + name); + } if (".stabstr".equals(name)) { dbgStabStr = sections[i]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2010-08-13 10:14:27
|
Revision: 747 http://mspsim.svn.sourceforge.net/mspsim/?rev=747&view=rev Author: fros4943 Date: 2010-08-13 10:14:21 +0000 (Fri, 13 Aug 2010) Log Message: ----------- added support for channel listeners Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-08-10 10:14:47 UTC (rev 746) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-08-13 10:14:21 UTC (rev 747) @@ -680,6 +680,12 @@ autoCRC = (data & ADR_AUTOCRC) != 0; autoAck = (data & AUTOACK) != 0; break; + case REG_FSCTRL: + if (cl != null) { + updateActiveFrequency(); + cl.changedChannel(activeChannel); + } + break; } } @@ -1223,6 +1229,14 @@ listener = rf; } + public interface ChannelListener { + public void changedChannel(int channel); + } + private ChannelListener cl = null; + public void setChannelListener(ChannelListener cl) { + this.cl = cl; + } + public void setVRegOn(boolean newOn) { if(on == newOn) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-10 10:14:54
|
Revision: 746 http://mspsim.svn.sourceforge.net/mspsim/?rev=746&view=rev Author: joxe Date: 2010-08-10 10:14:47 +0000 (Tue, 10 Aug 2010) Log Message: ----------- added more DWARF file reading Modified Paths: -------------- mspsim/se/sics/mspsim/debug/DwarfReader.java mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/ELFSection.java Modified: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-09 19:50:19 UTC (rev 745) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-10 10:14:47 UTC (rev 746) @@ -8,6 +8,17 @@ public class DwarfReader { + /* Operands for lines */ + public static final int DW_LNS_copy = 1; + public static final int DW_LNS_advance_pc = 2; + public static final int DW_LNS_advance_line = 3; + public static final int DW_LNS_set_file = 4; + public static final int DW_LNS_set_column = 5; + public static final int DW_LNS_negate_stmt = 6; + public static final int DW_LNS_set_basic_block = 7; + public static final int DW_LNS_const_add_pc = 8; + public static final int DW_LNS_fixed_advance_pc = 9; + ELF elfFile; class Arange { @@ -18,6 +29,12 @@ int segmentSize; } + /* some state for the line number handling */ + private int lineAddress; + private int lineFile; + private int lineLine; + private int lineColumn; + private ArrayList<Arange> aranges = new ArrayList<Arange>(); @@ -29,12 +46,72 @@ for (int i = 0; i < elfFile.getSectionCount(); i++) { ELFSection sec = elfFile.getSection(i); String name = sec.getSectionName(); + System.out.println("DWARF Section: " + name); if (".debug_aranges".equals(name)) { readAranges(sec); + } else if (".debug_line".equals(name)) { + readLines(sec); } } } + private void readLines(ELFSection sec) { + System.out.println("DWARF Line - ELF Section length: " + sec.getSize()); + int pos = 0; + + int totLen = sec.readElf32(pos + 0); + int version = sec.readElf16(pos + 4); + int proLen = sec.readElf32(pos + 6); + int minOpLen = sec.readElf8(pos + 10); + + int isStmt = sec.readElf8(pos + 11); + int lineBase = sec.readElf8(pos + 12); + int lineRange = sec.readElf8(pos + 13); + int opcodeBase = sec.readElf8(pos + 14); + + + System.out.println("Line total length: " + totLen); + System.out.println("Line pro length: " + proLen); + System.out.println("Line version: " + version); + + /* first char of includes (skip opcode lens)... */ + pos = pos + 15 + opcodeBase - 1; + System.out.println("Line --- include files ---"); + StringBuilder sb = new StringBuilder(); + /* if first char is zero => no more include directories... */ + int c; + while ((c = sec.readElf8(pos++)) != 0) { + sb.append((char)c); + while((c = sec.readElf8(pos++)) != 0) sb.append((char) c); + System.out.println("Line: include file: " + sb.toString()); + sb.setLength(0); + } + + System.out.println("Line --- source files ---"); + long dirIndex = 0; + long time = 0; + long size = 0; + while ((c = sec.readElf8(pos++)) != 0) { + sb.append((char)c); + while((c = sec.readElf8(pos++)) != 0) sb.append((char) c); + /* TODO: maybe move pos to the ELF section for easy and safe reading? */ + dirIndex = sec.readLEB128(pos); + pos += sec.LEB128Size(dirIndex); + time = sec.readLEB128(pos); + pos += sec.LEB128Size(time); + size = sec.readLEB128(pos); + pos += sec.LEB128Size(size); + + System.out.println("Line: source file: " + sb.toString() + " dir: " + dirIndex + " size: " + size); + + sb.setLength(0); + } + + + + System.out.println(); + } + /* DWARF - address ranges information */ private void readAranges(ELFSection sec) { System.out.println("DWARF Aranges - ELF Section length: " + sec.getSize()); Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-08-09 19:50:19 UTC (rev 745) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-08-10 10:14:47 UTC (rev 746) @@ -289,7 +289,8 @@ if (".stab".equals(name)) { dbgStab = sections[i]; } - if (".debug_aranges".equals(name)) { + if (".debug_aranges".equals(name) || + ".debug_line".equals(name)) { readDwarf = true; } } Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-09 19:50:19 UTC (rev 745) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-10 10:14:47 UTC (rev 746) @@ -122,7 +122,25 @@ return elf.readElf32(pos + offset); } + public int LEB128Size(long val) { + /* at least one byte, but possibly more */ + return (int) (1 + (val / 128)); + } + + public long readLEB128(int pos) { + long val = 0; + /* LSB first always? */ + int b; + int bitPos = 0; + do { + b = readElf8(pos++); + val = val + ((b & 127) << bitPos); + bitPos += 7; + } while ((b & 128) != 0); + return val; + } + public String toString() { String nameStr = getSectionName(); return "name: " + nameStr + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-08-09 19:50:25
|
Revision: 745 http://mspsim.svn.sourceforge.net/mspsim/?rev=745&view=rev Author: joxe Date: 2010-08-09 19:50:19 +0000 (Mon, 09 Aug 2010) Log Message: ----------- added initial dwarf 2.0 support Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/ELFSection.java Added Paths: ----------- mspsim/se/sics/mspsim/debug/DwarfReader.java Added: mspsim/se/sics/mspsim/debug/DwarfReader.java =================================================================== --- mspsim/se/sics/mspsim/debug/DwarfReader.java (rev 0) +++ mspsim/se/sics/mspsim/debug/DwarfReader.java 2010-08-09 19:50:19 UTC (rev 745) @@ -0,0 +1,71 @@ +package se.sics.mspsim.debug; + +import java.util.ArrayList; + +import se.sics.mspsim.util.Utils; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.ELFSection; + +public class DwarfReader { + + ELF elfFile; + + class Arange { + int length; + int version; + int offset; + int addressSize; + int segmentSize; + } + + private ArrayList<Arange> aranges = new ArrayList<Arange>(); + + + public DwarfReader(ELF elfFile) { + this.elfFile = elfFile; + } + + public void read() { + for (int i = 0; i < elfFile.getSectionCount(); i++) { + ELFSection sec = elfFile.getSection(i); + String name = sec.getSectionName(); + if (".debug_aranges".equals(name)) { + readAranges(sec); + } + } + } + + /* DWARF - address ranges information */ + private void readAranges(ELFSection sec) { + System.out.println("DWARF Aranges - ELF Section length: " + sec.getSize()); + int pos = 0; + int index = 0; + do { + Arange arange = new Arange(); + /* here we should read the address data */ + arange.length = sec.readElf32(pos + 0); /* length not including the length field */ + arange.version = sec.readElf16(pos + 4); /* version */ + arange.offset = sec.readElf32(pos + 6); /* 4 byte offset into debug_info section (?)*/ + arange.addressSize = sec.readElf8(pos + 10); /* size of address */ + arange.segmentSize = sec.readElf8(pos + 11); /* size of segment descriptor */ + System.out.println("DWARF: aranges no " + index); + System.out.println("DWARF: Length: " + arange.length); + System.out.println("DWARF: Version: " + arange.version); + System.out.println("DWARF: Offset: " + arange.offset); + System.out.println("DWARF: Address size: " + arange.addressSize); + + index++; + pos += 12; + if (arange.addressSize == 2) { + /* these needs to be added too! */ + int addr, len; + do { + addr = sec.readElf16(pos); + len = sec.readElf16(pos + 2); + pos += 4; + System.out.println("DWARF: ($" + Utils.hex16(addr) + "," + len + ")"); + } while (addr != 0 || len != 0); + } + } while (pos < sec.getSize()); + } +} Property changes on: mspsim/se/sics/mspsim/debug/DwarfReader.java ___________________________________________________________________ Added: svn:executable + * Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-07-19 22:36:51 UTC (rev 744) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-08-09 19:50:19 UTC (rev 745) @@ -48,13 +48,15 @@ import java.io.InputStream; import java.util.ArrayList; +import se.sics.mspsim.debug.DwarfReader; + public class ELF { private static final int EI_NIDENT = 16; private static final int EI_ENCODING = 5; private static final int[] MAGIC = new int[] {0x7f, 'E', 'L', 'F'}; - public static final boolean DEBUG = false; + public static final boolean DEBUG = true;//false; boolean encMSB = true; @@ -196,12 +198,33 @@ return pHeader; } -// public ELFSection getSection(int pos) { -// sec.name = getElf32(pos); -// pos += 4; -// } + public int getSectionCount() { + return shnum; + } + public ELFSection getSection(int index) { + return sections[index]; + } + int readElf32() { + int val = readElf32(pos); + pos += 4; + return val; + } + + int readElf16() { + int val = readElf16(pos); + pos += 2; + return val; + } + + int readElf8() { + int val = readElf16(pos); + pos += 1; + return val; + } + + int readElf32(int pos) { int b = 0; if (encMSB) { b = (elfData[pos++] & 0xff) << 24 | @@ -217,7 +240,7 @@ return b; } - int readElf16() { + int readElf16(int pos) { int b = 0; if (encMSB) { b = ((elfData[pos++] & 0xff) << 8) | @@ -229,7 +252,7 @@ return b; } - int readElf8() { + int readElf8(int pos) { return elfData[pos++] & 0xff; } @@ -255,15 +278,25 @@ } } + boolean readDwarf = false; /* Find sections */ for (int i = 0, n = shnum; i < n; i++) { - if (".stabstr".equals(sections[i].getSectionName())) { + String name = sections[i].getSectionName(); + System.out.println("ELF-Section: " + name); + if (".stabstr".equals(name)) { dbgStabStr = sections[i]; } - if (".stab".equals(sections[i].getSectionName())) { + if (".stab".equals(name)) { dbgStab = sections[i]; } + if (".debug_aranges".equals(name)) { + readDwarf = true; + } } + if (readDwarf) { + DwarfReader dwarf = new DwarfReader(this); + dwarf.read(); + } } Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2010-07-19 22:36:51 UTC (rev 744) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2010-08-09 19:50:19 UTC (rev 745) @@ -96,6 +96,10 @@ } } + public int getSize() { + return size; + } + public String getName(int i) { int pos = offset + i; StringBuffer sb = new StringBuffer(); @@ -106,6 +110,19 @@ return sb.toString(); } + public int readElf8(int pos) { + return elf.readElf8(pos + offset); + } + + public int readElf16(int pos) { + return elf.readElf16(pos + offset); + } + + public int readElf32(int pos) { + return elf.readElf32(pos + offset); + } + + public String toString() { String nameStr = getSectionName(); return "name: " + nameStr + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 22:36:57
|
Revision: 744 http://mspsim.svn.sourceforge.net/mspsim/?rev=744&view=rev Author: nifi Date: 2010-07-19 22:36:51 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Fixed sysinfo to not depend on ArgumentManager Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-19 22:17:21 UTC (rev 743) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-19 22:36:51 UTC (rev 744) @@ -53,7 +53,6 @@ import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430Constants; import se.sics.mspsim.core.TimeEvent; -import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.ConfigManager; import se.sics.mspsim.util.PluginRepository; @@ -400,7 +399,7 @@ handler.registerCommand("sysinfo", new BasicCommand("show info about the MSPSim system", "[-registry] [-config]") { public int executeCommand(CommandContext context) { - ArgumentManager config = (ArgumentManager) registry.getComponent("config"); + ConfigManager config = (ConfigManager) registry.getComponent("config"); context.out.println("--------- System info ----------\n"); context.out.println("MSPSim version: " + MSP430Constants.VERSION); context.out.println("Java version : " + System.getProperty("java.version") + " " + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 22:17:27
|
Revision: 743 http://mspsim.svn.sourceforge.net/mspsim/?rev=743&view=rev Author: nifi Date: 2010-07-19 22:17:21 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Updated CPU heat map to use Managed Window instead of JFrame Modified Paths: -------------- mspsim/se/sics/mspsim/cli/ProfilerCommands.java mspsim/se/sics/mspsim/ui/CPUHeatMap.java Modified: mspsim/se/sics/mspsim/cli/ProfilerCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2010-07-19 15:36:34 UTC (rev 742) +++ mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2010-07-19 22:17:21 UTC (rev 743) @@ -47,6 +47,7 @@ import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.Profiler; import se.sics.mspsim.ui.CPUHeatMap; +import se.sics.mspsim.ui.WindowManager; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.SimpleProfiler; @@ -55,7 +56,7 @@ */ public class ProfilerCommands implements CommandBundle { - public void setupCommands(ComponentRegistry registry, CommandHandler ch) { + public void setupCommands(final ComponentRegistry registry, CommandHandler ch) { final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); if (cpu != null) { ch.registerCommand("profile", new BasicCommand("show profile information", @@ -227,13 +228,23 @@ } }); - ch.registerCommand("readmap", new BasicCommand("read map", "") { + ch.registerCommand("readmap", new BasicAsyncCommand("read map", "") { + private CPUHeatMap hm; + public int executeCommand(CommandContext context) { - CPUHeatMap hm = new CPUHeatMap(); + hm = new CPUHeatMap((WindowManager) registry.getComponent(WindowManager.class)); cpu.setGlobalMonitor(hm); return 0; - } - }); + } + + public void stopCommand(CommandContext context) { + if (hm != null) { + cpu.setGlobalMonitor(null); + hm.close(); + hm = null; + } + } + }); } } Modified: mspsim/se/sics/mspsim/ui/CPUHeatMap.java =================================================================== --- mspsim/se/sics/mspsim/ui/CPUHeatMap.java 2010-07-19 15:36:34 UTC (rev 742) +++ mspsim/se/sics/mspsim/ui/CPUHeatMap.java 2010-07-19 22:17:21 UTC (rev 743) @@ -1,5 +1,6 @@ package se.sics.mspsim.ui; +import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -8,7 +9,6 @@ import java.awt.image.BufferedImage; import javax.swing.JComponent; -import javax.swing.JFrame; import javax.swing.Timer; import se.sics.mspsim.core.CPUMonitor; @@ -20,7 +20,7 @@ private Timer ticker; - private JFrame window; + private ManagedWindow window; private BufferedImage heatmap; private int[] heatR = new int[MSP430Core.MAX_MEM]; private int[] heatW = new int[MSP430Core.MAX_MEM]; @@ -28,11 +28,11 @@ private int heatMax = 0; private int mode = 1; - public CPUHeatMap() { - window = new JFrame("CPU Heat Map"); + public CPUHeatMap(WindowManager windowManager) { + window = windowManager.createWindow("CPU Heat Map"); heatmap = new BufferedImage(128, 512, BufferedImage.TYPE_INT_RGB); - window.setBounds(100, 100, 140, 530); - window.setVisible(true); + setPreferredSize(new Dimension(140, 530)); + setOpaque(true); window.add(this); ticker = new Timer(50, new ActionListener() { @@ -41,16 +41,29 @@ } }); ticker.start(); - window.addKeyListener(new KeyAdapter() { + + setFocusable(true); + addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent ke) { - System.out.println("Key pressed: " + ke.getKeyChar()); if (ke.getKeyChar() == 'm') { mode = mode ^ 1; } } }); + + window.setVisible(true); } + public void close() { + if (ticker != null) { + ticker.stop(); + } + if (window != null) { + window.setVisible(false); + window = null; + } + } + public void updateImage() { double factor = 250.0 / heatMax; switch (mode) { @@ -113,5 +126,5 @@ heatMax = val; } } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 15:36:40
|
Revision: 742 http://mspsim.svn.sourceforge.net/mspsim/?rev=742&view=rev Author: nifi Date: 2010-07-19 15:36:34 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Make sure all commands exit if first command in a chain is not asynchronous Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/Target.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2010-07-19 15:14:14 UTC (rev 741) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2010-07-19 15:36:34 UTC (rev 742) @@ -101,7 +101,10 @@ commands[index].stopCommand(); } return 1; - } else if (pid >= 0) { + } else if (pid < 0) { + // The first command is not asynchronous. Make sure all commands have stopped. + exitCommands(commands); + } else { boolean exited = false; for (int i = 0; i < commands.length && !exited; i++) { if (commands[i].hasExited()) { Modified: mspsim/se/sics/mspsim/cli/Target.java =================================================================== --- mspsim/se/sics/mspsim/cli/Target.java 2010-07-19 15:14:14 UTC (rev 741) +++ mspsim/se/sics/mspsim/cli/Target.java 2010-07-19 15:36:34 UTC (rev 742) @@ -116,10 +116,12 @@ public void removeContext(CommandContext context) { boolean close = false; synchronized (targets) { - if (contexts != null && contexts.remove(context)) { - if (DEBUG) { - System.out.println("Target: removed writer from " + if (contexts != null) { + if (contexts.remove(context)) { + if (DEBUG) { + System.out.println("Target: removed writer from " + name + " (" + contexts.size() + ')'); + } } if (contexts.size() == 0) { close = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 15:14:20
|
Revision: 741 http://mspsim.svn.sourceforge.net/mspsim/?rev=741&view=rev Author: nifi Date: 2010-07-19 15:14:14 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Use default location if no previous location exists Modified Paths: -------------- mspsim/se/sics/mspsim/ui/WindowUtils.java Modified: mspsim/se/sics/mspsim/ui/WindowUtils.java =================================================================== --- mspsim/se/sics/mspsim/ui/WindowUtils.java 2010-07-19 12:53:27 UTC (rev 740) +++ mspsim/se/sics/mspsim/ui/WindowUtils.java 2010-07-19 15:14:14 UTC (rev 741) @@ -97,6 +97,7 @@ window.pack(); } } else { + window.setLocationByPlatform(true); window.pack(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 12:53:34
|
Revision: 740 http://mspsim.svn.sourceforge.net/mspsim/?rev=740&view=rev Author: nifi Date: 2010-07-19 12:53:27 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Minor cleanup Modified Paths: -------------- mspsim/se/sics/mspsim/ui/ChartPanel.java Modified: mspsim/se/sics/mspsim/ui/ChartPanel.java =================================================================== --- mspsim/se/sics/mspsim/ui/ChartPanel.java 2010-07-19 12:40:54 UTC (rev 739) +++ mspsim/se/sics/mspsim/ui/ChartPanel.java 2010-07-19 12:53:27 UTC (rev 740) @@ -45,7 +45,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; -import java.util.ArrayList; import java.util.Hashtable; import javax.swing.BorderFactory; @@ -53,6 +52,8 @@ import javax.swing.JFrame; import javax.swing.border.Border; +import se.sics.mspsim.util.ArrayUtils; + /** * */ @@ -71,9 +72,8 @@ private static final Color LIGHT_GRAY = new Color(0xff909090); - private ArrayList<Chart> charts = new ArrayList<Chart>(); private Hashtable<String,Object> config = new Hashtable<String,Object>(); - private Chart[] chartCache = null; + private Chart[] charts = null; private Chart axisChart; @@ -96,29 +96,27 @@ } public synchronized void addChart(Chart chart) { - charts.add(chart); - chartCache = null; + charts = (Chart[]) ArrayUtils.add(Chart.class, charts, chart); } public synchronized void removeChart(Chart chart) { - charts.remove(chart); - chartCache = null; + charts = (Chart[]) ArrayUtils.remove(charts, chart); } - public synchronized Chart getChart(String name) { - for (int i = 0, n = charts.size(); i < n; i++) { - if (name.equals(charts.get(i).getName())) { - return charts.get(i); + public Chart getChart(String name) { + Chart[] charts = this.charts; + if (charts != null) { + for (int i = 0, n = charts.length; i < n; i++) { + if (name.equals(charts[i].getName())) { + return charts[i]; + } } } return null; } - public synchronized Chart[] getCharts() { - if (chartCache == null) { - chartCache = charts.toArray(new Chart[charts.size()]); - } - return chartCache; + public Chart[] getCharts() { + return charts; } public Object getConfig(String param) { @@ -178,7 +176,7 @@ g.drawRect(-1, -1, width + 2, height + 2); Chart[] chs = getCharts(); - if (chs.length > 0) { + if (chs != null && chs.length > 0) { double totMaxY = Double.MIN_VALUE, totMinY = Double.MAX_VALUE; double totMaxX = Double.MIN_VALUE, totMinX = Double.MAX_VALUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 12:41:00
|
Revision: 739 http://mspsim.svn.sourceforge.net/mspsim/?rev=739&view=rev Author: nifi Date: 2010-07-19 12:40:54 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Minor cleanup of command output Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-19 12:34:58 UTC (rev 738) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2010-07-19 12:40:54 UTC (rev 739) @@ -45,7 +45,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; -import java.util.Hashtable; import java.util.regex.Pattern; import se.sics.mspsim.chip.RFListener; @@ -67,8 +66,6 @@ */ public class MiscCommands implements CommandBundle { - private Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); - public void setupCommands(final ComponentRegistry registry, CommandHandler handler) { handler.registerCommand("grep", new BasicLineCommand("print lines matching the specified pattern", "[-i] [-v] <regexp>") { private PrintStream out; @@ -121,7 +118,6 @@ } }); - handler.registerCommand("speed", new BasicCommand("set the speed factor for the CPU", "[factor]") { public int executeCommand(CommandContext context) { MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); @@ -129,9 +125,7 @@ context.err.println("could not access the CPU."); return 1; } else if (context.getArgumentCount() == 0) { - long rate = cpu.getSleepRate(); - double d = rate / 25000.0; - context.out.println("Speed factor is set to " + (((int)(d * 100 + 0.5)) / 100.0)); + /* No speed specified. Simply show current speed. */ } else { double d = context.getArgumentAsDouble(0); if (d > 0.0) { @@ -142,6 +136,9 @@ return 1; } } + long rate = cpu.getSleepRate(); + double d = rate / 25000.0; + context.out.println("Speed factor is set to " + (((int)(d * 100 + 0.5)) / 100.0)); return 0; } }); @@ -306,7 +303,6 @@ } catch (Exception e1) { e1.printStackTrace(context.err); } - // TODO Auto-generated method stub return 1; } }); @@ -355,7 +351,7 @@ } }); - handler.registerCommand("rflistener", new BasicLineCommand("an rflisteer", "[input|output] <rf-chip>") { + handler.registerCommand("rflistener", new BasicLineCommand("an rflistener", "<input|output> <rf-chip>") { CommandContext context; RFListener listener; final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); @@ -363,28 +359,40 @@ this.context = ctx; String inout = context.getArgument(0); Chip chip = cpu.getChip(context.getArgument(1)); + if (chip == null) { + context.err.println("Error: could not find chip '" + context.getArgument(1) + '\''); + return 1; + } if ("output".equals(inout)) { if (chip instanceof RFSource) { - ((RFSource)chip).setRFListener(new RFListener(){ + ((RFSource)chip).setRFListener(new RFListener() { public void receivedByte(byte data) { - context.out.println("" + Utils.hex8(data)); + context.out.println(Utils.hex8(data)); } - }); + }); + } else { + context.err.println("Error: chip is not an RF source"); + return 1; } } else if ("input".equals(inout)){ listener = (RFListener) chip; } else { context.err.println("Error: illegal type: " + inout); + return 1; } return 0; } + public void lineRead(String line) { if (listener != null) { byte[] data = Utils.hexconv(line); - context.out.println("Should send bytes to radio: " + line); - for (int i = 0; i < data.length; i++) { - //context.out.println("Byte " + i + " = " + ((int) data[i] & 0xff)); - listener.receivedByte(data[i]); + if (data != null) { + context.out.println("RFListener: to radio: " + line); + for (int i = 0; i < data.length; i++) { + listener.receivedByte(data[i]); + } + } else { + context.out.println("RFListener: " + line); } } } @@ -397,8 +405,8 @@ context.out.println("MSPSim version: " + MSP430Constants.VERSION); context.out.println("Java version : " + System.getProperty("java.version") + " " + System.getProperty("java.vendor")); - context.out.println("Firmware : " + config.getProperty("firmwareFile")); - context.out.println("AutoloadScript: " + config.getProperty("autoloadScript")); + context.out.println("Firmware : " + config.getProperty("firmwareFile", "-")); + context.out.println("AutoloadScript: " + config.getProperty("autoloadScript", "-")); context.out.println(); if (context.getOption("registry")) { context.out.println("--------- Registry info --------\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-07-19 12:35:04
|
Revision: 738 http://mspsim.svn.sourceforge.net/mspsim/?rev=738&view=rev Author: nifi Date: 2010-07-19 12:34:58 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Added warning when command 'symbol' finds no matching symbols + minor cleanup Modified Paths: -------------- mspsim/se/sics/mspsim/cli/DebugCommands.java Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2010-07-19 12:26:00 UTC (rev 737) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2010-07-19 12:34:58 UTC (rev 738) @@ -205,26 +205,19 @@ } }); - ch.registerCommand("clear", new Command() { + ch.registerCommand("clear", new BasicCommand("clear a breakpoint or watch from a given address or symbol", "<address or symbol>") { public int executeCommand(final CommandContext context) { int baddr = context.getArgumentAsAddress(0); cpu.setBreakPoint(baddr, null); return 0; } - - public String getArgumentHelp(String commandName) { - return "<address or symbol>"; - } - - public String getCommandHelp(String commandName) { - return "clear a breakpoint or watch from a given address or symbol"; - } }); ch.registerCommand("symbol", new BasicCommand("list matching symbols", "<regexp>") { public int executeCommand(final CommandContext context) { String regExp = context.getArgument(0); MapEntry[] entries = context.getMapTable().getEntries(regExp); + boolean found = false; for (int i = 0; i < entries.length; i++) { MapEntry mapEntry = entries[i]; int address = mapEntry.getAddress(); @@ -232,7 +225,11 @@ Utils.hex16(address) + " (" + Utils.hex8(cpu.memory[address]) + " " + Utils.hex8(cpu.memory[address + 1]) + ") " + mapEntry.getType() + " in file " + mapEntry.getFile()); + found = true; } + if (!found) { + context.err.println("Could not find any symbols matching '" + regExp + '\''); + } return 0; } }); @@ -290,7 +287,6 @@ ch.registerCommand("stepmicro", new BasicCommand("single the CPU specified no micros", "<micro skip> <micro step>") { public int executeCommand(CommandContext context) { - int nr = context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1; long cyc = cpu.cycles; if (cpu.isRunning()) { context.err.println("Can not single step when emulation is running."); @@ -308,7 +304,6 @@ } }); - ch.registerCommand("stack", new BasicCommand("show stack info", "") { public int executeCommand(CommandContext context) { int stackEnd = context.getMapTable().heapStartAddress; @@ -323,15 +318,14 @@ int adr = context.getArgumentAsAddress(0); if (adr != -1) { try { - context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.read(adr, adr >= 0x100))); + context.out.println(context.getArgument(0) + " = $" + Utils.hex16(cpu.read(adr, adr >= 0x100))); } catch (Exception e) { - e.printStackTrace(context.out); + e.printStackTrace(context.err); } return 0; - } else { - context.err.println("unknown symbol: " + context.getArgument(0)); - return 1; } + context.err.println("unknown symbol: " + context.getArgument(0)); + return 1; } }); ch.registerCommand("printreg", new BasicCommand("print value of an register", "<register>") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |