Problem
bin/compile.php -y emits .bc / .s beside the binary for debugging, but multi-file phpc build --project and deployed CGI binaries still lack practical PHP source line → native PC mapping when scripts segfault or print wrong output (#764).
Operators debugging empty stdout or native crashes need gdb/lldb without manually correlating LLVM IR.
Goal
Improve debuggability for AOT web binaries:
- Optional DWARF or line tables: PHP
file:line → native address
- Document debugging workflow for
examples/003-MiniWebApp/.phpc/bin/app
- Optional: per-module CFG dump in project build output dir
Implementation hints
| Piece |
Files |
Notes |
| AOT emit |
lib/AOT/Linker.php, LLVM IR builder |
-g / DIBuilder line info from compile unit paths |
| CLI |
bin/compile.php, lib/Cli/PhpcBuild.php |
-y already dumps IR; extend --debug-symbols flag |
| Project build |
lib/Cli/PhpcBuild.php --project |
Emit build/debug/ with .s per unit when env set |
| Docs |
docs/deploy-web-aot.md, #445 |
gdb ./app, bt, map to Router.php:line |
Suggested workflow (acceptance demo)
phpc build --project examples/003-MiniWebApp -y
gdb -batch -ex run -ex bt --args env QUERY_STRING=route=home ./examples/003-MiniWebApp/.phpc/bin/app
# backtrace shows PHP file:line when DWARF present
Acceptance criteria
Dependencies
Priority
Medium — production deploy + #764 triage.
Related
Verification
make docker-build-22
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
./phpc build -y -o /tmp/dbg examples/000-HelloWorld/example.php
Links
Problem
bin/compile.php -yemits.bc/.sbeside the binary for debugging, but multi-filephpc build --projectand deployed CGI binaries still lack practical PHP source line → native PC mapping when scripts segfault or print wrong output (#764).Operators debugging empty stdout or native crashes need
gdb/lldbwithout manually correlating LLVM IR.Goal
Improve debuggability for AOT web binaries:
file:line→ native addressexamples/003-MiniWebApp/.phpc/bin/appImplementation hints
lib/AOT/Linker.php, LLVM IR builder-g/DIBuilderline info from compile unit pathsbin/compile.php,lib/Cli/PhpcBuild.php-yalready dumps IR; extend--debug-symbolsflaglib/Cli/PhpcBuild.php--projectbuild/debug/with.sper unit when env setdocs/deploy-web-aot.md, #445gdb ./app,bt, map toRouter.php:lineSuggested workflow (acceptance demo)
phpc build --project examples/003-MiniWebApp -y gdb -batch -ex run -ex bt --args env QUERY_STRING=route=home ./examples/003-MiniWebApp/.phpc/bin/app # backtrace shows PHP file:line when DWARF presentAcceptance criteria
gdbbacktracephp-compiler:22.04-devDependencies
Priority
Medium — production deploy + #764 triage.
Related
--list-units(compile graph, not DWARF)Verification
make docker-build-22 docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \ ./phpc build -y -o /tmp/dbg examples/000-HelloWorld/example.phpLinks