Author: DerekRhodes
Date: 2008-03-15 23:34:34 -0400 (Sat, 15 Mar 2008)
New Revision: 1149

Modified:
   trunk/pysoy/debug/debug_build.py
Log:
now printfs manual lock_acquire and lock_release statements

Modified: trunk/pysoy/debug/debug_build.py
===================================================================
--- trunk/pysoy/debug/debug_build.py    2008-03-16 02:29:20 UTC (rev 1148)
+++ trunk/pysoy/debug/debug_build.py    2008-03-16 03:34:34 UTC (rev 1149)
@@ -49,11 +49,14 @@
       nextLine  = Line(line, lineNum, self.filePath, self.curScope)
 
       self.buffer.append(nextLine.make_thread_line())        
+      lineType  = nextLine.get_line_type()
 
-      if nextLine.get_line_type() == 'cond':
+      if lineType == 'cond':
         self.buffer.append(nextLine.make_cond_line())
-      else:
+      if lineType == 'def' or lineType == 'cdef':
         self.buffer.append(nextLine.make_func_line())
+      if lineType == 'lock':
+        self.buffer.append(nextLine.make_lock_line())
           
   def build_outText(self):
     self.buffer   = map(str, self.buffer)
@@ -82,8 +85,9 @@
   def make_whitespace(self):
     for char in self.text:
       if char != ' ': 
+        if self.is_lock(): return
         self.whitespace += '  '
-        break
+        return
       self.whitespace += ' '
 
   def line_valid(self):           # can't print funcs with multiline args... 
yet
@@ -93,6 +97,7 @@
     return True
 
   def get_line_type(self):
+    if self.is_lock():        return 'lock'
     if not self.line_valid(): return False
     if self.is_cond():        return 'cond'
     if self.is_cdef():        return 'cdef'
@@ -100,12 +105,17 @@
     return False
     
   def is_cond(self):
-    if    self.stripped[0:2]   == 'if':    return True
-    if    self.stripped[0:3]   == 'for':   return True
-    if    self.stripped[0:4]   == 'elif':  return True
-    if    self.stripped[0:5]   == 'while': return True
+    if self.stripped[0:2]   == 'if':    return True
+    if self.stripped[0:3]   == 'for':   return True
+    if self.stripped[0:4]   == 'elif':  return True
+    if self.stripped[0:5]   == 'while': return True
     return False
-
+  
+  def is_lock(self):
+    if "py.PyThread_acquire_lock" in self.stripped: return True
+    if "py.PyThread_release_lock" in self.stripped: return True  
+    return False
+    
   def is_cdef(self):
     if self.stripped[0:4] == "cdef": return True
     return False
@@ -115,27 +125,32 @@
     return False
   
   def make_thread_line(self):
-    threadingMask = 'stdio.printf("%sThread ID: Python GIL, ")' 
+    threadingMask = 'stdio.printf("%sThread ID: Python GIL, ")#autogen' 
     threadingInfo = threadingMask % self.lineNum
     if self.curScope  == 'cdef':               #Print threading information 
also
-      threadingMask = r'stdio.printf("%sThread ID:%s 
,",<long>py.PyThread_get_thread_ident())'
+      threadingMask = r'stdio.printf("%sThread ID:%s 
,",<long>py.PyThread_get_thread_ident())#autogen'
       threadingInfo = threadingMask % (self.lineNum, '%d')   # snuck the '%d' 
in
     newLine = self.whitespace + threadingInfo + '\n'
     return newLine
     
   def make_func_line(self):
-    mask = '%sstdio.printf("%s: %s\\n") #autogen\n'
     lineText  = self.stripped.split('(')[0]
-    newLine = mask % (self.whitespace, self.filePath, lineText)
-    return newLine
+    return self.build_line(lineText)    
 
   def make_cond_line(self):
-    mask = '%sstdio.printf("%s: %s\\n")#autogen\n'
     lineText  = self.stripped
-    newLine = mask % ( self.whitespace, self.filePath, lineText)
+    return self.build_line(lineText)
+    
+  def make_lock_line(self):
+    lineText  = self.stripped
+    return self.build_line(lineText)
+    
+  def build_line(self, lineText):
+    mask = '%sstdio.printf("%s: %s\\n")#autogen\n'    
+    newLine = mask % (self.whitespace, self.filePath, lineText)    
     return newLine
-
-
+    
+        
 class Augmentator(object):
   def __init__(self, rootDir):
     self.rootDir  = rootDir
@@ -164,7 +179,7 @@
   msg = """\
 
+------------------------------------------------------------------------------+
 | debug_build.py                                                               
|
-| ------------------                                                           
|
++------------------------------------------------------------------------------|
 |  This program inserts printf statements in *.pxi files at the following      
|
 |  locations:                                                                  
|
 |  @ the def and cdef function heads                                           
|

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to