From c9f1de89341dcd3e5df7d2be19989ca58576bd3f Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 4 Dec 2020 09:58:14 +0000 Subject: [PATCH] added gdbinit file that does pretty-print of bounded_vector --- .gdbinit | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gdbinit diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 000000000..ac1495abc --- /dev/null +++ b/.gdbinit @@ -0,0 +1,34 @@ + +############################################ +# Pretty-Printers +############################################ + +python +###### srslte::bounded_vector ######## + +class BoundedVectorPrinter(object): + def __init__(self, val): + self.val = val + self.value_type = self.val.type.template_argument(0) + + def children(self): + start = self.val['buffer'].cast(self.value_type.pointer()) + length = int(self.val['size_']) + for idx in range(length): + yield f'[{idx}]', start[idx] + + def to_string(self): + length = int(self.val['size_']) + capacity = int(self.val.type.template_argument(1)) + return f'bounded_vector of length {length}, capacity {capacity}' + + def display_hint(self): + return 'array' + + @staticmethod + def make(val): + if str(val.type).startswith('srslte::bounded_vector<'): + return BoundedVectorPrinter(val) + +gdb.pretty_printers.append(BoundedVectorPrinter.make) +end