php-src/sapi/phpdbg
Dmitry Stogov 5ee8413259 Fixed bug #62210 (Exceptions can leak temporary variables. As a part of the fix serious refactoring was done. op_array->brk_cont_array was removed, and replaced with more general and speed efficient op_array->T_liveliness. ZEND_GOTO opcode is always replaced by ZEND_JMP at compile time). (Bob, Dmitry, Laruence)
Squashed commit of the following:

commit 38e22106d4
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 15:12:19 2015 +0300

    Added NEWS entry

commit 0a355935bf
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 15:06:32 2015 +0300

    Inline function, to eliminate repeatable checks

commit d937584f3a
Merge: 0341626 32677f5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 14:35:49 2015 +0300

    Merge branch 'master' into temporary_cleaning

    * master:
      Fixed bug #70006 (cli - function with default arg = STDOUT crash output).
      Fix x86 build
      Fixed use after free on closure_call_leak_with_exception.phpt
      Fixed test

commit 0341626ea9
Merge: 74869fa dec35de
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 12:00:53 2015 +0300

    Merge branch 'temporary_cleaning' of https://github.com/laruence/php-src into temporary_cleaning

    * 'temporary_cleaning' of https://github.com/laruence/php-src:
      Fixed checkpoint get
      Fixed crash of invalid pointer derefer
      cleanup

commit 74869fa673
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 11:45:34 2015 +0300

    Fixed wrong GOTO resolution

commit dec35ded32
Author: Xinchen Hui <laruence@gmail.com>
Date:   Tue Jul 7 15:58:49 2015 +0800

    Fixed checkpoint get

commit b0f419540a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 10:47:11 2015 +0300

    Fixed crash of invalid pointer derefer (laruence)

commit 7a428d98ca
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 10:35:47 2015 +0300

    Fixed identation

commit 9c3a4dce9c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 10:33:52 2015 +0300

    Fixed invalid size

commit 653abc670b
Author: Xinchen Hui <laruence@gmail.com>
Date:   Tue Jul 7 11:29:14 2015 +0800

    Fixed crash of invalid pointer derefer

commit e04500ceda
Author: Xinchen Hui <laruence@gmail.com>
Date:   Tue Jul 7 11:28:26 2015 +0800

    cleanup

commit 34183e1687
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 04:49:46 2015 +0300

    op_array->T_liveliness compression

commit 2f6ad84579
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 04:44:44 2015 +0300

    White spaces

commit be83f115a3
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 04:42:26 2015 +0300

    Identation

commit 1f5084b990
Merge: 91b620d 1adf3df
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 04:41:54 2015 +0300

    Merge branch 'master' into temporary_cleaning

    * master:
      Throw TypeError for invalid callback
      Fix crash when exception occurs during nested rope
      Fix crash when exception is thrown during ROPE_END
      Small cleanup in ternary compilation
      move the define to the right place
      fix ext/ldap build
      Rectify information about invalid shift warning being now ArithmeticError

commit 91b620d684
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 04:32:04 2015 +0300

    Replace GOTO by FREE/FE_FREE and JMP at compile time

commit 7052e56979
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Jul 7 02:25:08 2015 +0300

    Use zend_regenerate_var_liveliness_info() to regenerate information after pass two.

commit ae72b0dc67
Merge: a81c4bb a919fe8
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 21:02:34 2015 +0300

    Merge branch 'master' into temporary_cleaning

    * master:
      Do not display EXT_TYPE_UNUSED in phpdbg opcodes
      Run debug build with opcache on travis

commit a81c4bb8c6
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 20:59:34 2015 +0300

    Improved algorithm. It's actually the same algorithm with second loop removed and simpler temporary data structures. The only difference may be in "re-defined" vatriable handling. Now live-range in that case started from the seconnd definition (this must be more safe).

