Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
First semi-working version of oplines
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Nov 28, 2013
1 parent f8e7685 commit d7f6e88
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 23 deletions.
41 changes: 39 additions & 2 deletions phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,15 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
{
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], 8, NULL, php_phpdbg_destroy_bp_opcode, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0);
zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0);
zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0);
PHPDBG_G(opline_btree) = NULL;

return SUCCESS;
} /* }}} */
Expand Down Expand Up @@ -309,14 +312,14 @@ zend_function_entry phpdbg_user_functions[] = {

static zend_module_entry sapi_phpdbg_module_entry = {
STANDARD_MODULE_HEADER,
"phpdbg",
PHPDBG_NAME,
phpdbg_user_functions,
PHP_MINIT(phpdbg),
NULL,
PHP_RINIT(phpdbg),
PHP_RSHUTDOWN(phpdbg),
NULL,
"0.1",
PHPDBG_VERSION,
STANDARD_MODULE_PROPERTIES
};

Expand Down Expand Up @@ -458,6 +461,38 @@ static sapi_module_struct phpdbg_sapi_module = {
};
/* }}} */

void phpdbg_op_array_handler(zend_op_array *op_array) {
TSRMLS_FETCH();

phpdbg_save_oplines(op_array TSRMLS_CC);
phpdbg_resolve_op_array_breaks(op_array TSRMLS_CC);
}

#ifndef ZEND_EXT_API
#define ZEND_EXT_API ZEND_DLEXPORT
#endif
ZEND_EXTENSION();

ZEND_DLEXPORT zend_extension zend_extension_entry = {
PHPDBG_NAME,
PHPDBG_VERSION,
PHPDBG_AUTHORS,
PHPDBG_URL,
"(c) 2013",
NULL, /* startup_func_t */
NULL, /* shutdown_func_t */
NULL, /* activate_func_t */
NULL, /* deactivate_func_t */
NULL, /* message_handler_func_t */
phpdbg_op_array_handler, /* op_array_handler_func_t */
NULL, /* statement_handler_func_t */
NULL, /* fcall_begin_handler_func_t */
NULL, /* fcall_end_handler_func_t */
NULL, /* op_array_ctor_func_t */
NULL, /* op_array_dtor_func_t */
STANDARD_ZEND_EXTENSION_PROPERTIES
};

const opt_struct OPTIONS[] = { /* {{{ */
{'c', 1, "ini path override"},
{'d', 1, "define ini entry on command line"},
Expand Down Expand Up @@ -717,6 +752,8 @@ int main(int argc, char **argv) /* {{{ */
phpdbg->ini_entries = ini_entries;

if (phpdbg->startup(phpdbg) == SUCCESS) {
zend_register_extension(&zend_extension_entry, NULL);

zend_activate(TSRMLS_C);

#ifdef ZEND_SIGNALS
Expand Down
26 changes: 19 additions & 7 deletions phpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@
#define PHPDBG_LEAVE 5

/* {{{ tables */
#define PHPDBG_BREAK_FILE 0
#define PHPDBG_BREAK_SYM 1
#define PHPDBG_BREAK_OPLINE 2
#define PHPDBG_BREAK_METHOD 3
#define PHPDBG_BREAK_COND 4
#define PHPDBG_BREAK_OPCODE 5
#define PHPDBG_BREAK_TABLES 6 /* }}} */
#define PHPDBG_BREAK_FILE 0
#define PHPDBG_BREAK_SYM 1
#define PHPDBG_BREAK_OPLINE 2
#define PHPDBG_BREAK_METHOD 3
#define PHPDBG_BREAK_COND 4
#define PHPDBG_BREAK_OPCODE 5
#define PHPDBG_BREAK_FUNCTION_OPLINE 6
#define PHPDBG_BREAK_METHOD_OPLINE 7
#define PHPDBG_BREAK_TABLES 8/* }}} */

/* {{{ flags */
#define PHPDBG_HAS_FILE_BP (1<<1)
Expand Down Expand Up @@ -125,6 +127,9 @@
#endif /* }}} */

/* {{{ strings */
#define PHPDBG_NAME "phpdbg"
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.2.0-dev"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
Expand All @@ -137,8 +142,15 @@
#define PHPDBG_IO_FDS 3 /* }}} */

/* {{{ structs */
typedef union _phpdbg_btree phpdbg_btree;
union _phpdbg_btree {
phpdbg_btree *branches[2];
zend_op_array *op_array;
};

ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
HashTable bp[PHPDBG_BREAK_TABLES]; /* break points */
phpdbg_btree *opline_btree; /* opline root -> op_array */
HashTable registered; /* registered */
HashTable seek; /* seek oplines */
phpdbg_frame_t frame; /* frame */
Expand Down

0 comments on commit d7f6e88

Please sign in to comment.