Giter Site home page Giter Site logo

phacility / xhprof Goto Github PK

View Code? Open in Web Editor NEW
2.6K 2.6K 924.0 1.68 MB

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.

Home Page: http://pecl.php.net/package/xhprof

License: Apache License 2.0

PHP 46.93% C 21.29% CSS 1.14% HTML 18.81% JavaScript 11.83%

xhprof's People

Contributors

billf avatar c9s avatar danez avatar davidsklar avatar draco2003 avatar dshafik avatar enumag avatar erikwebb avatar glennpratt avatar imageoptimiser avatar joedevon avatar jwpage avatar martinsupiot avatar nousefreak avatar oliworx avatar rarst avatar remicollet avatar robocoder avatar scottmac avatar webdevel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xhprof's Issues

Version Tags

I've noticed that the PECL website has 5 listed versions (pre 1.0 betas, but milestones nonetheless) while the Git repo has no tags listed. Is there any plan to match the PECL version tags on the Git repo?

Add support for HHVM compatible xhprof_frame_begin & xhprof_frame_end

The HHVM implementation of XHProf includes two handy functions and a wrapper class to allow sub-function profiling:

  • xhprof_frame_begin : Starts an artificial frame. Together with xhprof_frame_end(), this times one block of code execution as if it were a function call, allowing people to define arbitrary function boundaries. Prefer to use XhprofFrame classobjects instead of calling this function directly.
  • xhprof_frame_end : Ends an artificial frame that xhprof_frame_begin() started. One has to make sure there are no exceptions in between these two calls, as otherwise, it may report incorrect timings. Also, xhprof_frame_begin() and xhprof_frame_end() have to be paired up really well, so not to interfere with regular function's profiling, unless that's the intention. Prefer to use XhprofFrame classobjects instead of calling this function directly.
  • XhprofFrame : Wrapper object that calls xhprof_frame_begin in its constructor and xhprof_frame_end in its destructor.
class XhprofFrame {
  public function __construct($name) {
    xhprof_frame_begin($name);
  }
  public function __destruct() {
    xhprof_frame_end();
  }
}

Too long TSC calibration

Xhprof finds out how many TSC ticks goes into 5 ms period. And it does it for each core. It lasts 120 ms on our 24-core server, much more than PHP takes executing the script!
Maybe exists any way to do this calibration only for different physical CPUs (not all cores)?

Wrong value of Content-Length when mbstring.func_overload is enabled

Hi.

I've found a small bug when mbstring.func_overload=2. In parameters of xhprof_generate_mime_header function you're passing length as return of strlen($content). For example here https://github.com/phacility/xhprof/blob/master/xhprof_lib/utils/callgraph_utils.php#L484.

And return value of strlen($content) will differ (from real size of string in bytes) if mbstring.func_overload=2 and mbstring.internal_encoding='utf-8'. Such combination will cause "wrong" length and will cut off part of callgraph image. In result callgraph image will be downloaded only partially and only part of image will be shown in browser (checked in Google Chrome).

I'm not sure about "right way" to fix it, but in my example it can be easily fixed via replacing call of strlen($content) with call of mb_strlen($content, '8bit').

Php 5.6 Error 500.

Hello,

Xhprof causes segfault on php56 with activate internal functions.

Debug:

Program terminated with signal 11, Segmentation fault.
#0 zif_min (ht=, return_value=0x7fb030a87c78, return_value_ptr=0x0, this_ptr=, return_value_used=)

at /root/php-5.6.22/ext/standard/array.c:982

982 RETVAL_ZVAL_FAST(*min);

(gdb) bt
#0 zif_min (ht=, return_value=0x7fb030a87c78, return_value_ptr=0x0, this_ptr=, return_value_used=)

at /root/php-5.6.22/ext/standard/array.c:982

#1 0x00007fb0412a0317 in hp_execute_internal (execute_data=0x7fb049b30b38, fci=0x0, ret=1) at /root/xhprof/extension/xhprof.c:1730
#2 0x000000000090c035 in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:560
#3 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30b38) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#4 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30b38) at /root/xhprof/extension/xhprof.c:1675
#5 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#6 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30938) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#7 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30938) at /root/xhprof/extension/xhprof.c:1675
#8 0x00000000008fa866 in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (execute_data=0x7fb049b30750) at /root/php-5.6.22/Zend/zend_vm_execute.h:31580
#9 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30750) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#10 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30750) at /root/xhprof/extension/xhprof.c:1675
#11 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#12 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30628) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#13 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30628) at /root/xhprof/extension/xhprof.c:1675
#14 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#15 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30520) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#16 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30520) at /root/xhprof/extension/xhprof.c:1675
#17 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#18 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30408) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#19 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30408) at /root/xhprof/extension/xhprof.c:1675
#20 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#21 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30320) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#22 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30320) at /root/xhprof/extension/xhprof.c:1675
#23 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#24 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30230) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#25 0x00007fb04129fca9 in hp_execute_ex (execute_data=0x7fb049b30230) at /root/xhprof/extension/xhprof.c:1675
#26 0x000000000090c69c in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:592
#27 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b30088) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#28 0x000000000087f8d2 in zend_call_function (fci=0x7fff89bd8cd0, fci_cache=) at /root/php-5.6.22/Zend/zend_execute_API.c:829
#29 0x000000000077f28f in zif_call_user_func (ht=, return_value=0x7fb049b68610, return_value_ptr=, this_ptr=,

return_value_used=<value optimized out>) at /root/php-5.6.22/ext/standard/basic_functions.c:4761

