Skip to content

Conversation

@xepozz
Copy link
Contributor

@xepozz xepozz commented May 27, 2025

It helps me when I reach the default case to understand what was it.

I think it may help others as well.

E_ERROR,
"Unknown AST node kind %d. Expression: \"%s\".",
ast->kind,
ZSTR_VAL(zend_ast_export("", ast, ""))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that zend_ast_export must be functional, which is not given when the AST is broken so that PHP is unable to handle it.

The included gdb script is capable of pretty-printing the AST. I suggest debugging this situation with gdb.

@iluuu1994
Copy link
Member

I agree with Tim. Use gdb, we have print support for AST nodes.

> p *ast
$2 = ((zend_ast*)0x7ffff3877090) = {kind = ZEND_AST_ECHO, attr = 0, lineno = 1, child[0] = ((zend_ast_zval*)0x7ffff384f038) = {kind = ZEND_AST_ZVAL, attr = 0, val = ((zval*) 0x7ffff384f040) "Hello world!"}}

It's not the most readable, but it gets the job done.

@iluuu1994 iluuu1994 closed this May 27, 2025
@xepozz
Copy link
Contributor Author

xepozz commented May 27, 2025

What if I don't use the dbg?
Actually, it's just a tip for developers while doing tests.

image image

@iluuu1994 is there the same tip for lldb?

@TimWolla
Copy link
Member

It's not the most readable, but it gets the job done.

FWIW: set print pretty on prints this multi-line.

@iluuu1994
Copy link
Member

No, but gdb works on mac too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants