Skip to content

Commit c8e80f1

Browse files
authored
Document zend_vm_gen.php --with-lines flag (#142)
1 parent 570d8b4 commit c8e80f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Book/php7/debugging.rst

+9
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ Debug symbols
1111
GDB requires debug symbols to map the memory addresses in your binary to the original position in your source code. To
1212
generate debug symbols you need to pass the ``--enable-debug`` flag to the ``./configure`` script. To get even more
1313
debugging information you may add the ``CFLAGS="-ggdb3"`` flag which will add support for macros.
14+
15+
Debugging the VM
16+
----------------
17+
18+
The VM lives in the big ``zend_vm_execute.h`` file that is generated by ``zend_vm_gen.php`` from ``zend_vm_def.h``.
19+
Debugging this file can be tedious because it is very large, and it's often not obvious which specialized handler
20+
will run. Luckily, it is possible to debug ``zend_vm_def.h`` directly by generating the VM using the
21+
``php Zend/zend_vm_gen.php --with-lines`` command. This will annotate the code with the ``#line`` preprocessor directive
22+
to allow the debugger to know the origin of the generated instructions.

0 commit comments

Comments
 (0)