|
@@ -9,6 +9,7 @@ def parse_memory_trace(input_file, output_file):
|
|
|
active_memory_requests = {}
|
|
|
|
|
|
malloc_pattern = re.compile(r'dmmlib - m (0x\w+) (\d+)')
|
|
|
+ realloc_pattern = re.compile(r'dmmlib - r (0x\w+) (0x\w+) (\d+)')
|
|
|
free_pattern = re.compile(r'dmmlib - f (0x\w+)')
|
|
|
|
|
|
for line in input_file:
|
|
@@ -20,6 +21,16 @@ 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)
|
|
|
+
|
|
|
+ realloc_match = realloc_pattern.search(line)
|
|
|
+ if realloc_match:
|
|
|
+ if realloc_match.group(2) not in active_memory_requests:
|
|
|
+ active_memory_requests[realloc_match.group(2)] = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(6))
|
|
|
+ variable_declaration = ''.join([' void *var_', active_memory_requests[realloc_match.group(2)], ';\n'])
|
|
|
+ output_file.write(variable_declaration)
|
|
|
+ new_line = ''.join([' var_', active_memory_requests[realloc_match.group(2)], ' = realloc(', realloc_match.group(1), ', ', realloc_match.group(3), ');\n'])
|
|
|
+ output_file.write(new_line)
|
|
|
+
|
|
|
free_match = free_pattern.search(line)
|
|
|
if free_match:
|
|
|
if free_match.group(1) in active_memory_requests:
|