Skip to content

Commit

Permalink
Move var_dump() to HNI, kill off variable.idl.json
Browse files Browse the repository at this point in the history
Summary: Note that this modifies xdebug code-coverage behavior.

Our xdebug implementation doesn't profile IDL based
builtins, but it does happily profile HNI based ones.

It *should* profile all IDL based functions,
so that'll have to be fixed in a followup,
but for now I've re-recorded the effected xdebug tests
to provide the correct results.

Reviewed By: @ptarjan

Differential Revision: D1515818
  • Loading branch information
sgolemon authored and hhvm-bot committed Aug 25, 2014
1 parent f5ac082 commit 4d5a311
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 54 deletions.
2 changes: 1 addition & 1 deletion hphp/runtime/base/program-functions.cpp
Expand Up @@ -670,7 +670,7 @@ void execute_command_line_end(int xhprof, bool coverage, const char *program) {
}

if (xhprof) {
f_var_dump(HHVM_FN(json_encode)(f_xhprof_disable()));
HHVM_FN(var_dump)(HHVM_FN(json_encode)(f_xhprof_disable()));
}
g_context->onShutdownPostSend();
Eval::Debugger::InterruptPSPEnded(program);
Expand Down
22 changes: 13 additions & 9 deletions hphp/runtime/ext/std/ext_std_variable.cpp
Expand Up @@ -159,20 +159,23 @@ Variant HHVM_FUNCTION(var_export, const Variant& expression,
return res;
}

void f_var_dump(const Variant& v) {
VariableSerializer vs(VariableSerializer::Type::VarDump, 0, 2);
static ALWAYS_INLINE void do_var_dump(VariableSerializer vs,
const Variant& expression) {
// manipulate maxCount to match PHP behavior
if (!v.isObject()) {
if (!expression.isObject()) {
vs.incMaxCount();
}
vs.serialize(v, false);
vs.serialize(expression, false);
}

void f_var_dump(int _argc, const Variant& expression,
const Array& _argv /* = null_array */) {
f_var_dump(expression);
for (int i = 0; i < _argv.size(); i++) {
f_var_dump(_argv[i]);
void HHVM_FUNCTION(var_dump, const Variant& expression,
const Array& _argv /*=null_array */) {
VariableSerializer vs(VariableSerializer::Type::VarDump, 0, 2);
do_var_dump(vs, expression);

auto sz = _argv.size();
for (int i = 0; i < sz; i++) {
do_var_dump(vs, _argv[i]);
}
}

Expand Down Expand Up @@ -406,6 +409,7 @@ void StandardExtension::initVariable() {
HHVM_FE(print_r);
HHVM_FE(var_export);
HHVM_FE(debug_zval_dump);
HHVM_FE(var_dump);
HHVM_FE(serialize);
HHVM_FE(unserialize);
HHVM_FE(get_defined_vars);
Expand Down
5 changes: 2 additions & 3 deletions hphp/runtime/ext/std/ext_std_variable.h
Expand Up @@ -47,9 +47,8 @@ bool HHVM_FUNCTION(settype, VRefParam var, const String& type);

Variant HHVM_FUNCTION(print_r, const Variant& expression, bool ret = false);
Variant HHVM_FUNCTION(var_export, const Variant& expression, bool ret = false);
void f_var_dump(const Variant& v);
void f_var_dump(int _argc, const Variant& expression,
const Array& _argv /* = null_array */);
void HHVM_FUNCTION(var_dump,
const Variant& v, const Array& _argv = null_array);
void HHVM_FUNCTION(debug_zval_dump, const Variant& variable);
String HHVM_FUNCTION(serialize, const Variant& value);
Variant HHVM_FUNCTION(unserialize, const String& str,
Expand Down
11 changes: 11 additions & 0 deletions hphp/runtime/ext/std/ext_std_variable.php
Expand Up @@ -131,8 +131,19 @@ function print_r(mixed $expression,
function var_export(mixed $expression,
bool $ret = false): mixed;

/* Dumps information about a variable
*
* This function displays structured information about one or more expressions
* that includes its type and value. Arrays and objects are explored
* recursively with values indented to show structure.
*
* @param mixed $var - Variable to dump
*/
/* Dumps a string representation of an internal zend value to output.

This comment has been minimized.

Copy link
@SiebelsTim

SiebelsTim Aug 26, 2014

Contributor

@sgolemon This comment got messed up.

*/
<<__Native>>
function var_dump(mixed $arg1, ...$argv): void;

<<__Native>>
function debug_zval_dump(mixed $variable): void;

Expand Down
26 changes: 0 additions & 26 deletions hphp/system/idl/variable.idl.json

This file was deleted.

10 changes: 5 additions & 5 deletions hphp/test/ext/test_base.cpp
Expand Up @@ -53,8 +53,8 @@ bool TestBase::VerifySame(const char *exp1, const char *exp2,
const Variant& v1, const Variant& v2) {
if (!same(v1, v2)) {
g_context->obEndAll();
printf("%s = \n", exp1); f_var_dump(v1);
printf("%s = \n", exp2); f_var_dump(v2);
printf("%s = \n", exp1); HHVM_FN(var_dump)(v1);
printf("%s = \n", exp2); HHVM_FN(var_dump)(v2);
return false;
}
return true;
Expand All @@ -65,8 +65,8 @@ bool TestBase::VerifyClose(const char *exp1, const char *exp2,
double diff = v1 > v2 ? v1 - v2 : v2 - v1;
if (diff > 0.00001) {
g_context->obEndAll();
printf("%s = \n", exp1); f_var_dump(v1);
printf("%s = \n", exp2); f_var_dump(v2);
printf("%s = \n", exp1); HHVM_FN(var_dump)(v1);
printf("%s = \n", exp2); HHVM_FN(var_dump)(v2);
return false;
}
return true;
Expand All @@ -75,7 +75,7 @@ bool TestBase::VerifyClose(const char *exp1, const char *exp2,
bool TestBase::array_value_exists(const Variant& var, const Variant& value) {
bool found = !same(f_array_search(value, var.toArray()), false);
if (!found) {
f_var_dump(var);
HHVM_FN(var_dump)(var);
}
return found;
}
10 changes: 5 additions & 5 deletions hphp/test/slow/ext_xdebug/code_coverage_started.php.expectf
Expand Up @@ -6,7 +6,7 @@ array(1) {
[5]=>
int(1)
[6]=>
int(1)
int(2)
[8]=>
int(1)
}
Expand All @@ -19,7 +19,7 @@ array(1) {
[11]=>
int(1)
[12]=>
int(1)
int(2)
[14]=>
int(2)
[15]=>
Expand All @@ -32,16 +32,16 @@ array(1) {
[11]=>
int(1)
[12]=>
int(1)
int(2)
[14]=>
int(2)
[15]=>
int(1)
int(2)
[16]=>
int(1)
[17]=>
int(2)
[18]=>
int(1)
}
}
}
4 changes: 2 additions & 2 deletions hphp/test/slow/ext_xdebug/get_code_coverage.php.expectf
Expand Up @@ -20,7 +20,7 @@ array(1) {
[2]=>
int(1)
[5]=>
int(16)
int(32)
[6]=>
int(16)
[9]=>
Expand All @@ -38,4 +38,4 @@ array(1) {
[17]=>
int(1)
}
}
}
6 changes: 3 additions & 3 deletions hphp/test/slow/ext_xdebug/profiling_tester.php.expectf
Expand Up @@ -24,7 +24,7 @@ fn=php::xdebug_call_file

fl=php:internal
fn=php::var_dump
0 %d
145 %d

fl=%s/test/slow/ext_xdebug/profiling_testee.inc
fn=Baz::86ctor
Expand Down Expand Up @@ -60,7 +60,7 @@ calls=1 0 0

fl=php:internal
fn=php::var_dump
0 %d
145 %d

fl=%s/test/slow/ext_xdebug/profiling_testee.inc
fn=bar
Expand Down Expand Up @@ -92,7 +92,7 @@ calls=1 0 0

fl=php:internal
fn=php::var_dump
0 %d
145 %d

fl=%s/test/slow/ext_xdebug/profiling_testee.inc
fn={main}
Expand Down
Binary file modified hphp/test/slow/ext_xdebug/remote_step_over.php.expectf
Binary file not shown.
2 changes: 2 additions & 0 deletions hphp/test/slow/ext_xdebug/remote_step_over.test.in
Expand Up @@ -15,3 +15,5 @@ step_over -i 14
step_over -i 15
step_over -i 16
step_over -i 17
step_over -i 18
step_over -i 19

0 comments on commit 4d5a311

Please sign in to comment.