From 93e9a51589346d672c6e91bb9ca0ab5b81420eac Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 31 Mar 2024 20:50:49 +0100 Subject: [PATCH] Add 'Rank' GDB pretty-printing --- utils/gdb/seer_pretty_printers.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/utils/gdb/seer_pretty_printers.py b/utils/gdb/seer_pretty_printers.py index 78efca0..aec66d6 100644 --- a/utils/gdb/seer_pretty_printers.py +++ b/utils/gdb/seer_pretty_printers.py @@ -78,6 +78,25 @@ class File(enum.IntEnum): return self.name.title() +class Rank(enum.IntEnum): + """ + Python representation of a 'seer::board::rank::Rank' raw value. + """ + + # Should be kept in sync with the enum in `rank.rs` + First = 0 + Second = 1 + Third = 2 + Fourth = 3 + Fifth = 4 + Sixth = 5 + Seventh = 6 + Eighth = 7 + + def __str__(self): + return self.name.title() + + class SquarePrinter(object): "Print a seer::board::square::Square" @@ -118,6 +137,16 @@ class FilePrinter(object): return str(self._val) +class RankPrinter(object): + "Print a seer::board::rank::Rank" + + def __init__(self, val): + self._val = Rank(int(val)) + + def to_string(self): + return str(self._val) + + def build_pretty_printer(): pp = gdb.printing.RegexpCollectionPrettyPrinter('seer') @@ -125,6 +154,7 @@ def build_pretty_printer(): pp.add_printer('Bitboard', '^seer::board::bitboard::Bitboard$', BitboardPrinter) pp.add_printer('Color', '^seer::board::color::Color$', ColorPrinter) pp.add_printer('File', '^seer::board::file::File$', FilePrinter) + pp.add_printer('Rank', '^seer::board::rank::Rank$', RankPrinter) return pp