GDB: apply ast pretty printing to specialized structures (#17884)

The `ZendAstPrettyPrinter` had logic to handle the various structures that are
based on `zend_ast`, like `zend_ast_decl`, but the printer was only installed
when the value was a `zend_ast`, meaning that for the specialized structures
the details wouldn't be shown unless they were cast (in GDB) to `zend_ast`.
Instead, just register the printer for the specialized structures too.
This commit is contained in:
DanielEScherzer 2025-02-25 00:17:14 -08:00 committed by GitHub
parent cc116067b2
commit 0b42749621
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -156,7 +156,11 @@ class ZendAstKindPrettyPrinter(gdb.printing.PrettyPrinter):
pp_set.add_printer('zend_ast_kind', '^zend_ast_kind$', ZendAstKindPrettyPrinter)
class ZendAstPrettyPrinter(gdb.printing.PrettyPrinter):
"Print a zend_ast"
"""
Print a zend_ast, or one of the specialized structures based on it:
zend_ast_decl, zend_ast_list, zend_ast_op_array, zend_ast_zval, or
zend_ast_znode
"""
def __init__(self, val):
self.val = val
@ -229,6 +233,11 @@ class ZendAstPrettyPrinter(gdb.printing.PrettyPrinter):
pp_set.add_printer('zend_ast', '^_zend_ast$', ZendAstPrettyPrinter)
pp_set.add_printer('zend_ast_decl', '^_zend_ast_decl$', ZendAstPrettyPrinter)
pp_set.add_printer('zend_ast_list', '^_zend_ast_list$', ZendAstPrettyPrinter)
pp_set.add_printer('zend_ast_op_array', '^_zend_ast_op_array$', ZendAstPrettyPrinter)
pp_set.add_printer('zend_ast_zval', '^_zend_ast_zval$', ZendAstPrettyPrinter)
pp_set.add_printer('zend_ast_znode', '^_zend_ast_znode$', ZendAstPrettyPrinter)
class ZvalPrettyPrinter(gdb.printing.PrettyPrinter):
"Print a zval"