Skip to content

GDB pretty print for zend_ast has some exceptions #17782

Closed
@DanielEScherzer

Description

@DanielEScherzer

Description

Create /var/www/html/test.php with:

<?php

assert(false && new class {
    public function __construct() {}
} );

And then

  • start gdb
  • input set print pretty on
  • add breakpoint break /usr/src/php/Zend/zend_compile.c:4356
    This corresponds to

    php-src/Zend/zend_compile.c

    Lines 4354 to 4357 in 65d4331

    static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string *name, zend_function *fbc, uint32_t lineno) /* {{{ */
    {
    if (EG(assertions) >= 0) {
  • run the script, run /var/www/html/test.php
  • examine the AST for args (raw) with p /r *args->child[0]->child[1]
    Output:
$1 = {
  kind = 527,
  attr = 0,
  lineno = 3,
  child = {0x7ffff3262150}
}
  • try to use the pretty printer, p *args->child[0]->child[1]

Resulted in this output:

$2 = ((zend_ast*)0x7ffff3203118) = {
  kind = ZEND_AST_NEW,
  attr = 0,
  lineno = 3,
  child[0] = ((zend_ast_decl*)0x7ffff3262150) = {
    kind = ZEND_AST_CLASS,
    attr = 0Python Exception <class 'gdb.error'>: There is no member named start_lineno.

    ...
  },
  child[1] = ((zend_ast_list*)0x7ffff3202d70) = {
    kind = ZEND_AST_ARG_LIST,
    attr = 0,
    lineno = 3Python Exception <class 'gdb.error'>: There is no member named children.

    ...
  }
}

But I expected this output instead:

[no exceptions]

PHP Version

65d4331

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions