CVS: python msp430-ram-usage.py,1.5,1.6

"Chris Liechti" <[email protected]> Tue, 10 Feb 2009 16:29:27 +0000
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv25008/python

Modified Files:
	msp430-ram-usage.py 
Log Message:
add stack size check option, which will exit the tool with exit code set != 0 if its not within range

Index: msp430-ram-usage.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430-ram-usage.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- msp430-ram-usage.py	3 Jun 2008 10:21:37 -0000	1.5
+++ msp430-ram-usage.py	10 Feb 2009 16:29:23 -0000	1.6
@@ -15,13 +15,31 @@
 from optparse import OptionParser
 
 parser = OptionParser()
-parser.add_option("-d", "--detailed", dest="detailed", default=False,
-    help="print a detailed list of labels", action="store_true")
-parser.add_option("-c", "--compact", dest="compact", default=False,
-    help="print a compact list of used bytes", action="store_true")
+
+parser.add_option("-d", "--detailed",
+    dest = "detailed", default=False,
+    help = "print a detailed list of labels",
+    action = "store_true"
+)
+parser.add_option("-c", "--compact",
+    dest = "compact",
+    default = False,
+    help = "print a compact list of used bytes",
+    action = "store_true"
+)
 parser.add_option("-q", "--quiet",
-    action="store_false", dest="verbose", default=True,
-    help="don't print status messages to stdout")
+    action = "store_false",
+    dest = "verbose",
+    default = True,
+    help = "don't print status messages to stdout"
+)
+parser.add_option("--min-stack",
+    action = "store",
+    dest = "min_stack",
+    type = "int",
+    default = None,
+    help = "fail if free space for stack is not as large as this"
+)
 
 (options, args) = parser.parse_args()
 
@@ -29,7 +47,6 @@
     parser.error("missing object file name")
 
 
-
 # regexp to parse lines like the following one
 #   959: 000002aa     0 OBJECT  GLOBAL DEFAULT    6 rxdata
 re_obj = re.compile(r':[ \t]+([0-9a-f]+)[ \t]+([0-9a-f]+)[ \t]+(\w+)[ \t]+.* (.*)$')
@@ -96,6 +113,7 @@
 while address >= objs['__data_start'][0] and not mmap.has_key(address):
     address -= 1
     stackmem += 1
+
 # calc total and print summary
 size = objs['__stack'][0] - objs['__data_start'][0]
 print 'RAM usage summary:'
@@ -103,3 +121,8 @@
 print 'the stack can grow up to %d bytes (continous memory at end of RAM)' % (
     stackmem & 0xfffe   #round size, even number
 )
+
+if options.min_stack is not None:
+    if (stackmem & 0xfffe) < options.min_stack:
+        print "ERROR: Stack size is smaller than the given value (--min-stack=%d)" % (options.min_stack,)
+        sys.exit(2)


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com