Changeset 593 in svn
- Timestamp:
- 2009-07-05T04:06:15Z (9 years ago)
- Location:
- branches/1.3
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/coverager.c
r406 r593 27 27 { 28 28 coverager_t cov = *(coverager_t*) pDest; 29 #ifdef DEBUG 30 fprintf(stderr, "destroy %p\n", cov); 31 #endif 29 TRACE("destroy %p", cov); 32 30 zend_hash_destroy(cov); 33 31 efree(cov); … … 39 37 struct stat st; 40 38 41 #ifdef DEBUG 42 fprintf(stderr, "mkdirs %s %d %s %d\n", root, rootlen, path, pathlen); 43 #endif 39 TRACE("mkdirs %s %d %s %d", root, rootlen, path, pathlen); 44 40 fullpath = do_alloca(rootlen + pathlen + 1); 45 41 memcpy(fullpath, root, rootlen); … … 56 52 *chr = PHP_DIR_SEPARATOR; 57 53 } 58 #ifdef DEBUG 59 fprintf(stderr, "mkdir %s\n", fullpath); 60 #endif 54 TRACE("mkdir %s", fullpath); 61 55 #if PHP_MAJOR_VERSION > 5 62 56 php_stream_mkdir(fullpath, 0700, REPORT_ERRORS, NULL); … … 113 107 114 108 if (newfile) { 115 #ifdef DEBUG 116 fprintf(stderr, "new file\n"); 117 #endif 109 TRACE("%s", "new file"); 118 110 } 119 111 else if (outstat.st_size) { … … 123 115 goto bailout; 124 116 } 125 #ifdef DEBUG 126 fprintf(stderr, "oldsize %d\n", (int) len); 127 #endif 117 TRACE("oldsize %d", (int) len); 128 118 do { 129 119 p = (long *) contents; … … 133 123 } 134 124 if (*p++ != PCOV_HEADER_MAGIC) { 135 #ifdef DEBUG 136 fprintf(stderr, "wrong magic in file %s\n", outfilename); 137 #endif 125 TRACE("wrong magic in file %s", outfilename); 138 126 break; 139 127 } … … 290 278 strcpy(outfilename + dumpdir_len + size - 1, ".pcov"); 291 279 292 #ifdef DEBUG 293 fprintf(stderr, "outfilename %s\n", outfilename); 294 #endif 280 TRACE("outfilename %s", outfilename); 295 281 xc_coverager_save_cov(ZSTR_S(s), outfilename, *pcov TSRMLS_CC); 296 282 zend_hash_move_forward_ex(XG(coverages), &pos); … … 354 340 355 341 if (zend_hash_find(XG(coverages), filename, len, (void **) &pcov) == SUCCESS) { 356 #ifdef DEBUG 357 fprintf(stderr, "got coverage %s %p\n", filename, *pcov); 358 #endif 342 TRACE("got coverage %s %p", filename, *pcov); 359 343 return *pcov; 360 344 } … … 363 347 zend_hash_init(cov, 0, NULL, NULL, 0); 364 348 zend_hash_add(XG(coverages), filename, len, (void **) &cov, sizeof(cov), NULL); 365 #ifdef DEBUG 366 fprintf(stderr, "new coverage %s %p\n", filename, cov); 367 #endif 349 TRACE("new coverage %s %p", filename, cov); 368 350 return cov; 369 351 } … … 534 516 } 535 517 if (*p++ != PCOV_HEADER_MAGIC) { 536 #ifdef DEBUG 537 fprintf(stderr, "wrong magic in xcache_coverager_decode"); 538 #endif 518 TRACE("%s", "wrong magic in xcache_coverager_decode"); 539 519 return; 540 520 } -
branches/1.3/mem.c
r394 r593 13 13 #include "xc_shm.h" 14 14 #include "align.h" 15 #include "utils.h" 15 16 16 17 #ifdef TEST 17 # define ALLOC_DEBUG18 #endif 19 #ifdef ALLOC_DEBUG18 # define DEBUG 19 #endif 20 #ifdef DEBUG 20 21 # define ALLOC_DEBUG_BLOCK_CHECK 21 22 #endif … … 91 92 realsize = ALIGN(realsize); 92 93 93 #ifdef ALLOC_DEBUG 94 fprintf(stderr, "avail: %d (%dKB). Allocate size: %d realsize: %d (%dKB)" 94 TRACE("avail: %d (%dKB). Allocate size: %d realsize: %d (%dKB)" 95 95 , mem->avail, mem->avail / 1024 96 96 , size 97 97 , realsize, realsize / 1024 98 98 ); 99 #endif100 99 do { 101 100 p = NULL; 102 101 if (mem->avail < realsize) { 103 #ifdef ALLOC_DEBUG 104 fprintf(stderr, " oom\n"); 105 #endif 102 TRACE("%s", " oom"); 106 103 break; 107 104 } … … 132 129 133 130 if (b == NULL) { 134 #ifdef ALLOC_DEBUG 135 fprintf(stderr, " no fit chunk\n"); 136 #endif 131 TRACE("%s", " no fit chunk"); 137 132 break; 138 133 } … … 149 144 if (cur->size == realsize) { 150 145 prev->next = cur->next; 151 #ifdef ALLOC_DEBUG 152 fprintf(stderr, " perfect fit. Got: %p\n", p); 153 #endif 146 TRACE(" perfect fit. Got: %p", p); 154 147 break; 155 148 } … … 169 162 */ 170 163 171 #ifdef ALLOC_DEBUG 172 fprintf(stderr, " -> avail: %d (%dKB). new next: %p offset: %d %dKB. Got: %p\n" 164 TRACE(" -> avail: %d (%dKB). new next: %p offset: %d %dKB. Got: %p" 173 165 , mem->avail, mem->avail / 1024 174 166 , newb … … 176 168 , p 177 169 ); 178 #endif179 170 prev->next = newb; 180 171 /* prev|cur|newb|next … … 193 184 194 185 cur = (xc_block_t *) (CHAR_PTR(p) - BLOCK_HEADER_SIZE()); 195 #ifdef ALLOC_DEBUG 196 fprintf(stderr, "freeing: %p", p); 197 fprintf(stderr, ", size=%d", cur->size); 198 #endif 186 TRACE("freeing: %p, size=%d", p, cur->size); 199 187 xc_block_check(cur); 200 188 assert((char*)mem < (char*)cur && (char*)cur < (char*)mem + mem->size); … … 211 199 size = cur->size; 212 200 213 #ifdef ALLOC_DEBUG 214 fprintf(stderr, ", avail %d (%dKB)", mem->avail, mem->avail / 1024); 215 #endif 201 TRACE(" avail %d (%dKB)", mem->avail, mem->avail / 1024); 216 202 mem->avail += size; 217 203 … … 221 207 b->next = cur->next; 222 208 cur = b; 223 #ifdef ALLOC_DEBUG 224 fprintf(stderr, ", combine prev"); 225 #endif 209 TRACE("%s", " combine prev"); 226 210 } 227 211 … … 231 215 cur->size += b->size; 232 216 cur->next = b->next; 233 #ifdef ALLOC_DEBUG 234 fprintf(stderr, ", combine next"); 235 #endif 236 } 237 #ifdef ALLOC_DEBUG 238 fprintf(stderr, " -> avail %d (%dKB)\n", mem->avail, mem->avail / 1024); 239 #endif 217 TRACE("%s", " combine next"); 218 } 219 TRACE(" -> avail %d (%dKB)", mem->avail, mem->avail / 1024); 240 220 return size; 241 221 } -
branches/1.3/mmap.c
r394 r593 1 2 #undef ALLOC_DEBUG3 1 4 2 #include <stdio.h> … … 34 32 #define XC_SHM_IMPL _xc_mmap_shm_t 35 33 #include "xc_shm.h" 34 #include "utils.h" 36 35 37 36 #ifndef max … … 55 54 }; 56 55 57 #undef NDEBUG58 #ifdef ALLOC_DEBUG59 # define inline60 #else61 # define NDEBUG62 #endif63 #include <assert.h>64 56 /* }}} */ 65 57 #define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0) -
branches/1.3/processor/main.m4
r394 r593 39 39 IFSTORE(` 40 40 IFASSERT(`{ 41 if (!xc_stack_ size(&processor->allocsizes)) {41 if (!xc_stack_count(&processor->allocsizes)) { 42 42 fprintf(stderr, "mismatch `$@' at line %d\n", __LINE__); 43 43 } -
branches/1.3/stack.c
r394 r593 4 4 typedef xc_stack_t* S; 5 5 6 void xc_stack_init (S stack)6 void xc_stack_init_ex(S stack, int initsize) 7 7 { 8 8 stack->cnt = 0; 9 stack->size = 8;9 stack->size = initsize; 10 10 stack->data = malloc(sizeof(void *) * stack->size); 11 11 } … … 43 43 } 44 44 45 int xc_stack_ size(S stack)45 int xc_stack_count(S stack) 46 46 { 47 47 assert(stack != NULL); -
branches/1.3/stack.h
r394 r593 7 7 8 8 #define S xc_stack_t* 9 void xc_stack_init(S stack); 9 void xc_stack_init_ex(S stack, int initsize); 10 #define xc_stack_init(stack) xc_stack_init_ex(stack, 8) 10 11 void xc_stack_destroy(S stack); 11 12 void xc_stack_push(S stack, void *item); … … 13 14 void *xc_stack_top(S stack); 14 15 void *xc_stack_get(S stack, int n); 15 int xc_stack_ size(S stack);16 int xc_stack_count(S stack); 16 17 void xc_stack_reverse(S stack); 17 18 #undef S -
branches/1.3/utils.c
r436 r593 333 333 zend_op *opline; 334 334 335 #ifdef DEBUG 336 fprintf(stderr, "binding %d\n", oplineno); 337 #endif 335 TRACE("binding %d", oplineno); 338 336 assert(oplineno >= 0); 339 337 … … 354 352 355 353 parent_name = &(opline - 1)->op2.u.constant; 356 # ifdef DEBUG 357 fprintf(stderr, "binding with parent %s\n", Z_STRVAL_P(parent_name)); 358 # endif 354 TRACE("binding with parent %s", Z_STRVAL_P(parent_name)); 359 355 if (zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) { 360 356 return FAILURE; … … 371 367 zend_op *fetch_class_opline = opline - 1; 372 368 373 # ifdef DEBUG 374 fprintf(stderr, "%s %p\n", Z_STRVAL(fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant)); 375 # endif 369 TRACE("%s %p", Z_STRVAL(fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant)); 376 370 OP_ZVAL_DTOR(fetch_class_opline->op2); 377 371 fetch_class_opline->opcode = ZEND_NOP; … … 736 730 } 737 731 /* }}} */ 732 int xc_vtrace(const char *fmt, va_list args) /* {{{ */ 733 { 734 vfprintf(stderr, fmt, args); 735 return 0; 736 } 737 /* }}} */ 738 int xc_trace(const char *fmt, ...) /* {{{ */ 739 { 740 va_list args; 741 742 va_start(args, fmt); 743 xc_vtrace(fmt, args); 744 va_end(args); 745 return 0; 746 } 747 /* }}} */ -
branches/1.3/utils.h
r408 r593 1 1 #include "php.h" 2 #include "xcache.h" 3 4 #ifdef DEBUG 5 # define IFDEBUG(x) (x) 6 # define TRACE(fmt, ...) \ 7 xc_trace("%s:%d: " fmt "\r\n", __FILE__, __LINE__, __VA_ARGS__) 8 int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); 9 # undef NDEBUG 10 # undef inline 11 # define inline 12 #else 13 # define TRACE(fmt, ...) do { } while (0) 14 # define IFDEBUG(x) do { } while (0) 15 # ifndef NDEBUG 16 # define NDEBUG 17 # endif 18 #endif 19 #include <assert.h> 2 20 3 21 typedef struct { -
branches/1.3/xc_malloc.c
r479 r593 11 11 #include "php.h" 12 12 #include "align.h" 13 #include "utils.h" 13 14 14 15 struct _xc_malloc_mem_t { … … 116 117 xc_shmsize_t memoffset; 117 118 }; 118 119 #undef NDEBUG120 #ifdef ALLOC_DEBUG121 # define inline122 #else123 # define NDEBUG124 #endif125 #include <assert.h>126 119 /* }}} */ 127 120 -
branches/1.3/xc_shm.h
r394 r593 1 #ifndef XC_SHM_H 2 #define XC_SHM_H 1 3 typedef struct _xc_shm_handlers_t xc_shm_handlers_t; 2 4 … … 66 68 xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2); 67 69 void xc_shm_destroy(xc_shm_t *shm); 70 #endif -
branches/1.3/xcache.c
r560 r593 30 30 #include "xcache_globals.h" 31 31 #include "processor.h" 32 #include "utils.h"33 32 #include "const_string.h" 34 33 #include "opcode_spec.h" 35 36 #ifdef DEBUG 37 # undef NDEBUG 38 # undef inline 39 # define inline 40 #else 41 # ifndef NDEBUG 42 # define NDEBUG 43 # endif 44 #endif 45 #include <assert.h> 34 #include "utils.h" 46 35 47 36 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl) … … 245 234 static void xc_entry_hold_php_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 246 235 { 247 #ifdef DEBUG 248 fprintf(stderr, "hold %s\n", xce->name.str.val); 249 #endif 236 TRACE("hold %s", xce->name.str.val); 250 237 xce->refcount ++; 251 238 xc_stack_push(&XG(php_holds)[xce->cache->cacheid], (void *)xce); … … 292 279 static XC_ENTRY_APPLY_FUNC(xc_gc_expires_php_entry_dmz) /* {{{ */ 293 280 { 294 #ifdef DEBUG 295 fprintf(stderr, "ttl %lu, %lu %lu\n", (zend_ulong) XG(request_time), (zend_ulong) entry->atime, xc_php_ttl); 296 #endif 281 TRACE("ttl %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) entry->atime, xc_php_ttl); 297 282 if (XG(request_time) > entry->atime + xc_php_ttl) { 298 283 return 1; … … 311 296 static void xc_gc_expires_one(xc_cache_t *cache, zend_ulong gc_interval, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */ 312 297 { 313 #ifdef DEBUG 314 fprintf(stderr, "interval %lu, %lu %lu\n", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval); 315 #endif 298 TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval); 316 299 if (XG(request_time) - cache->last_gc_expires >= gc_interval) { 317 300 ENTER_LOCK(cache) { … … 630 613 for (i = 0; i < cachecount; i ++) { 631 614 s = &holds[i]; 632 #ifdef DEBUG 633 fprintf(stderr, "holded %d\n", xc_stack_size(s)); 634 #endif 635 if (xc_stack_size(s)) { 615 TRACE("holded %d", xc_stack_count(s)); 616 if (xc_stack_count(s)) { 636 617 cache = ((xc_entry_t *)xc_stack_top(s))->cache; 637 618 ENTER_LOCK(cache) { 638 while (xc_stack_ size(s)) {619 while (xc_stack_count(s)) { 639 620 xce = (xc_entry_t*) xc_stack_pop(s); 640 #ifdef DEBUG 641 fprintf(stderr, "unhold %s\n", xce->name.str.val); 642 #endif 621 TRACE("unhold %s", xce->name.str.val); 643 622 xce->refcount --; 644 623 assert(xce->refcount >= 0); … … 829 808 assert(0); 830 809 } 831 #ifdef DEBUG 832 fprintf(stderr, "got ZEND_DECLARE_INHERITED_CLASS: %s\n", class_name + 1); 833 #endif 810 TRACE("got ZEND_DECLARE_INHERITED_CLASS: %s", class_name + 1); 834 811 /* let's see which class */ 835 812 for (i = 0; i < php->classinfo_cnt; i ++) { … … 915 892 /* found */ 916 893 if (stored_xce) { 917 #ifdef DEBUG 918 fprintf(stderr, "found %s, catch it\n", stored_xce->name.str.val); 919 #endif 894 TRACE("found %s, catch it", stored_xce->name.str.val); 920 895 xc_entry_hold_php_dmz(stored_xce TSRMLS_CC); 921 896 cache->hits ++; … … 944 919 945 920 /* {{{ compile */ 946 #ifdef DEBUG 947 fprintf(stderr, "compiling %s\n", filename); 948 #endif 921 TRACE("compiling %s", filename); 949 922 950 923 /* make compile inside sandbox */ … … 1125 1098 } LEAVE_LOCK_EX(cache); 1126 1099 /* }}} */ 1127 #ifdef DEBUG 1128 fprintf(stderr, "stored\n"); 1129 #endif 1100 TRACE("%s", "stored"); 1130 1101 1131 1102 #define X_FREE(var) \ … … 1186 1157 CG(compiled_filename) = stored_xce->name.str.val; 1187 1158 CG(zend_lineno) = 0; 1188 #ifdef DEBUG 1189 fprintf(stderr, "restoring %s\n", stored_xce->name.str.val); 1190 #endif 1159 TRACE("restoring %s", stored_xce->name.str.val); 1191 1160 xc_processor_restore_xc_entry_t(&xce, stored_xce, xc_readonly_protection TSRMLS_CC); 1192 1161 #ifdef SHOW_DPRINT … … 1221 1190 CG(in_compilation) = 0; 1222 1191 CG(compiled_filename) = NULL; 1223 #ifdef DEBUG 1224 fprintf(stderr, "restored %s\n", stored_xce->name.str.val); 1225 #endif 1192 TRACE("restored %s", stored_xce->name.str.val); 1226 1193 return op_array; 1227 1194 } … … 2006 1973 stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 2007 1974 if (stored_xce) { 2008 #ifdef DEBUG 2009 fprintf(stderr, "incdec: gotxce %s\n", xce.name.str.val); 2010 #endif 1975 TRACE("incdec: gotxce %s", xce.name.str.val); 2011 1976 /* timeout */ 2012 1977 if (VAR_ENTRY_EXPIRED(stored_xce)) { 2013 #ifdef DEBUG 2014 fprintf(stderr, "incdec: expired\n"); 2015 #endif 1978 TRACE("%s", "incdec: expired"); 2016 1979 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 2017 1980 stored_xce = NULL; … … 2024 1987 stored_xce->ctime = XG(request_time); 2025 1988 stored_xce->ttl = xce.ttl; 2026 #ifdef DEBUG 2027 fprintf(stderr, "incdec: islong\n"); 2028 #endif 1989 TRACE("%s", "incdec: islong"); 2029 1990 value = Z_LVAL_P(stored_var->value); 2030 1991 value += (inc == 1 ? count : - count); … … 2036 1997 } 2037 1998 else { 2038 #ifdef DEBUG 2039 fprintf(stderr, "incdec: notlong\n"); 2040 #endif 1999 TRACE("%s", "incdec: notlong"); 2041 2000 xc_processor_restore_zval(&oldzval, stored_xce->data.var->value, stored_xce->have_references TSRMLS_CC); 2042 2001 convert_to_long(&oldzval); … … 2046 2005 } 2047 2006 } 2048 #ifdef DEBUG2049 2007 else { 2050 fprintf(stderr, "incdec: %s not found\n", xce.name.str.val); 2051 } 2052 #endif 2008 TRACE("incdec: %s not found", xce.name.str.val); 2009 } 2053 2010 2054 2011 value += (inc == 1 ? count : - count); … … 2495 2452 2496 2453 zend_llist_prepend_element(&zend_extensions, &extension); 2497 #ifdef DEBUG 2498 fprintf(stderr, "registered\n"); 2499 #endif 2454 TRACE("%s", "registered"); 2500 2455 } 2501 2456
Note: See TracChangeset
for help on using the changeset viewer.