DoorKeeper/tools/gdb/libdoorkeeper.py

42 lines
1.2 KiB
Python

import gdb;
import re;
class VectorWrapperPrinter:
def __init__(self, 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:
return None;
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 register_printers(parObjfile):
parObjfile.pretty_printers.append(vector_wrapper_match);