Skip to content

Commit

Permalink
Inline GDB scripts in the PHP binary (php#13600)
Browse files Browse the repository at this point in the history
This inlines .gdbinit and php_gdb.py in the .debug_gdb_scripts section of the PHP binary so that GDB can auto-load them regardless of the current directory or the availability of the PHP source code (albeit some functionalities of php_gdb.py currently rely on the source being available).
  • Loading branch information
arnaud-lb authored Apr 16, 2024
1 parent af5db45 commit 46b6ad6
Show file tree
Hide file tree
Showing 6 changed files with 1,091 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# Collapse generated files within git and pull request diff.
**/*_arginfo.h linguist-generated -diff
/main/gdb_inlined_script.c linguist-generated -diff
/Zend/zend_vm_execute.h linguist-generated -diff
/Zend/zend_vm_handlers.h linguist-generated -diff
/Zend/zend_vm_opcodes.[ch] linguist-generated -diff
Expand Down
1 change: 1 addition & 0 deletions .github/actions/verify-generated-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ runs:
[[ "$OSTYPE" == "darwin"* ]] && export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
scripts/dev/credits
scripts/dev/genfiles
scripts/gdb/debug_gdb_scripts_gen.php
Zend/zend_vm_gen.php
ext/tokenizer/tokenizer_data_gen.php
build/gen_stub.php -f --generate-optimizer-info --verify
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,17 @@ PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c \
network.c php_open_temporary_file.c php_odbc_utils.c safe_bcmp.c \
output.c getopt.c php_syslog.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)

if printf "#if __ELF__\nelf\n#endif\n" | $CC -E - | grep elf > /dev/null; then
PHP_ADD_SOURCES(main, debug_gdb_scripts.c)

cat >> Makefile.objects <<EOF
$abs_srcdir/main/debug_gdb_scripts.c: $abs_srcdir/scripts/gdb/debug_gdb_scripts_gen.php $abs_srcdir/scripts/gdb/php_gdb.py $abs_srcdir/.gdbinit
@if test ! -z "\$(PHP)"; then \\
\$(PHP) $abs_srcdir/scripts/gdb/debug_gdb_scripts_gen.php; \\
fi;
EOF
fi

PHP_ADD_SOURCES_X(main, fastcgi.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_FASTCGI_OBJS, no)

PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \
Expand Down
Loading

0 comments on commit 46b6ad6

Please sign in to comment.