Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .arcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"project_id" : "xhprof",
"conduit_uri" : "https://secure.phabricator.com/",
"remote_hooks_installed" : true,
"copyright_holder" : "Facebook, Inc."
}
"phabricator.uri": "https://secure.phabricator.com/",
"load": ["support/libxhprof"],
"unit.engine": "XHProfExtensionUnitTestEngine"
}
30 changes: 30 additions & 0 deletions .arclint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"exclude": [
"(^xhprof_html/jquery/)",
"(^xhprof_html/docs/)",
"(^extension/Makefile.local)"
],
"linters": {
"chmod": {
"type": "chmod"
},
"filename": {
"type": "filename"
},
"generated": {
"type": "generated"
},
"merge-conflict": {
"type": "merge-conflict"
},
"nolint": {
"type": "nolint"
},
"text-without-length": {
"type": "text",
"severity": {
"3": "disabled"
}
}
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ extension/*
!extension/php_xhprof.h
!extension/tests/
!extension/xhprof.c

extension/tests/*.sh
extension/tests/*.exp
extension/tests/*.out
extension/tests/*.diff
extension/tests/*.log
extension/tests/*.php

support/libxhprof/.phutil_module_cache
3 changes: 2 additions & 1 deletion CREDITS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Originally developed at Facebook, XHProf was open sourced in Mar, 2009.

XHProf is now maintained by Phacility.

Creators:
Changhao Jiang
Kannan Muthukkaruppan
Expand All @@ -9,4 +11,3 @@ Creators:
Additional Contributors:
George Cabrera - UI enhancements
Paul Saab - FreeBSD port

1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
2 changes: 0 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ For installation and usage notes refer to:

To view the latest version of the doc, go to:
http://pecl.php.net/package/xhprof ---> [View Documentation]


1 change: 1 addition & 0 deletions bin/xhprofile
17 changes: 0 additions & 17 deletions composer.json

This file was deleted.

1 change: 0 additions & 1 deletion extension/config.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

PHP_ARG_ENABLE(xhprof, whether to enable xhprof support,
[ --enable-xhprof Enable xhprof support])

Expand Down
2 changes: 1 addition & 1 deletion extension/php_xhprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ PHP_FUNCTION(xhprof_disable);
PHP_FUNCTION(xhprof_sample_enable);
PHP_FUNCTION(xhprof_sample_disable);

#endif /* PHP_XHPROF_H */
#endif /* PHP_XHPROF_H */
1 change: 0 additions & 1 deletion extension/tests/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ function print_canonical($xhprof_data) {
echo "\n";
}
}

2 changes: 1 addition & 1 deletion extension/tests/xhprof_001.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Basic Profiling Test
XHProf: Basic Profiling Test
Author: Kannan
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/xhprof_002.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Test (direct and indirect) recursive function calls.
XHProf: Test (direct and indirect) recursive function calls.
Author: Kannan
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/xhprof_003.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Test Class Methods, Constructors, Destructors.
XHProf: Test Class Methods, Constructors, Destructors.
Author: Kannan
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/xhprof_004.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Test Include File (load/run_init operations)
XHProf: Test Include File (load/run_init operations)
Author: Kannan
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/xhprof_005.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Timer Tests
XHProf: Timer Tests
Author: Kannan
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/xhprof_006.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Basic Sampling Test
XHProf: Basic Sampling Test
Author: mpal
--FILE--
<?php
Expand Down
14 changes: 7 additions & 7 deletions extension/tests/xhprof_007.phpt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--TEST--
XHPRrof: Test excluding call_user_func and similar functions
XHProf: Test excluding call_user_func and similar functions
Author: mpal
--FILE--
<?php

include_once dirname(__FILE__).'/common.php';

