[xdebug-general] "script" output name patch

From: Brian Shire <shire[@]facebook.com>
Date: Wed, 03 May 2006 19:35:37 -0700

The following patch (also attached) adds a "script" value to the
profiler_output_name option. This will write the profiler output to a
filename that consists of the script's full path (using underscores). ie:
/var/www/index.php becomes var_www_index_php_cachegrind.out.

We found it useful to associate specific file requests to profiler output.
This will only be on a per entry point basis ie: included files don't get
their own .out file. Thought it might be useful/something to consider
including.

Brian Shire
shire[@]facebook.com

--- xdebug.orig/xdebug_profiler.c 2006-05-03 17:31:25.000000000 -0700
+++ xdebug/xdebug_profiler.c 2006-05-03 18:13:54.000000000 -0700
@@ -58,12 +58,22 @@
 int xdebug_profiler_init(char *script_name TSRMLS_DC)
 {
        char *filename;
+ char *script_name_tmp, *char_ptr;
 
        if (strcmp(XG(profiler_output_name), "crc32") == 0) {
                filename = xdebug_sprintf("%s/cachegrind.out.%lu",
XG(profiler_output_dir), xdebug_crc32(script_name, strlen(script_name)));
        } else if (strcmp(XG(profiler_output_name), "timestamp") == 0) {
                time_t the_time = time(NULL);
                filename = xdebug_sprintf("%s/cachegrind.out.%ld",
XG(profiler_output_dir), the_time);
+ } else if (strcmp(XG(profiler_output_name), "script") == 0) {
+ script_name_tmp = estrdup(script_name+1);
+ while((char_ptr = strpbrk(script_name_tmp, "/\\")) != NULL)
{
+ char_ptr[0] = '_'; /* replace slashes with
underscores */
+ }
+ char_ptr = strrchr(script_name_tmp, '.');
+ if(char_ptr) { char_ptr[0] = '_'; } /* replace .php
with _php */
+ filename = xdebug_sprintf("%s/%s_cachegrind.out",
XG(profiler_output_dir), script_name_tmp);
+ efree(script_name_tmp);
        } else {
                filename = xdebug_sprintf("%s/cachegrind.out.%ld",
XG(profiler_output_dir), getpid());
        }

Received on Thu May 04 2006 - 04:35:47 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST