- Implemented file.h and path.h PrettyPrinter
This commit is contained in:
@@ -25,8 +25,10 @@ from . import containers
|
||||
from . import strings
|
||||
from . import memory
|
||||
from . import utility
|
||||
from . import filesystem
|
||||
|
||||
def register_printers(obj):
|
||||
gdb.printing.register_pretty_printer(obj, containers.printer)
|
||||
gdb.printing.register_pretty_printer(obj, strings.printer)
|
||||
gdb.printing.register_pretty_printer(obj, memory.printer)
|
||||
gdb.printing.register_pretty_printer(obj, memory.printer)
|
||||
gdb.printing.register_pretty_printer(obj, filesystem.printer)
|
||||
@@ -17,9 +17,7 @@
|
||||
# ======================================================================================================================
|
||||
|
||||
import gdb
|
||||
import re
|
||||
from collections import deque
|
||||
from . import utility
|
||||
|
||||
# OPTIONAL =============================================================================================================
|
||||
class OptionalPrinter:
|
||||
@@ -326,15 +324,15 @@ class MapPrinter:
|
||||
def register_printers():
|
||||
print("registering containers")
|
||||
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)
|
||||
pp.add_printer('rdtree', '^fennec::rdtree<.*>$', RDTreePrinter)
|
||||
pp.add_printer('set', '^fennec::set<.*>$', SetPrinter)
|
||||
pp.add_printer('map', '^fennec::map<.*>$', MapPrinter)
|
||||
pp.add_printer('fennec::optional', '^fennec::optional<.*>$', OptionalPrinter)
|
||||
pp.add_printer('fennec::pair', '^fennec::pair<.*>$', PairPrinter)
|
||||
pp.add_printer('fennec::tuple', '^fennec::tuple<.*>$', TuplePrinter)
|
||||
pp.add_printer('fennec::array', '^fennec::array<.*>$', ArrayPrinter)
|
||||
pp.add_printer('fennec::dynarray', '^fennec::dynarray<.*>$', DynArrayPrinter)
|
||||
pp.add_printer('fennec::list', '^fennec::list<.*>$', ListPrinter)
|
||||
pp.add_printer('fennec::rdtree', '^fennec::rdtree<.*>$', RDTreePrinter)
|
||||
pp.add_printer('fennec::set', '^fennec::set<.*>$', SetPrinter)
|
||||
pp.add_printer('fennec::map', '^fennec::map<.*>$', MapPrinter)
|
||||
return pp
|
||||
|
||||
printer = register_printers()
|
||||
|
||||
60
gdb/fennec/filesystem.py
Normal file
60
gdb/fennec/filesystem.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# ======================================================================================================================
|
||||
# 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/>.
|
||||
# ======================================================================================================================
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
# PATH =================================================================================================================
|
||||
class PathPrinter:
|
||||
def __init__(self, val):
|
||||
self.val = val['_str']['_str']
|
||||
|
||||
def to_string(self):
|
||||
value = "\"" + self.val['_data'].string('', 'replace', self.val['_capacity'] - 1) + "\""
|
||||
return value
|
||||
|
||||
def display_hint(self):
|
||||
return 'string'
|
||||
|
||||
|
||||
# PATH =================================================================================================================
|
||||
class FilePrinter:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
self.path = val['_path']['_str']['_str']
|
||||
|
||||
def to_string(self):
|
||||
if self.val['_handle']:
|
||||
value = "{ path = \"" + self.path['_data'].string('', 'replace', self.path['_capacity'] - 1) + "\" }"
|
||||
return value
|
||||
return "{ closed }"
|
||||
|
||||
def display_hint(self):
|
||||
return 'string'
|
||||
|
||||
|
||||
# GDB Code =============================================================================================================
|
||||
|
||||
def register_printers():
|
||||
print("registering filesystem")
|
||||
pp = gdb.printing.RegexpCollectionPrettyPrinter("fennec::filesystem")
|
||||
pp.add_printer('fennec::path', '^fennec::path$', PathPrinter)
|
||||
pp.add_printer('fennec::file', '^fennec::file$', FilePrinter)
|
||||
return pp
|
||||
|
||||
printer = register_printers()
|
||||
@@ -17,7 +17,6 @@
|
||||
# ======================================================================================================================
|
||||
|
||||
import gdb
|
||||
import re
|
||||
|
||||
# ALLOCATION ===========================================================================================================
|
||||
class AllocationPrinter:
|
||||
@@ -38,7 +37,7 @@ class AllocationPrinter:
|
||||
def register_printers():
|
||||
print("registering memory")
|
||||
pp = gdb.printing.RegexpCollectionPrettyPrinter("fennec::memory")
|
||||
pp.add_printer('allocation', '^fennec::allocation<.*>$', AllocationPrinter)
|
||||
pp.add_printer('fennec::allocation', '^fennec::allocation<.*>$', AllocationPrinter)
|
||||
return pp
|
||||
|
||||
printer = register_printers()
|
||||
@@ -17,7 +17,6 @@
|
||||
# ======================================================================================================================
|
||||
|
||||
import gdb
|
||||
import re
|
||||
|
||||
# CSTRING ==============================================================================================================
|
||||
class CStringPrinter:
|
||||
@@ -53,10 +52,10 @@ class StringPrinter:
|
||||
def register_printers():
|
||||
print("registering strings")
|
||||
pp = gdb.printing.RegexpCollectionPrettyPrinter("fennec::strings")
|
||||
pp.add_printer('cstring', '^fennec::cstring$', CStringPrinter)
|
||||
pp.add_printer('wcstring', '^fennec::wcstring$', CStringPrinter)
|
||||
pp.add_printer('string', '^fennec::_string<.*>$', StringPrinter)
|
||||
pp.add_printer('wstring', '^fennec::_wstring<.*>$', StringPrinter)
|
||||
pp.add_printer('fennec::cstring', '^fennec::cstring$', CStringPrinter)
|
||||
pp.add_printer('fennec::wcstring', '^fennec::wcstring$', CStringPrinter)
|
||||
pp.add_printer('fennec::string', '^fennec::_string<.*>$', StringPrinter)
|
||||
pp.add_printer('fennec::wstring', '^fennec::_wstring<.*>$', StringPrinter)
|
||||
return pp
|
||||
|
||||
printer = register_printers()
|
||||
Reference in New Issue
Block a user