#30 0x000000000090c292 in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.22/Zend/zend_vm_execute.h:558
#31 0x00000000008fbb20 in execute_ex (execute_data=0x7fb049b2ff68) at /root/php-5.6.22/Zend/zend_vm_execute.h:363
#32 0x000000000088d339 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/php-5.6.22/Zend/zend.c:1341
#33 0x000000000082caea in php_execute_script (primary_file=0x7fff89bdd6a0) at /root/php-5.6.22/main/main.c:2613
#34 0x000000000093c997 in main (argc=, argv=) at /root/php-5.6.22/sapi/fpm/fpm/fpm_main.c:1989

Thanks.

project status

I am a core maintainer for the IUS project. We received a request to create RPM packages for this module. What is the current status of this project? Here are the things that I can observe that concern me from a packaging standpoint.

  • The pecl page doesn't have any releases that are marked stable. The most recent beta release was 0.9.4 on 2013-09-30.
  • Even though the pecl page lists the latest version as 0.9.4, the current source indicates that the version is 0.9.2.
  • The pecl page claims that the source is facebook/xhprof, but that redirects to this repository instead. Is this a fork or the official code base?
  • As of today (2016-03-14), the most recent commit on this repository was over a year ago (2015-02-26).
  • There are no tagged releases.
  • There are open GitHub issues as well as bugs on bugs.php.net. Which place is appropriate for reporting issues?

PHP7 under CYGWIN (x86-64) compilation error

