Changeset 593 in svn for branches/1.3


Ignore:
Timestamp:
2009-07-05T04:06:15Z (6 years ago)
Author:
Xuefer
Message:

merged r304,r305,r306,r307 from trunk

Location:
branches/1.3
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/coverager.c

    r406 r593  
    2727{
    2828    coverager_t cov = *(coverager_t*) pDest;
    29 #ifdef DEBUG
    30     fprintf(stderr, "destroy %p\n", cov);
    31 #endif
     29    TRACE("destroy %p", cov);
    3230    zend_hash_destroy(cov);
    3331    efree(cov);
     
    3937    struct stat st;
    4038
    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);
    4440    fullpath = do_alloca(rootlen + pathlen + 1);
    4541    memcpy(fullpath, root, rootlen);
     
    5652            *chr = PHP_DIR_SEPARATOR;
    5753        }
    58 #ifdef DEBUG
    59         fprintf(stderr, "mkdir %s\n", fullpath);
    60 #endif
     54        TRACE("mkdir %s", fullpath);
    6155#if PHP_MAJOR_VERSION > 5
    6256        php_stream_mkdir(fullpath, 0700, REPORT_ERRORS, NULL);
     
    113107
    114108    if (newfile) {
    115 #ifdef DEBUG
    116         fprintf(stderr, "new file\n");
    117 #endif
     109        TRACE("%s", "new file");
    118110    }
    119111    else if (outstat.st_size) {
     
    123115            goto bailout;
    124116        }
    125 #ifdef DEBUG
    126         fprintf(stderr, "oldsize %d\n", (int) len);
    127 #endif
     117        TRACE("oldsize %d", (int) len);
    128118        do {
    129119            p = (long *) contents;
     
    133123            }
    134124            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);
    138126                break;
    139127            }
     
    290278            strcpy(outfilename + dumpdir_len + size - 1, ".pcov");
    291279
    292 #ifdef DEBUG
    293             fprintf(stderr, "outfilename %s\n", outfilename);
    294 #endif
     280            TRACE("outfilename %s", outfilename);
    295281            xc_coverager_save_cov(ZSTR_S(s), outfilename, *pcov TSRMLS_CC);
    296282            zend_hash_move_forward_ex(XG(coverages), &pos);
     
    354340
    355341    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);
    359343        return *pcov;
    360344    }
     
    363347        zend_hash_init(cov, 0, NULL, NULL, 0);
    364348        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);
    368350        return cov;
    369351    }
     
    534516    }
    535517    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");
    539519        return;
    540520    }
  • branches/1.3/mem.c

    r394 r593  
    1313#include "xc_shm.h"
    1414#include "align.h"
     15#include "utils.h"
    1516
    1617#ifdef TEST
    17 #   define ALLOC_DEBUG
    18 #endif
    19 #ifdef ALLOC_DEBUG
     18#   define DEBUG
     19#endif
     20#ifdef DEBUG
    2021#   define ALLOC_DEBUG_BLOCK_CHECK
    2122#endif
     
    9192    realsize = ALIGN(realsize);
    9293
    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)"
    9595            , mem->avail, mem->avail / 1024
    9696            , size
    9797            , realsize, realsize / 1024
    9898            );
    99 #endif
    10099    do {
    101100        p = NULL;
    102101        if (mem->avail < realsize) {
    103 #ifdef ALLOC_DEBUG
    104             fprintf(stderr, " oom\n");
    105 #endif
     102            TRACE("%s", " oom");
    106103            break;
    107104        }
     
    132129
    133130        if (b == NULL) {
    134 #ifdef ALLOC_DEBUG
    135             fprintf(stderr, " no fit chunk\n");
    136 #endif
     131            TRACE("%s", " no fit chunk");
    137132            break;
    138133        }
     
    149144        if (cur->size == realsize) {
    150145            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);
    154147            break;
    155148        }
     
    169162         */
    170163
    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"
    173165                , mem->avail, mem->avail / 1024
    174166                , newb
     
    176168                , p
    177169                );
    178 #endif
    179170        prev->next = newb;
    180171        /* prev|cur|newb|next
     
    193184
    194185    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);
    199187    xc_block_check(cur);
    200188    assert((char*)mem < (char*)cur && (char*)cur < (char*)mem + mem->size);
     
    211199    size = cur->size;
    212200
    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);
    216202    mem->avail += size;
    217203
     
    221207        b->next = cur->next;
    222208        cur = b;
    223 #ifdef ALLOC_DEBUG
    224         fprintf(stderr, ", combine prev");
    225 #endif
     209        TRACE("%s", " combine prev");
    226210    }
    227211
     
    231215        cur->size += b->size;
    232216        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);
    240220    return size;
    241221}
  • branches/1.3/mmap.c

    r394 r593  
    1 
    2 #undef ALLOC_DEBUG
    31
    42#include <stdio.h>
     
    3432#define XC_SHM_IMPL _xc_mmap_shm_t
    3533#include "xc_shm.h"
     34#include "utils.h"
    3635
    3736#ifndef max
     
    5554};
    5655
    57 #undef NDEBUG
    58 #ifdef ALLOC_DEBUG
    59 #   define inline
    60 #else
    61 #   define NDEBUG
    62 #endif
    63 #include <assert.h>
    6456/* }}} */
    6557#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  
    3939    IFSTORE(`
    4040        IFASSERT(`{
    41             if (!xc_stack_size(&processor->allocsizes)) {
     41            if (!xc_stack_count(&processor->allocsizes)) {
    4242                fprintf(stderr, "mismatch `$@' at line %d\n", __LINE__);
    4343            }
  • branches/1.3/stack.c

    r394 r593  
    44typedef xc_stack_t* S;
    55
    6 void xc_stack_init(S stack)
     6void xc_stack_init_ex(S stack, int initsize)
    77{
    88    stack->cnt = 0;
    9     stack->size = 8;
     9    stack->size = initsize;
    1010    stack->data = malloc(sizeof(void *) * stack->size);
    1111}
     
    4343}
    4444
    45 int xc_stack_size(S stack)
     45int xc_stack_count(S stack)
    4646{
    4747    assert(stack != NULL);
  • branches/1.3/stack.h

    r394 r593  
    77
    88#define S xc_stack_t*
    9 void xc_stack_init(S stack);
     9void xc_stack_init_ex(S stack, int initsize);
     10#define xc_stack_init(stack) xc_stack_init_ex(stack, 8)
    1011void xc_stack_destroy(S stack);
    1112void xc_stack_push(S stack, void *item);
     
    1314void *xc_stack_top(S stack);
    1415void *xc_stack_get(S stack, int n);
    15 int xc_stack_size(S stack);
     16int xc_stack_count(S stack);
    1617void xc_stack_reverse(S stack);
    1718#undef S
  • branches/1.3/utils.c

    r436 r593  
    333333    zend_op *opline;
    334334
    335 #ifdef DEBUG
    336     fprintf(stderr, "binding %d\n", oplineno);
    337 #endif
     335    TRACE("binding %d", oplineno);
    338336    assert(oplineno >= 0);
    339337
     
    354352
    355353            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));
    359355            if (zend_lookup_class(Z_STRVAL_P(parent_name), Z_STRLEN_P(parent_name), &pce TSRMLS_CC) == FAILURE) {
    360356                return FAILURE;
     
    371367            zend_op *fetch_class_opline = opline - 1;
    372368
    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));
    376370            OP_ZVAL_DTOR(fetch_class_opline->op2);
    377371            fetch_class_opline->opcode = ZEND_NOP;
     
    736730}
    737731/* }}} */
     732int xc_vtrace(const char *fmt, va_list args) /* {{{ */
     733{
     734    vfprintf(stderr, fmt, args);
     735    return 0;
     736}
     737/* }}} */
     738int 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  
    11#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__)
     8int 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>
    220
    321typedef struct {
  • branches/1.3/xc_malloc.c

    r479 r593  
    1111#include "php.h"
    1212#include "align.h"
     13#include "utils.h"
    1314
    1415struct _xc_malloc_mem_t {
     
    116117    xc_shmsize_t       memoffset;
    117118};
    118 
    119 #undef NDEBUG
    120 #ifdef ALLOC_DEBUG
    121 #   define inline
    122 #else
    123 #   define NDEBUG
    124 #endif
    125 #include <assert.h>
    126119/* }}} */
    127120
  • branches/1.3/xc_shm.h

    r394 r593  
     1#ifndef XC_SHM_H
     2#define XC_SHM_H
    13typedef struct _xc_shm_handlers_t xc_shm_handlers_t;
    24
     
    6668xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2);
    6769void xc_shm_destroy(xc_shm_t *shm);
     70#endif
  • branches/1.3/xcache.c

    r560 r593  
    3030#include "xcache_globals.h"
    3131#include "processor.h"
    32 #include "utils.h"
    3332#include "const_string.h"
    3433#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"
    4635
    4736#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl)
     
    245234static void xc_entry_hold_php_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
    246235{
    247 #ifdef DEBUG
    248     fprintf(stderr, "hold %s\n", xce->name.str.val);
    249 #endif
     236    TRACE("hold %s", xce->name.str.val);
    250237    xce->refcount ++;
    251238    xc_stack_push(&XG(php_holds)[xce->cache->cacheid], (void *)xce);
     
    292279static XC_ENTRY_APPLY_FUNC(xc_gc_expires_php_entry_dmz) /* {{{ */
    293280{
    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);
    297282    if (XG(request_time) > entry->atime + xc_php_ttl) {
    298283        return 1;
     
    311296static void xc_gc_expires_one(xc_cache_t *cache, zend_ulong gc_interval, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */
    312297{
    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);
    316299    if (XG(request_time) - cache->last_gc_expires >= gc_interval) {
    317300        ENTER_LOCK(cache) {
     
    630613    for (i = 0; i < cachecount; i ++) {
    631614        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)) {
    636617            cache = ((xc_entry_t *)xc_stack_top(s))->cache;
    637618            ENTER_LOCK(cache) {
    638                 while (xc_stack_size(s)) {
     619                while (xc_stack_count(s)) {
    639620                    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);
    643622                    xce->refcount --;
    644623                    assert(xce->refcount >= 0);
     
    829808        assert(0);
    830809    }
    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);
    834811    /* let's see which class */
    835812    for (i = 0; i < php->classinfo_cnt; i ++) {
     
    915892        /* found */
    916893        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);
    920895            xc_entry_hold_php_dmz(stored_xce TSRMLS_CC);
    921896            cache->hits ++;
     
    944919
    945920    /* {{{ compile */
    946 #ifdef DEBUG
    947     fprintf(stderr, "compiling %s\n", filename);
    948 #endif
     921    TRACE("compiling %s", filename);
    949922
    950923    /* make compile inside sandbox */
     
    11251098    } LEAVE_LOCK_EX(cache);
    11261099    /* }}} */
    1127 #ifdef DEBUG
    1128     fprintf(stderr, "stored\n");
    1129 #endif
     1100    TRACE("%s", "stored");
    11301101
    11311102#define X_FREE(var) \
     
    11861157    CG(compiled_filename) = stored_xce->name.str.val;
    11871158    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);
    11911160    xc_processor_restore_xc_entry_t(&xce, stored_xce, xc_readonly_protection TSRMLS_CC);
    11921161#ifdef SHOW_DPRINT
     
    12211190    CG(in_compilation)    = 0;
    12221191    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);
    12261193    return op_array;
    12271194}
     
    20061973        stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
    20071974        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);
    20111976            /* timeout */
    20121977            if (VAR_ENTRY_EXPIRED(stored_xce)) {
    2013 #ifdef DEBUG
    2014                 fprintf(stderr, "incdec: expired\n");
    2015 #endif
     1978                TRACE("%s", "incdec: expired");
    20161979                xc_entry_remove_dmz(stored_xce TSRMLS_CC);
    20171980                stored_xce = NULL;
     
    20241987                    stored_xce->ctime = XG(request_time);
    20251988                    stored_xce->ttl   = xce.ttl;
    2026 #ifdef DEBUG
    2027                     fprintf(stderr, "incdec: islong\n");
    2028 #endif
     1989                    TRACE("%s", "incdec: islong");
    20291990                    value = Z_LVAL_P(stored_var->value);
    20301991                    value += (inc == 1 ? count : - count);
     
    20361997                }
    20371998                else {
    2038 #ifdef DEBUG
    2039                     fprintf(stderr, "incdec: notlong\n");
    2040 #endif
     1999                    TRACE("%s", "incdec: notlong");
    20412000                    xc_processor_restore_zval(&oldzval, stored_xce->data.var->value, stored_xce->have_references TSRMLS_CC);
    20422001                    convert_to_long(&oldzval);
     
    20462005            }
    20472006        }
    2048 #ifdef DEBUG
    20492007        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        }
    20532010
    20542011        value += (inc == 1 ? count : - count);
     
    24952452
    24962453    zend_llist_prepend_element(&zend_extensions, &extension);
    2497 #ifdef DEBUG
    2498     fprintf(stderr, "registered\n");
    2499 #endif
     2454    TRACE("%s", "registered");
    25002455}
    25012456
Note: See TracChangeset for help on using the changeset viewer.