logo       

cvs: pear(execute_wrapper) /PECL/apd php_apd.c php_apd.h: msg#00621

php.cvs.pear

Subject: cvs: pear(execute_wrapper) /PECL/apd php_apd.c php_apd.h

gschlossnagle Fri Sep 27 14:13:45 2002 EDT

Modified files: (Branch: execute_wrapper)
/pear/PECL/apd php_apd.c php_apd.h
Log:
added filename/lineno traces into the pprof traces


Index: pear/PECL/apd/php_apd.c
diff -u pear/PECL/apd/php_apd.c:1.39.2.8 pear/PECL/apd/php_apd.c:1.39.2.9
--- pear/PECL/apd/php_apd.c:1.39.2.8 Tue Sep 24 23:48:28 2002
+++ pear/PECL/apd/php_apd.c Fri Sep 27 14:13:45 2002
@@ -375,30 +375,38 @@
const char* fname,
int type,
const char *filename,
- int lineNum)
+ int linenum)
{
CallStack* stack;
CallStackEntry* entry;
+ int filenum;

int i = 0;
TSRMLS_FETCH();
stack = (CallStack*) APD_GLOBALS(stack);
- entry = mkCallStackEntry(fname, filename, lineNum, type);
+ entry = mkCallStackEntry(fname, filename, linenum, type);
apd_stack_push(stack, entry);
if(APD_GLOBALS(pproftrace)) {
summary_t *summaryStats;
+ int *filenum;
+ if ( zend_hash_find(APD_GLOBALS(file_summary), (char *) filename,
strlen(filename) + 1, (void *) &filenum) == FAILURE ) {
+ filenum = (int *) emalloc(sizeof(int));
+ *filenum = ++APD_GLOBALS(file_index);
+ apd_pprof_fprintf("! %d %s\n", *filenum, filename);
+ zend_hash_add(APD_GLOBALS(file_summary), (char *) filename,
+ strlen(filename) + 1, filenum, sizeof(int), NULL);
+ }
if ( zend_hash_find(APD_GLOBALS(summary), (char *) fname,
strlen(fname) + 1, (void *) &summaryStats) == SUCCESS )
{
- apd_pprof_fprintf("+ %d\n", summaryStats->index);
- }
- else {
+ apd_pprof_fprintf("+ %di %d %d\n", summaryStats->index, *filenum,
linenum);
+ } else {
summaryStats = (summary_t *) emalloc(sizeof(summary_t));
summaryStats->calls = 1;
summaryStats->index = ++APD_GLOBALS(index);
summaryStats->totalTime = 0;
zend_hash_add(APD_GLOBALS(summary), (char *) fname, strlen(fname)
+ 1, summaryStats, sizeof(summary_t), NULL);
apd_pprof_fprintf("& %d %s %d\n", summaryStats->index, fname,
type);
- apd_pprof_fprintf("+ %d\n", summaryStats->index);
+ apd_pprof_fprintf("+ %d %d %d\n", summaryStats->index, *filenum,
linenum);
}
}
}
@@ -714,6 +722,8 @@
APD_GLOBALS(dump_sock_id) = 0;
APD_GLOBALS(bitmask) = 0;
APD_GLOBALS(summary) = (HashTable*) emalloc(sizeof(HashTable));
+ APD_GLOBALS(file_summary) = (HashTable*) emalloc(sizeof(HashTable));
+ APD_GLOBALS(file_index) = 0;
APD_GLOBALS(interactive_mode) = 0;
APD_GLOBALS(ignore_interactive) = 0;
APD_GLOBALS(lastclock) = times(&APD_GLOBALS(lasttms));
@@ -721,6 +731,7 @@
APD_GLOBALS(firstclock) = APD_GLOBALS(lastclock);
gettimeofday(&APD_GLOBALS(lasttime), NULL);
zend_hash_init(APD_GLOBALS(summary), 0, NULL, NULL, 0);
+ zend_hash_init(APD_GLOBALS(file_summary), 0, NULL, NULL, 0);
initializeTracer();
return SUCCESS;
}
@@ -767,7 +778,9 @@
APD_GLOBALS(dump_sock_id)=0;
}
zend_hash_destroy(APD_GLOBALS(summary));
+ zend_hash_destroy(APD_GLOBALS(file_summary));
efree(APD_GLOBALS(summary));
+ efree(APD_GLOBALS(file_summary));
return SUCCESS;
}

@@ -1144,9 +1157,13 @@
apd_dump_session_start();
}

-void apd_pprof_header() {
+void apd_pprof_header(TSRMLS_DC) {
summary_t *summaryStats;
char *fname = "main";
+ char *filename;
+ int linenum, *filenum;
+ filename = zend_get_executed_filename(TSRMLS_C);
+ linenum = zend_get_executed_lineno(TSRMLS_C);
apd_pprof_fprintf("#Pprof [APD] v0.9\n");
apd_pprof_fprintf("hz=%d\n", sysconf(_SC_CLK_TCK));
apd_pprof_fprintf("caller=%s\n",zend_get_executed_filename(TSRMLS_C));
@@ -1157,8 +1174,13 @@
summaryStats->totalTime = 0;
APD_GLOBALS(index) = 1;
zend_hash_add(APD_GLOBALS(summary), fname, strlen(fname) + 1,
summaryStats, sizeof(summary_t), NULL);
+ filenum = (int *) emalloc(sizeof(int));
+ *filenum = ++APD_GLOBALS(file_index);
+ apd_pprof_fprintf("! %d %s\n", *filenum, filename);
+ zend_hash_add(APD_GLOBALS(file_summary), (char *) filename,
+ strlen(filename) + 1, filenum, sizeof(int), NULL);
apd_pprof_fprintf("& %d %s %d\n", summaryStats->index, fname,
ZEND_USER_FUNCTION);
- apd_pprof_fprintf("+ %d\n", summaryStats->index);
+ apd_pprof_fprintf("+ %d %d %d\n", summaryStats->index, *filenum,
linenum);

}

@@ -1205,7 +1227,7 @@
zend_error(E_ERROR, "%s() failed to open %s for tracing",
get_active_function_name(TSRMLS_C), path);
}
efree(path);
- apd_pprof_header();
+ apd_pprof_header(TSRMLS_C);
}


Index: pear/PECL/apd/php_apd.h
diff -u pear/PECL/apd/php_apd.h:1.14.2.1 pear/PECL/apd/php_apd.h:1.14.2.2
--- pear/PECL/apd/php_apd.h:1.14.2.1 Tue Sep 24 23:48:28 2002
+++ pear/PECL/apd/php_apd.h Fri Sep 27 14:13:45 2002
@@ -106,6 +106,7 @@
ZEND_BEGIN_MODULE_GLOBALS(apd)
void* stack;
HashTable* summary;
+ HashTable* file_summary;
char* dumpdir; /* directory for dumping seesion traces to */
FILE* dump_file; /* FILE for dumping session traces to */
FILE* pprof_file; /* File for profiling output */
@@ -117,6 +118,7 @@
struct tms firsttms; /* Last time recorded */
struct tms lasttms; /* Last time recorded */
int index; /* current index of functions for pprof
tracing */
+ int file_index; /* current index of functions for pprof
tracing */
long bitmask; /* Bitmask for determining what gets logged
*/
long pproftrace; /* Flag for whether we are doing profiling */
void* last_mem_header; /* tail of persistent zend_mem_header
list */



--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise