mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix potentially uninitialized warnings in phpdbg
This commit is contained in:
parent
88bfd2ae98
commit
c09b63595e
8 changed files with 47 additions and 41 deletions
|
@ -671,11 +671,11 @@ static PHP_FUNCTION(phpdbg_end_oplog)
|
|||
|
||||
{
|
||||
zend_string *last_file = NULL;
|
||||
HashTable *file_ht;
|
||||
HashTable *file_ht = NULL;
|
||||
zend_string *last_function = (void *)~(uintptr_t)0;
|
||||
zend_class_entry *last_scope = NULL;
|
||||
|
||||
HashTable *insert_ht;
|
||||
HashTable *insert_ht = NULL;
|
||||
zend_long insert_idx;
|
||||
|
||||
do {
|
||||
|
@ -717,6 +717,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
|
|||
insert_idx = cur->op->lineno;
|
||||
}
|
||||
|
||||
ZEND_ASSERT(insert_ht && file_ht);
|
||||
{
|
||||
zval *num = zend_hash_index_find(insert_ht, insert_idx);
|
||||
if (!num) {
|
||||
|
|
|
@ -171,7 +171,7 @@ void phpdbg_switch_frame(int frame) /* {{{ */
|
|||
|
||||
static void phpdbg_dump_prototype(zval *tmp) /* {{{ */
|
||||
{
|
||||
zval *funcname, *class, class_zv, *type, *args, *argstmp;
|
||||
zval *funcname, *class, class_zv, *args, *argstmp;
|
||||
|
||||
funcname = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("function"));
|
||||
|
||||
|
@ -183,21 +183,22 @@ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */
|
|||
}
|
||||
|
||||
if (class) {
|
||||
type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type"));
|
||||
zval *type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type"));
|
||||
|
||||
phpdbg_xml(" symbol=\"%s%s%s\"", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname));
|
||||
phpdbg_out("%s%s%s(", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname));
|
||||
} else {
|
||||
phpdbg_xml(" symbol=\"%s\"", Z_STRVAL_P(funcname));
|
||||
phpdbg_out("%s(", Z_STRVAL_P(funcname));
|
||||
}
|
||||
|
||||
args = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("args"));
|
||||
|
||||
phpdbg_xml(" symbol=\"%s%s%s\"", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
|
||||
|
||||
if (args) {
|
||||
phpdbg_xml(">");
|
||||
} else {
|
||||
phpdbg_xml(" />");
|
||||
}
|
||||
|
||||
phpdbg_out("%s%s%s(", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
|
||||
|
||||
if (args) {
|
||||
const zend_function *func = NULL;
|
||||
const zend_arg_info *arginfo = NULL;
|
||||
|
|
|
@ -343,11 +343,11 @@ PHPDBG_INFO(literal) /* {{{ */
|
|||
PHPDBG_INFO(memory) /* {{{ */
|
||||
{
|
||||
size_t used, real, peak_used, peak_real;
|
||||
zend_mm_heap *heap;
|
||||
zend_mm_heap *orig_heap = NULL;
|
||||
zend_bool is_mm;
|
||||
|
||||
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
|
||||
heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem());
|
||||
orig_heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem());
|
||||
}
|
||||
if ((is_mm = is_zend_mm())) {
|
||||
used = zend_memory_usage(0);
|
||||
|
@ -355,8 +355,8 @@ PHPDBG_INFO(memory) /* {{{ */
|
|||
peak_used = zend_memory_peak_usage(0);
|
||||
peak_real = zend_memory_peak_usage(1);
|
||||
}
|
||||
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
|
||||
zend_mm_set_heap(heap);
|
||||
if (orig_heap) {
|
||||
zend_mm_set_heap(orig_heap);
|
||||
}
|
||||
|
||||
if (is_mm) {
|
||||
|
|
|
@ -1030,9 +1030,8 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
|
|||
} else {
|
||||
phpdbg_mixed_write(fd, msg, msglen);
|
||||
}
|
||||
return msglen;
|
||||
}
|
||||
break;
|
||||
return msglen;
|
||||
|
||||
/* no formatting on logging output */
|
||||
case P_LOG:
|
||||
|
@ -1046,6 +1045,7 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
|
|||
}
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
|
||||
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
|
||||
|
|
|
@ -1687,33 +1687,33 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */
|
|||
return ret;
|
||||
} /* }}} */
|
||||
|
||||
static inline void list_code() {
|
||||
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
|
||||
const char *file_char = zend_get_executed_filename();
|
||||
zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
|
||||
phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno());
|
||||
efree(file);
|
||||
}
|
||||
}
|
||||
|
||||
/* code may behave weirdly if EG(exception) is set; thus backup it */
|
||||
#define DO_INTERACTIVE(allow_async_unsafe) do { \
|
||||
const zend_op *backup_opline; \
|
||||
const zend_op *before_ex; \
|
||||
if (exception) { \
|
||||
const zend_op *before_ex = EG(opline_before_exception); \
|
||||
const zend_op *backup_opline = NULL; \
|
||||
if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) { \
|
||||
backup_opline = EG(current_execute_data)->opline; \
|
||||
} \
|
||||
before_ex = EG(opline_before_exception); \
|
||||
GC_ADDREF(exception); \
|
||||
zend_clear_exception(); \
|
||||
} \
|
||||
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \
|
||||
const char *file_char = zend_get_executed_filename(); \
|
||||
zend_string *file = zend_string_init(file_char, strlen(file_char), 0); \
|
||||
phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno()); \
|
||||
efree(file); \
|
||||
} \
|
||||
\
|
||||
switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \
|
||||
zval zv; \
|
||||
case PHPDBG_LEAVE: \
|
||||
case PHPDBG_FINISH: \
|
||||
case PHPDBG_UNTIL: \
|
||||
case PHPDBG_NEXT: \
|
||||
if (exception) { \
|
||||
if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) \
|
||||
list_code(); \
|
||||
switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \
|
||||
zval zv; \
|
||||
case PHPDBG_LEAVE: \
|
||||
case PHPDBG_FINISH: \
|
||||
case PHPDBG_UNTIL: \
|
||||
case PHPDBG_NEXT: \
|
||||
if (backup_opline \
|
||||
&& (backup_opline->opcode == ZEND_HANDLE_EXCEPTION || backup_opline->opcode == ZEND_CATCH)) { \
|
||||
EG(current_execute_data)->opline = backup_opline; \
|
||||
EG(exception) = exception; \
|
||||
|
@ -1722,11 +1722,12 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */
|
|||
zend_throw_exception_internal(&zv); \
|
||||
} \
|
||||
EG(opline_before_exception) = before_ex; \
|
||||
} \
|
||||
/* fallthrough */ \
|
||||
default: \
|
||||
goto next; \
|
||||
} \
|
||||
} else { \
|
||||
list_code(); \
|
||||
phpdbg_interactive(allow_async_unsafe, NULL); \
|
||||
} \
|
||||
goto next; \
|
||||
} while (0)
|
||||
|
||||
void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
|
||||
|
|
|
@ -430,7 +430,7 @@ PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent,
|
|||
PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, phpdbg_parse_var_with_arg_func step_cb, zend_bool silent, void *arg) {
|
||||
int ret = FAILURE;
|
||||
zend_bool new_index = 1;
|
||||
char *last_index;
|
||||
char *last_index = NULL;
|
||||
size_t index_len = 0;
|
||||
zval *zv;
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
|
|||
zend_extension *extension;
|
||||
zend_llist_position pos;
|
||||
zval *name = NULL;
|
||||
zend_string *strkey;
|
||||
zend_string *strkey = NULL;
|
||||
|
||||
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
|
||||
while (extension) {
|
||||
|
@ -257,6 +257,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
|
|||
break;
|
||||
}
|
||||
name = NULL;
|
||||
strkey = NULL;
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
if (name) {
|
||||
|
@ -283,6 +284,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
|
|||
pefree(elm, zend_extensions.persistent);
|
||||
zend_extensions.count--;
|
||||
} else {
|
||||
ZEND_ASSERT(strkey);
|
||||
zend_hash_del(Z_ARRVAL_P(zvp), strkey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1014,13 +1014,14 @@ void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) {
|
|||
}
|
||||
if (watch->type == WATCH_ON_BUCKET) {
|
||||
if (watch->backup.bucket.key != watch->addr.bucket->key || (watch->backup.bucket.key != NULL && watch->backup.bucket.h != watch->addr.bucket->h)) {
|
||||
phpdbg_watch_element *element;
|
||||
phpdbg_watch_element *element = NULL;
|
||||
zval *new;
|
||||
|
||||
ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
|
||||
break;
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
ZEND_ASSERT(element); /* elements must be non-empty */
|
||||
new = zend_symtable_find(element->parent_container, element->name_in_parent);
|
||||
|
||||
if (!new) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue