Browse Source

generate_c_testbench: search the whole line for the trace message

Ioannis Koutras 12 years ago
parent
commit
a901b6515e
1 changed files with 5 additions and 5 deletions
  1. 5 5
      scripts/generate_c_testbench.py

+ 5 - 5
scripts/generate_c_testbench.py

@@ -8,11 +8,11 @@ import string
 def parse_memory_trace(input_file, output_file):
     active_memory_requests = {}
 
-    malloc_pattern = re.compile(r'^dmmlib - m (0x\w+) (\d+)')
-    free_pattern   = re.compile(r'^dmmlib - f (0x\w+)')
+    malloc_pattern = re.compile(r'dmmlib - m (0x\w+) (\d+)')
+    free_pattern   = re.compile(r'dmmlib - f (0x\w+)')
 
     for line in input_file:
-        malloc_match = malloc_pattern.match(line)
+        malloc_match = malloc_pattern.search(line)
         if malloc_match:
             if malloc_match.group(1) not in active_memory_requests:
                 active_memory_requests[malloc_match.group(1)] = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(6))
@@ -20,14 +20,14 @@ def parse_memory_trace(input_file, output_file):
                 output_file.write(variable_declaration)
             new_line = ''.join(['    var_', active_memory_requests[malloc_match.group(1)], ' = malloc(', malloc_match.group(2), ');\n'])
             output_file.write(new_line)
-        free_match = free_pattern.match(line)
+        free_match = free_pattern.search(line)
         if free_match:
             if free_match.group(1) in active_memory_requests:
                 new_line = ''.join(['    free(var_', active_memory_requests[free_match.group(1)], ');\n'])
                 del active_memory_requests[free_match.group(1)]
                 output_file.write(new_line)
             else:
-                print "Warning: free call without an actual malloc"
+                print "Warning: free call without an actual allocation beforehands"
 
     input_file.close()