- Debugged more PrettyPrinters, all implemented thus far work in testing
- Fixed implementation of tuple.h, TODO: Still need to complete - Wrote a PrettyPrinter for tuple.h
This commit is contained in:
@@ -24,6 +24,7 @@ import gdb
|
||||
from . import containers
|
||||
from . import strings
|
||||
from . import memory
|
||||
from . import utility
|
||||
|
||||
def register_printers(obj):
|
||||
gdb.printing.register_pretty_printer(obj, containers.printer)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import gdb
|
||||
import re
|
||||
from collections import deque
|
||||
from . import utility
|
||||
|
||||
# OPTIONAL =============================================================================================================
|
||||
class OptionalPrinter:
|
||||
@@ -34,7 +35,7 @@ class OptionalPrinter:
|
||||
else:
|
||||
return "{ empty }"
|
||||
|
||||
# OPTIONAL =============================================================================================================
|
||||
# PAIR =================================================================================================================
|
||||
class PairPrinter:
|
||||
"""Print a fennec::optional"""
|
||||
|
||||
@@ -48,8 +49,28 @@ class PairPrinter:
|
||||
return ("first", self.val['first']), ("second", self.val['second'])
|
||||
|
||||
|
||||
# TUPLE ================================================================================================================
|
||||
|
||||
class TuplePrinter:
|
||||
"""Print a fennec::tuple"""
|
||||
|
||||
def __init__(self, val):
|
||||
self.fields = val.type.fields()[0].type.fields()
|
||||
self.elems = val
|
||||
self.count = len(self.fields)
|
||||
|
||||
def to_string(self):
|
||||
return " { size = " + str(len(self.fields)) + " }"
|
||||
|
||||
def children(self):
|
||||
return (('[{}]'.format(i), self.elems.cast(self.fields[i].type)['value']) for i in range(self.count))
|
||||
|
||||
|
||||
|
||||
# ARRAY ================================================================================================================
|
||||
class ArrayPrinter:
|
||||
"""Print a fennec::array"""
|
||||
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
@@ -66,6 +87,8 @@ class ArrayPrinter:
|
||||
|
||||
# DYNARRAY =============================================================================================================
|
||||
class DynArrayPrinter:
|
||||
"""Print a fennec::dynarray"""
|
||||
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
@@ -201,6 +224,7 @@ class RDTreePrinter:
|
||||
# SET ==================================================================================================================
|
||||
|
||||
class SetPrinter:
|
||||
"""Print a fennec::set"""
|
||||
|
||||
class Iterator:
|
||||
def __init__(self, table, capacity):
|
||||
@@ -244,6 +268,7 @@ class SetPrinter:
|
||||
# MAP ==================================================================================================================
|
||||
|
||||
class MapPrinter:
|
||||
"""Print a fennec::map"""
|
||||
|
||||
class Iterator:
|
||||
def __init__(self, table, capacity):
|
||||
@@ -272,12 +297,12 @@ class MapPrinter:
|
||||
|
||||
if not self.move:
|
||||
self.move = True
|
||||
return ('key' + str(i), key)
|
||||
return 'key' + str(i), key
|
||||
else:
|
||||
self.move = False
|
||||
self.index = self.index + 1
|
||||
self.node = self.node + 1
|
||||
return ('value' + str(i), val)
|
||||
return 'value' + str(i), val
|
||||
|
||||
def __init__(self, val):
|
||||
self.table = val['_set']['_alloc']['_data']
|
||||
@@ -303,6 +328,7 @@ def register_printers():
|
||||
pp = gdb.printing.RegexpCollectionPrettyPrinter("fennec::containers")
|
||||
pp.add_printer('optional', '^fennec::optional<.*>$', OptionalPrinter)
|
||||
pp.add_printer('pair', '^fennec::pair<.*>$', PairPrinter)
|
||||
pp.add_printer('tuple', '^fennec::tuple<.*>$', TuplePrinter)
|
||||
pp.add_printer('array', '^fennec::array<.*>$', ArrayPrinter)
|
||||
pp.add_printer('dynarray', '^fennec::dynarray<.*>$', DynArrayPrinter)
|
||||
pp.add_printer('list', '^fennec::list<.*>$', ListPrinter)
|
||||
|
||||
20
gdb/fennec/utility.py
Normal file
20
gdb/fennec/utility.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# ======================================================================================================================
|
||||
# fennec, a free and open source game engine
|
||||
# Copyright © 2025 Medusa Slockbower
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
# ======================================================================================================================
|
||||
|
||||
def printMembers(obj):
|
||||
print(str(dir(obj)))
|
||||
Reference in New Issue
Block a user