commit 9a16810f7a
Merge: bbfbe47 001ecd3
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 17:57:45 2015 +0300

    Merge branch 'master' into temporary_cleaning

    * master:
      Simplify TMP var number decoding (without HashTable)

commit bbfbe470c8
Merge: 0bda4ab 436b01e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 17:02:01 2015 +0300

    Merge branch 'master' into temporary_cleaning

    * master:
      Avoid dangerous optimization
      Fixed JMPZNZ instruction printing
      Attempt at falling back on ldap_find_control for Mac OS

commit 0bda4abea7
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 16:05:33 2015 +0300

    Fixed live-range construction for OP_DATA opcode
    Added comments about algorithm assumtions

commit 521ad9df98
Merge: 4398dab a09dcb0
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Mon Jul 6 14:54:15 2015 +0200

    Merge branch 'master' of https://github.com/php/php-src into temporary_cleaning

commit 4398dab82f
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Mon Jul 6 13:51:27 2015 +0200

    Add a few phpt tests related to temporary cleaning

commit 739656f83f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 14:28:49 2015 +0300

    Fixed Zend/tests/foreach_004.phpt failure (FE_FETCH shouldn't be included into TMP vatriablr live range)

commit 3df462a2bc
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 13:41:02 2015 +0300

    Improve data layout (reduce the op_array structure size on 64-bit systems)

commit 883b73c56e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Jul 6 13:28:45 2015 +0300

    Removed op_array->brk_cont_array

commit ae5e58b598
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Mon Jul 6 04:22:58 2015 +0200

    Fix bug with brk_cont variable free / free loop vars via temporary liveliness info

commit b4223ca627
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Mon Jul 6 04:07:07 2015 +0200

    Fix bugs / cleanup fixes

commit ea33189d22
Author: Xinchen Hui <laruence@gmail.com>
Date:   Sun Jul 5 20:58:38 2015 +0800

    Removed useless TsTop

commit 1dbb007e4a
Merge: 550bbf8 3a8af24
Author: Xinchen Hui <laruence@gmail.com>
Date:   Sat Jul 4 15:06:44 2015 +0800

    Merge branch 'temporary_cleaning' of https://github.com/dstogov/php-src into temporary_cleaning

commit 3a8af24529
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jul 3 16:15:36 2015 +0300

    More exceptions from regular liveliness analyses (with explanation in comments).
    Mark old "unexplained" exceptions with ???.

commit ba721efa2c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jul 3 14:16:09 2015 +0300

    Print list of live temp variables (at least for internal debugging)

commit 8d1f88fe91
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jul 3 13:31:56 2015 +0300

    Use op_array->T_liveliness to free incomplete ropes and restore error_reporting level on exception

commit 80c1d0d779
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jul 3 11:05:39 2015 +0300

    Don't keep empty T_liveliness

commit 501ae8aaac
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jul 2 22:31:48 2015 +0300

    Reverted changes to Zend/zend_arena.h.
    Reuse CG(arena) instead of creating a new one.

commit a4fce36907
Merge: 6ff7246 fd0fcce
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jul 2 22:01:42 2015 +0300

    Merge branch 'temporary_cleaning' of github.com:bwoebi/php-src into temporary_cleaning

    * 'temporary_cleaning' of github.com:bwoebi/php-src:
      Fix remaining issues with compacted temporaries
      Fix regression from last commit (+1 ?!)
      Fix off-by-one (opcache may remove last ZEND_RETURN)
      Speed algorithm up, more fail safety when reusing temporaries
      Dumb bug in opcode.c (forgot to update Ts[i])
      Fix opcache support
      Exempt ROPE temporaries from freeing
      Hmm, we need temporary info for all the opcodes
      Add opcache support for cleaning in optimization step (Opcache seems to have a few unrelated issues which blow up together with that patch)
      Add proper temporary cleaning upon frame abortion
      Fix arena on small sizes (size < sizeof(zend_arena))

commit fd0fcce811
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Thu Jul 2 20:00:33 2015 +0200

    Fix remaining issues with compacted temporaries

commit 427dc58bbb
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Wed Jul 1 22:49:12 2015 +0200

    Fix regression from last commit (+1 ?!)

commit 1adcf56a6e
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Wed Jul 1 22:17:07 2015 +0200

    Fix off-by-one (opcache may remove last ZEND_RETURN)

commit 25b231b784
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Wed Jul 1 20:59:24 2015 +0200

    Speed algorithm up, more fail safety when reusing temporaries

commit 22d9d05350
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Wed Jul 1 16:48:46 2015 +0200

    Dumb bug in opcode.c (forgot to update Ts[i])

commit 6538269bfa
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Wed Jul 1 13:05:52 2015 +0200

    Fix opcache support

commit 333a7c4a88
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Sat Jun 27 22:40:21 2015 +0200

    Exempt ROPE temporaries from freeing

commit 02585f7708
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Fri Jun 26 16:20:55 2015 +0200

    Hmm, we need temporary info for all the opcodes

commit cbcaedbd78
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Fri Jun 26 01:04:09 2015 +0200

    Add opcache support for cleaning in optimization step
    (Opcache seems to have a few unrelated issues which blow up together with that patch)

commit fef649f406
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Fri Jun 26 01:02:27 2015 +0200

    Add proper temporary cleaning upon frame abortion

commit 1cec2e7271
Author: Bob Weinand <bobwei9@hotmail.com>
Date:   Thu Jun 25 23:33:21 2015 +0200

    Fix arena on small sizes (size < sizeof(zend_arena))
2015-07-07 15:41:12 +03:00
..
tests Improve phpdbg opcode dump 2015-05-24 20:29:57 +02:00
travis Merge sapi/phpdbg into PHP-5.6 2014-06-15 15:47:14 +02:00
.gdbinit
.gitignore Merge sapi/phpdbg into PHP-5.6 2014-06-09 10:06:29 +02:00
.phpdbginit
.travis.yml go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00
Changelog.md
config.m4 go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00
config.w32 go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00
CREDITS
Makefile.frag Merge sapi/phpdbg into PHP-5.6 2014-07-06 01:17:50 +02:00
phpdbg_bp.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_bp.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_break.c Fix parent command offsets 2015-03-21 23:19:12 +01:00
phpdbg_break.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_btree.c s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_btree.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_cmd.c s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_cmd.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_eol.c s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_eol.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_frame.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_frame.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_help.c Remove now unneeded step option (-s) 2015-06-29 01:00:12 +02:00
phpdbg_help.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_info.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_info.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_io.c Fixed the fix in f68dc94aa7 2015-05-27 16:47:15 +08:00
phpdbg_io.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_lexer.c trailing whitespace removal 2015-01-10 15:07:38 -08:00
phpdbg_lexer.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_lexer.l trailing whitespace removal 2015-01-10 15:07:38 -08:00
phpdbg_list.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_list.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_opcode.c Fixed bug #62210 (Exceptions can leak temporary variables. As a part of the fix serious refactoring was done. op_array->brk_cont_array was removed, and replaced with more general and speed efficient op_array->T_liveliness. ZEND_GOTO opcode is always replaced by ZEND_JMP at compile time). (Bob, Dmitry, Laruence) 2015-07-07 15:41:12 +03:00
phpdbg_opcode.h Simplify TMP var number decoding (without HashTable) 2015-07-06 17:56:48 +03:00
phpdbg_out.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_out.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_parser.c trailing whitespace removal 2015-01-10 15:07:38 -08:00
phpdbg_parser.h trailing whitespace removal 2015-01-10 15:07:38 -08:00
phpdbg_parser.y trailing whitespace removal 2015-01-10 15:07:38 -08:00
phpdbg_print.c Simplify TMP var number decoding (without HashTable) 2015-07-06 17:56:48 +03:00
phpdbg_print.h Provide method to access opcodes via command line argument 2015-04-19 21:54:09 +02:00
phpdbg_prompt.c Simplify TMP var number decoding (without HashTable) 2015-07-06 17:56:48 +03:00
phpdbg_prompt.h Add next command / Fix recursion/exceptions with u/F/L 2015-04-21 12:31:57 +02:00
phpdbg_rinit_hook.c s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_rinit_hook.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_set.c Fix parent command offsets 2015-03-21 23:19:12 +01:00
phpdbg_set.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_sigio_win32.c Fix copyright years 2015-03-13 11:27:40 +02:00
phpdbg_sigio_win32.h Fix copyright years 2015-03-13 11:27:40 +02:00
phpdbg_sigsafe.c Fixed phpdbg build 2015-05-14 16:47:22 +03:00
phpdbg_sigsafe.h Fixed phpdbg build 2015-05-14 16:47:22 +03:00
phpdbg_utils.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_utils.h Make backtraces *much* more readable 2015-06-29 02:51:10 +02:00
phpdbg_wait.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_wait.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_watch.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_watch.h Stabilize watchpoints 2015-04-19 12:53:29 +02:00
phpdbg_webdata_transfer.c Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 13:59:27 +03:00
phpdbg_webdata_transfer.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_win.c s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg_win.h s/PHP Version 5/PHP Version 7/g 2015-03-13 11:09:42 +02:00
phpdbg.1 Replaces php5 with php7, without whitespace changes. 2014-09-20 10:01:44 +02:00
phpdbg.c integrate the applink shim in the other bins 2015-07-03 07:11:14 +02:00
phpdbg.h Add phpdbg userland API to fetch oplog 2015-06-22 12:58:33 +02:00
phpdbg.init.d
README.md go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00
test.php Merge sapi/phpdbg into PHP-5.6 2014-04-21 23:30:08 +02:00
web-bootstrap.php
xml.md go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00
zend_mm_structs.h go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol) 2014-11-26 18:38:36 +01:00

The interactive PHP debugger

Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality or performance of your code.

phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+

phpdbg on travis-ci

Features

  • Stepthrough Debugging
  • Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode)
  • Easy Access to PHP with built-in eval()
  • Easy Access to Currently Executing Code
  • Userland API
  • SAPI Agnostic - Easily Integrated
  • PHP Configuration File Support
  • JIT Super Globals - Set Your Own!!
  • Optional readline Support - Comfortable Terminal Operation
  • Remote Debugging Support - Bundled Java GUI
  • Easy Operation - See Help :)

Planned

  • Improve Everything :)

Installation

To install phpdbg, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command.

cd /usr/src/php-src/sapi
git clone https://github.com/krakjoe/phpdbg
cd ../
./buildconf --force
./configure --enable-phpdbg
make -j8
make install-phpdbg

Where the source directory has been used previously to build PHP, there exists a file named config.nice which can be used to invoke configure with the same parameters as were used by the last execution of configure.

Note: PHP must be configured with the switch --with-readline for phpdbg to support history, autocompletion, tab-listing etc.

Command Line Options

The following switches are implemented (just like cli SAPI):

  • -n ignore php ini
  • -c search for php ini in path
  • -z load zend extension
  • -d define php ini entry

The following switches change the default behaviour of phpdbg:

  • -v disables quietness
  • -s enabled stepping
  • -e sets execution context
  • -b boring - disables use of colour on the console
  • -I ignore .phpdbginit (default init file)
  • -i override .phpgdbinit location (implies -I)
  • -O set oplog output file
  • -q do not print banner on startup
  • -r jump straight to run
  • -E enable step through eval()
  • -l listen ports for remote mode
  • -a listen address for remote mode
  • -S override SAPI name

Note: Passing -rr will cause phpdbg to quit after execution, rather than returning to the console.

Getting Started

See the website for tutorials/documentation

http://phpdbg.com