Skip to content

Commit cee72c1

Browse files
committed
Merge branch 'master' of sapi/phpdbg into PHP-5.6
Including phpdbg.
2 parents 436ca2d + ef3e011 commit cee72c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+10215
-0
lines changed

sapi/phpdbg/.gdbinit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
define ____phpdbg_globals
2+
if basic_functions_module.zts
3+
if !$tsrm_ls
4+
set $tsrm_ls = ts_resource_ex(0, 0)
5+
end
6+
set $phpdbg = ((zend_phpdbg_globals*) (*((void ***) $tsrm_ls))[phpdbg_globals_id-1])
7+
else
8+
set $phpdbg = phpdbg_globals
9+
end
10+
end

sapi/phpdbg/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.libs/
2+
./phpdbg
3+
*.lo
4+
*.o
5+
build

sapi/phpdbg/.phpdbginit

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
##########################################################
2+
# .phpdbginit
3+
#
4+
# Lines starting with # are ignored
5+
# Code must start and end with <: and :> respectively
6+
##########################################################
7+
# Place initialization commands one per line
8+
##########################################################
9+
# exec sapi/phpdbg/test.php
10+
# set color prompt white-bold
11+
# set color notice green
12+
# set color error red
13+
14+
##########################################################
15+
# Embedding code in .phpdbginit
16+
##########################################################
17+
<:
18+
/*
19+
* This embedded PHP is executed at init time
20+
*/
21+
22+
/*
23+
* Functions defined and registered by init
24+
* will persist across cleans
25+
*/
26+
27+
/*
28+
function my_debugging_function()
29+
{
30+
var_dump(func_get_args());
31+
}
32+
*/
33+
34+
/* phpdbg_break(PHPDBG_METHOD, "phpdbg::method"); */
35+
/* phpdbg_break(PHPDBG_FUNC, "my_global_function"); */
36+
/* phpdbg_break(PHPDBG_FILE, "/path/to/file.php:10"); */
37+
38+
/*
39+
If readline is loaded, you might want to setup completion:
40+
*/
41+
if (function_exists('readline_completion_function')) {
42+
readline_completion_function(function(){
43+
return array_merge(
44+
get_defined_functions()['user'],
45+
array_keys(get_defined_constants())
46+
);
47+
});
48+
}
49+
50+
/*
51+
Setting argv made trivial ...
52+
53+
argv 1 2 3 4
54+
^ set argv for next execution
55+
56+
argv
57+
^ unset argv for next execution
58+
59+
*/
60+
function argv()
61+
{
62+
$argv = func_get_args();
63+
64+
if (!$argv) {
65+
$_SERVER['argv'] = array();
66+
$_SERVER['argc'] = 0;
67+
return;
68+
}
69+
70+
$_SERVER['argv'] = array_merge
71+
(
72+
array("phpdbg"),
73+
$argv
74+
);
75+
$_SERVER['argc'] = count($_SERVER['argv']);
76+
77+
return $_SERVER['argv'];
78+
}
79+
:>
80+
##########################################################
81+
# Now carry on initializing phpdbg ...
82+
##########################################################
83+
# R my_debugging_function
84+
# R argv
85+
86+
##########################################################
87+
# PHP has many functions that might be useful
88+
# ... you choose ...
89+
##########################################################
90+
# R touch
91+
# R unlink
92+
# R scandir
93+
# R glob
94+
95+
##########################################################
96+
# Remember: *you have access to the shell*
97+
##########################################################
98+
# The output of registered function calls is not,
99+
# by default, very pretty (unless you implement
100+
# and register a new implementation for phpdbg)
101+
# The output of shell commands will usually be more
102+
# readable on the console
103+
##########################################################
104+
# TLDR; if you have a good shell, use it ...
105+
##########################################################

sapi/phpdbg/.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: c
2+
3+
script: ./travis/ci.sh

sapi/phpdbg/Changelog.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
ChangeLog for phpdbg
2+
====================
3+
4+
Version 0.3.0 2013-00-00
5+
------------------------
6+
7+
1. Added ability to disable an enable a single breakpoint
8+
2. Added ability to override SAPI name
9+
3. Added extended conditional breakpoint support "break at"
10+
4. Fix loading of zend extnsions with -z
11+
5. Fix crash when loading .phpdbginit with command line switch
12+
6. Fix crash on startup errors
13+
7. Added init.d for remote console (redhat)
14+
8. Added phpdbg_exec userland function
15+
9. Added testing facilities
16+
10. Added break on n-th opline support
17+
11. Improved trace output
18+
19+
Version 0.2.0 2013-11-31
20+
------------------------
21+
22+
1. Added "break delete <id>" command
23+
2. Added "break opcode <opcode>" command
24+
3. Added "set" command - control prompt and console colors
25+
4. .phpdbginit now searched in (additional) ini dirs
26+
5. Added source command - load additional .phpdbginit script during session
27+
6. Added remote console mode
28+
7. Added info memory command
29+
30+
Version 0.1.0 2013-11-23
31+
------------------------
32+
33+
1. New commands:
34+
- until (continue until the current line is executed)
35+
- frame (switch to a frame in the current stack for inspection)
36+
- info (quick access to useful information on the console)
37+
- finish (continue until the current function has returned)
38+
- leave (continue until the current function is returning)
39+
- shell (shell a command)
40+
- register (register a function for use as a command)
41+
2. Added printers for class and method
42+
3. Make uniform commands and aliases where possible
43+
4. Include all alias information and sub-command information in help
44+
5. Added signal handling to break execution (ctrl-c)
45+
6. Fixed #13 (Output Buffering Control seems fail)
46+
7. Fixed #14 (Fixed typo in Makefile.frag)
47+
48+
49+
Version 0.0.1 2013-11-15
50+
------------------------
51+
52+
1. Initial features

sapi/phpdbg/Makefile.frag

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
phpdbg: $(BUILD_BINARY)
2+
3+
phpdbg-shared: $(BUILD_SHARED)
4+
5+
$(BUILD_SHARED): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
6+
$(BUILD_PHPDBG_SHARED)
7+
8+
$(BUILD_BINARY): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS)
9+
$(BUILD_PHPDBG)
10+
11+
install-phpdbg: $(BUILD_BINARY)
12+
@echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/"
13+
@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
14+
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log
15+
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run
16+
@$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT)
17+
18+
clean-phpdbg:
19+
@echo "Cleaning phpdbg object files ..."
20+
find sapi/phpdbg/ -name *.lo -o -name *.o | xargs rm -f
21+
22+
test-phpdbg:
23+
@echo "Running phpdbg tests ..."
24+
@$(top_builddir)/sapi/cli/php sapi/phpdbg/tests/run-tests.php --phpdbg sapi/phpdbg/phpdbg
25+
26+
.PHONY: clean-phpdbg test-phpdbg
27+
28+

sapi/phpdbg/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
The interactive PHP debugger
2+
============================
3+
4+
Implemented as a SAPI module, phpdbg can excert complete control over the environment without impacting the functionality or performance of your code.
5+
6+
phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+
7+
8+
[![phpdbg on travis-ci](https://travis-ci.org/krakjoe/phpdbg.png?branch=master)](https://travis-ci.org/krakjoe/phpdbg)
9+
10+
Features
11+
========
12+
13+
- Stepthrough Debugging
14+
- Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode)
15+
- Easy Access to PHP with built-in eval()
16+
- Easy Access to Currently Executing Code
17+
- Userland API
18+
- SAPI Agnostic - Easily Integrated
19+
- PHP Configuration File Support
20+
- JIT Super Globals - Set Your Own!!
21+
- Optional readline Support - Comfortable Terminal Operation
22+
- Remote Debugging Support - Bundled Java GUI
23+
- Easy Operation - See Help :)
24+
25+
Planned
26+
=======
27+
28+
- Improve Everything :)
29+
30+
Installation
31+
============
32+
33+
To install **phpdbg**, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command.
34+
35+
```
36+
cd /usr/src/php-src/sapi
37+
git clone https://github.com/krakjoe/phpdbg
38+
cd ../
39+
./buildconf --force
40+
./configure --enable-phpdbg
41+
make -j8
42+
make install-phpdbg
43+
```
44+
45+
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
46+
parameters as were used by the last execution of *configure*.
47+
48+
**Note:** PHP must be configured with the switch --with-readline for phpdbg to support history, autocompletion, tab-listing etc.
49+
50+
Command Line Options
51+
====================
52+
53+
The following switches are implemented (just like cli SAPI):
54+
55+
- -n ignore php ini
56+
- -c search for php ini in path
57+
- -z load zend extension
58+
- -d define php ini entry
59+
60+
The following switches change the default behaviour of phpdbg:
61+
62+
- -v disables quietness
63+
- -s enabled stepping
64+
- -e sets execution context
65+
- -b boring - disables use of colour on the console
66+
- -I ignore .phpdbginit (default init file)
67+
- -i override .phpgdbinit location (implies -I)
68+
- -O set oplog output file
69+
- -q do not print banner on startup
70+
- -r jump straight to run
71+
- -E enable step through eval()
72+
- -l listen ports for remote mode
73+
- -a listen address for remote mode
74+
- -S override SAPI name
75+
76+
**Note:** Passing -rr will cause phpdbg to quit after execution, rather than returning to the console.
77+
78+
Getting Started
79+
===============
80+
81+
See the website for tutorials/documentation
82+
83+
http://phpdbg.com

sapi/phpdbg/config.m4

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
dnl
2+
dnl $Id$
3+
dnl
4+
5+
PHP_ARG_ENABLE(phpdbg, for phpdbg support,
6+
[ --enable-phpdbg Build phpdbg], yes, yes)
7+
8+
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
9+
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
10+
11+
if test "$PHP_PHPDBG" != "no"; then
12+
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
13+
14+
if test "$PHP_PHPDBG_DEBUG" != "no"; then
15+
AC_DEFINE(PHPDBG_DEBUG, 1, [ ])
16+
else
17+
AC_DEFINE(PHPDBG_DEBUG, 0, [ ])
18+
fi
19+
20+
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
21+
PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c"
22+
23+
PHP_SUBST(PHP_PHPDBG_CFLAGS)
24+
PHP_SUBST(PHP_PHPDBG_FILES)
25+
26+
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag])
27+
PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)])
28+
29+
BUILD_BINARY="sapi/phpdbg/phpdbg"
30+
BUILD_SHARED="sapi/phpdbg/libphpdbg.la"
31+
32+
BUILD_PHPDBG="\$(LIBTOOL) --mode=link \
33+
\$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
34+
\$(PHP_GLOBAL_OBJS) \
35+
\$(PHP_BINARY_OBJS) \
36+
\$(PHP_PHPDBG_OBJS) \
37+
\$(EXTRA_LIBS) \
38+
\$(PHPDBG_EXTRA_LIBS) \
39+
\$(ZEND_EXTRA_LIBS) \
40+
-o \$(BUILD_BINARY)"
41+
42+
BUILD_PHPDBG_SHARED="\$(LIBTOOL) --mode=link \
43+
\$(CC) -shared -Wl,-soname,libphpdbg.so -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
44+
\$(PHP_GLOBAL_OBJS) \
45+
\$(PHP_BINARY_OBJS) \
46+
\$(PHP_PHPDBG_OBJS) \
47+
\$(EXTRA_LIBS) \
48+
\$(PHPDBG_EXTRA_LIBS) \
49+
\$(ZEND_EXTRA_LIBS) \
50+
\-DPHPDBG_SHARED \
51+
-o \$(BUILD_SHARED)"
52+
53+
PHP_SUBST(BUILD_BINARY)
54+
PHP_SUBST(BUILD_SHARED)
55+
PHP_SUBST(BUILD_PHPDBG)
56+
PHP_SUBST(BUILD_PHPDBG_SHARED)
57+
fi
58+
59+
dnl ## Local Variables:
60+
dnl ## tab-width: 4
61+
dnl ## End:

sapi/phpdbg/config.w32

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG_ENABLE('phpdbg', 'Build phpdbg', 'yes');
2+
ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no');
3+
4+
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c';
5+
PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll';
6+
PHPDBG_EXE='phpdbg.exe';
7+
8+
if (PHP_PHPDBG == "yes") {
9+
/* build phpdbg binary */
10+
SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE);
11+
ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib");
12+
}
13+
14+
if (PHP_PHPDBGS == "yes") {
15+
SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32');
16+
ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib");
17+
}
18+
19+

0 commit comments

Comments
 (0)