$ make
/bin/sh /cygdrive/c/wamp64/www/test-website/xhprof/extension/libtool --mode=compile cc  -I. -I/cygdrive/c/wamp64/www/test-website/xhprof/extension -DPHP_ATOM_INC -I/cygdrive/c/wamp64/www/test-website/xhprof/extension/include -I/cygdrive/c/wamp64/www/test-website/xhprof/extension/main -I/cygdrive/c/wamp64/www/test-website/xhprof/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c -o xhprof.lo
libtool: compile:  cc -I. -I/cygdrive/c/wamp64/www/test-website/xhprof/extension -DPHP_ATOM_INC -I/cygdrive/c/wamp64/www/test-website/xhprof/extension/include -I/cygdrive/c/wamp64/www/test-website/xhprof/extension/main -I/cygdrive/c/wamp64/www/test-website/xhprof/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c  -DDLL_EXPORT -DPIC -o .libs/xhprof.o
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:210:3: error: unknown type name โ€˜cpu_set_tโ€™
   cpu_set_t prev_mask;
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:317:26: error: unknown type name โ€˜cpu_set_tโ€™
 int restore_cpu_affinity(cpu_set_t * prev_mask);
                          ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜zm_startup_xhprofโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:67:40: warning: implicit declaration of function โ€˜sched_getaffinityโ€™ [-Wimplicit-function-declaration]
 # define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
                                        ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:456:7: note: in expansion of macro โ€˜GET_AFFINITYโ€™
   if (GET_AFFINITY(0, sizeof(cpu_set_t), &hp_globals.prev_mask) < 0) {
       ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:456:30: error: โ€˜cpu_set_tโ€™ undeclared (first use in this function)
   if (GET_AFFINITY(0, sizeof(cpu_set_t), &hp_globals.prev_mask) < 0) {
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:67:61: note: in definition of macro โ€˜GET_AFFINITYโ€™
 # define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
                                                             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:456:30: note: each undeclared identifier is reported only once for each function it appears in
   if (GET_AFFINITY(0, sizeof(cpu_set_t), &hp_globals.prev_mask) < 0) {
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:67:61: note: in definition of macro โ€˜GET_AFFINITYโ€™
 # define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
                                                             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_init_profiler_stateโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:667:5: warning: implicit declaration of function โ€˜FREE_ZVALโ€™[-Wimplicit-function-declaration]
     FREE_ZVAL(hp_globals.stats_count);
     ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:669:3: warning: implicit declaration of function โ€˜MAKE_STD_ZVALโ€™ [-Wimplicit-function-declaration]
   MAKE_STD_ZVAL(hp_globals.stats_count);
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:677:5: warning: implicit declaration of function โ€˜restore_cpu_affinityโ€™ [-Wimplicit-function-declaration]
     restore_cpu_affinity(&hp_globals.prev_mask);
     ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_get_function_nameโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:936:21: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜function_stateโ€™
     curr_func = data->function_state.function;
                     ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:939:10: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     func = curr_func->common.function_name;
          ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:950:13: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
         cls = curr_func->common.scope->name;
             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:951:22: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜objectโ€™
       } else if (data->object) {
                      ^
In file included from /usr/include/php/Zend/zend.h:31:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:952:28: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜objectโ€™
         cls = Z_OBJCE(*data->object)->name;
                            ^
/usr/include/php/Zend/zend_types.h:530:26: note: in definition of macro โ€˜Z_OBJโ€™
 #define Z_OBJ(zval)     (zval).value.obj
                          ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:952:15: note: in expansion of macro โ€˜Z_OBJCEโ€™
         cls = Z_OBJCE(*data->object)->name;
               ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1013:41: warning: passing argument 1 of โ€˜hp_get_base_filenameโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
         filename = hp_get_base_filename((curr_func->op_array).filename);
                                         ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:897:20: note: expected โ€˜const char *โ€™ but argument is of type โ€˜zend_string * {aka struct _zend_string *}โ€™
 static const char *hp_get_base_filename(const char *filename) {
                    ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_inc_countโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1093:26: warning: passing argument 2 of โ€˜zend_hash_findโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
   if (zend_hash_find(ht, name, strlen(name) + 1, &data) == SUCCESS) {
                          ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: expected โ€˜zend_string * {aka struct _zend_string *}โ€™ but argument is of type โ€˜char *โ€™
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1093:7: error: too many arguments to function โ€˜zend_hash_findโ€™
   if (zend_hash_find(ht, name, strlen(name) + 1, &data) == SUCCESS) {
       ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
In file included from /usr/include/php/Zend/zend.h:31:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1094:30: warning: implicit declaration of function โ€˜Z_LVAL_PPโ€™ [-Wimplicit-function-declaration]
     ZVAL_LONG(*(zval**)data, Z_LVAL_PP((zval**)data) + count);
                              ^
/usr/include/php/Zend/zend_types.h:610:19: note: in definition of macro โ€˜ZVAL_LONGโ€™
   Z_LVAL_P(__z) = l;    \
                   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_hash_lookupโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1117:26: warning: passing argument 2 of โ€˜zend_hash_findโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
   if (zend_hash_find(ht, symbol, strlen(symbol) + 1, &data) == SUCCESS) {
                          ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: expected โ€˜zend_string * {aka struct _zend_string *}โ€™ but argument is of type โ€˜char *โ€™
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1117:7: error: too many arguments to function โ€˜zend_hash_findโ€™
   if (zend_hash_find(ht, symbol, strlen(symbol) + 1, &data) == SUCCESS) {
       ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_sample_stackโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1181:21: error: macro "add_assoc_string" passed 4 arguments, but takes just 3
                    1);
                     ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1178:3: error: โ€˜add_assoc_stringโ€™ undeclared (first use in this function)
   add_assoc_string(hp_globals.stats_count,
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜bind_to_cpuโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1251:3: error: unknown type name โ€˜cpu_set_tโ€™
   cpu_set_t new_mask;
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1253:3: warning: implicit declaration of function โ€˜CPU_ZEROโ€™[-Wimplicit-function-declaration]
   CPU_ZERO(&new_mask);
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1254:3: warning: implicit declaration of function โ€˜CPU_SETโ€™[-Wimplicit-function-declaration]
   CPU_SET(cpu_id, &new_mask);
   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:66:40: warning: implicit declaration of function โ€˜sched_setaffinityโ€™ [-Wimplicit-function-declaration]
 # define SET_AFFINITY(pid, size, mask) sched_setaffinity(0, size, mask)
                                        ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1256:7: note: in expansion of macro โ€˜SET_AFFINITYโ€™
   if (SET_AFFINITY(0, sizeof(cpu_set_t), &new_mask) < 0) {
       ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1256:30: error: โ€˜cpu_set_tโ€™ undeclared (first use in this function)
   if (SET_AFFINITY(0, sizeof(cpu_set_t), &new_mask) < 0) {
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:66:61: note: in definition of macro โ€˜SET_AFFINITYโ€™
 # define SET_AFFINITY(pid, size, mask) sched_setaffinity(0, size, mask)
                                                             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: At top level:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1382:26: error: unknown type name โ€˜cpu_set_tโ€™
 int restore_cpu_affinity(cpu_set_t * prev_mask) {
                          ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_execute_exโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1656:36: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜op_arrayโ€™
   zend_op_array *ops = execute_data->op_array;
                                    ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_execute_internalโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1709:43: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜op_arrayโ€™
   func = hp_get_function_name(current_data->op_array TSRMLS_CC);
                                           ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1722:47: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜function_stateโ€™
       ((zend_internal_function *) execute_data->function_state.function)->handler(
                                               ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1724:13: error: โ€˜struct _zend_fcall_infoโ€™ has no member named โ€˜retval_ptr_ptrโ€™
         *fci->retval_ptr_ptr,
             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1725:12: error: โ€˜struct _zend_fcall_infoโ€™ has no member named โ€˜retval_ptr_ptrโ€™
         fci->retval_ptr_ptr,
            ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1726:12: error: โ€˜struct _zend_fcall_infoโ€™ has no member named โ€˜object_ptrโ€™
         fci->object_ptr,
            ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1729:34: warning: implicit declaration of function โ€˜EX_TMP_VARโ€™ [-Wimplicit-function-declaration]
       zval **return_value_ptr = &EX_TMP_VAR(execute_data, execute_data->opline->result.var)->var.ptr;
                                  ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1729:92: error: invalid type argument of โ€˜->โ€™ (have โ€˜intโ€™)
       zval **return_value_ptr = &EX_TMP_VAR(execute_data, execute_data->opline->result.var)->var.ptr;
                   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1730:47: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜function_stateโ€™
       ((zend_internal_function *) execute_data->function_state.function)->handler(
                                               ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1733:22: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜function_stateโ€™
         (execute_data->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
                      ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1736:21: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜objectโ€™
         execute_data->object,
                     ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_beginโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1864:28: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     _zend_execute_internal = zend_execute_internal;
                            ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1869:29: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
       zend_execute_internal = hp_execute_internal;
                             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_stopโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1937:25: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
   zend_execute_internal = _zend_execute_internal;
                         ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_zval_at_keyโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1964:13: error: โ€˜zval {aka struct _zval_struct}โ€™ has no member named โ€˜typeโ€™
   if (values->type == IS_ARRAY) {
             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1970:28: warning: passing argument 2 of โ€˜zend_hash_findโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
     if (zend_hash_find(ht, key, len, (void**)&value) == SUCCESS) {
                            ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: expected โ€˜zend_string * {aka struct _zend_string *}โ€™ but argument is of type โ€˜char *โ€™
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1970:9: error: too many arguments to function โ€˜zend_hash_findโ€™
     if (zend_hash_find(ht, key, len, (void**)&value) == SUCCESS) {
         ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:154:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c: In function โ€˜hp_strings_in_zvalโ€™:
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:1994:13: error: โ€˜zval {aka struct _zval_struct}โ€™ has no member named โ€˜typeโ€™
   if (values->type == IS_ARRAY) {
             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2014:47: warning: passing argument 2 of โ€˜zend_hash_get_current_key_exโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       type = zend_hash_get_current_key_ex(ht, &str, &len, &idx, 0, NULL);
                                               ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:168:30: note: expected โ€˜zend_string ** {aka struct _zend_string **}โ€™ but argument is of type โ€˜char **โ€™
 ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosit
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2014:53: warning: passing argument 3 of โ€˜zend_hash_get_current_key_exโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       type = zend_hash_get_current_key_ex(ht, &str, &len, &idx, 0, NULL);
                                                     ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:168:30: note: expected โ€˜zend_ulong * {aka long unsigned int *}โ€™ but argument is of type โ€˜uint * {aka unsigned int *}โ€™
 ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosit
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2014:59: warning: passing argument 4 of โ€˜zend_hash_get_current_key_exโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       type = zend_hash_get_current_key_ex(ht, &str, &len, &idx, 0, NULL);
                                                           ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:168:30: note: expected โ€˜HashPosition * {aka unsigned int *}โ€™ but argument is of type โ€˜ulong * {aka long unsigned int *}โ€™
 ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosit
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2014:14: error: too many arguments to function โ€˜zend_hash_get_current_key_exโ€™
       type = zend_hash_get_current_key_ex(ht, &str, &len, &idx, 0, NULL);
              ^
In file included from /usr/include/php/Zend/zend.h:36:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_hash.h:168:30: note: declared here
 ZEND_API int   ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosit
                              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2017:58: error: macro "zend_hash_get_current_data" passed 2 arguments, but takes just 1
         if ((zend_hash_get_current_data(ht, (void**)&data) == SUCCESS) &&
                                                          ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2017:14: error: โ€˜zend_hash_get_current_dataโ€™ undeclared (first use in this function)
         if ((zend_hash_get_current_data(ht, (void**)&data) == SUCCESS) &&
              ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2018:13: warning: implicit declaration of function โ€˜Z_TYPE_PPโ€™ [-Wimplicit-function-declaration]
             Z_TYPE_PP(data) == IS_STRING &&
             ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2019:20: warning: implicit declaration of function โ€˜Z_STRVAL_PPโ€™ [-Wimplicit-function-declaration]
             strcmp(Z_STRVAL_PP(data), ROOT_SYMBOL)) { /* do not ignore "main" */
                    ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2019:20: warning: passing argument 1 of โ€˜strcmpโ€™ makes pointer from integer without a cast [-Wint-conversion]
In file included from /usr/include/stdlib.h:11:0,
                 from /usr/include/php/main/php_config.h:2504,
                 from /usr/include/php/Zend/zend_config.h:1,
                 from /usr/include/php/Zend/zend_portability.h:48,
                 from /usr/include/php/Zend/zend_types.h:27,
                 from /usr/include/php/Zend/zend.h:31,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/string.h:32:6: note: expected โ€˜const char *โ€™ but argument is of type โ€˜intโ€™
 int  _EXFUN(strcmp,(const char *, const char *));
      ^
In file included from /usr/include/php/Zend/zend.h:33:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_alloc.h:172:35: warning: passing argument 1 of โ€˜_estrdupโ€™ makes pointer from integer without a cast [-Wint-conversion]
 #define estrdup(s)       _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                   ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2020:24: note: in expansion of macro โ€˜estrdupโ€™
           result[ix] = estrdup(Z_STRVAL_PP(data));
                        ^
In file included from /usr/include/php/Zend/zend.h:33:0,
                 from /usr/include/php/main/php.h:35,
                 from /cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:27:
/usr/include/php/Zend/zend_alloc.h:84:31: note: expected โ€˜const char *โ€™ but argument is of type โ€˜intโ€™
 ZEND_API char*  ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
                               ^
/cygdrive/c/wamp64/www/test-website/xhprof/extension/xhprof.c:2025:19: error: โ€˜zval {aka struct _zval_struct}โ€™ has no member named โ€˜typeโ€™
   } else if(values->type == IS_STRING) {
                   ^
make: *** [Makefile:192: xhprof.lo] Error 1
$ uname -a
CYGWIN_NT-10.0 <hostname> 2.6.1(0.305/5/3) 2016-12-16 11:55 x86_64 Cygwin
$ php --version
PHP 7.0.14 (cli) (built: Dec 10 2016 22:44:41) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

Xhprof build failed with php 7.1

Hi,
I'm having php 7.1.0 installed via src and am trying to install xhprof extension from RustJason php7 branch but unable to build it. While running make command am getting this error

/opt/xhprof/xhprof/extension/xhprof.c:1470:20: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜called_scopeโ€™
   if (execute_data ->called_scope != NULL && func != NULL) {
                    ^~
/opt/xhprof/xhprof/extension/xhprof.c:1472:40: error: โ€˜zend_execute_data {aka struct _zend_execute_data}โ€™ has no member named โ€˜called_scopeโ€™
  zend_string *class_name = execute_data->called_scope->name;
                                        ^~
Makefile:193: recipe for target 'xhprof.lo' failed
make: *** [xhprof.lo] Error 1 

On further investing I found that with php 7.0 in structure _zend_execute_data have zend_class_entry * called_scope which is not present in php 7.1. So is there any way to build xhprof with php 7.1.

One solution is downgrade php 7.1 to 7.0 which is not possible.

So, please help me out in this.

Segfault under cgroup limitation

Running xhprof in a cgroup-limited environment (using cpuset.cpus feature) causes xhprof to be killed by a segfault every time.

How to reproduce : easiest way is to create a lxc container with lxc.cgroup.cpuset.cpus = 0 on a multi-core computer and run scripts/xhprofile.php in it.

-$ pwd
~/xhprof/scripts
-$ ./xhprofile.php xhprofile.php 
setaffinity: Invalid argument
Segmentation fault

Expected behavior : it should run. Well, at least, it should not get a segfault.

Environment : debian, kernel 3.12, lxc 0.8

Add ability to change sampling rate

Right now, the sampling rate from xhprof_sample_enable is hardcoded to once every 100ms. This isn't granular enough for much of the stuff I need it for, and definitely isn't granular enough to produce things like flamegraphs from.

It'd be nice to be able to set this via either an INI setting or via a parameter to xhprof_sample_enable to allow more detail in samples.

Fix PECL repository so installation is complete

I've witnessed PHP.net bug #65922 a few times on multiple environments (basically, anywhere XHProf is installed on Ubuntu or CentOS with PHP 5.5.x); basically, the PECL repository seems to be missing all the static resources (e.g. all the non-.php files inside https://github.com/phacility/xhprof/tree/master/xhprof_html).

Therefore, when a user visits the xhprof_html directory, the webserver returns a bunch of 404s, none of the JS works, and everything on the page is unstyled.

PHP 7 support

With the introduction of PHP 7 the phpapi has changed a bit. As a result xhprof won't compile when phpized with the PHP 7.0 phpize.

Is someone planning to do PHP 7 support?

make error (PHP7 on Mac)

โžœ  ~ php -v  
PHP 7.0.6 (cli) (built: Apr 29 2016 04:21:39) ( NTS )  
Copyright (c) 1997-2016 The PHP Group  
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies  

๐Ÿ˜ญ ๐Ÿ˜ข

โžœ  ~ sudo pecl install xhprof-beta
......

running: make
/bin/sh /private/tmp/pear/install/pear-build-rootUysn3G/xhprof-0.9.4/libtool --mode=compile cc  -I. -I/private/tmp/pear/install/xhprof/extension -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootUysn3G/xhprof-0.9.4/include -I/private/tmp/pear/install/pear-build-rootUysn3G/xhprof-0.9.4/main -I/private/tmp/pear/install/xhprof/extension -I/usr/local/Cellar/php70/7.0.6/include/php -I/usr/local/Cellar/php70/7.0.6/include/php/main -I/usr/local/Cellar/php70/7.0.6/include/php/TSRM -I/usr/local/Cellar/php70/7.0.6/include/php/Zend -I/usr/local/Cellar/php70/7.0.6/include/php/ext -I/usr/local/Cellar/php70/7.0.6/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /private/tmp/pear/install/xhprof/extension/xhprof.c -o xhprof.lo
mkdir .libs
 cc -I. -I/private/tmp/pear/install/xhprof/extension -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootUysn3G/xhprof-0.9.4/include -I/private/tmp/pear/install/pear-build-rootUysn3G/xhprof-0.9.4/main -I/private/tmp/pear/install/xhprof/extension -I/usr/local/Cellar/php70/7.0.6/include/php -I/usr/local/Cellar/php70/7.0.6/include/php/main -I/usr/local/Cellar/php70/7.0.6/include/php/TSRM -I/usr/local/Cellar/php70/7.0.6/include/php/Zend -I/usr/local/Cellar/php70/7.0.6/include/php/ext -I/usr/local/Cellar/php70/7.0.6/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/xhprof/extension/xhprof.c  -fno-common -DPIC -o .libs/xhprof.o
/private/tmp/pear/install/xhprof/extension/xhprof.c:662:5: warning: implicit declaration of function 'FREE_ZVAL' is invalid in C99 [-Wimplicit-function-declaration]
    FREE_ZVAL(hp_globals.stats_count);
    ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:664:3: warning: implicit declaration of function 'MAKE_STD_ZVAL' is invalid in C99 [-Wimplicit-function-declaration]
  MAKE_STD_ZVAL(hp_globals.stats_count);
  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:931:23: error: no member named 'function_state' in 'struct _zend_execute_data'
    curr_func = data->function_state.function;
                ~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:934:10: warning: incompatible pointer types assigning to 'const char *' from 'zend_string *' (aka 'struct _zend_string *') [-Wincompatible-pointer-types]
    func = curr_func->common.function_name;
         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:945:13: warning: incompatible pointer types assigning to 'const char *' from 'zend_string *' (aka 'struct _zend_string *') [-Wincompatible-pointer-types]
        cls = curr_func->common.scope->name;
            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:946:24: error: no member named 'object' in 'struct _zend_execute_data'
      } else if (data->object) {
                 ~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:947:30: error: no member named 'object' in 'struct _zend_execute_data'
        cls = Z_OBJCE(*data->object)->name;
                       ~~~~  ^
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_types.h:542:33: note: expanded from macro 'Z_OBJCE'
#define Z_OBJCE(zval)                           (Z_OBJ(zval)->ce)
                                                       ^~~~
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_types.h:530:26: note: expanded from macro 'Z_OBJ'
#define Z_OBJ(zval)                                     (zval).value.obj
                                                         ^~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1002:41: warning: incompatible pointer types passing 'zend_string *' (aka 'struct _zend_string *') to parameter of type 'const char *' [-Wincompatible-pointer-types]
        filename = hp_get_base_filename((curr_func->op_array).filename);
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:892:53: note: passing argument to parameter 'filename' here
static const char *hp_get_base_filename(const char *filename) {
                                                    ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1082:32: error: too many arguments to function call, expected 2, have 4
  if (zend_hash_find(ht, name, strlen(name) + 1, &data) == SUCCESS) {
      ~~~~~~~~~~~~~~           ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_hash.h:154:1: note: 'zend_hash_find' declared here
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
^
/usr/local/Cellar/php70/7.0.6/include/php/main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
                  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1083:30: warning: implicit declaration of function 'Z_LVAL_PP' is invalid in C99 [-Wimplicit-function-declaration]
    ZVAL_LONG(*(zval**)data, Z_LVAL_PP((zval**)data) + count);
                             ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1106:34: error: too many arguments to function call, expected 2, have 4
  if (zend_hash_find(ht, symbol, strlen(symbol) + 1, &data) == SUCCESS) {
      ~~~~~~~~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_hash.h:154:1: note: 'zend_hash_find' declared here
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
^
/usr/local/Cellar/php70/7.0.6/include/php/main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
                  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1170:20: error: too many arguments provided to function-like macro invocation
                   1);
                   ^
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_API.h:406:9: note: macro 'add_assoc_string' defined here
#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
        ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1167:3: error: use of undeclared identifier 'add_assoc_string'
  add_assoc_string(hp_globals.stats_count,
  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1245:7: warning: implicit declaration of function 'thread_policy_set' is invalid in C99 [-Wimplicit-function-declaration]
  if (SET_AFFINITY(0, sizeof(cpu_set_t), &new_mask) < 0) {
      ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:61:9: note: expanded from macro 'SET_AFFINITY'
        thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY, mask, \
        ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1645:38: error: no member named 'op_array' in 'struct _zend_execute_data'
  zend_op_array *ops = execute_data->op_array;
                       ~~~~~~~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1698:45: error: no member named 'op_array' in 'struct _zend_execute_data'
  func = hp_get_function_name(current_data->op_array TSRMLS_CC);
                              ~~~~~~~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1706:14: warning: initializing 'zend_op *' (aka 'struct _zend_op *') with an expression of type 'const zend_op *' (aka 'const struct _zend_op *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    zend_op *opline = EX(opline);
             ^        ~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1708:5: error: use of undeclared identifier 'temp_variable'
    temp_variable *retvar = &EX_T(opline->result.var);
    ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1708:20: error: use of undeclared identifier 'retvar'
    temp_variable *retvar = &EX_T(opline->result.var);
                   ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1708:30: warning: implicit declaration of function 'EX_TMP_VAR' is invalid in C99 [-Wimplicit-function-declaration]
    temp_variable *retvar = &EX_T(opline->result.var);
                             ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1688:24: note: expanded from macro 'EX_T'
#define EX_T(offset) (*EX_TMP_VAR(execute_data, offset))
                       ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1708:30: error: indirection requires pointer operand ('int' invalid)
    temp_variable *retvar = &EX_T(opline->result.var);
                             ^~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1688:23: note: expanded from macro 'EX_T'
#define EX_T(offset) (*EX_TMP_VAR(execute_data, offset))
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1709:36: error: no member named 'function_state' in 'struct _zend_execute_data'
    ((zend_internal_function *) EX(function_state).function)->handler(
                                ~~~^~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1673:38: note: expanded from macro 'EX'
#define EX(element) ((execute_data)->element)
                     ~~~~~~~~~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1712:28: error: no member named 'function_state' in 'struct _zend_execute_data'
                       (EX(function_state).function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ?
                        ~~~^~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1673:38: note: expanded from macro 'EX'
#define EX(element) ((execute_data)->element)
                     ~~~~~~~~~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1714:27: error: no member named 'object' in 'struct _zend_execute_data'
                       EX(object), ret TSRMLS_CC);
                       ~~~^~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1673:38: note: expanded from macro 'EX'
#define EX(element) ((execute_data)->element)
                     ~~~~~~~~~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1711:24: error: use of undeclared identifier 'retvar'
                       retvar->var.ptr,
                       ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1830:28: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, struct _zend_fcall_info *, int)' (aka 'void (*)(struct _zend_execute_data *, struct _zend_fcall_info *, int)') from 'void (*)(zend_execute_data *, zval *)' (aka 'void (*)(struct _zend_execute_data *, struct _zval_struct *)') [-Wincompatible-pointer-types]
    _zend_execute_internal = zend_execute_internal;
                           ^ ~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1835:29: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, zval *)' (aka 'void (*)(struct _zend_execute_data *, struct _zval_struct *)') from 'void (zend_execute_data *, struct _zend_fcall_info *, int)' (aka 'void (struct _zend_execute_data *, struct _zend_fcall_info *, int)') [-Wincompatible-pointer-types]
      zend_execute_internal = hp_execute_internal;
                            ^ ~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1903:25: warning: incompatible pointer types assigning to 'void (*)(zend_execute_data *, zval *)' (aka 'void (*)(struct _zend_execute_data *, struct _zval_struct *)') from 'void (*)(zend_execute_data *, struct _zend_fcall_info *, int)' (aka 'void (*)(struct _zend_execute_data *, struct _zend_fcall_info *, int)') [-Wincompatible-pointer-types]
  zend_execute_internal = _zend_execute_internal;
                        ^ ~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/install/xhprof/extension/xhprof.c:1930:15: error: no member named 'type' in 'struct _zval_struct'
  if (values->type == IS_ARRAY) {
      ~~~~~~  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1936:33: error: too many arguments to function call, expected 2, have 4
    if (zend_hash_find(ht, key, len, (void**)&value) == SUCCESS) {
        ~~~~~~~~~~~~~~          ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php70/7.0.6/include/php/Zend/zend_hash.h:154:1: note: 'zend_hash_find' declared here
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
^
/usr/local/Cellar/php70/7.0.6/include/php/main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
                  ^
/private/tmp/pear/install/xhprof/extension/xhprof.c:1960:15: error: no member named 'type' in 'struct _zval_struct'
  if (values->type == IS_ARRAY) {
      ~~~~~~  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
12 warnings and 20 errors generated.
make: *** [xhprof.lo] Error 1
ERROR: `make' failed

Tagged version?

Hi... it's been a while now... would you please make a first official release?

augmentedtypes & xhprof break composer

I can install & run composer. However, after installing
php56-augmentedtypes
or
php56-xhprof

composer --version no longer outputs any value.
See also https://github.com/Homebrew/homebrew-php/issues/1424

Parameter Value
OS X Version: Yosemite 10.10
Homebrew Version: 0.9.5
PHP Version in use: 5.6.2
Xcode Version: 6.1
Output of gcc -v: Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.0.0 Thread model: posix
Output of php -v: PHP 5.6.2 (cli) (built: Nov 7 2014 16:32:39)
Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
Output of brew doctor (within a gist) Your system is ready to brew.
Output of composer --version Composer version 1.0.0-alpha8 2014-01-06 18:39:59

seg fault in zif_current

Hi,

xhprof: 0.9.4
php: 5.6
OS: FreeBSD 10.x

After the "xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);" - I get SIGSEGV (signal)

Attaching a debugger (unfortunately without symbols) I see:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004ac204 in zif_current ()
(gdb) bt
#0  0x00000000004ac204 in zif_current ()
#1  0x0000000808bae832 in hp_execute_internal () from /usr/local/lib/php/20131226/xhprof.so
#2  0x00000000005f2ff6 in zend_do_fcall_common_helper_SPEC ()
#3  0x00000000005b4288 in execute_ex ()
#4  0x0000000808bae3d9 in hp_execute_ex () from /usr/local/lib/php/20131226/xhprof.so
#5  0x00000000005f32ca in zend_do_fcall_common_helper_SPEC ()
#6  0x00000000005b4288 in execute_ex ()
#7  0x0000000808bae3d9 in hp_execute_ex () from /usr/local/lib/php/20131226/xhprof.so
#8  0x00000000005f32ca in zend_do_fcall_common_helper_SPEC ()
#9  0x00000000005b4288 in execute_ex ()
#10 0x000000000057f1cc in zend_call_function ()
#11 0x00000000004b6404 in zif_call_user_func_array ()
#12 0x00000000005f3104 in zend_do_fcall_common_helper_SPEC ()
#13 0x00000000005b4288 in execute_ex ()
#14 0x000000000057f1cc in zend_call_function ()
#15 0x00000000004b6404 in zif_call_user_func_array ()
#16 0x00000000005f3104 in zend_do_fcall_common_helper_SPEC ()
#17 0x00000000005b4288 in execute_ex ()
#18 0x000000000058c223 in zend_execute_scripts ()
#19 0x0000000000533c33 in php_execute_script ()
#20 0x0000000000617af9 in main ()

Not quite sure if this is a known issue?

thanks,

Add Buggregator to README (OpenSource Tool for Analyzing xhprof profiles)

Hi there,

XHProf is a crucial tool for many developers in profiling their PHP applications.

I would like to propose adding a link to the Buggregator repository in your README. Buggregator is an open-source tool that complements XHProf by providing enhanced profiling and analysis features for PHP applications.

We are working hard to provide one of the best open-source solutions and tools for debugging PHP applications for developers. It would be great to have a link to it in your README.

Here is docs with information on how to use it.

Adding this link can help developers discover additional resources to optimize their development processes.

Thx!

Segmentation fault when xhprof extension is enabled

Recently, I started getting segmentation faults when using certain PHP libraries (such as caxy/php-htmldiff). I noticed that the faults only occur when the xhprof php extension is enabled. If I disable it, the segfaults disappear. So I surmise that either xhprof is causing the segfaults, or the problem is perhaps with memory allocation and xhprof just happened to be the extension to trigger the problem. Either way, I'd appreciate some help.

Here's the backtrace from the core dump: https://pastebin.com/4iVHND1G

Here's the full background on the issue (I originally thought it was a problem with the caxy/php-htmldiff library): caxy/php-htmldiff#74

Temp dir

In xhprof_lib/utils/xhprof_runs.php on line 99, you are setting the default temp dir to "/tmp." This causes problems on Windows servers, so I suggest you use sys_get_temp_dir() instead.

Add option to write to file

Scenario: PHP crashes due to a segfault or whatever.

IF xhprof had an option to write to file, this could be a huge help to debug whitescreens.

That a write-to-file might be horribly slow in the first place is no problem for this use case.

when array_pop be called, phpfpm core dump

PHP 5.6.4 (cli) (built: Jan 22 2015 18:32:17)
Linux slave-6 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

index.php:
xhprof_enable();

$test = array('test', 'test2');

array_pop($test);

$xhprof_data = xhprof_disable();

php index.php
Segmentation fault (core dumped)

And I gdb the /tmp/coredumpfile

(gdb) bt
#0 0x00000000006e0690 in zif_array_walk (ht=34685360, return_value=0x0, return_value_ptr=, this_ptr=,

return_value_used=<value optimized out>) at /home/www/Downloads/php-5.6.4/ext/standard/array.c:1131

#1 0x00007fa6042370f0 in ?? ()
#2 0x00000000012a8620 in fp_maskr ()
#3 0x000000000087340d in zend_do_fcall_common_helper_SPEC (execute_data=) at /home/www/Downloads/php-5.6.4/Zend/zend_vm_execute.h:629
#4 0x0000000000862fa0 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=0x0) at /home/www/Downloads/php-5.6.4/Zend/zend_vm_execute.h:3016
#5 0x00000000012a8798 in fp_maskr ()
#6 0x0000000000000000 in ?? ()

is this a xhprof bug? how to fixed this bug?

Debug PHP build (--enable-debug) reports memory leaks from tests/xhprof_007.phpt

[Fri Nov 28 22:35:58 2014]  Script:  '/opt/xhprof/extension/tests/xhprof_007.php'
/opt/xhprof/extension/xhprof.c(1992) :  Freeing 0x7FD5BFFB80A8 (48 bytes), script=/opt/xhprof/extension/tests/xhprof_007.php
Last leak repeated 4 times
[Fri Nov 28 22:35:58 2014]  Script:  '/opt/xhprof/extension/tests/xhprof_007.php'
/opt/xhprof/extension/xhprof.c(2011) :  Freeing 0x7FD5BFFC1038 (15 bytes), script=/opt/xhprof/extension/tests/xhprof_007.php
Last leak repeated 20 times
=== Total 26 memory leaks detected ===

These leaks are from memory allocated by hp_strings_in_zval which is called by hp_get_ignored_functions_from_arg to populate the ignored functions list provided to xhprof_enable. This memory is in turn cleaned up by hp_array_del in hp_clean_profiler_state which is called by hp_end in the extension's shutdown function. The clean up function is however not called by xhprof_disable so when multiple xhprof_enable calls are made in a single request (as is done by tests/xhprof_007.php) memory will be leaked.

Can't open subdirectory of /tmp or /var/tmp

I faced this problem while using xhprof and php-fpm on centos 7.

If you use php-fpm daemon configured to use private tmp directory (set to true by default in centos 7) and set xhprof.output_dir as subdirectory of /tmp, you probably notice than reports files can't be saved to that dir.
In that case you get the following message: "PHP Warning: fopen(/tmp/xhprof/58ed54f13807d.xhprof_testing.xhprof): failed to open stream: No such file or directory in /usr/share/pear/xhprof_lib/utils/xhprof_runs.php on line 136".
This happens because of php-fpm service cleans up /tmp directory each time the service started/restarted. So you have to create all subdirectories into /tmp each time you restart php-fpm.

Example:

$ cat /etc/php.d/xhprof.ini 
[xhprof]
extension=xhprof.so
xhprof.output_dir="/tmp/xhprof"
$ cat /usr/lib/systemd/system/php-fpm.service | grep PrivateTmp
PrivateTmp=true
$ sudo ls /tmp/systemd-private-b5096469cfb44152913c896b78570a6d-php-fpm.service-lP5PdF/tmp/xhprof
58f35870bd648.xhprof_testing.xhprof
$ sudo systemctl restart php-fpm
$ sudo ls /tmp/systemd-private-b5096469cfb44152913c896b78570a6d-php-fpm.service-EqBde7/tmp/xhprof
ls: cannot access /tmp/systemd-private-b5096469cfb44152913c896b78570a6d-php-fpm.service-EqBde7/tmp/xhprof: No such file or directory

PHP80 / Possible memory leak on array_filter vs opcache

I've experienced a memory leak using array_filter when both opcahe and xhprof are enabled.

here is a demo script:

<?php
// array_filter_short.php
namespace Somewhere\On\Earth;
class Foo {
    function leaking(array $array) {
        $f = function ($array) {
            return \array_filter($array, fn($item) => !is_null($item));
        };
        for (;;) {
            $clone = (array) $array;
            $res = $f($clone);
            printf("memory: %d\n", \memory_get_usage());
            unset($clone, $res);
        }
    }
    function run() {
        $array = array_combine(range(1, 1000, 2), array_fill(1, 500, null));
        $array += array_combine(range(2, 1000, 2), array_fill(1, 500, true));
        $this->leaking($array);
    }
}
(new Foo())->run();

Test it with

php80 -n -dzend_extension=opcache -dopcache.enable=1 -dopcache.enable_cli=1 -dextension=xhprof.so array_filter_short.php

Here is the PHP bug I've filled
https://bugs.php.net/bug.php?id=81215

$run is not extracted from the URL if it's not hex characters

I have runs in /tmp that will load if I force a $run = $_GET['run']; in index.php

If I do not FORCE $run, only runs that match [a-f0-9] will be loaded.

So far I cannot figure out why it is not extracting $run from the query string with a limited character set. But this really messes things up when you want to define custom run_ids and they do not conform to a purely [a-f0-9] type naming convention.

JUnit XML export

Hi,

I'm considering implementing some performance testing in my deployment pipeline, and therefore i'm considering xhprof, i'm already using it in my development environment, so it's a familiar tool to me.

I'm considering to implement a JUnit xml export, so that it can be use inside of jenkins, so see if the performance changes over time, on a predefined set of visited URL's at the website.

Do you have any notes to add to this, and how do you like the idea?

I'm acutually think its better to put it in xhgui [1]

  1. https://github.com/perftools/xhgui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.