From 5a1dbda3c3968612d548ac157c5e2ad79166a30d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 25 Aug 2015 00:42:01 +0200 Subject: [PATCH] Add gdb pretty-printer for TileCoords. --- tools/gdb/libdoorkeeper.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/gdb/libdoorkeeper.py b/tools/gdb/libdoorkeeper.py index faf94f4..811dd6f 100644 --- a/tools/gdb/libdoorkeeper.py +++ b/tools/gdb/libdoorkeeper.py @@ -3,13 +3,26 @@ import re; class VectorWrapperPrinter: def __init__(self, parVal): - self.val = parVal + self.val = parVal; def to_string(self): sz = int(self.val["m_wrapped"].type.template_argument(1)); arr_vals = ", ".join(str(self.val["m_wrapped"]["_M_elems"][z]) for z in range(0, sz)); return "<{0}>".format(arr_vals); + def display_hint(self): + return "array"; + +class TileCoordsPrinter: + def __init__(self, parVal): + self.val = parVal; + + def to_string(self): + return "{{m_pos = {0}, m_size = {1} (upper)}}".format(self.val["m_pos"], self.val["m_size"]); + + def display_hint(self): + return "map"; + def vector_wrapper_match(parVal): tag_value = str(parVal.type.strip_typedefs().tag); if tag_value == None: @@ -17,21 +30,13 @@ def vector_wrapper_match(parVal): reg_vecbase = re.compile("^vwr::implem::VecBase<.*>$"); reg_vec = re.compile("^vwr::Vec<.*>$"); + reg_tilecoords = re.compile("^dk::TileCoords<.*>$"); if reg_vecbase.match(tag_value) or reg_vec.match(tag_value): return VectorWrapperPrinter(parVal); + elif reg_tilecoords.match(tag_value): + return TileCoordsPrinter(parVal); else: return None; -def display_hint(self): - return "array"; - def register_printers(parObjfile): parObjfile.pretty_printers.append(vector_wrapper_match); - -# (gdb) p parFrom -# $1 = (const dk::Viewport<2u>::coords &) @0x7fffffffb810: { >> = {m_wrapped = {_M_elems = {0, -# 0}}}, , 2u>> = {, true>> = {}, }, static unit_x = , static unit_y = } - -# (gdb) p parFrom -# $1 = (const dk::Viewport<2u>::coords &) @0x7fffffffb810: { >> = -# {0, 0}, , 2u>> = {, true>> = {}, }, static unit_x = , static unit_y = }