Skip to content

Commit

Permalink
zend_string/char* changes for filenames in code coverage (and others)
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Sep 12, 2015
1 parent 3f013de commit e9dac87
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_op_array *op_array)

lineno = EG(current_execute_data)->opline->lineno;

file = (char *) op_array->filename;
file = (char*) STR_NAME_VAL(op_array->filename);

if (XG(do_code_coverage)) {
xdebug_count_line(file, lineno, 0, 0 TSRMLS_CC);
Expand Down
20 changes: 6 additions & 14 deletions xdebug_code_coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,6 @@ static void xdebug_analyse_oparray(zend_op_array *opa, xdebug_set *set, xdebug_b
}
}

#if PHP_VERSION_ID >= 70000
# define STR_NAME_VAL(k) (k)->val
#else
# define STR_NAME_VAL(k) (k)
#endif

static void xdebug_build_fname_from_oparray(xdebug_func *tmp, zend_op_array *opa TSRMLS_DC)
{
int closure = 0;
Expand All @@ -765,7 +759,7 @@ static void xdebug_build_fname_from_oparray(xdebug_func *tmp, zend_op_array *opa
if (strcmp(STR_NAME_VAL(opa->function_name), "{closure}") == 0) {
tmp->function = xdebug_sprintf(
"{closure:%s:%d-%d}",
opa->filename,
STR_NAME_VAL(opa->filename),
opa->line_start,
opa->line_end
);
Expand All @@ -785,8 +779,6 @@ static void xdebug_build_fname_from_oparray(xdebug_func *tmp, zend_op_array *opa
}
}

#undef STR_NAME_VAL

static char* xdebug_func_format(xdebug_func *func TSRMLS_DC)
{
switch (func->type) {
Expand Down Expand Up @@ -862,7 +854,7 @@ static int prefill_from_function_table(zend_op_array *opa TSRMLS_DC, int num_arg
{
if (opa->type == ZEND_USER_FUNCTION) {
if ((long) opa->reserved[XG(dead_code_analysis_tracker_offset)] < XG(dead_code_last_start_id)) {
prefill_from_oparray((char *) opa->filename, opa TSRMLS_CC);
prefill_from_oparray((char*) STR_NAME_VAL(opa->filename), opa TSRMLS_CC);
}
}

Expand Down Expand Up @@ -890,11 +882,11 @@ static int prefill_from_class_table(zend_class_entry **class_entry TSRMLS_DC, in
void xdebug_prefill_code_coverage(zend_op_array *op_array TSRMLS_DC)
{
if ((long) op_array->reserved[XG(dead_code_analysis_tracker_offset)] < XG(dead_code_last_start_id)) {
prefill_from_oparray((char *) op_array->filename, op_array TSRMLS_CC);
prefill_from_oparray((char*) STR_NAME_VAL(op_array->filename), op_array TSRMLS_CC);
}

zend_hash_apply_with_arguments(CG(function_table) TSRMLS_CC, (apply_func_args_t) prefill_from_function_table, 1, op_array->filename);
zend_hash_apply_with_arguments(CG(class_table) TSRMLS_CC, (apply_func_args_t) prefill_from_class_table, 1, op_array->filename);
zend_hash_apply_with_arguments(CG(function_table) TSRMLS_CC, (apply_func_args_t) prefill_from_function_table, 1, STR_NAME_VAL(op_array->filename));
zend_hash_apply_with_arguments(CG(class_table) TSRMLS_CC, (apply_func_args_t) prefill_from_class_table, 1, STR_NAME_VAL(op_array->filename));
}

void xdebug_code_coverage_start_of_function(zend_op_array *op_array TSRMLS_DC)
Expand All @@ -916,7 +908,7 @@ void xdebug_code_coverage_end_of_function(zend_op_array *op_array TSRMLS_DC)
{
xdebug_str str = { 0, 0, NULL };
xdebug_path *path = xdebug_path_info_get_path_for_level(XG(paths_stack), XG(level) TSRMLS_CC);
char *file = (char *) op_array->filename;
char *file = (char*) STR_NAME_VAL(op_array->filename);
xdebug_func func_info;
char *function_name;

Expand Down
2 changes: 1 addition & 1 deletion xdebug_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ char *xdebug_str_to_str(char *haystack, size_t length, char *needle, size_t need
new_str = php_str_to_str(haystack, length, needle, needle_len, str, str_len);
*new_len = new_str->len;

retval = estrdup(new_str->val);
retval = estrndup(new_str->val, new_str->len);

zend_string_release(new_str);

Expand Down
6 changes: 1 addition & 5 deletions xdebug_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ void xdebug_profiler_function_user_end(function_stack_entry *fse, zend_op_array*

if (fse->prev) {
xdebug_call_entry *ce = xdmalloc(sizeof(xdebug_call_entry));
#if PHP_VERSION_ID >= 70000
ce->filename = op_array ? xdstrdup(op_array->filename->val) : xdstrdup(fse->filename);
#else
ce->filename = op_array ? xdstrdup(op_array->filename) : xdstrdup(fse->filename);
#endif
ce->filename = op_array ? xdstrdup(STR_NAME_VAL(op_array->filename)) : xdstrdup(fse->filename);
ce->function = xdstrdup(tmp_name);
ce->time_taken = fse->profile.time;
ce->lineno = fse->lineno;
Expand Down

0 comments on commit e9dac87

Please sign in to comment.