[php-src] PR #13520: Add GDB pretty-printers for zend_ast
| From: | arnaud-lb | Date: | Mon, 26 Feb 2024 18:31:39 +0000 |
| Subject: | [php-src] PR #13520: Add GDB pretty-printers for zend_ast | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-25148@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/13520
Author: arnaud-lb
This builds on top of https://github.com/php/php-src/pull/13463 to
add GDB pretty-printers for
zend_ast. Since ASTs contain zval, I've also included
a minimal zval pretty printer.
Similarly to https://github.com/php/php-src/pull/13463,
with these printers I'm trying to not hide the internals of the pretty printed types as this
would be inconvenient when debugging. I just use to_string() to print a small string
representation of the type when possible, and children() to help GDB walk the struct.
As zend_ast are deep structures, these settings are useful:
```
(gdb) set print pretty on
(gdb) set print max-depth 2
```
The first one enables indentation.
```
(gdb) p ast
$1 = (zend_ast *) 0x7ffff7a87180
(gdb) p /r *ast
$2 = {
kind = 67,
attr = 0,
lineno = 1,
child = {0x1}
}
(gdb) p *ast
$3 = ((zend_ast_decl*)0x7ffff7a87180) = {
kind = ZEND_AST_FUNC_DECL,
attr = 0,
start_lineno = 1,
end_lineno = 1,
flags = 0,
doc_comment = 0x0,
name = "some_function_name",
child[0] = ((zend_ast_list*)0x7ffff7a870c0) = {
kind = ZEND_AST_PARAM_LIST,
attr = 0,
lineno = 1,
children = 2,
child[0] = ((zend_ast*)0x7ffff7a87090) = {...},
child[1] = ((zend_ast*)0x7ffff7a87120) = {...}
},
child[1] = 0x0,
child[2] = ((zend_ast_list*)0x7ffff7a87150) = {
kind = ZEND_AST_STMT_LIST,
attr = 0,
lineno = 1,
children = 0
},
child[3] = 0x0,
child[4] = 0x0
}
```