summary history branches tags files
commit:c7f90747fc66393117dd33df552f3146ee308f90
author:mrmekon
committer:mrmekon
date:Mon Nov 12 11:14:48 2012 -0500
parents:b7dce3993a500c2ad3b10d693e12c30fa1bab1a1
Don't barf on spaces in command line arguments.  Check for ELF file before giving it to microchip's libraries.
diff --git a/mdb/picdebugger.py b/mdb/picdebugger.py
line changes: +0/-1
index dd4e47d..ac8454c
--- a/mdb/picdebugger.py
+++ b/mdb/picdebugger.py
@@ -137,7 +137,6 @@ class picdebugger(com.microchip.mplab.util.observers.Observer):
     def load(self, file):
         # Load ELF file onto target
         self.loader = self.assembly.getLookup().lookup(Loader)
-        print "Loading ELF file..."
         try:
             self.loader.Load(file)
             self.mdb.Program(Debugger.PROGRAM_OPERATION.AUTO_SELECT)

diff --git a/picdb.py b/picdb.py
line changes: +12/-2
index 31c505c..48053b2
--- a/picdb.py
+++ b/picdb.py
@@ -69,14 +69,23 @@ Drops to a Python prompt for debug-level introspection.
 Usage: debug
 '''
         pdb.set_trace()
-            
+
     def cmdLoad(self, args):
         '''
 Load an ELF file onto target board.
 Usage: load <file>
 <file> can be a full absolute path, or relative to the working directory.
 '''
-        self.dbg.load(args)
+        fullpath = args
+        if fullpath[0] != '/':
+            cwd = os.getcwd()
+            path = args if args[0:2] != "./" else args[2:]
+            fullpath = cwd + "/" + path
+        self.log.info("Loading ELF: %s" % fullpath)
+        if not os.path.exists(fullpath):
+            self.log.error("File does not exist.")
+            return
+        self.dbg.load(fullpath)
         self.log.info("Resetting target...")
         self.dbg.reset()
         pc = self.dbg.getPC()
@@ -315,6 +324,7 @@ if __name__ == "__main__":
                       help="Debug script to execute.")
     (options, args) = parser.parse_args()
 
+
     interp = CommandInterpreter()
     if hasattr(options, "target"):
         interp.executeCommand("connect %s" % options.target)

diff --git a/picdb.sh b/picdb.sh
line changes: +1/-1
index 7fc6b6a..1712a97
--- a/picdb.sh
+++ b/picdb.sh
@@ -1,5 +1,5 @@
 MPLAB_JAR_PATH=/Applications/microchip/mplabx/mplab_ipe.app/Contents/Resources/Java/lib
 JAVAARGS=
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-CLASSPATH=$(echo "$MPLAB_JAR_PATH/"*.jar | tr ' ' ':') jython $JAVAARGS "$DIR"/picdb.py $@
+CLASSPATH=$(echo "$MPLAB_JAR_PATH/"*.jar | tr ' ' ':') jython $JAVAARGS "$DIR"/picdb.py "$@"