summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_list.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2016-10-12 20:11:51 +0200
committerBob Weinand <bobwei9@hotmail.com>2016-10-12 20:15:49 +0200
commit5aae01104f88f98f42fd997d360757651f7cc919 (patch)
tree7952bc03a1e88f1c1208e19c23e8a98ba968e3b7 /sapi/phpdbg/phpdbg_list.c
parent74b5662536ccdf9b7b02c495f02a27c64e27fff7 (diff)
downloadphp-git-5aae01104f88f98f42fd997d360757651f7cc919.tar.gz
Add stdin command and -s command line parameter to phpdbg
This allows reading the initial script file from stdin instead of being forced to put the script into a file in order to run it with phpdbg. Especially important for programmatic execution of phpdbg. Also adding tests/include_once.phpt and tests/set_exception_handler.phpt as I seem to have forgotten to git add them sometime long ago...
Diffstat (limited to 'sapi/phpdbg/phpdbg_list.c')
-rw-r--r--sapi/phpdbg/phpdbg_list.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 6895bea43e..87594614e1 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -62,9 +62,15 @@ PHPDBG_LIST(lines) /* {{{ */
} break;
case FILE_PARAM: {
- zend_string *file = zend_string_init(param->file.name, strlen(param->file.name), 0);
+ zend_string *file;
+ char resolved_path_buf[MAXPATHLEN];
+ const char *abspath = param->file.name;
+ if (VCWD_REALPATH(abspath, resolved_path_buf)) {
+ abspath = resolved_path_buf;
+ }
+ file = zend_string_init(abspath, strlen(abspath), 0);
phpdbg_list_file(file, param->file.line, 0, 0);
- efree(file);
+ zend_string_release(file);
} break;
phpdbg_default_switch_case();
@@ -127,16 +133,8 @@ void phpdbg_list_file(zend_string *filename, uint count, int offset, uint highli
{
uint line, lastline;
phpdbg_file_source *data;
- char resolved_path_buf[MAXPATHLEN];
- const char *abspath;
-
- if (VCWD_REALPATH(ZSTR_VAL(filename), resolved_path_buf)) {
- abspath = resolved_path_buf;
- } else {
- abspath = ZSTR_VAL(filename);
- }
- if (!(data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), abspath, strlen(abspath)))) {
+ if (!(data = zend_hash_find_ptr(&PHPDBG_G(file_sources), filename))) {
phpdbg_error("list", "type=\"unknownfile\"", "Could not find information about included file...");
return;
}
@@ -287,6 +285,7 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
return NULL;
}
+ dataptr->filename = estrdup(dataptr->filename);
dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr);
phpdbg_resolve_pending_file_break(filename);
@@ -305,6 +304,17 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
if (VCWD_REALPATH(filename, resolved_path_buf)) {
filename = resolved_path_buf;
+
+ if (file->opened_path) {
+ zend_string_release(file->opened_path);
+ file->opened_path = zend_string_init(filename, strlen(filename), 0);
+ } else {
+ if (file->free_filename) {
+ efree((char *) file->filename);
+ }
+ file->free_filename = 1;
+ file->filename = estrdup(filename);
+ }
}
op_array = PHPDBG_G(init_compile_file)(file, type);
@@ -355,7 +365,7 @@ zend_op_array *phpdbg_compile_string(zval *source_string, char *filename) {
return NULL;
}
- fake_name = strpprintf(0, "%s\0%p", filename, op_array->opcodes);
+ fake_name = strpprintf(0, "%s%c%p", filename, 0, op_array->opcodes);
dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
zend_hash_add_ptr(&PHPDBG_G(file_sources), fake_name, dataptr);
@@ -377,6 +387,7 @@ void phpdbg_free_file_source(zval *zv) {
if (data->buf) {
efree(data->buf);
}
+ efree(data->filename);
destroy_op_array(&data->op_array);