Changeset 305 in svn
Legend:
- Unmodified
- Added
- Removed
-
trunk/coverager.c
r288 r305 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 } -
trunk/mem.c
r302 r305 15 15 16 16 #ifdef TEST 17 # define ALLOC_DEBUG18 #endif 19 #ifdef ALLOC_DEBUG17 # define DEBUG 18 #endif 19 #ifdef DEBUG 20 20 # define ALLOC_DEBUG_BLOCK_CHECK 21 21 #endif … … 91 91 realsize = ALIGN(realsize); 92 92 93 #ifdef ALLOC_DEBUG 94 fprintf(stderr, "avail: %d (%dKB). Allocate size: %d realsize: %d (%dKB)" 93 TRACE("avail: %d (%dKB). Allocate size: %d realsize: %d (%dKB)" 95 94 , mem->avail, mem->avail / 1024 96 95 , size 97 96 , realsize, realsize / 1024 98 97 ); 99 #endif100 98 do { 101 99 p = NULL; 102 100 if (mem->avail < realsize) { 103 #ifdef ALLOC_DEBUG 104 fprintf(stderr, " oom\n"); 105 #endif 101 TRACE(" oom"); 106 102 break; 107 103 } … … 132 128 133 129 if (b == NULL) { 134 #ifdef ALLOC_DEBUG 135 fprintf(stderr, " no fit chunk\n"); 136 #endif 130 TRACE(" no fit chunk"); 137 131 break; 138 132 } … … 149 143 if (cur->size == realsize) { 150 144 prev->next = cur->next; 151 #ifdef ALLOC_DEBUG 152 fprintf(stderr, " perfect fit. Got: %p\n", p); 153 #endif 145 TRACE(" perfect fit. Got: %p", p); 154 146 break; 155 147 } … … 169 161 */ 170 162 171 #ifdef ALLOC_DEBUG 172 fprintf(stderr, " -> avail: %d (%dKB). new next: %p offset: %d %dKB. Got: %p\n" 163 TRACE(" -> avail: %d (%dKB). new next: %p offset: %d %dKB. Got: %p" 173 164 , mem->avail, mem->avail / 1024 174 165 , newb … … 176 167 , p 177 168 ); 178 #endif179 169 prev->next = newb; 180 170 /* prev|cur|newb|next … … 193 183 194 184 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 185 TRACE("freeing: %p, size=%d", p, cur->size); 199 186 xc_block_check(cur); 200 187 assert((char*)mem < (char*)cur && (char*)cur < (char*)mem + mem->size); … … 211 198 size = cur->size; 212 199 213 #ifdef ALLOC_DEBUG 214 fprintf(stderr, ", avail %d (%dKB)", mem->avail, mem->avail / 1024); 215 #endif 200 TRACE(" avail %d (%dKB)", mem->avail, mem->avail / 1024); 216 201 mem->avail += size; 217 202 … … 221 206 b->next = cur->next; 222 207 cur = b; 223 #ifdef ALLOC_DEBUG 224 fprintf(stderr, ", combine prev"); 225 #endif 208 TRACE(" combine prev"); 226 209 } 227 210 … … 231 214 cur->size += b->size; 232 215 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 216 TRACE(" combine next"); 217 } 218 TRACE(" -> avail %d (%dKB)", mem->avail, mem->avail / 1024); 240 219 return size; 241 220 } -
trunk/mmap.c
r302 r305 1 2 #undef ALLOC_DEBUG3 1 4 2 #include <stdio.h> … … 34 32 #define XC_SHM_IMPL 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) -
trunk/utils.c
r295 r305 331 331 zend_op *opline; 332 332 333 #ifdef DEBUG 334 fprintf(stderr, "binding %d\n", oplineno); 335 #endif 333 TRACE("binding %d", oplineno); 336 334 assert(oplineno >= 0); 337 335 … … 352 350 353 351 parent_name = &(opline - 1)->op2.u.constant; 354 # ifdef DEBUG 355 fprintf(stderr, "binding with parent %s\n", Z_STRVAL_P(parent_name)); 356 # endif 352 TRACE("binding with parent %s", Z_STRVAL_P(parent_name)); 357 353 if (zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) { 358 354 return FAILURE; … … 369 365 zend_op *fetch_class_opline = opline - 1; 370 366 371 # ifdef DEBUG 372 fprintf(stderr, "%s %p\n", Z_STRVAL(fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant)); 373 # endif 367 TRACE("%s %p", Z_STRVAL(fetch_class_opline->op2.u.constant), Z_STRVAL(fetch_class_opline->op2.u.constant)); 374 368 OP_ZVAL_DTOR(fetch_class_opline->op2); 375 369 fetch_class_opline->opcode = ZEND_NOP; … … 707 701 } 708 702 /* }}} */ 703 int xc_vtrace(const char *fmt, va_list args) /* {{{ */ 704 { 705 vfprintf(stderr, fmt, args); 706 return 0; 707 } 708 /* }}} */ 709 int xc_trace(const char *fmt, ...) /* {{{ */ 710 { 711 va_list args; 712 713 va_start(args, fmt); 714 xc_vtrace(fmt, args); 715 va_end(args); 716 return 0; 717 } 718 /* }}} */ -
trunk/utils.h
r268 r305 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 { -
trunk/xc_malloc.c
r302 r305 7 7 #include "php.h" 8 8 #include "align.h" 9 #include "utils.h" 9 10 10 11 struct _xc_mem_t { … … 112 113 xc_shmsize_t memoffset; 113 114 }; 114 115 #undef NDEBUG116 #ifdef ALLOC_DEBUG117 # define inline118 #else119 # define NDEBUG120 #endif121 #include <assert.h>122 115 /* }}} */ 123 116 -
trunk/xc_shm.h
r163 r305 1 #ifndef XC_SHM_H 2 #define XC_SHM_H 1 3 typedef struct _xc_shm_t xc_shm_t; 2 4 typedef size_t xc_shmsize_t; … … 63 65 xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2); 64 66 void xc_shm_destroy(xc_shm_t *shm); 67 #endif -
trunk/xcache.c
r299 r305 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) … … 243 232 static void xc_entry_hold_php_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 244 233 { 245 #ifdef DEBUG 246 fprintf(stderr, "hold %s\n", xce->name.str.val); 247 #endif 234 TRACE("hold %s", xce->name.str.val); 248 235 xce->refcount ++; 249 236 xc_stack_push(&XG(php_holds)[xce->cache->cacheid], (void *)xce); … … 290 277 static XC_ENTRY_APPLY_FUNC(xc_gc_expires_php_entry_dmz) /* {{{ */ 291 278 { 292 #ifdef DEBUG 293 fprintf(stderr, "ttl %lu, %lu %lu\n", (zend_ulong) XG(request_time), (zend_ulong) entry->atime, xc_php_ttl); 294 #endif 279 TRACE("ttl %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) entry->atime, xc_php_ttl); 295 280 if (XG(request_time) > entry->atime + xc_php_ttl) { 296 281 return 1; … … 309 294 static void xc_gc_expires_one(xc_cache_t *cache, zend_ulong gc_interval, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */ 310 295 { 311 #ifdef DEBUG 312 fprintf(stderr, "interval %lu, %lu %lu\n", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval); 313 #endif 296 TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval); 314 297 if (XG(request_time) - cache->last_gc_expires >= gc_interval) { 315 298 ENTER_LOCK(cache) { … … 623 606 for (i = 0; i < cachecount; i ++) { 624 607 s = &holds[i]; 625 #ifdef DEBUG 626 fprintf(stderr, "holded %d\n", xc_stack_size(s)); 627 #endif 608 TRACE("holded %d", xc_stack_size(s)); 628 609 if (xc_stack_size(s)) { 629 610 cache = ((xc_entry_t *)xc_stack_top(s))->cache; … … 631 612 while (xc_stack_size(s)) { 632 613 xce = (xc_entry_t*) xc_stack_pop(s); 633 #ifdef DEBUG 634 fprintf(stderr, "unhold %s\n", xce->name.str.val); 635 #endif 614 TRACE("unhold %s", xce->name.str.val); 636 615 xce->refcount --; 637 616 assert(xce->refcount >= 0); … … 811 790 assert(0); 812 791 } 813 #ifdef DEBUG 814 fprintf(stderr, "got ZEND_DECLARE_INHERITED_CLASS: %s\n", class_name + 1); 815 #endif 792 TRACE("got ZEND_DECLARE_INHERITED_CLASS: %s", class_name + 1); 816 793 /* let's see which class */ 817 794 for (i = 0; i < php->classinfo_cnt; i ++) { … … 891 868 /* found */ 892 869 if (stored_xce) { 893 #ifdef DEBUG 894 fprintf(stderr, "found %s, catch it\n", stored_xce->name.str.val); 895 #endif 870 TRACE("found %s, catch it", stored_xce->name.str.val); 896 871 xc_entry_hold_php_dmz(stored_xce TSRMLS_CC); 897 872 cache->hits ++; … … 920 895 921 896 /* {{{ compile */ 922 #ifdef DEBUG 923 fprintf(stderr, "compiling %s\n", filename); 924 #endif 897 TRACE("compiling %s", filename); 925 898 926 899 /* make compile inside sandbox */ … … 1088 1061 } LEAVE_LOCK_EX(cache); 1089 1062 /* }}} */ 1090 #ifdef DEBUG 1091 fprintf(stderr, "stored\n"); 1092 #endif 1063 TRACE("%s", "stored"); 1093 1064 1094 1065 #define X_FREE(var) \ … … 1146 1117 CG(compiled_filename) = stored_xce->name.str.val; 1147 1118 CG(zend_lineno) = 0; 1148 #ifdef DEBUG 1149 fprintf(stderr, "restoring %s\n", stored_xce->name.str.val); 1150 #endif 1119 TRACE("restoring %s", stored_xce->name.str.val); 1151 1120 xc_processor_restore_xc_entry_t(&xce, stored_xce, xc_readonly_protection TSRMLS_CC); 1152 1121 #ifdef SHOW_DPRINT … … 1181 1150 CG(in_compilation) = 0; 1182 1151 CG(compiled_filename) = NULL; 1183 #ifdef DEBUG 1184 fprintf(stderr, "restored %s\n", stored_xce->name.str.val); 1185 #endif 1152 TRACE("restored %s", stored_xce->name.str.val); 1186 1153 return op_array; 1187 1154 } … … 1875 1842 stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 1876 1843 if (stored_xce) { 1877 #ifdef DEBUG 1878 fprintf(stderr, "incdec: gotxce %s\n", xce.name.str.val); 1879 #endif 1844 TRACE("incdec: gotxce %s", xce.name.str.val); 1880 1845 /* timeout */ 1881 1846 if (VAR_ENTRY_EXPIRED(stored_xce)) { 1882 #ifdef DEBUG 1883 fprintf(stderr, "incdec: expired\n"); 1884 #endif 1847 TRACE("%s", "incdec: expired"); 1885 1848 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 1886 1849 stored_xce = NULL; … … 1892 1855 stored_xce->ctime = XG(request_time); 1893 1856 stored_xce->ttl = xce.ttl; 1894 #ifdef DEBUG 1895 fprintf(stderr, "incdec: islong\n"); 1896 #endif 1857 TRACE("%s", "incdec: islong"); 1897 1858 value = Z_LVAL_P(stored_var->value); 1898 1859 value += (inc == 1 ? count : - count); … … 1902 1863 } 1903 1864 else { 1904 #ifdef DEBUG 1905 fprintf(stderr, "incdec: notlong\n"); 1906 #endif 1865 TRACE("%s", "incdec: notlong"); 1907 1866 xc_processor_restore_zval(&oldzval, stored_xce->data.var->value, stored_xce->have_references TSRMLS_CC); 1908 1867 convert_to_long(&oldzval); … … 1912 1871 } 1913 1872 } 1914 #ifdef DEBUG1915 1873 else { 1916 fprintf(stderr, "incdec: %s not found\n", xce.name.str.val); 1917 } 1918 #endif 1874 TRACE("incdec: %s not found", xce.name.str.val); 1875 } 1919 1876 1920 1877 value += (inc == 1 ? count : - count); … … 2360 2317 2361 2318 zend_llist_prepend_element(&zend_extensions, &extension); 2362 #ifdef DEBUG 2363 fprintf(stderr, "registered\n"); 2364 #endif 2319 TRACE("%s", "registered"); 2365 2320 } 2366 2321
Note: See TracChangeset
for help on using the changeset viewer.