commit fc092082c67da5e85770c3a71c5288584e5d1f99
parent 7b9be9e0a8fbed15d4d1afb4d788543718ef3e79
Author: Tizian Leonhardt <tizianleonhardt@web.de>
Date: Fri, 5 Feb 2021 13:54:01 +0100
Add rk-debug to toggle debug messages; set pagination off to avoid system stalls
Diffstat:
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/project/extract_sizeret.py b/project/extract_sizeret.py
@@ -35,6 +35,8 @@ mem_map = {}
size_at_entry = None
+debug = False
+
class PrintMem(gdb.Command):
def __init__(self):
super(PrintMem, self).__init__("rk-print-mem", gdb.COMMAND_DATA)
@@ -50,6 +52,17 @@ class PrintMem(gdb.Command):
PrintMem()
+class RKDebug(gdb.Command):
+ def __init__(self):
+ super(RKDebug, self).__init__("rk-debug", gdb.COMMAND_USER)
+
+ def invoke(self, arg, from_tty):
+ global debug
+ debug = not debug
+ print(f"Debug messages set to {debug}")
+
+RKDebug()
+
class EntryExitBreakpoint(gdb.Breakpoint):
def __init__(self, b):
@@ -79,7 +92,10 @@ class EntryExitBreakpoint(gdb.Breakpoint):
(size, address) = extret
mem_map[address] = (type, size, caller)
- print("Allocating ", (type, size, caller))
+
+ if debug:
+ print("Allocating ", (type, size, caller))
+
return False
def extract(self, frame):
@@ -128,6 +144,7 @@ class FreeBreakpoint(gdb.Breakpoint):
def stop(self):
global mem_map
global free_funcs
+ global debug
frame = gdb.newest_frame()
@@ -140,7 +157,8 @@ class FreeBreakpoint(gdb.Breakpoint):
return False
if x in mem_map:
- print("Freeing ", mem_map[x])
+ if debug:
+ print("Freeing ", mem_map[x])
mem_map.pop(x)
return False
@@ -156,6 +174,8 @@ class Stage3():
global exits
global types
+ gdb.execute("set pagination off")
+
with open(self.dictfile, 'r') as dct:
types = json.load(dct)