$xhprof_ignored_functions = array( 'ignored_functions' =>
$xhprof_ignored_functions = array( 'ignored_functions' =>
array('call_user_func',
'call_user_func_array',
'my_call_user_func_safe',
Expand All @@ -20,8 +20,8 @@ function foo($x) {
for ($idx = 0; $idx < 2; $idx++) {
$sum += bar();
}
echo "hello: {$x}\n" ;
return strlen("hello: {$x}");
echo @"hello: {$x}\n" ;
return @strlen("hello: {$x}");
}

function foo_array($x1, $x2 = 'test') {
Expand All @@ -30,8 +30,8 @@ function foo_array($x1, $x2 = 'test') {
foreach ($x as $idx) {
$sum += bar();
}
echo "hello: " . $x[0] . $x[1] . "\n";
return strlen("hello: {$x[0]} {$x[1]}");
echo @"hello: {$x[0]}{$x[1]}\n";
return @strlen("hello: {$x[0]} {$x[1]}");
}

function my_call_user_func_safe($function, $args = 'my_safe') {
Expand Down Expand Up @@ -161,7 +161,7 @@ echo "\n";

// 5c: Sanity test to only ignore my_call_user_func_array_safe
echo "Part 5c: Only ignore call_user_func_array\n";
$xhprof_ignored_functions = array('ignored_functions' =>
$xhprof_ignored_functions = array('ignored_functions' =>
'my_call_user_func_array_safe');
xhprof_enable(XHPROF_FLAGS_MEMORY, $xhprof_ignored_functions);
test_my_call_user_func_array_safe('foo_array');
Expand Down
4 changes: 2 additions & 2 deletions extension/tests/xhprof_008.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
XHPRrof: Sampling Mode Test
XHProf: Sampling Mode Test
Author: kannan
--FILE--
<?php
Expand Down Expand Up @@ -50,7 +50,7 @@ foreach ($output2 as $sample) {
//
// our default sampling frequency is 0.1 seconds. So
// we would expect about 8 samples (given that foo()
// sleeps for 0.8 seconds). However, we might in future
// sleeps for 0.8 seconds). However, we might in future
// allow the sampling frequency to be modified. So rather
// than depend on the absolute number of samples, we'll
// check to see if $count2 is roughly double of $count1.
Expand Down
19 changes: 19 additions & 0 deletions extension/tests/xhprof_009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
XHProf: PHP 5.5 crash in hp_execute_internal
Author: epriestley
--FILE--
<?php

function loader() {
// <empty>
}

spl_autoload_register('loader', $throw = true);

xhprof_enable();

class_exists('ThisClassDoesNotExist');
echo "OK\n";

--EXPECT--
OK
16 changes: 16 additions & 0 deletions extension/tests/xhprof_010.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
XHProf: Crash with auto_append_file
Author: epriestley
--INI--
include_path={PWD}
auto_append_file=xhprof_010_append.php
--FILE--
<?php

xhprof_enable();
echo "MAIN\n";

?>
--EXPECTF--
MAIN
APPENDED
3 changes: 3 additions & 0 deletions extension/tests/xhprof_010_append.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo "APPENDED\n";
15 changes: 15 additions & 0 deletions extension/tests/xhprof_011.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
XHProf: Crash with auto_prepend_file
Author: epriestley
--INI--
include_path={PWD}
auto_prepend_file=xhprof_011_prepend.php
--FILE--
<?php

echo "MAIN\n";

?>
--EXPECTF--
PREPENDED
MAIN
4 changes: 4 additions & 0 deletions extension/tests/xhprof_011_prepend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

xhprof_enable();
echo "PREPENDED\n";
32 changes: 32 additions & 0 deletions extension/tests/xhprof_012.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
XHProf: Memory Leak in Ignored Functions
Author: epriestley
--FILE--
<?php

$old = memory_get_usage();

// This test covers a leak where the ignored function list would not be
// deallocated properly after a new call to xhprof_enable().

$large = str_repeat('x', (1024 * 1024 * 16));
xhprof_enable(0, array('ignored_functions' => array($large)));
xhprof_disable();
unset($large);

xhprof_enable();
xhprof_disable();

$new = memory_get_usage();

$missing = ($new - $old);

if ($missing >= (1024 * 1024 * 16)) {
echo "LEAKED A LOT OF MEMORY\n";
} else {
echo "DID NOT LEAK A LOT OF MEMORY\n";
}

?>
--EXPECTF--
DID NOT LEAK A LOT OF MEMORY
39 changes: 36 additions & 3 deletions extension/xhprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ static inline uint8 hp_inline_hash(char * str) {
* @author mpal
*/
static void hp_get_ignored_functions_from_arg(zval *args) {

if (hp_globals.ignored_function_names) {
hp_array_del(hp_globals.ignored_function_names);
}

if (args != NULL) {
zval *zresult = NULL;

Expand Down Expand Up @@ -961,7 +966,13 @@ static char *hp_get_function_name(zend_op_array *ops TSRMLS_DC) {
/* we are dealing with a special directive/function like
* include, eval, etc.
*/
#if ZEND_EXTENSION_API_NO >= 220100525
#if ZEND_EXTENSION_API_NO >= 220121212
if (data->prev_execute_data) {
curr_op = data->prev_execute_data->opline->extended_value;
} else {
curr_op = data->opline->extended_value;
}
#elif ZEND_EXTENSION_API_NO >= 220100525
curr_op = data->opline->extended_value;
#else
curr_op = data->opline->op2.u.constant.value.lval;
Expand Down Expand Up @@ -1703,8 +1714,30 @@ ZEND_DLEXPORT void hp_execute_internal(zend_execute_data *execute_data,

if (!_zend_execute_internal) {
/* no old override to begin with. so invoke the builtin's implementation */

#if ZEND_EXTENSION_API_NO >= 220121212
/* PHP 5.5. This is just inlining a copy of execute_internal(). */

if (fci != NULL) {
((zend_internal_function *) execute_data->function_state.function)->handler(
fci->param_count,
*fci->retval_ptr_ptr,
fci->retval_ptr_ptr,
fci->object_ptr,
1 TSRMLS_CC);
} else {
zval **return_value_ptr = &EX_TMP_VAR(execute_data, execute_data->opline->result.var)->var.ptr;
((zend_internal_function *) execute_data->function_state.function)->handler(
execute_data->opline->extended_value,
*return_value_ptr,
(execute_data->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
? return_value_ptr
: NULL,
execute_data->object,
ret TSRMLS_CC);
}
#elif ZEND_EXTENSION_API_NO >= 220100525
zend_op *opline = EX(opline);
#if ZEND_EXTENSION_API_NO >= 220100525
temp_variable *retvar = &EX_T(opline->result.var);
((zend_internal_function *) EX(function_state).function)->handler(
opline->extended_value,
Expand All @@ -1713,6 +1746,7 @@ ZEND_DLEXPORT void hp_execute_internal(zend_execute_data *execute_data,
&retvar->var.ptr:NULL,
EX(object), ret TSRMLS_CC);
#else
zend_op *opline = EX(opline);
((zend_internal_function *) EX(function_state).function)->handler(
opline->extended_value,
EX_T(opline->result.u.var).var.ptr,
Expand Down Expand Up @@ -2016,4 +2050,3 @@ static inline void hp_array_del(char **name_array) {
efree(name_array);
}
}

2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ XHProf is a function-level hierarchical profiler for PHP and has a simple HTML b
<user>macvicar</user>
<email>scott@fb.com</email>
<active>yes</active>
</developer>
</lead>
<date>2009-03-28</date>
<version>
<release>0.9.2</release>
Expand Down
Loading