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);
}
Beispiel #2
0
static void do_var_dump(const Variant& v) {
  auto const cli = XDEBUG_GLOBAL(CliColor);
  XDebugExporter exporter;
  exporter.max_depth = XDEBUG_GLOBAL(VarDisplayMaxDepth);
  exporter.max_children = XDEBUG_GLOBAL(VarDisplayMaxChildren);
  exporter.max_data = XDEBUG_GLOBAL(VarDisplayMaxData);
  exporter.page = 0;

  String str;

  auto const html_errors =
    ThreadInfo::s_threadInfo->m_reqInjectionData.hasHtmlErrors();
  if (html_errors) {
    str = xdebug_get_zval_value_fancy(v, exporter);
  } else if ((cli == 1 && is_output_tty()) || cli == 2) {
    str = xdebug_get_zval_value_ansi(v, exporter);
  } else {
    str = xdebug_get_zval_value_text(v, exporter);
  }

  g_context->write(str);
}