/* }}} */ static void xc_coverager_clean(TSRMLS_D) /* {{{ */ { if (XG(coverages)) { HashPosition pos; coverager_t *pcov; zend_hash_internal_pointer_reset_ex(XG(coverages), &pos); while (zend_hash_get_current_data_ex(XG(coverages), (void **) &pcov, &pos) == SUCCESS) { long *phits; coverager_t cov; HashPosition pos2; cov = *pcov; zend_hash_internal_pointer_reset_ex(cov, &pos2); while (zend_hash_get_current_data_ex(cov, (void**)&phits, &pos2) == SUCCESS) { long hits = *phits; if (hits != -1) { hits = -1; zend_hash_index_update(cov, pos2->h, &hits, sizeof(hits), NULL); } zend_hash_move_forward_ex(cov, &pos2); } zend_hash_move_forward_ex(XG(coverages), &pos); } } }
void xdebug_function_monitor_record(char *func_name, char *filename, int lineno TSRMLS_DC) { xdebug_monitored_function_entry *record; record = xdebug_monitored_function_init(func_name, filename, lineno); xdebug_llist_insert_next(XG(monitored_functions_found), XDEBUG_LLIST_TAIL(XG(monitored_functions_found)), record); }
static void xc_coverager_initenv(TSRMLS_D) /* {{{ */ { if (!XG(coverages)) { XG(coverages) = emalloc(sizeof(HashTable)); zend_hash_init(XG(coverages), 0, NULL, xc_destroy_coverage, 0); } }
/* }}} */ static void xc_coverager_autodump(TSRMLS_D) /* {{{ */ { coverager_t *pcov; zstr s; char *outfilename; int dumpdir_len, outfilelen, alloc_len = 0; uint size; HashPosition pos; if (XG(coverages) && xc_coveragedump_dir) { dumpdir_len = strlen(xc_coveragedump_dir); alloc_len = dumpdir_len + 1 + 128; outfilename = emalloc(alloc_len); strcpy(outfilename, xc_coveragedump_dir); zend_hash_internal_pointer_reset_ex(XG(coverages), &pos); while (zend_hash_get_current_data_ex(XG(coverages), (void **) &pcov, &pos) == SUCCESS) { zend_hash_get_current_key_ex(XG(coverages), &s, &size, NULL, 0, &pos); outfilelen = dumpdir_len + size + 5; if (alloc_len < outfilelen) { alloc_len = outfilelen + 128; outfilename = erealloc(outfilename, alloc_len); } strcpy(outfilename + dumpdir_len, ZSTR_S(s)); strcpy(outfilename + dumpdir_len + size - 1, ".pcov"); TRACE("outfilename %s", outfilename); xc_coverager_save_cov(ZSTR_S(s), outfilename, *pcov TSRMLS_CC); zend_hash_move_forward_ex(XG(coverages), &pos); } efree(outfilename); } }
xdebug_var_export_options* xdebug_var_export_options_from_ini(TSRMLS_D) { xdebug_var_export_options *options; options = xdmalloc(sizeof(xdebug_var_export_options)); options->max_children = XG(display_max_children); options->max_data = XG(display_max_data); options->max_depth = XG(display_max_depth); options->show_hidden = 0; if (options->max_children == -1) { options->max_children = 1048576; } else if (options->max_children < 1) { options->max_children = 1; } if (options->max_data == -1) { options->max_data = 1073741824; } else if (options->max_data < 1) { options->max_data = 1; } if (options->max_depth == -1) { options->max_depth = 4096; } else if (options->max_depth < 0) { options->max_depth = 0; } options->runtime = (xdebug_var_runtime_page*) xdmalloc((options->max_depth + 1) * sizeof(xdebug_var_runtime_page)); options->no_decoration = 0; return options; }
function_stack_entry *xdebug_get_stack_frame(int nr TSRMLS_DC) { xdebug_llist_element *le; if (!XG(stack)) { return NULL; } if (!(le = XDEBUG_LLIST_TAIL(XG(stack)))) { return NULL; } if (nr < 0) { return NULL; } while (nr) { nr--; le = XDEBUG_LLIST_PREV(le); if (!le) { return NULL; } } return XDEBUG_LLIST_VALP(le); }
/* }}} */ static void xc_coverager_cleanup(TSRMLS_D) /* {{{ */ { if (XG(coverages)) { zend_hash_destroy(XG(coverages)); efree(XG(coverages)); XG(coverages) = NULL; } }
static void dump_used_var_with_contents(void *htmlq, xdebug_hash_element* he, void *argument) { int html = *(int *)htmlq; int len; zval *zvar; char *contents; char *name = (char*) he->ptr; HashTable *tmp_ht; char **formats; xdebug_str *str = (xdebug_str *) argument; TSRMLS_FETCH(); if (!he->ptr) { return; } /* Bail out on $this and $GLOBALS */ if (strcmp(name, "this") == 0 || strcmp(name, "GLOBALS") == 0) { return; } #if PHP_VERSION_ID >= 50300 if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } #endif tmp_ht = XG(active_symbol_table); XG(active_symbol_table) = EG(active_symbol_table); zvar = xdebug_get_php_symbol(name, strlen(name) + 1); XG(active_symbol_table) = tmp_ht; formats = select_formats(PG(html_errors) TSRMLS_CC); if (!zvar) { xdebug_str_add(str, xdebug_sprintf(formats[9], name), 1); return; } if (html) { contents = xdebug_get_zval_value_fancy(NULL, zvar, &len, 0, NULL TSRMLS_CC); } else { contents = xdebug_get_zval_value(zvar, 0, NULL); } if (contents) { xdebug_str_add(str, xdebug_sprintf(formats[8], name, contents), 1); } else { xdebug_str_add(str, xdebug_sprintf(formats[9], name), 1); } xdfree(contents); }
void xdebug_log_stack(const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC) { xdebug_llist_element *le; function_stack_entry *i; char *tmp_log_message; tmp_log_message = xdebug_sprintf( "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); php_log_err(tmp_log_message TSRMLS_CC); xdfree(tmp_log_message); if (XG(stack) && XG(stack)->size) { php_log_err("PHP Stack trace:" TSRMLS_CC); for (le = XDEBUG_LLIST_HEAD(XG(stack)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { int c = 0; /* Comma flag */ unsigned int j = 0; /* Counter */ char *tmp_name; xdebug_str log_buffer = {0, 0, NULL}; i = XDEBUG_LLIST_VALP(le); tmp_name = xdebug_show_fname(i->function, 0, 0 TSRMLS_CC); xdebug_str_add(&log_buffer, xdebug_sprintf("PHP %3d. %s(", i->level, tmp_name), 1); xdfree(tmp_name); /* Printing vars */ for (j = 0; j < i->varc; j++) { char *tmp_varname, *tmp_value; if (c) { xdebug_str_addl(&log_buffer, ", ", 2, 0); } else { c = 1; } tmp_varname = i->var[j].name ? xdebug_sprintf("$%s = ", i->var[j].name) : xdstrdup(""); xdebug_str_add(&log_buffer, tmp_varname, 0); xdfree(tmp_varname); if (i->var[j].addr) { tmp_value = xdebug_get_zval_value(i->var[j].addr, 0, NULL); xdebug_str_add(&log_buffer, tmp_value, 0); xdfree(tmp_value); } else { xdebug_str_addl(&log_buffer, "*uninitialized*", 15, 0); } } xdebug_str_add(&log_buffer, xdebug_sprintf(") %s:%d", i->filename, i->lineno), 1); php_log_err(log_buffer.d TSRMLS_CC); xdebug_str_free(&log_buffer); } } }
function_stack_entry *xdebug_get_stack_tail(TSRMLS_D) { xdebug_llist_element *le; if (XG(stack)) { if ((le = XDEBUG_LLIST_TAIL(XG(stack)))) { return XDEBUG_LLIST_VALP(le); } else { return NULL; } } else { return NULL; } }
void xc_coverager_request_init(TSRMLS_D) /* {{{ */ { if (XG(coverager)) { xc_coverager_enable(TSRMLS_C); #ifdef ZEND_COMPILE_EXTENDED_INFO CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; #else CG(extended_info) = 1; #endif } else { XG(coverage_enabled) = 0; } }
void xdebug_append_error_description(xdebug_str *str, int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC) { char **formats = select_formats(html TSRMLS_CC); char *escaped; #if PHP_VERSION_ID >= 50400 size_t newlen; #else int newlen; #endif if (html) { escaped = php_escape_html_entities_ex(buffer, strlen(buffer), &newlen, 0, 0, NULL, 1 TSRMLS_CC); } else { escaped = estrdup(buffer); } if (strlen(XG(file_link_format)) > 0 && html) { char *file_link; create_file_link(&file_link, error_filename, error_lineno TSRMLS_CC); xdebug_str_add(str, xdebug_sprintf(formats[11], error_type_str, escaped, file_link, error_filename, error_lineno), 1); xdfree(file_link); } else { xdebug_str_add(str, xdebug_sprintf(formats[1], error_type_str, escaped, error_filename, error_lineno), 1); } efree(escaped); }
static int create_file_link(char **filename, const char *error_filename, int error_lineno TSRMLS_DC) { xdebug_str fname = {0, 0, NULL}; char *format = XG(file_link_format); while (*format) { if (*format != '%') { xdebug_str_addl(&fname, (char *) format, 1, 0); } else { format++; switch (*format) { case 'f': /* filename */ xdebug_str_add(&fname, xdebug_sprintf("%s", error_filename), 1); break; case 'l': /* line number */ xdebug_str_add(&fname, xdebug_sprintf("%d", error_lineno), 1); break; case '%': /* literal % */ xdebug_str_addl(&fname, "%", 1, 0); break; } } format++; } *filename = fname.d; return fname.l; }
static PHP_RINIT_FUNCTION(xcache_coverager) /* {{{ */ { if (XG(coverager)) { if (XG(coverager_autostart)) { xc_coverager_start(TSRMLS_C); } #ifdef ZEND_COMPILE_EXTENDED_INFO CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; #else CG(extended_info) = 1; #endif } else { XG(coverager_started) = 0; } return SUCCESS; }
static void xdebug_path_info_make_sure_level_exists(xdebug_path_info *path_info, unsigned int level TSRMLS_DC) { unsigned int i = 0, orig_size; orig_size = path_info->paths_size; if (level >= path_info->paths_size) { path_info->paths_size = level + 32; path_info->paths = realloc(path_info->paths, sizeof(xdebug_path*) * path_info->paths_size); for (i = orig_size; i < XG(branches).size; i++) { XG(branches).last_branch_nr[i] = -1; } for (i = orig_size; i < path_info->paths_size; i++) { path_info->paths[i] = NULL; } } }
void xdebug_path_info_add_path_for_level(xdebug_path_info *path_info, xdebug_path *path, unsigned int level TSRMLS_DC) { int i = 0, orig_size; orig_size = path_info->paths_size; if (level > path_info->paths_size) { path_info->paths_size = level + 32; path_info->paths = realloc(path_info->paths, sizeof(xdebug_path*) * path_info->paths_size); for (i = orig_size; i < XG(branches).size; i++) { XG(branches).last_branch_nr[i] = -1; } for (i = orig_size; i < path_info->paths_size; i++) { path_info->paths[i] = NULL; } } path_info->paths[level] = path; }
void xdebug_append_error_description(xdebug_str *str, int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC) { char **formats = select_formats(html TSRMLS_CC); if (strlen(XG(file_link_format)) > 0 && html) { char *file_link; create_file_link(&file_link, error_filename, error_lineno TSRMLS_CC); xdebug_str_add(str, xdebug_sprintf(formats[11], error_type_str, buffer, file_link, error_filename, error_lineno), 1); xdfree(file_link); } else { xdebug_str_add(str, xdebug_sprintf(formats[1], error_type_str, buffer, error_filename, error_lineno), 1); } }
char* xdebug_return_trace_assignment(function_stack_entry *i, char *varname, zval *retval, char *op, char *filename, int lineno TSRMLS_DC) { int j = 0; xdebug_str str = {0, 0, NULL}; char *tmp_value; if (XG(trace_format) != 0) { return xdstrdup(""); } xdebug_str_addl(&str, " ", 20, 0); if (XG(show_mem_delta)) { xdebug_str_addl(&str, " ", 8, 0); } for (j = 0; j <= i->level; j++) { xdebug_str_addl(&str, " ", 2, 0); } xdebug_str_addl(&str, " => ", 6, 0); xdebug_str_add(&str, varname, 0); if (op[0] != '\0' ) { /* pre/post inc/dec ops are special */ xdebug_str_add(&str, xdebug_sprintf(" %s ", op), 1); tmp_value = xdebug_get_zval_value(retval, 0, NULL); if (tmp_value) { xdebug_str_add(&str, tmp_value, 1); } else { xdebug_str_addl(&str, "NULL", 4, 0); } } xdebug_str_add(&str, xdebug_sprintf(" %s:%d\n", filename, lineno), 1); return str.d; }
int xdebug_common_override_handler(ZEND_OPCODE_HANDLER_ARGS) { if (XG(do_code_coverage)) { zend_op *cur_opcode; int lineno; char *file; zend_op_array *op_array = execute_data->op_array; cur_opcode = *EG(opline_ptr); lineno = cur_opcode->lineno; file = (char *)op_array->filename; xdebug_count_line(file, lineno, 0, 0 TSRMLS_CC); } return ZEND_USER_OPCODE_DISPATCH; }
void xdebug_trace_function_end(function_stack_entry *fse, int function_nr TSRMLS_DC) { if (XG(do_trace) && XG(trace_file)) { char *t = return_trace_stack_frame_end(fse, function_nr TSRMLS_CC); if (fprintf(XG(trace_file), "%s", t) < 0) { fclose(XG(trace_file)); XG(trace_file) = NULL; } else { fflush(XG(trace_file)); } xdfree(t); } }
xdebug_trace_handler_t *xdebug_select_trace_handler(int options TSRMLS_DC) { xdebug_trace_handler_t *tmp; switch (XG(trace_format)) { case 0: tmp = &xdebug_trace_handler_textual; break; case 1: tmp = &xdebug_trace_handler_computerized; break; case 2: tmp = &xdebug_trace_handler_html; break; } if (options & XDEBUG_TRACE_OPTION_COMPUTERIZED) { tmp = &xdebug_trace_handler_computerized; } if (options & XDEBUG_TRACE_OPTION_HTML) { tmp = &xdebug_trace_handler_html; } return tmp; }
xdebug_trace_handler_t *xdebug_select_trace_handler(int options TSRMLS_DC) { xdebug_trace_handler_t *tmp; switch (XG(trace_format)) { case 0: tmp = &xdebug_trace_handler_textual; break; case 1: tmp = &xdebug_trace_handler_computerized; break; case 2: tmp = &xdebug_trace_handler_html; break; default: php_error(E_NOTICE, "A wrong value for xdebug.trace_format was selected (%d), defaulting to the textual format.", XG(trace_format)); tmp = &xdebug_trace_handler_textual; break; } if (options & XDEBUG_TRACE_OPTION_COMPUTERIZED) { tmp = &xdebug_trace_handler_computerized; } if (options & XDEBUG_TRACE_OPTION_HTML) { tmp = &xdebug_trace_handler_html; } return tmp; }
/***************************************************************************** ** PHP Variable related utility functions */ zval* xdebug_get_php_symbol(char* name, int name_length) { HashTable *st = NULL; zval **retval; TSRMLS_FETCH(); st = XG(active_symbol_table); if (st && st->nNumOfElements && zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) { return *retval; } st = EG(active_op_array)->static_variables; if (st) { if (zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) { return *retval; } } st = &EG(symbol_table); if (zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) { return *retval; } return NULL; }
static void only_leave_first_catch(zend_op_array *opa, xdebug_branch_info *branch_info, int position) { unsigned int exit_jmp; #if PHP_VERSION_ID >= 70300 && ZEND_USE_ABS_JMP_ADDR zend_op *base_address = &(opa->opcodes[0]); #endif if (opa->opcodes[position].opcode == ZEND_FETCH_CLASS) { position++; } if (opa->opcodes[position].opcode != ZEND_CATCH) { return; } xdebug_set_remove(branch_info->entry_points, position); #if PHP_VERSION_ID >= 70300 if (!(opa->opcodes[position].extended_value & ZEND_LAST_CATCH)) { exit_jmp = XDEBUG_ZNODE_JMP_LINE(opa->opcodes[position].op2, position, base_address); #else if (!opa->opcodes[position].result.num) { # if PHP_VERSION_ID >= 70100 exit_jmp = position + ((signed int) opa->opcodes[position].extended_value / sizeof(zend_op)); # else exit_jmp = opa->opcodes[position].extended_value; # endif #endif if (opa->opcodes[exit_jmp].opcode == ZEND_FETCH_CLASS) { exit_jmp++; } if (opa->opcodes[exit_jmp].opcode == ZEND_CATCH) { only_leave_first_catch(opa, branch_info, exit_jmp); } } } void xdebug_branch_post_process(zend_op_array *opa, xdebug_branch_info *branch_info) { unsigned int i; int in_branch = 0, last_start = -1; #if PHP_VERSION_ID >= 70300 && ZEND_USE_ABS_JMP_ADDR zend_op *base_address = &(opa->opcodes[0]); #endif /* Figure out which CATCHes are chained, and hence which ones should be * considered entry points */ for (i = 0; i < branch_info->entry_points->size; i++) { if (xdebug_set_in(branch_info->entry_points, i) && opa->opcodes[i].opcode == ZEND_CATCH) { #if PHP_VERSION_ID >= 70300 # if ZEND_USE_ABS_JMP_ADDR if (opa->opcodes[i].op2.jmp_addr != NULL) { # else if (opa->opcodes[i].op2.jmp_offset != 0) { # endif only_leave_first_catch(opa, branch_info, XDEBUG_ZNODE_JMP_LINE(opa->opcodes[i].op2, i, base_address)); } #elif PHP_VERSION_ID >= 70100 only_leave_first_catch(opa, branch_info, i + ((signed int) opa->opcodes[i].extended_value / sizeof(zend_op))); #else only_leave_first_catch(opa, branch_info, opa->opcodes[i].extended_value); #endif } } for (i = 0; i < branch_info->starts->size; i++) { if (xdebug_set_in(branch_info->starts, i)) { if (in_branch) { branch_info->branches[last_start].outs_count = 1; branch_info->branches[last_start].outs[0] = i; branch_info->branches[last_start].end_op = i-1; branch_info->branches[last_start].end_lineno = branch_info->branches[i].start_lineno; } last_start = i; in_branch = 1; } if (xdebug_set_in(branch_info->ends, i)) { size_t j; for (j = 0; j < branch_info->branches[i].outs_count; j++) { branch_info->branches[last_start].outs[j] = branch_info->branches[i].outs[j]; } branch_info->branches[last_start].outs_count = branch_info->branches[i].outs_count; branch_info->branches[last_start].end_op = i; branch_info->branches[last_start].end_lineno = branch_info->branches[i].start_lineno; in_branch = 0; } } } void xdebug_path_add(xdebug_path *path, unsigned int nr) { if (!path) { return; } if (path->elements_count == path->elements_size) { path->elements_size += 32; path->elements = realloc(path->elements, sizeof(unsigned int) * path->elements_size); } path->elements[path->elements_count] = nr; path->elements_count++; } static void xdebug_path_info_add_path(xdebug_path_info *path_info, xdebug_path *path) { if (path_info->paths_count == path_info->paths_size) { path_info->paths_size += 32; path_info->paths = realloc(path_info->paths, sizeof(xdebug_path*) * path_info->paths_size); } path_info->paths[path_info->paths_count] = path; path_info->paths_count++; } static void xdebug_path_info_make_sure_level_exists(xdebug_path_info *path_info, unsigned int level TSRMLS_DC) { unsigned int i = 0, orig_size; orig_size = path_info->paths_size; if (level >= path_info->paths_size) { path_info->paths_size = level + 32; path_info->paths = realloc(path_info->paths, sizeof(xdebug_path*) * path_info->paths_size); for (i = orig_size; i < XG(branches).size; i++) { XG(branches).last_branch_nr[i] = -1; } for (i = orig_size; i < path_info->paths_size; i++) { path_info->paths[i] = NULL; } } }
/* }}} */ static void xc_coverager_stop(TSRMLS_D) /* {{{ */ { XG(coverager_started) = 0; }
static zend_op_array *xc_check_initial_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */ { XG(initial_compile_file_called) = 1; return old_compile_file(h, type TSRMLS_CC); }
void ANCFBeamBE2D::EvalF2(Vector& f, double t) { Body2D::EvalF2(f, t); TMStartTimer(22); // do the computation /*ConstVector<ANCFBeamBE2DmaxDOF> fadd(2*NS()); // temporary storage vector ConstVector<ANCFBeamBE2DmaxDOF> delta_eps(2*NS()), delta_kappa(2*NS()); double EI = GetBeamEIy(); double EA = GetBeamEA(); for (IntegrationPointsIterator ip(integrationRuleStiffness); !ip.IsEnd(); ++ip) { double x = ip.Point2D().X(); double eps = GetEpsAxial(x); double kappa = GetKappa(x); GetDeltaEpsAxial(x, delta_eps); GetDeltaKappa(x, delta_kappa); fadd += ((EA*eps)*delta_eps + (EI*kappa)*delta_kappa) * (ip.Weight() * lx*0.5); } f -= fadd;*/ ConstVector<ANCFBeamBE2DmaxDOF> fadd(2*NS()); // temporary storage vector ConstVector<ANCFBeamBE2DmaxDOF> delta_eps(2*NS()), delta_kappa(2*NS()); double EI = GetBeamEIy(); double EA = GetBeamEA(); for (IntegrationPointsIterator ip(integrationRuleStiffness); !ip.IsEnd(); ++ip) { double x = ip.Point2D().X(); //Vector2D rx = GetPosx2D(x); //Vector2D rxx = GetPosxx2D(x); Vector2D rx, rxx; for (int i = 1; i <= NS(); i++) { //double sx = ip.GetVectorData(1)->Get(i) * 2./lx; //double sxx = ip.GetVectorData(2)->Get(i) * 4./(lx*lx); double sx = GetS0x(x, i) * 2./GetLx(); double sxx = GetS0xx(x, i) * 4./(GetLx()*GetLx()); double d1 = q0(2*i-1) + XG(2*i-1); double d2 = q0(2*i ) + XG(2*i ); rx(1) += sx * d1; rx(2) += sx * d2; rxx(1) += sxx * d1; rxx(2) += sxx * d2; } double rxn2 = rx.Norm2(); double eps = rx.Norm() - 1.0; double kappa = (rx.Cross(rxx))/rxn2; double d = 1./rx.Norm(); double kdux = -2.*rx(1)*kappa / rxn2 + rxx(2) / rxn2; double kduxx = -rx(2) / rxn2; double kdwx = -2.*rx(2)*kappa / rxn2 - rxx(1) / rxn2; double kdwxx = rx(1) / rxn2; for (int j = 1; j <= NS(); j++) { double sx = GetS0x(x, j) * 2./GetLx(); double sxx = GetS0xx(x, j) * 4./(GetLx()*GetLx()); //double sx = ip.GetVectorData(1)->Get(j) * 2./lx; //double sxx = ip.GetVectorData(2)->Get(j) * 4./(lx*lx); delta_eps(2*j-1) = d * rx(1) * sx; delta_eps(2*j ) = d * rx(2) * sx; delta_kappa(2*j-1) = (kdux * sx + kduxx * sxx); delta_kappa(2*j ) = (kdwx * sx + kdwxx * sxx); } fadd += ((EA*eps)*delta_eps + (EI*kappa)*delta_kappa) * (ip.Weight() * GetLx()*0.5); } f -= fadd; TMStopTimer(22); };
void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC) { xdebug_llist_element *le; function_stack_entry *i; int len; char **formats = select_formats(html TSRMLS_CC); if (XG(stack) && XG(stack)->size) { i = XDEBUG_LLIST_VALP(XDEBUG_LLIST_HEAD(XG(stack))); xdebug_str_add(str, formats[2], 0); for (le = XDEBUG_LLIST_HEAD(XG(stack)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) { int c = 0; /* Comma flag */ int j = 0; /* Counter */ char *tmp_name; i = XDEBUG_LLIST_VALP(le); tmp_name = xdebug_show_fname(i->function, html, 0 TSRMLS_CC); if (html) { #if HAVE_PHP_MEMORY_USAGE xdebug_str_add(str, xdebug_sprintf(formats[3], i->level, i->time - XG(start_time), i->memory, tmp_name), 1); #else xdebug_str_add(str, xdebug_sprintf(formats[3], i->level, i->time - XG(start_time), tmp_name), 1); #endif } else { #if HAVE_PHP_MEMORY_USAGE xdebug_str_add(str, xdebug_sprintf(formats[3], i->time - XG(start_time), i->memory, i->level, tmp_name), 1); #else xdebug_str_add(str, xdebug_sprintf(formats[3], i->time - XG(start_time), i->level, tmp_name), 1); #endif } xdfree(tmp_name); /* Printing vars */ for (j = 0; j < i->varc; j++) { char *tmp_value, *tmp_fancy_value, *tmp_fancy_synop_value; int newlen; if (c) { xdebug_str_addl(str, ", ", 2, 0); } else { c = 1; } if (i->var[j].name && XG(collect_params) >= 4) { if (html) { xdebug_str_add(str, xdebug_sprintf("<span>$%s = </span>", i->var[j].name), 1); } else { xdebug_str_add(str, xdebug_sprintf("$%s = ", i->var[j].name), 1); } } if (i->var[j].addr) { if (html) { tmp_value = xdebug_get_zval_value(i->var[j].addr, 0, NULL); tmp_fancy_value = xdebug_xmlize(tmp_value, strlen(tmp_value), &newlen); tmp_fancy_synop_value = xdebug_get_zval_synopsis_fancy("", i->var[j].addr, &len, 0, NULL TSRMLS_CC); switch (XG(collect_params)) { case 1: // synopsis xdebug_str_add(str, xdebug_sprintf("<span>%s</span>", tmp_fancy_synop_value), 1); break; case 2: // synopsis + full in tooltip xdebug_str_add(str, xdebug_sprintf("<span title='%s'>%s</span>", tmp_fancy_value, tmp_fancy_synop_value), 1); break; case 3: // full default: xdebug_str_add(str, xdebug_sprintf("<span>%s</span>", tmp_fancy_value), 1); break; } xdfree(tmp_value); efree(tmp_fancy_value); xdfree(tmp_fancy_synop_value); } else { switch (XG(collect_params)) { case 1: // synopsis case 2: tmp_value = xdebug_get_zval_synopsis(i->var[j].addr, 0, NULL); break; case 3: default: tmp_value = xdebug_get_zval_value(i->var[j].addr, 0, NULL); break; } if (tmp_value) { xdebug_str_add(str, xdebug_sprintf("%s", tmp_value), 1); xdfree(tmp_value); } else { xdebug_str_addl(str, "???", 3, 0); } } } else { xdebug_str_addl(str, "???", 3, 0); } } if (i->include_filename) { xdebug_str_add(str, xdebug_sprintf(formats[4], i->include_filename), 1); } if (html) { if (strlen(XG(file_link_format)) > 0) { char *just_filename = strrchr(i->filename, DEFAULT_SLASH); char *file_link; create_file_link(&file_link, i->filename, i->lineno TSRMLS_CC); xdebug_str_add(str, xdebug_sprintf(formats[10], i->filename, file_link, just_filename, i->lineno), 1); xdfree(file_link); } else { char *just_filename = strrchr(i->filename, DEFAULT_SLASH); xdebug_str_add(str, xdebug_sprintf(formats[5], i->filename, just_filename, i->lineno), 1); } } else { xdebug_str_add(str, xdebug_sprintf(formats[5], i->filename, i->lineno), 1); } } if (XG(dump_globals) && !(XG(dump_once) && XG(dumped))) { char *tmp = xdebug_get_printable_superglobals(html TSRMLS_CC); if (tmp) { xdebug_str_add(str, tmp, 1); } XG(dumped) = 1; } if (XG(show_local_vars) && XG(stack) && XDEBUG_LLIST_TAIL(XG(stack))) { int scope_nr = XG(stack)->size; i = XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))); if (i->user_defined == XDEBUG_INTERNAL && XDEBUG_LLIST_PREV(XDEBUG_LLIST_TAIL(XG(stack))) && XDEBUG_LLIST_VALP(XDEBUG_LLIST_PREV(XDEBUG_LLIST_TAIL(XG(stack))))) { i = XDEBUG_LLIST_VALP(XDEBUG_LLIST_PREV(XDEBUG_LLIST_TAIL(XG(stack)))); scope_nr--; } if (i->used_vars && i->used_vars->size) { xdebug_hash *tmp_hash; xdebug_str_add(str, xdebug_sprintf(formats[6], scope_nr), 1); tmp_hash = xdebug_used_var_hash_from_llist(i->used_vars); xdebug_hash_apply_with_argument(tmp_hash, (void*) &html, dump_used_var_with_contents, (void *) str); xdebug_hash_destroy(tmp_hash); } } } }
void xdebug_init_debugger(TSRMLS_D) { xdebug_open_log(TSRMLS_C); if (XG(remote_connect_back)) { zval **remote_addr = NULL; XDEBUG_LOG_PRINT(XG(remote_log_file), "I: Checking remote connect back address.\n"); if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "X_HTTP_FORWARDED_FOR", 21, (void**)&remote_addr) == FAILURE) { zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr); } if (remote_addr) { XDEBUG_LOG_PRINT(XG(remote_log_file), "I: Remote address found, connecting to %s:%d.\n", Z_STRVAL_PP(remote_addr), XG(remote_port)); XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port)); } else { XDEBUG_LOG_PRINT(XG(remote_log_file), "W: Remote address not found, connecting to configured address/port: %s:%d. :-|\n", XG(remote_host), XG(remote_port)); XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port)); } } else { XDEBUG_LOG_PRINT(XG(remote_log_file), "I: Connecting to configured address/port: %s:%d.\n", XG(remote_host), XG(remote_port)); XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port)); } if (XG(context).socket >= 0) { XDEBUG_LOG_PRINT(XG(remote_log_file), "I: Connected to client. :-)\n"); XG(remote_enabled) = 0; /* Get handler from mode */ XG(context).handler = xdebug_handler_get(XG(remote_handler)); if (!XG(context).handler) { zend_error(E_WARNING, "The remote debug handler '%s' is not supported.", XG(remote_handler)); XDEBUG_LOG_PRINT(XG(remote_log_file), "E: The remote debug handler '%s' is not supported. :-(\n", XG(remote_handler)); } else if (!XG(context).handler->remote_init(&(XG(context)), XDEBUG_REQ)) { /* The request could not be started, ignore it then */ XDEBUG_LOG_PRINT(XG(remote_log_file), "E: The debug session could not be started. :-(\n"); } else { /* All is well, turn off script time outs */ XG(remote_enabled) = 1; } } else { XDEBUG_LOG_PRINT(XG(remote_log_file), "E: Could not connect to client. :-(\n"); } if (!XG(remote_enabled)) { xdebug_close_log(TSRMLS_C); } }
void xdebug_do_jit(TSRMLS_D) { if (!XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) { xdebug_init_debugger(TSRMLS_C); } }