Adapted opline_num breakpoints to master branch

This commit is contained in:
Bob Weinand 2013-12-07 15:35:35 +01:00
commit 50db4919ce
47 changed files with 4454 additions and 642 deletions

View file

@ -143,6 +143,120 @@ PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
} /* }}} */
PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* dest TSRMLS_DC) /* {{{ */
{
switch ((dest->type = src->type)) {
case STR_PARAM:
dest->str = estrndup(src->str, src->len);
dest->len = src->len;
break;
case ADDR_PARAM:
dest->addr = src->addr;
break;
case NUMERIC_PARAM:
dest->num = src->num;
break;
case METHOD_PARAM:
dest->method.class = estrdup(src->method.class);
dest->method.name = estrdup(src->method.name);
break;
case FILE_PARAM:
dest->file.name = estrdup(src->file.name);
dest->file.line = src->file.line;
break;
case EMPTY_PARAM: { /* do nothing */ } break;
}
} /* }}} */
PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */
{
zend_ulong hash = param->type;
switch (param->type) {
case STR_PARAM:
hash += zend_inline_hash_func(param->str, param->len);
break;
case METHOD_PARAM:
hash += zend_inline_hash_func(param->method.class, strlen(param->method.class));
hash += zend_inline_hash_func(param->method.name, strlen(param->method.name));
break;
case FILE_PARAM:
hash += zend_inline_hash_func(param->file.name, strlen(param->file.name));
hash += param->file.line;
break;
case ADDR_PARAM:
hash += param->addr;
break;
case NUMERIC_PARAM:
hash += param->num;
break;
case EMPTY_PARAM: { /* do nothing */ } break;
}
return hash;
} /* }}} */
PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_param_t *r TSRMLS_DC) /* {{{ */
{
if (l && r) {
if (l->type == r->type) {
switch (l->type) {
case STR_PARAM:
return (l->len == r->len) &&
(memcmp(l->str, r->str, l->len) == SUCCESS);
case NUMERIC_PARAM:
return (l->num == r->num);
case ADDR_PARAM:
return (l->addr == r->addr);
case FILE_PARAM: {
if (l->file.line == r->file.line) {
size_t lengths[2] = {
strlen(l->file.name), strlen(r->file.name)};
if (lengths[0] == lengths[1]) {
return (memcmp(
l->file.name, r->file.name, lengths[0]) == SUCCESS);
}
}
} break;
case METHOD_PARAM: {
size_t lengths[2] = {
strlen(l->method.class), strlen(r->method.class)};
if (lengths[0] == lengths[1]) {
if (memcmp(l->method.class, r->method.class, lengths[0]) == SUCCESS) {
lengths[0] = strlen(l->method.name);
lengths[1] = strlen(r->method.name);
if (lengths[0] == lengths[1]) {
return (memcmp(
l->method.name, r->method.name, lengths[0]) == SUCCESS);
}
}
}
} break;
case EMPTY_PARAM:
return 1;
}
}
}
return 0;
} /* }}} */
PHPDBG_API phpdbg_input_t **phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC) /* {{{ */
{
char *p;
@ -242,35 +356,48 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
char *cmd = NULL;
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if (buffered == NULL) {
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) &&
(buffered == NULL)) {
fflush(PHPDBG_G(io)[PHPDBG_STDOUT]);
}
if (buffered == NULL) {
#ifndef HAVE_LIBREADLINE
char buf[PHPDBG_MAX_CMD];
if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C)) ||
if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) ||
!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
/* the user has gone away */
phpdbg_error("Failed to read console !");
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout();
return NULL;
}
cmd = buf;
#else
cmd = readline(phpdbg_get_prompt(TSRMLS_C));
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
char buf[PHPDBG_MAX_CMD];
if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
cmd = buf;
} else cmd = NULL;
} else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
if (!cmd) {
/* the user has gone away */
phpdbg_error("Failed to read console !");
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout();
return NULL;
}
add_history(cmd);
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
add_history(cmd);
}
#endif
} else cmd = buffered;
/* allocate and sanitize buffer */
buffer = (phpdbg_input_t*) emalloc(sizeof(phpdbg_input_t));
buffer = (phpdbg_input_t*) ecalloc(1, sizeof(phpdbg_input_t));
if (!buffer) {
return NULL;
}
@ -296,7 +423,8 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
#endif
#ifdef HAVE_LIBREADLINE
if (!buffered && cmd) {
if (!buffered && cmd &&
!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
free(cmd);
}
#endif
@ -307,6 +435,21 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
return NULL;
} /* }}} */
PHPDBG_API void phpdbg_destroy_argv(phpdbg_input_t **argv, int argc TSRMLS_DC) /* {{{ */
{
if (argv) {
if (argc) {
int arg;
for (arg=0; arg<argc; arg++) {
phpdbg_destroy_input(
&argv[arg] TSRMLS_CC);
}
}
efree(argv);
}
} /* }}} */
PHPDBG_API void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
{
if (*input) {
@ -314,17 +457,8 @@ PHPDBG_API void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
efree((*input)->string);
}
if ((*input)->argc > 0) {
int arg;
for (arg=0; arg<(*input)->argc; arg++) {
phpdbg_destroy_input(
&(*input)->argv[arg] TSRMLS_CC);
}
}
if ((*input)->argv) {
efree((*input)->argv);
}
phpdbg_destroy_argv(
(*input)->argv, (*input)->argc TSRMLS_CC);
efree(*input);
}
@ -398,7 +532,7 @@ PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *in
int arg;
for (arg=1; arg<input->argc; arg++) {
phpdbg_debug(
"\t#%d: [%s=%d]",
"\t#%d: [%s=%zu]",
arg,
input->argv[arg]->string,
input->argv[arg]->length);