diff options
Diffstat (limited to 'gs/psi')
-rw-r--r-- | gs/psi/fapiufst.c | 2 | ||||
-rw-r--r-- | gs/psi/ialloc.c | 36 | ||||
-rw-r--r-- | gs/psi/iapi.c | 22 | ||||
-rw-r--r-- | gs/psi/idebug.c | 98 | ||||
-rw-r--r-- | gs/psi/idict.c | 41 | ||||
-rw-r--r-- | gs/psi/idisp.c | 2 | ||||
-rw-r--r-- | gs/psi/idstack.c | 10 | ||||
-rw-r--r-- | gs/psi/igc.c | 152 | ||||
-rw-r--r-- | gs/psi/igcref.c | 54 | ||||
-rw-r--r-- | gs/psi/igcstr.c | 41 | ||||
-rw-r--r-- | gs/psi/igcstr.h | 2 | ||||
-rw-r--r-- | gs/psi/ilocate.c | 46 | ||||
-rw-r--r-- | gs/psi/imain.c | 16 | ||||
-rw-r--r-- | gs/psi/imainarg.c | 12 | ||||
-rw-r--r-- | gs/psi/iname.c | 16 | ||||
-rw-r--r-- | gs/psi/interp.c | 16 | ||||
-rw-r--r-- | gs/psi/ireclaim.c | 4 | ||||
-rw-r--r-- | gs/psi/isave.c | 100 | ||||
-rw-r--r-- | gs/psi/iscan.c | 28 | ||||
-rw-r--r-- | gs/psi/zcie.c | 20 | ||||
-rw-r--r-- | gs/psi/zcolor.c | 40 | ||||
-rw-r--r-- | gs/psi/zcontext.c | 7 | ||||
-rw-r--r-- | gs/psi/zdscpars.c | 2 | ||||
-rw-r--r-- | gs/psi/zfapi.c | 10 | ||||
-rw-r--r-- | gs/psi/zfcid0.c | 4 | ||||
-rw-r--r-- | gs/psi/zfile.c | 2 | ||||
-rw-r--r-- | gs/psi/zfjbig2.c | 2 | ||||
-rw-r--r-- | gs/psi/zfjpx.c | 8 | ||||
-rw-r--r-- | gs/psi/zicc.c | 12 | ||||
-rw-r--r-- | gs/psi/zpcolor.c | 4 | ||||
-rw-r--r-- | gs/psi/zvmem.c | 10 |
31 files changed, 419 insertions, 400 deletions
diff --git a/gs/psi/fapiufst.c b/gs/psi/fapiufst.c index 2f81c47e6..eb14a9544 100644 --- a/gs/psi/fapiufst.c +++ b/gs/psi/fapiufst.c @@ -1760,7 +1760,7 @@ static void gs_fapiufst_finit(i_plugin_instance *this, i_plugin_client_memory *m FSA_FROM_SERVER; #if UFST_MEMORY_CHECKING - dprintf1("UFST used %Lf kb\n", ((long double)maxmem) / 1024); + dmprintf1(r->mem, "UFST used %Lf kb\n", ((long double)maxmem) / 1024); #endif if (r->If.ig.d != &ufst_descriptor) diff --git a/gs/psi/ialloc.c b/gs/psi/ialloc.c index 46c0e814e..c2332bd4e 100644 --- a/gs/psi/ialloc.c +++ b/gs/psi/ialloc.c @@ -171,9 +171,9 @@ gs_alloc_ref_array(gs_ref_memory_t * mem, ref * parr, uint attrs, ref *end; obj = (ref *) mem->cc.rtop - 1; /* back up over last ref */ - if_debug4('A', "[a%d:+$ ]%s(%u) = 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), - num_refs, (ulong) obj); + if_debug4m('A', (const gs_memory_t *)mem, "[a%d:+$ ]%s(%u) = 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), + num_refs, (ulong) obj); mem->cc.rcur[-1].o_size += num_refs * sizeof(ref); end = (ref *) (mem->cc.rtop = mem->cc.cbot += num_refs * sizeof(ref)); @@ -249,16 +249,16 @@ gs_resize_ref_array(gs_ref_memory_t * mem, ref * parr, ref *end = (ref *) (mem->cc.cbot = mem->cc.rtop -= diff * sizeof(ref)); - if_debug4('A', "[a%d:<$ ]%s(%u) 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), diff, - (ulong) obj); + if_debug4m('A', (const gs_memory_t *)mem, "[a%d:<$ ]%s(%u) 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), diff, + (ulong) obj); mem->cc.rcur[-1].o_size -= diff * sizeof(ref); make_mark(end - 1); } else { /* Punt. */ - if_debug4('A', "[a%d:<$#]%s(%u) 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), diff, - (ulong) obj); + if_debug4m('A', (const gs_memory_t *)mem, "[a%d:<$#]%s(%u) 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), diff, + (ulong) obj); mem->lost.refs += diff * sizeof(ref); } r_set_size(parr, new_num_refs); @@ -293,9 +293,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname) mem->cc.rtop = 0; } else { /* Deallocate it at the end of the refs object. */ - if_debug4('A', "[a%d:-$ ]%s(%u) 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), - num_refs, (ulong) obj); + if_debug4m('A', (const gs_memory_t *)mem, "[a%d:-$ ]%s(%u) 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), + num_refs, (ulong) obj); mem->cc.rcur[-1].o_size -= num_refs * sizeof(ref); mem->cc.rtop = mem->cc.cbot = (byte *) (obj + 1); make_mark(obj); @@ -314,9 +314,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname) (byte *) (obj + (num_refs + 1)) == cl.cp->cend ) { /* Free the chunk. */ - if_debug4('a', "[a%d:-$L]%s(%u) 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), - num_refs, (ulong) obj); + if_debug4m('a', (const gs_memory_t *)mem, "[a%d:-$L]%s(%u) 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), + num_refs, (ulong) obj); if ((gs_memory_t *)mem != mem->stable_memory) alloc_save_remove(mem, (ref_packed *)obj, "gs_free_ref_array"); alloc_free_chunk(cl.cp, mem); @@ -325,9 +325,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname) } /* Punt, but fill the array with nulls so that there won't be */ /* dangling references to confuse the garbage collector. */ - if_debug4('A', "[a%d:-$#]%s(%u) 0x%lx\n", - ialloc_trace_space(mem), client_name_string(cname), num_refs, - (ulong) obj); + if_debug4m('A', (const gs_memory_t *)mem, "[a%d:-$#]%s(%u) 0x%lx\n", + ialloc_trace_space(mem), client_name_string(cname), num_refs, + (ulong) obj); { uint size; diff --git a/gs/psi/iapi.c b/gs/psi/iapi.c index 2846aab45..2e9ac7cad 100644 --- a/gs/psi/iapi.c +++ b/gs/psi/iapi.c @@ -30,11 +30,13 @@ #include "gsmalloc.h" #include "gslibctx.h" -/* number of threads to allow per process - * currently more than 1 is guarenteed to fail +#ifndef GS_THREADSAFE +/* Number of threads to allow per process. Unless GS_THREADSAFE is defined + * more than 1 is guarenteed to fail. */ -//static int gsapi_instance_counter = 0; -//static const int gsapi_instance_max = 1; +static int gsapi_instance_counter = 0; +static const int gsapi_instance_max = 1; +#endif /* Return revision numbers and strings of Ghostscript. */ /* Used for determining if wrong GSDLL loaded. */ @@ -65,10 +67,12 @@ gsapi_new_instance(void **pinstance, void *caller_handle) if (pinstance == NULL) return e_Fatal; +#ifndef GS_THREADSAFE /* limited to 1 instance, till it works :) */ - //if ( gsapi_instance_counter >= gsapi_instance_max ) - // return e_Fatal; - //++gsapi_instance_counter; + if ( gsapi_instance_counter >= gsapi_instance_max ) + return e_Fatal; + ++gsapi_instance_counter; +#endif if (*pinstance == NULL) /* first instance in this process */ @@ -120,7 +124,9 @@ gsapi_delete_instance(void *lib) /* Release the memory (frees up everything) */ gs_malloc_release(minst->heap); - //--gsapi_instance_counter; +#ifndef GS_THREADSAFE + --gsapi_instance_counter; +#endif } } diff --git a/gs/psi/idebug.c b/gs/psi/idebug.c index 660cc3d8b..7c5984d64 100644 --- a/gs/psi/idebug.c +++ b/gs/psi/idebug.c @@ -45,7 +45,7 @@ debug_print_name(const gs_memory_t *mem, const ref * pnref) ref sref; name_string_ref(mem, pnref, &sref); - debug_print_string(sref.value.const_bytes, r_size(&sref)); + debug_print_string(mem, sref.value.const_bytes, r_size(&sref)); } void debug_print_name_index(const gs_memory_t *mem, name_index_t nidx) @@ -63,49 +63,49 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref) uint size = r_size(pref); ref nref; - dprintf1("(%x)", r_type_attrs(pref)); + dmprintf1(mem, "(%x)", r_type_attrs(pref)); switch (r_type(pref)) { case t_array: - dprintf2("array(%u)0x%lx", size, (ulong) pref->value.refs); + dmprintf2(mem, "array(%u)0x%lx", size, (ulong) pref->value.refs); break; case t_astruct: goto strct; case t_boolean: - dprintf1("boolean %x", pref->value.boolval); + dmprintf1(mem, "boolean %x", pref->value.boolval); break; case t_device: - dprintf1("device 0x%lx", (ulong) pref->value.pdevice); + dmprintf1(mem, "device 0x%lx", (ulong) pref->value.pdevice); break; case t_dictionary: - dprintf3("dict(%u/%u)0x%lx", + dmprintf3(mem, "dict(%u/%u)0x%lx", dict_length(pref), dict_maxlength(pref), (ulong) pref->value.pdict); break; case t_file: - dprintf1("file 0x%lx", (ulong) pref->value.pfile); + dmprintf1(mem, "file 0x%lx", (ulong) pref->value.pfile); break; case t_fontID: goto strct; case t_integer: - dprintf1("int %d", pref->value.intval); + dmprintf1(mem, "int %d", pref->value.intval); break; case t_mark: - dprintf("mark"); + dmprintf(mem, "mark"); break; case t_mixedarray: - dprintf2("mixed packedarray(%u)0x%lx", size, + dmprintf2(mem, "mixed packedarray(%u)0x%lx", size, (ulong) pref->value.packed); break; case t_name: - dprintf2("name(0x%lx#%u)", (ulong) pref->value.pname, + dmprintf2(mem, "name(0x%lx#%u)", (ulong) pref->value.pname, name_index(mem, pref)); debug_print_name(mem, pref); break; case t_null: - dprintf("null"); + dmprintf(mem, "null"); break; case t_oparray: - dprintf2("op_array(%u)0x%lx:", size, (ulong) pref->value.const_refs); + dmprintf2(mem, "op_array(%u)0x%lx:", size, (ulong) pref->value.const_refs); { const op_array_table *opt = get_op_array(mem, size); @@ -114,23 +114,23 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref) debug_print_name(mem, &nref); break; case t_operator: - dprintf1("op(%u", size); + dmprintf1(mem, "op(%u", size); if (size > 0 && size < op_def_count) /* just in case */ - dprintf1(":%s", (const char *)(op_index_def(size)->oname + 1)); - dprintf1(")0x%lx", (ulong) pref->value.opproc); + dmprintf1(mem, ":%s", (const char *)(op_index_def(size)->oname + 1)); + dmprintf1(mem, ")0x%lx", (ulong) pref->value.opproc); break; case t_real: - dprintf1("real %f", pref->value.realval); + dmprintf1(mem, "real %f", pref->value.realval); break; case t_save: - dprintf1("save %lu", pref->value.saveid); + dmprintf1(mem, "save %lu", pref->value.saveid); break; case t_shortarray: - dprintf2("short packedarray(%u)0x%lx", size, + dmprintf2(mem, "short packedarray(%u)0x%lx", size, (ulong) pref->value.packed); break; case t_string: - dprintf2("string(%u)0x%lx", size, (ulong) pref->value.bytes); + dmprintf2(mem, "string(%u)0x%lx", size, (ulong) pref->value.bytes); break; case t_struct: strct:{ @@ -139,14 +139,14 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref) gs_memory_type_ptr_t otype = gs_ref_memory_procs.object_type(NULL, obj); - dprintf2("struct %s 0x%lx", + dmprintf2(mem, "struct %s 0x%lx", (r_is_foreign(pref) ? "-foreign-" : gs_struct_type_name_string(otype)), (ulong) obj); } break; default: - dprintf1("type 0x%x", r_type(pref)); + dmprintf1(mem, "type 0x%x", r_type(pref)); } } static void @@ -157,24 +157,24 @@ debug_print_packed_ref(const gs_memory_t *mem, const ref_packed *pref) switch (*pref >> r_packed_type_shift) { case pt_executable_operator: - dprintf("<op_name>"); + dmprintf(mem, "<op_name>"); op_index_ref(mem, elt, &nref); debug_print_ref(mem, &nref); break; case pt_integer: - dprintf1("<int> %d", (int)elt + packed_min_intval); + dmprintf1(mem, "<int> %d", (int)elt + packed_min_intval); break; case pt_literal_name: - dprintf("<lit_name>"); + dmprintf(mem, "<lit_name>"); goto ptn; case pt_executable_name: - dprintf("<exec_name>"); + dmprintf(mem, "<exec_name>"); ptn: name_index_ref(mem, elt, &nref); - dprintf2("(0x%lx#%u)", (ulong) nref.value.pname, elt); + dmprintf2(mem, "(0x%lx#%u)", (ulong) nref.value.pname, elt); debug_print_name(mem, &nref); break; default: - dprintf2("<packed_%d?>0x%x", *pref >> r_packed_type_shift, elt); + dmprintf2(mem, "<packed_%d?>0x%x", *pref >> r_packed_type_shift, elt); } } void @@ -184,7 +184,7 @@ debug_print_ref_packed(const gs_memory_t *mem, const ref_packed *rpp) debug_print_packed_ref(mem, rpp); else debug_print_full_ref(mem, (const ref *)rpp); - dflush(); + dmflush(mem); } void debug_print_ref(const gs_memory_t *mem, const ref * pref) @@ -206,17 +206,17 @@ debug_dump_one_ref(const gs_memory_t *mem, const ref * p) const ref_attr_print_mask_t *ap = apm; if (type >= tx_next_index) - dprintf1("0x%02x?? ", type); + dmprintf1(mem, "0x%02x?? ", type); else if (type >= t_next_index) - dprintf("opr* "); + dmprintf(mem, "opr* "); else - dprintf1("%s ", type_strings[type]); + dmprintf1(mem, "%s ", type_strings[type]); for (; ap->mask; ++ap) if ((attrs & ap->mask) == ap->value) - dputc(ap->print); - dprintf2(" 0x%04x 0x%08lx", r_size(p), *(const ulong *)&p->value); + dmputc(mem, ap->print); + dmprintf2(mem, " 0x%04x 0x%08lx", r_size(p), *(const ulong *)&p->value); print_ref_data(mem, p); - dflush(); + dmflush(mem); } static void print_ref_data(const gs_memory_t *mem, const ref *p) @@ -230,7 +230,7 @@ print_ref_data(const gs_memory_t *mem, const ref *p) pchars == buf && ((buf[plen] = 0), strcmp((char *)buf, "--nostringval--")) ) - dprintf1(" = %s", (char *)buf); + dmprintf1(mem, " = %s", (char *)buf); #undef BUF_SIZE } @@ -243,11 +243,11 @@ debug_dump_refs(const gs_memory_t *mem, const ref * from, uint count = size; if (size && msg) - dprintf2("%s at 0x%lx:\n", msg, (ulong) from); + dmprintf2(mem, "%s at 0x%lx:\n", msg, (ulong) from); while (count--) { - dprintf2("0x%lx: 0x%04x ", (ulong)p, r_type_attrs(p)); + dmprintf2(mem, "0x%lx: 0x%04x ", (ulong)p, r_type_attrs(p)); debug_dump_one_ref(mem, p); - dputc('\n'); + dmputc(mem, '\n'); p++; } } @@ -264,12 +264,12 @@ debug_dump_stack(const gs_memory_t *mem, const ref *p = ref_stack_index(pstack, --i); if (m) { - dprintf2("%s at 0x%lx:\n", m, (ulong) pstack); + dmprintf2(mem, "%s at 0x%lx:\n", m, (ulong) pstack); m = NULL; } - dprintf2("0x%lx: 0x%02x ", (ulong)p, r_type(p)); + dmprintf2(mem, "0x%lx: 0x%02x ", (ulong)p, r_type(p)); debug_dump_one_ref(mem, p); - dputc('\n'); + dmputc(mem, '\n'); } } @@ -283,10 +283,10 @@ debug_dump_array(const gs_memory_t *mem, const ref * array) switch (type) { default: - dprintf2("%s at 0x%lx isn't an array.\n", - (type < countof(type_strings) ? - type_strings[type] : "????"), - (ulong) array); + dmprintf2(mem, "%s at 0x%lx isn't an array.\n", + (type < countof(type_strings) ? + type_strings[type] : "????"), + (ulong) array); return; case t_oparray: /* This isn't really an array, but we'd like to see */ @@ -307,12 +307,12 @@ debug_dump_array(const gs_memory_t *mem, const ref * array) packed_get(mem, pp, &temp); if (r_is_packed(pp)) { - dprintf2("0x%lx* 0x%04x ", (ulong)pp, (uint)*pp); + dmprintf2(mem, "0x%lx* 0x%04x ", (ulong)pp, (uint)*pp); print_ref_data(mem, &temp); } else { - dprintf2("0x%lx: 0x%02x ", (ulong)pp, r_type(&temp)); + dmprintf2(mem, "0x%lx: 0x%02x ", (ulong)pp, r_type(&temp)); debug_dump_one_ref(mem, &temp); } - dputc('\n'); + dmputc(mem, '\n'); } } diff --git a/gs/psi/idict.c b/gs/psi/idict.c index 4d4084d5f..3e4891dc4 100644 --- a/gs/psi/idict.c +++ b/gs/psi/idict.c @@ -105,10 +105,12 @@ dict_find(const ref * pdref, const ref * pkey, ref ** ppvalue) ) stats_dict.probe2++; } +#ifndef GS_THREADSAFE /* Do the cheap flag test before the expensive remainder test. */ if (gs_debug_c('d') && !(stats_dict.lookups % 1000)) dlprintf3("[d]lookups=%ld probe1=%ld probe2=%ld\n", stats_dict.lookups, stats_dict.probe1, stats_dict.probe2); +#endif return code; } #define dict_find real_dict_find @@ -502,8 +504,8 @@ dict_put(ref * pdref /* t_dictionary */ , const ref * pkey, const ref * pvalue, } else { ref *kp = pdict->keys.value.refs + index; - if_debug2('d', "[d]0x%lx: fill key at 0x%lx\n", - (ulong) pdict, (ulong) kp); + if_debug2m('d', (const gs_memory_t *)mem, "[d]0x%lx: fill key at 0x%lx\n", + (ulong) pdict, (ulong) kp); store_check_dest(pdref, pkey); ref_assign_old_in(mem, &pdict->keys, kp, pkey, "dict_put(key)"); /* set key of pair */ @@ -517,21 +519,22 @@ dict_put(ref * pdref /* t_dictionary */ , const ref * pkey, const ref * pvalue, if (pname->pvalue == pv_no_defn && CAN_SET_PVALUE_CACHE(pds, pdref, mem) ) { /* Set the cache. */ - if_debug0('d', "[d]set cache\n"); + if_debug0m('d', (const gs_memory_t *)mem, "[d]set cache\n"); pname->pvalue = pvslot; } else { /* The cache can't be used. */ - if_debug0('d', "[d]no cache\n"); + if_debug0m('d', (const gs_memory_t *)mem, "[d]no cache\n"); pname->pvalue = pv_other; } } rcode = 1; } - if_debug8('d', "[d]0x%lx: put key 0x%lx 0x%lx\n value at 0x%lx: old 0x%lx 0x%lx, new 0x%lx 0x%lx\n", - (ulong) pdref->value.pdict, - ((const ulong *)pkey)[0], ((const ulong *)pkey)[1], - (ulong) pvslot, - ((const ulong *)pvslot)[0], ((const ulong *)pvslot)[1], - ((const ulong *)pvalue)[0], ((const ulong *)pvalue)[1]); + if_debug8m('d', (const gs_memory_t *)mem, + "[d]0x%lx: put key 0x%lx 0x%lx\n value at 0x%lx: old 0x%lx 0x%lx, new 0x%lx 0x%lx\n", + (ulong) pdref->value.pdict, + ((const ulong *)pkey)[0], ((const ulong *)pkey)[1], + (ulong) pvslot, + ((const ulong *)pvslot)[0], ((const ulong *)pvslot)[1], + ((const ulong *)pvalue)[0], ((const ulong *)pvalue)[1]); ref_assign_old_in(mem, &pdref->value.pdict->values, pvslot, pvalue, "dict_put(value)"); return rcode; @@ -581,8 +584,9 @@ dict_undef(ref * pdref, const ref * pkey, dict_stack_t *pds) ref_packed *pkp = pdict->keys.value.writable_packed + index; bool must_save = ref_must_save_in(mem, &pdict->keys); - if_debug3('d', "[d]0x%lx: removing key at 0%lx: 0x%x\n", - (ulong)pdict, (ulong)pkp, (uint)*pkp); + if_debug3m('d', (const gs_memory_t *)mem, + "[d]0x%lx: removing key at 0%lx: 0x%x\n", + (ulong)pdict, (ulong)pkp, (uint)*pkp); /* See the initial comment for why it is safe not to save */ /* the change if the keys array itself is new. */ if (must_save) @@ -615,8 +619,9 @@ dict_undef(ref * pdref, const ref * pkey, dict_stack_t *pds) } else { /* not packed */ ref *kp = pdict->keys.value.refs + index; - if_debug4('d', "[d]0x%lx: removing key at 0%lx: 0x%lx 0x%lx\n", - (ulong)pdict, (ulong)kp, ((ulong *)kp)[0], ((ulong *)kp)[1]); + if_debug4m('d', (const gs_memory_t *)mem, + "[d]0x%lx: removing key at 0%lx: 0x%lx 0x%lx\n", + (ulong)pdict, (ulong)kp, ((ulong *)kp)[0], ((ulong *)kp)[1]); make_null_old_in(mem, &pdict->keys, kp, "dict_undef(key)"); /* * Accumulating deleted entries slows down lookup. @@ -866,10 +871,10 @@ dict_next(const ref * pdref, int index, ref * eltp /* ref eltp[2] */ ) (!dict_is_packed(pdict) && !r_has_type(eltp, t_null)) ) { eltp[1] = *vp; - if_debug6('d', "[d]0x%lx: index %d: %lx %lx, %lx %lx\n", - (ulong) pdict, index, - ((ulong *) eltp)[0], ((ulong *) eltp)[1], - ((ulong *) vp)[0], ((ulong *) vp)[1]); + if_debug6m('d', dict_mem(pdict), "[d]0x%lx: index %d: %lx %lx, %lx %lx\n", + (ulong) pdict, index, + ((ulong *) eltp)[0], ((ulong *) eltp)[1], + ((ulong *) vp)[0], ((ulong *) vp)[1]); return index; } } diff --git a/gs/psi/idisp.c b/gs/psi/idisp.c index 2be51d00e..6a0157f8b 100644 --- a/gs/psi/idisp.c +++ b/gs/psi/idisp.c @@ -96,7 +96,7 @@ display_set_callback(gs_main_instance *minst, display_callback *callback) if (was_open) { code = gs_opendevice(dev); if (code < 0) { - dprintf("**** Unable to open the display device, quitting.\n"); + dmprintf(dev->memory, "**** Unable to open the display device, quitting.\n"); return_error(code); } } diff --git a/gs/psi/idstack.c b/gs/psi/idstack.c index ad41ad26e..0c042de9c 100644 --- a/gs/psi/idstack.c +++ b/gs/psi/idstack.c @@ -66,10 +66,12 @@ dstack_find_name_by_index(dict_stack_t * pds, uint nidx) ) INCR(probes[1]); } +#ifndef GS_THREADSAFE if (gs_debug_c('d') && !(stats_dstack.lookups % 1000)) dlprintf3("[d]lookups=%ld probe1=%ld probe2=%ld\n", stats_dstack.lookups, stats_dstack.probes[0], stats_dstack.probes[1]); +#endif return pvalue; } #define dstack_find_name_by_index real_dstack_find_name_by_index @@ -119,11 +121,11 @@ dstack_find_name_by_index(dict_stack_t * pds, uint nidx) ref dnref; name_index_ref(mem, nidx, &dnref); - dlputs("[D]lookup "); + dmlputs(mem, "[D]lookup "); debug_print_name(mem, &dnref); - dprintf3(" in 0x%lx(%u/%u)\n", - (ulong) pdict, dict_length(pdref), - dict_maxlength(pdref)); + dmprintf3(mem," in 0x%lx(%u/%u)\n", + (ulong) pdict, dict_length(pdref), + dict_maxlength(pdref)); } #endif #define INCR_DEPTH(pdref)\ diff --git a/gs/psi/igc.c b/gs/psi/igc.c index b6aa02327..f8ffc642f 100644 --- a/gs/psi/igc.c +++ b/gs/psi/igc.c @@ -121,12 +121,12 @@ const gs_ptr_procs_t ptr_name_index_procs = /* Top level of garbage collector. */ #ifdef DEBUG static void -end_phase(const char *str) +end_phase(const gs_memory_t *mem, const char *str) { if (gs_debug_c('6')) { - dlprintf1("[6]---------------- end %s ----------------\n", - (const char *)str); - dflush(); + dmlprintf1(mem, "[6]---------------- end %s ----------------\n", + (const char *)str); + dmflush(mem); } } static const char *const depth_dots_string = ".........."; @@ -151,7 +151,7 @@ gc_validate_spaces(gs_ref_memory_t **spaces, int max_space, gc_state_t *gcst) ialloc_validate_memory(mem, gcst); } #else /* !DEBUG */ -# define end_phase(str) DO_NOTHING +# define end_phase(mem,str) DO_NOTHING #endif /* DEBUG */ void @@ -243,7 +243,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) (void **)&space_memories[ispace], "gc_top_level"); - end_phase("register space roots"); + end_phase(state.heap,"register space roots"); #ifdef DEBUG @@ -251,7 +251,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) gc_validate_spaces(space_memories, max_trace, &state); - end_phase("pre-validate pointers"); + end_phase(state.heap,"pre-validate pointers"); #endif @@ -267,7 +267,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) gc_strings_set_marks(cp, false); } - end_phase("clear chunk marks"); + end_phase(state.heap,"clear chunk marks"); /* Clear the marks of roots. We must do this explicitly, */ /* since some roots are not in any chunk. */ @@ -276,11 +276,11 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) enum_ptr_t eptr; eptr.ptr = *rp->p; - if_debug_root('6', "[6]unmarking root", rp); + if_debug_root('6', (const gs_memory_t *)mem, "[6]unmarking root", rp); (*rp->ptype->unmark)(&eptr, &state); } - end_phase("clear root marks"); + end_phase(state.heap,"clear root marks"); if (global) { op_array_table *global_ops = get_global_op_array(cmem); @@ -314,8 +314,9 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) end->next = pms; pms->prev = end; pms->on_heap = false; - if_debug2('6', "[6]adding free 0x%lx(%u) to mark stack\n", - (ulong) pms, pms->count); + if_debug2m('6', (const gs_memory_t *)mem, + "[6]adding free 0x%lx(%u) to mark stack\n", + (ulong) pms, pms->count); } cp->rescan_bot = cp->cend; cp->rescan_top = cp->cbase; @@ -330,11 +331,11 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) /* Mark from roots. */ for_roots(max_trace, mem, rp) { - if_debug_root('6', "[6]marking root", rp); + if_debug_root('6', (const gs_memory_t *)mem, "[6]marking root", rp); more |= gc_trace(rp, &state, mark_stack); } - end_phase("mark"); + end_phase(state.heap,"mark"); /* If this is a local GC, mark from non-local chunks. */ @@ -350,7 +351,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) more |= gc_rescan_chunk(cp, &state, mark_stack); } - end_phase("mark overflow"); + end_phase(state.heap,"mark overflow"); } /* Free the mark stack. */ @@ -372,13 +373,13 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) } } - end_phase("free mark stack"); + end_phase(state.heap,"free mark stack"); if (global) { gc_trace_finish(&state); names_trace_finish(state.ntable, &state); - end_phase("finish trace"); + end_phase(state.heap,"finish trace"); } /* Filter save change lists with removing elements, @@ -399,12 +400,12 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) for_chunks(min_collect - 1, mem, cp) gc_objects_clear_marks((const gs_memory_t *)mem, cp); - end_phase("post-clear marks"); + end_phase(state.heap,"post-clear marks"); for_chunks(min_collect - 1, mem, cp) gc_clear_reloc(cp); - end_phase("clear reloc"); + end_phase(state.heap,"clear reloc"); /* Set the relocation of roots outside any chunk to o_untraced, */ /* so we won't try to relocate pointers to them. */ @@ -436,7 +437,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) gs_enable_free((gs_memory_t *)space_memories[i], true); } - end_phase("set reloc"); + end_phase(state.heap,"set reloc"); /* Relocate pointers. */ @@ -447,11 +448,12 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) for_collected_chunks(mem, cp) gc_do_reloc(cp, mem, &state); - end_phase("relocate chunks"); + end_phase(state.heap,"relocate chunks"); for_roots(max_trace, mem, rp) { - if_debug3('6', "[6]relocating root 0x%lx: 0x%lx -> 0x%lx\n", - (ulong) rp, (ulong) rp->p, (ulong) * rp->p); + if_debug3m('6', (const gs_memory_t *)mem, + "[6]relocating root 0x%lx: 0x%lx -> 0x%lx\n", + (ulong) rp, (ulong) rp->p, (ulong) * rp->p); if (rp->ptype == ptr_ref_type) { ref *pref = (ref *) * rp->p; @@ -460,21 +462,22 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) &state); } else *rp->p = (*rp->ptype->reloc) (*rp->p, &state); - if_debug3('6', "[6]relocated root 0x%lx: 0x%lx -> 0x%lx\n", - (ulong) rp, (ulong) rp->p, (ulong) * rp->p); + if_debug3m('6', (const gs_memory_t *)mem, + "[6]relocated root 0x%lx: 0x%lx -> 0x%lx\n", + (ulong) rp, (ulong) rp->p, (ulong) * rp->p); } - end_phase("relocate roots"); + end_phase(state.heap,"relocate roots"); /* Compact data. We only do this for spaces we are collecting. */ for_collected_spaces(ispace) { for_space_mems(ispace, mem) { for_mem_chunks(mem, cp) { - if_debug_chunk('6', "[6]compacting chunk", cp); + if_debug_chunk('6', (const gs_memory_t *)mem, "[6]compacting chunk", cp); gc_objects_compact(cp, &state); - gc_strings_compact(cp); - if_debug_chunk('6', "[6]after compaction:", cp); + gc_strings_compact(cp, cmem); + if_debug_chunk('6', (const gs_memory_t *)mem, "[6]after compaction:", cp); if (mem->pcc == cp) mem->cc = *cp; } @@ -483,7 +486,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) } } - end_phase("compact"); + end_phase(state.heap,"compact"); /* Free empty chunks. */ @@ -493,7 +496,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) } } - end_phase("free empty chunks"); + end_phase(state.heap,"free empty chunks"); /* * Update previous_status to reflect any freed chunks, @@ -525,20 +528,21 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) next = mem->saved; mem->saved = prev; mem->previous_status = total; - if_debug3('6', - "[6]0x%lx previous allocated=%lu, used=%lu\n", - (ulong) mem, total.allocated, total.used); + if_debug3m('6', (const gs_memory_t *)mem, + "[6]0x%lx previous allocated=%lu, used=%lu\n", + (ulong) mem, total.allocated, total.used); gs_memory_status((gs_memory_t *) mem, &total); mem->gc_allocated = mem->allocated + total.allocated; } mem = space_memories[ispace]; mem->previous_status = total; mem->gc_allocated = mem->allocated + total.allocated; - if_debug3('6', "[6]0x%lx previous allocated=%lu, used=%lu\n", - (ulong) mem, total.allocated, total.used); + if_debug3m('6', (const gs_memory_t *)mem, + "[6]0x%lx previous allocated=%lu, used=%lu\n", + (ulong) mem, total.allocated, total.used); } - end_phase("update stats"); + end_phase(state.heap,"update stats"); no_collect: @@ -548,7 +552,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) gs_unregister_root((gs_memory_t *)space_memories[ispace], &space_roots[ispace], "gc_top_level"); - end_phase("unregister space roots"); + end_phase(state.heap,"unregister space roots"); #ifdef DEBUG @@ -556,7 +560,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global) gc_validate_spaces(space_memories, max_trace, &state); - end_phase("validate pointers"); + end_phase(state.heap,"validate pointers"); #endif } @@ -601,7 +605,7 @@ ptr_name_index_unmark(enum_ptr_t *pep, gc_state_t * gcst) static void gc_objects_clear_marks(const gs_memory_t *mem, chunk_t * cp) { - if_debug_chunk('6', "[6]unmarking chunk", cp); + if_debug_chunk('6', mem, "[6]unmarking chunk", cp); SCAN_CHUNK_OBJECTS(cp) DO_ALL struct_proc_clear_marks((*proc)) = @@ -610,9 +614,9 @@ gc_objects_clear_marks(const gs_memory_t *mem, chunk_t * cp) if (pre->o_type != &st_free) debug_check_object(pre, cp, NULL); #endif - if_debug3('7', " [7](un)marking %s(%lu) 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) size, (ulong) pre); + if_debug3m('7', (const gs_memory_t *)mem, " [7](un)marking %s(%lu) 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) size, (ulong) pre); o_set_unmarked(pre); if (proc != 0) (*proc) (mem, pre + 1, size, pre->o_type); @@ -668,7 +672,7 @@ gc_rescan_chunk(chunk_t * cp, gc_state_t * pstate, gc_mark_stack * pmstack) if (sbot > stop) return 0; root.p = ∁ - if_debug_chunk('6', "[6]rescanning chunk", cp); + if_debug_chunk('6', mem, "[6]rescanning chunk", cp); cp->rescan_bot = cp->cend; cp->rescan_top = cp->cbase; SCAN_CHUNK_OBJECTS(cp) @@ -677,8 +681,8 @@ gc_rescan_chunk(chunk_t * cp, gc_state_t * pstate, gc_mark_stack * pmstack) else if ((byte *) (pre + 1) > stop) return more; /* 'break' won't work here */ else { - if_debug2('7', " [7]scanning/marking 0x%lx(%lu)\n", - (ulong) pre, (ulong) size); + if_debug2m('7', mem, " [7]scanning/marking 0x%lx(%lu)\n", + (ulong) pre, (ulong) size); if (pre->o_type == &st_refs) { ref_packed *rp = (ref_packed *) (pre + 1); char *end = (char *)rp + size; @@ -731,12 +735,12 @@ gc_trace_chunk(const gs_memory_t *mem, chunk_t * cp, gc_state_t * pstate, gc_mar int min_trace = pstate->min_collect; root.p = ∁ - if_debug_chunk('6', "[6]marking from chunk", cp); + if_debug_chunk('6', mem, "[6]marking from chunk", cp); SCAN_CHUNK_OBJECTS(cp) DO_ALL { - if_debug2('7', " [7]scanning/marking 0x%lx(%lu)\n", - (ulong) pre, (ulong) size); + if_debug2m('7', mem, " [7]scanning/marking 0x%lx(%lu)\n", + (ulong) pre, (ulong) size); if (pre->o_type == &st_refs) { ref_packed *rp = (ref_packed *) (pre + 1); char *end = (char *)rp + size; @@ -799,7 +803,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack) BEGIN\ if (names_mark_index(nt, nidx)) {\ new |= 1;\ - if_debug2('8', " [8]marked name 0x%lx(%u)\n",\ + if_debug2m('8', gcst_get_memory_ptr(pstate), " [8]marked name 0x%lx(%u)\n",\ (ulong)names_index_ptr(nt, nidx), nidx);\ }\ END @@ -845,17 +849,17 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack) continue; } debug_check_object(ptr - 1, NULL, NULL); - ts:if_debug4('7', " [7]%smarking %s 0x%lx[%u]", - depth_dots(sp, pms), - struct_type_name_string(ptr[-1].o_type), - (ulong) ptr, sp->index); + ts:if_debug4m('7', pstate->heap, " [7]%smarking %s 0x%lx[%u]", + depth_dots(sp, pms), + struct_type_name_string(ptr[-1].o_type), + (ulong) ptr, sp->index); mproc = ptr[-1].o_type->enum_ptrs; if (mproc == gs_no_struct_enum_ptrs || (ptp = (*mproc) (gcst_get_memory_ptr(pstate), ptr, pre_obj_contents_size(ptr - 1), sp->index, &nep, ptr[-1].o_type, pstate)) == 0 ) { - if_debug0('7', " - done\n"); + if_debug0m('7', pstate->heap, " - done\n"); sp--; continue; } @@ -864,7 +868,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack) /* template for pointer enumeration work. */ nptr = (void *)nep.ptr; sp->index++; - if_debug1('7', " = 0x%lx\n", (ulong) nptr); + if_debug1m('7', pstate->heap, " = 0x%lx\n", (ulong) nptr); /* Descend into nep.ptr, whose pointer type is ptp. */ if (ptp == ptr_struct_type) { sp[1].index = 0; @@ -904,7 +908,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack) continue; } --(sp->index); - if_debug3('8', " [8]%smarking refs 0x%lx[%u]\n", + if_debug3m('8', pstate->heap, " [8]%smarking refs 0x%lx[%u]\n", depth_dots(sp, pms), (ulong) pptr, sp->index); if (r_is_packed(pptr)) { if (!r_has_pmark(pptr)) { @@ -1175,7 +1179,7 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp) chunk_head_t *chead = cp->chead; byte *pfree = (byte *) & chead->free; /* most recent free object */ - if_debug_chunk('6', "[6]setting reloc for chunk", cp); + if_debug_chunk('6', gcst->heap, "[6]setting reloc for chunk", cp); gc_init_reloc(cp); SCAN_CHUNK_OBJECTS(cp) DO_ALL @@ -1188,16 +1192,16 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp) ) { /* Free object */ reloc += sizeof(obj_header_t) + obj_align_round(size); if ((finalize = pre->o_type->finalize) != 0) { - if_debug2('u', "[u]GC finalizing %s 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) (pre + 1)); + if_debug2m('u', gcst->heap, "[u]GC finalizing %s 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) (pre + 1)); (*finalize) (gcst->cur_mem, pre + 1); } pfree = (byte *) pre; pre->o_back = (pfree - (byte *) chead) >> obj_back_shift; pre->o_nreloc = reloc; - if_debug3('7', " [7]at 0x%lx, unmarked %lu, new reloc = %u\n", - (ulong) pre, (ulong) size, reloc); + if_debug3m('7', gcst->heap, " [7]at 0x%lx, unmarked %lu, new reloc = %u\n", + (ulong) pre, (ulong) size, reloc); } else { /* Useful object */ debug_check_object(pre, cp, gcst); pre->o_back = ((byte *) pre - pfree) >> obj_back_shift; @@ -1205,8 +1209,8 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp) END_OBJECTS_SCAN #ifdef DEBUG if (reloc != 0) { - if_debug1('6', "[6]freed %u", reloc); - if_debug_chunk('6', " in", cp); + if_debug1m('6', gcst->heap, "[6]freed %u", reloc); + if_debug_chunk('6', gcst->heap, " in", cp); } #endif } @@ -1219,7 +1223,7 @@ gc_do_reloc(chunk_t * cp, gs_ref_memory_t * mem, gc_state_t * pstate) { chunk_head_t *chead = cp->chead; - if_debug_chunk('6', "[6]relocating in chunk", cp); + if_debug_chunk('6', (const gs_memory_t *)mem, "[6]relocating in chunk", cp); SCAN_CHUNK_OBJECTS(cp) DO_ALL #ifdef DEBUG @@ -1235,10 +1239,10 @@ gc_do_reloc(chunk_t * cp, gs_ref_memory_t * mem, gc_state_t * pstate) struct_proc_reloc_ptrs((*proc)) = pre->o_type->reloc_ptrs; - if_debug3('7', - " [7]relocating ptrs in %s(%lu) 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) size, (ulong) pre); + if_debug3m('7', (const gs_memory_t *)mem, + " [7]relocating ptrs in %s(%lu) 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) size, (ulong) pre); if (proc != 0) (*proc) (pre + 1, size, pre->o_type, pstate); } @@ -1334,10 +1338,10 @@ gc_objects_compact(chunk_t * cp, gc_state_t * gcst) const struct_shared_procs_t *procs = pre->o_type->shared; debug_check_object(pre, cp, gcst); - if_debug4('7', - " [7]compacting %s 0x%lx(%lu) to 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) pre, (ulong) size, (ulong) dpre); + if_debug4m('7', cmem, + " [7]compacting %s 0x%lx(%lu) to 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) pre, (ulong) size, (ulong) dpre); if (procs == 0) { if (dpre != pre) memmove(dpre, pre, diff --git a/gs/psi/igcref.c b/gs/psi/igcref.c index 9bff137c4..e22123442 100644 --- a/gs/psi/igcref.c +++ b/gs/psi/igcref.c @@ -28,9 +28,9 @@ /* Define whether to trace every step of relocating ref pointers. */ #if 0 -# define rputc(c) dputc(c) +# define rputc(m,c) dmputc(m,c) #else -# define rputc(c) DO_NOTHING +# define rputc(m,c) DO_NOTHING #endif /* Forward references */ @@ -118,9 +118,9 @@ refs_clear_marks(const gs_memory_t *cmem, if (r_is_packed(rp)) { #ifdef DEBUG if (gs_debug_c('8')) { - dlprintf1(" [8]unmark packed 0x%lx ", (ulong) rp); + dmlprintf1(cmem, " [8]unmark packed 0x%lx ", (ulong) rp); debug_print_ref(cmem, (const ref *)rp); - dputs("\n"); + dmputs(cmem, "\n"); } #endif r_clear_pmark(rp); @@ -130,9 +130,9 @@ refs_clear_marks(const gs_memory_t *cmem, #ifdef DEBUG if (gs_debug_c('8')) { - dlprintf1(" [8]unmark ref 0x%lx ", (ulong) rp); + dmlprintf1(cmem, " [8]unmark ref 0x%lx ", (ulong) rp); debug_print_ref(cmem, pref); - dputs("\n"); + dmputs(cmem, "\n"); } #endif r_clear_attrs(pref, l_mark); @@ -413,9 +413,9 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) /* The following assignment is logically unnecessary; */ /* we do it only for convenience in debugging. */ pref = (ref *) rp; - if_debug3('8', " [8]relocating %s %d ref at 0x%lx\n", - (r_has_attr(pref, l_mark) ? "marked" : "unmarked"), - r_btype(pref), (ulong) pref); + if_debug3m('8', gcst->heap, " [8]relocating %s %d ref at 0x%lx\n", + (r_has_attr(pref, l_mark) ? "marked" : "unmarked"), + r_btype(pref), (ulong) pref); if ((r_has_attr(pref, l_mark) || do_all) && r_space(pref) >= min_trace ) { @@ -436,7 +436,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) break; /* Non-trivial non-struct cases */ case t_dictionary: - rputc('d'); + rputc(gcst->heap, 'd'); SET_RELOC(pref->value.pdict, (dict *)igc_reloc_ref_ptr((ref_packed *)pref->value.pdict, gcst)); break; @@ -456,12 +456,12 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) * just after it. */ if (size < max_size_st_refs / sizeof(ref)) { - rputc('a'); + rputc(gcst->heap, 'a'); SET_RELOC(pref->value.refs, (ref *) igc_reloc_ref_ptr( (ref_packed *) pref->value.refs, gcst)); } else { - rputc('A'); + rputc(gcst->heap, 'A'); /* * See the t_shortarray case below for why we * decrement size. @@ -477,7 +477,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) break; case t_mixedarray: if (r_size(pref) != 0) { /* value.refs might be NULL */ - rputc('m'); + rputc(gcst->heap, 'm'); SET_RELOC(pref->value.packed, igc_reloc_ref_ptr(pref->value.packed, gcst)); } @@ -495,7 +495,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) * beginning. */ if (size != 0) { /* value.refs might be NULL */ - rputc('s'); + rputc(gcst->heap, 's'); /* * igc_reloc_ref_ptr has to be able to determine * whether the pointer points into a space that @@ -534,15 +534,15 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst) } break; case t_oparray: - rputc('o'); + rputc(gcst->heap, 'o'); SET_RELOC(pref->value.const_refs, (const ref *)igc_reloc_ref_ptr((const ref_packed *)pref->value.const_refs, gcst)); break; default: goto no_reloc; /* don't print trace message */ } - if_debug2('8', " [8]relocated 0x%lx => 0x%lx\n", - (ulong)before, (ulong)after); + if_debug2m('8', gcst->heap, " [8]relocated 0x%lx => 0x%lx\n", + (ulong)before, (ulong)after); } no_reloc: rp += packed_per_ref; @@ -577,11 +577,11 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst) * each such unmarked packed ref we pass over, * we have to decrement the final relocation. */ - rputc((*rp & lp_mark ? '1' : '0')); + rputc(gcst->heap, (*rp & lp_mark ? '1' : '0')); if (!(*rp & lp_mark)) { if (*rp != pt_tag(pt_integer) + packed_max_value) { /* This is a stored relocation value. */ - rputc('\n'); + rputc(gcst->heap, '\n'); rp = print_reloc(prp, "ref", (const ref_packed *) ((const char *)prp - @@ -601,7 +601,7 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst) } if (!ref_type_uses_size_or_null(r_type(RP_REF(rp)))) { /* reloc is in r_size */ - rputc('\n'); + rputc(gcst->heap, '\n'); rp = print_reloc(prp, "ref", (const ref_packed *) (r_size(RP_REF(rp)) == 0 ? prp : @@ -609,7 +609,7 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst) r_size(RP_REF(rp)) + dec))); break; } - rputc('u'); + rputc(gcst->heap, 'u'); rp += packed_per_ref; } /* Use a severely deprecated pun to remove the const property. */ @@ -688,7 +688,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui if (r_is_packed(src)) { if (!r_has_pmark(src)) break; - if_debug1('8', " [8]packed ref 0x%lx \"copied\"\n", + if_debug1m('8', mem, " [8]packed ref 0x%lx \"copied\"\n", (ulong) src); *src &= ~lp_mark; src++; @@ -697,7 +697,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui if (!r_has_attr(pref, l_mark)) break; - if_debug1('8', " [8]ref 0x%lx \"copied\"\n", (ulong) src); + if_debug1m('8', mem, " [8]ref 0x%lx \"copied\"\n", (ulong) src); r_clear_attrs(pref, l_mark); src += packed_per_ref; } @@ -707,7 +707,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui for (;;) { if (r_is_packed(src)) { if (r_has_pmark(src)) { - if_debug2('8', " [8]packed ref 0x%lx copied to 0x%lx\n", + if_debug2m('8', mem, " [8]packed ref 0x%lx copied to 0x%lx\n", (ulong) src, (ulong) dest); *dest++ = *src & ~lp_mark; } @@ -716,8 +716,8 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui if (r_has_attr((ref *) src, l_mark)) { ref rtemp; - if_debug2('8', " [8]ref 0x%lx copied to 0x%lx\n", - (ulong) src, (ulong) dest); + if_debug2m('8', mem, " [8]ref 0x%lx copied to 0x%lx\n", + (ulong) src, (ulong) dest); /* We can't just use ref_assign_inline, */ /* because the source and destination */ /* might overlap! */ @@ -738,7 +738,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui /* Check that the relocation came out OK. */ /* NOTE: this check only works within a single chunk. */ if ((byte *) src - (byte *) dest != r_size((ref *) src - 1) + sizeof(ref)) { - lprintf3("Reloc error for refs 0x%lx: reloc = %lu, stored = %u\n", + mlprintf3(mem, "Reloc error for refs 0x%lx: reloc = %lu, stored = %u\n", (ulong) dpre, (ulong) ((byte *) src - (byte *) dest), (uint) r_size((ref *) src - 1)); gs_abort(mem); diff --git a/gs/psi/igcstr.c b/gs/psi/igcstr.c index d2bb62ceb..28f6d89d7 100644 --- a/gs/psi/igcstr.c +++ b/gs/psi/igcstr.c @@ -21,6 +21,7 @@ #include "gsstruct.h" #include "iastate.h" #include "igcstr.h" +#include "igc.h" /* Forward references */ static bool gc_mark_string(const byte *, uint, bool, const chunk_t *); @@ -117,11 +118,11 @@ gc_mark_string(const byte * ptr, uint size, bool set, const chunk_t * cp) * equivalent of fwrite. */ static void -dfwrite(const byte *ptr, uint count) +dmfwrite(const gs_memory_t *mem, const byte *ptr, uint count) { uint i; for (i = 0; i < count; ++i) - dputc(ptr[i]); + dmputc(mem, ptr[i]); } #endif @@ -134,15 +135,15 @@ gc_string_mark(const byte * ptr, uint size, bool set, gc_state_t * gcst) if (size == 0) return false; -#define dprintstr()\ - dputc('('); dfwrite(ptr, min(size, 20));\ - dputs((size <= 20 ? ")" : "...)")) +#define dmprintstr(mem)\ + dmputc(mem, '('); dmfwrite(mem, ptr, min(size, 20));\ + dmputs(mem, (size <= 20 ? ")" : "...)")) if (!(cp = gc_locate(ptr, gcst))) { /* not in a chunk */ #ifdef DEBUG if (gs_debug_c('5')) { - dlprintf2("[5]0x%lx[%u]", (ulong) ptr, size); - dprintstr(); - dputs(" not in a chunk\n"); + dmlprintf2(gcst->heap, "[5]0x%lx[%u]", (ulong) ptr, size); + dmprintstr(gcst->heap); + dmputs(gcst->heap, " not in a chunk\n"); } #endif return false; @@ -180,11 +181,11 @@ gc_string_mark(const byte * ptr, uint size, bool set, gc_state_t * gcst) marks = gc_mark_string(ptr, size, set, cp); #ifdef DEBUG if (gs_debug_c('5')) { - dlprintf4("[5]%s%smarked 0x%lx[%u]", + dmlprintf4(gcst->heap, "[5]%s%smarked 0x%lx[%u]", (marks ? "" : "already "), (set ? "" : "un"), (ulong) ptr, size); - dprintstr(); - dputc('\n'); + dmprintstr(gcst->heap); + dmputc(gcst->heap, '\n'); } #endif return marks; @@ -338,7 +339,7 @@ igc_reloc_param_string(gs_param_string * sptr, gc_state_t * gcst) /* Compact the strings in a chunk. */ void -gc_strings_compact(chunk_t * cp) +gc_strings_compact(chunk_t * cp, const gs_memory_t *mem) { if (cp->smark != 0) { byte *hi = cp->climit; @@ -357,24 +358,24 @@ gc_strings_compact(chunk_t * cp) for (; i < n; i += R) { uint j; - dlprintf1("[4]0x%lx: ", (ulong) (base + i)); + dmlprintf1(mem, "[4]0x%lx: ", (ulong) (base + i)); for (j = i; j < i + R; j++) { byte ch = base[j]; if (ch <= 31) { - dputc('^'); - dputc(ch + 0100); + dmputc(mem, '^'); + dmputc(mem, ch + 0100); } else - dputc(ch); + dmputc(mem, ch); } - dputc(' '); + dmputc(mem, ' '); for (j = i; j < i + R; j++) - dputc((cp->smark[j >> 3] & (1 << (j & 7)) ? + dmputc(mem, (cp->smark[j >> 3] & (1 << (j & 7)) ? '+' : '.')); #undef R if (!(i & (string_data_quantum - 1))) - dprintf1(" %u", cp->sreloc[i >> log2_string_data_quantum]); - dputc('\n'); + dmprintf1(mem, " %u", cp->sreloc[i >> log2_string_data_quantum]); + dmputc(mem, '\n'); } } #endif diff --git a/gs/psi/igcstr.h b/gs/psi/igcstr.h index ac9f6b370..4bf0fbc93 100644 --- a/gs/psi/igcstr.h +++ b/gs/psi/igcstr.h @@ -27,7 +27,7 @@ void gc_strings_set_marks(chunk_t *, bool); bool gc_string_mark(const byte *, uint, bool, gc_state_t *); void gc_strings_clear_reloc(chunk_t *); void gc_strings_set_reloc(chunk_t *); -void gc_strings_compact(chunk_t *); +void gc_strings_compact(chunk_t *, const gs_memory_t *); string_proc_reloc(igc_reloc_string); const_string_proc_reloc(igc_reloc_const_string); param_string_proc_reloc(igc_reloc_param_string); diff --git a/gs/psi/ilocate.c b/gs/psi/ilocate.c index ac041066e..96d32a321 100644 --- a/gs/psi/ilocate.c +++ b/gs/psi/ilocate.c @@ -248,13 +248,13 @@ ialloc_validate_memory(const gs_ref_memory_t * mem, gc_state_t * gcst) const chunk_t *cp; int i; - if_debug3('6', "[6]validating memory 0x%lx, space %d, level %d\n", - (ulong) mem, mem->space, level); + if_debug3m('6', (gs_memory_t *)mem, "[6]validating memory 0x%lx, space %d, level %d\n", + (ulong) mem, mem->space, level); /* Validate chunks. */ for (cp = smem->cfirst; cp != 0; cp = cp->cnext) if (do_validate_chunk(cp, gcst)) { - lprintf3("while validating memory 0x%lx, space %d, level %d\n", - (ulong) mem, mem->space, level); + mlprintf3((gs_memory_t *)mem, "while validating memory 0x%lx, space %d, level %d\n", + (ulong) mem, mem->space, level); gs_abort(gcst->heap); } /* Validate freelists. */ @@ -268,15 +268,15 @@ ialloc_validate_memory(const gs_ref_memory_t * mem, gc_state_t * gcst) uint size = pfree[-1].o_size; if (pfree[-1].o_type != &st_free) { - lprintf3("Non-free object 0x%lx(%u) on freelist %i!\n", - (ulong) pfree, size, i); + mlprintf3((gs_memory_t *)mem, "Non-free object 0x%lx(%u) on freelist %i!\n", + (ulong) pfree, size, i); break; } if ((i == LARGE_FREELIST_INDEX && size < max_freelist_size) || (i != LARGE_FREELIST_INDEX && (size < free_size - obj_align_mask || size > free_size))) { - lprintf3("Object 0x%lx(%u) size wrong on freelist %i!\n", - (ulong) pfree, size, i); + mlprintf3((gs_memory_t *)mem, "Object 0x%lx(%u) size wrong on freelist %i!\n", + (ulong) pfree, size, i); break; } } @@ -307,7 +307,7 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst) { int ret = 0; - if_debug_chunk('6', "[6]validating chunk", cp); + if_debug_chunk('6', gcst->heap, "[6]validating chunk", cp); SCAN_CHUNK_OBJECTS(cp); DO_ALL if (pre->o_type == &st_free) { @@ -317,12 +317,12 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst) return 1; } } else if (do_validate_object(pre + 1, cp, gcst)) { - dprintf_chunk("while validating chunk", cp); + dmprintf_chunk(gcst->heap, "while validating chunk", cp); return 1; } - if_debug3('7', " [7]validating %s(%lu) 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) size, (ulong) pre); + if_debug3m('7', gcst->heap, " [7]validating %s(%lu) 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) size, (ulong) pre); if (pre->o_type == &st_refs) { const ref_packed *rp = (const ref_packed *)(pre + 1); const char *end = (const char *)rp + size; @@ -334,10 +334,10 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst) ret = ialloc_validate_ref_packed(rp, gcst); # endif if (ret) { - lprintf3("while validating %s(%lu) 0x%lx\n", + mlprintf3(gcst->heap, "while validating %s(%lu) 0x%lx\n", struct_type_name_string(pre->o_type), (ulong) size, (ulong) pre); - dprintf_chunk("in chunk", cp); + dmprintf_chunk(gcst->heap, "in chunk", cp); return ret; } rp = packed_next(rp); @@ -368,7 +368,7 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst) ret = ialloc_validate_ref_packed(eptr.ptr, gcst); # endif if (ret) { - dprintf_chunk("while validating chunk", cp); + dmprintf_chunk(gcst->heap, "while validating chunk", cp); return ret; } } @@ -586,13 +586,13 @@ do_validate_object(const obj_header_t * ptr, const chunk_t * cp, st = *gcst; /* no side effects! */ if (!(cp = gc_locate(pre, &st))) { - lprintf1("Object 0x%lx not in any chunk!\n", - (ulong) ptr); + mlprintf1(gcst->heap, "Object 0x%lx not in any chunk!\n", + (ulong) ptr); return 1; /*gs_abort(); */ } } if (otype == &st_free) { - lprintf3("Reference to free object 0x%lx(%lu), in chunk 0x%lx!\n", + mlprintf3(gcst->heap, "Reference to free object 0x%lx(%lu), in chunk 0x%lx!\n", (ulong) ptr, (ulong) size, (ulong) cp); return 1; } @@ -602,10 +602,10 @@ do_validate_object(const obj_header_t * ptr, const chunk_t * cp, (oname = struct_type_name_string(otype), *oname < 33 || *oname > 126) ) { - lprintf2("Bad object 0x%lx(%lu),\n", - (ulong) ptr, (ulong) size); - dprintf2(" ssize = %u, in chunk 0x%lx!\n", - otype->ssize, (ulong) cp); + mlprintf2(gcst->heap, "Bad object 0x%lx(%lu),\n", + (ulong) ptr, (ulong) size); + dmprintf2(gcst->heap, " ssize = %u, in chunk 0x%lx!\n", + otype->ssize, (ulong) cp); return 1; } return 0; diff --git a/gs/psi/imain.c b/gs/psi/imain.c index 891f25d5d..3a71a1c1e 100644 --- a/gs/psi/imain.c +++ b/gs/psi/imain.c @@ -867,7 +867,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code) i_ctx_p = minst->i_ctx_p; /* get current interp context */ if (gs_debug_c(':')) { print_resource_usage(minst, &gs_imemory, "Final"); - dprintf1("%% Exiting instance 0x%p\n", minst); + dmprintf1(minst->heap, "%% Exiting instance 0x%p\n", minst); } /* Do the equivalent of a restore "past the bottom". */ /* This will release all memory, close all open files, etc. */ @@ -959,10 +959,10 @@ print_resource_usage(const gs_main_instance * minst, gs_dual_memory_t * dmem, } } } - dprintf4("%% %s time = %g, memory allocated = %lu, used = %lu\n", - msg, utime[0] - minst->base_time[0] + - (utime[1] - minst->base_time[1]) / 1000000000.0, - allocated, used); + dmprintf4(minst->heap, "%% %s time = %g, memory allocated = %lu, used = %lu\n", + msg, utime[0] - minst->base_time[0] + + (utime[1] - minst->base_time[1]) / 1000000000.0, + allocated, used); } /* Dump the stacks after interpretation */ @@ -972,11 +972,11 @@ gs_main_dump_stack(gs_main_instance *minst, int code, ref * perror_object) i_ctx_t *i_ctx_p = minst->i_ctx_p; zflush(i_ctx_p); /* force out buffered output */ - dprintf1("\nUnexpected interpreter error %d.\n", code); + dmprintf1(minst->heap, "\nUnexpected interpreter error %d.\n", code); if (perror_object != 0) { - dputs("Error object: "); + dmputs(minst->heap, "Error object: "); debug_print_ref(minst->heap, perror_object); - dputc('\n'); + dmputc(minst->heap, '\n'); } debug_dump_stack(minst->heap, &o_stack, "Operand stack"); debug_dump_stack(minst->heap, &e_stack, "Execution stack"); diff --git a/gs/psi/imainarg.c b/gs/psi/imainarg.c index b5301e24e..58d8655d7 100644 --- a/gs/psi/imainarg.c +++ b/gs/psi/imainarg.c @@ -216,10 +216,10 @@ gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[]) if (gs_debug[':'] && arg[1] == 'Z') { int i; - dprintf1("%% Init started, instance 0x%p, with args: ", minst); + dmprintf1(minst->heap, "%% Init started, instance 0x%p, with args: ", minst); for (i=1; i<argc; i++) - dprintf1("%s ", argv[i]); - dprintf("\n"); + dmprintf1(minst->heap, "%s ", argv[i]); + dmprintf(minst->heap, "\n"); } break; default: @@ -238,10 +238,10 @@ gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[]) if (gs_debug[':']) { int i; - dprintf1("%% Init done, instance 0x%p, with args: ", minst); + dmprintf1(minst->heap, "%% Init done, instance 0x%p, with args: ", minst); for (i=1; i<argc; i++) - dprintf1("%s ", argv[i]); - dprintf("\n"); + dmprintf1(minst->heap, "%s ", argv[i]); + dmprintf(minst->heap, "\n"); } if (!minst->run_start) return e_Quit; diff --git a/gs/psi/iname.c b/gs/psi/iname.c index c99374008..2eb8ee29f 100644 --- a/gs/psi/iname.c +++ b/gs/psi/iname.c @@ -63,12 +63,12 @@ name_print(const char *msg, const name_table *nt, uint nidx, const int *pflag) const name *pname = names_index_ptr_inline(nt, nidx); const byte *str = pnstr->string_bytes; - dlprintf1("[n]%s", msg); + dmlprintf1(nt->memory, "[n]%s", msg); if (pflag) - dprintf1("(%d)", *pflag); - dprintf2(" (0x%lx#%u)", (ulong)pname, nidx); - debug_print_string(str, pnstr->string_size); - dprintf2("(0x%lx,%u)\n", (ulong)str, pnstr->string_size); + dmprintf1(nt->memory, "(%d)", *pflag); + dmprintf2(nt->memory, " (0x%lx#%u)", (ulong)pname, nidx); + debug_print_string(nt->memory, str, pnstr->string_size); + dmprintf2(nt->memory, "(0x%lx,%u)\n", (ulong)str, pnstr->string_size); } # define if_debug_name(msg, nt, nidx, pflag)\ if ( gs_debug_c('n') ) name_print(msg, nt, nidx, pflag) @@ -513,7 +513,7 @@ name_alloc_sub(name_table * nt) for (i0 = 0; i0 < NT_HASH_SIZE; i0 += 16) { int i; - dlprintf1("[n]chain %d:", i0); + dmlprintf1(mem, "[n]chain %d:", i0); for (i = i0; i < i0 + 16; i++) { int n = 0; uint nidx; @@ -523,9 +523,9 @@ name_alloc_sub(name_table * nt) names_index_string_inline(nt, nidx)) ) n++; - dprintf1(" %d", n); + dmprintf1(mem, " %d", n); } - dputc('\n'); + dmputc(mem, '\n'); } } #endif diff --git a/gs/psi/interp.c b/gs/psi/interp.c index 506f8b899..d384e8164 100644 --- a/gs/psi/interp.c +++ b/gs/psi/interp.c @@ -94,16 +94,16 @@ do_call_operator_verbose(op_proc_t op_proc, i_ctx_t *i_ctx_p) int code; #ifndef SHOW_STACK_DEPTHS - if_debug1('!', "[!]operator %s\n", op_get_name_string(op_proc)); + if_debug1m('!', imemory, "[!]operator %s\n", op_get_name_string(op_proc)); #else - if_debug3('!', "[!][es=%d os=%d]operator %s\n", + if_debug3m('!', imemory, "[!][es=%d os=%d]operator %s\n", esp-i_ctx_p->exec_stack.stack.bot, osp-i_ctx_p->op_stack.stack.bot, op_get_name_string(op_proc)); #endif code = do_call_operator(op_proc, i_ctx_p); #if defined(SHOW_STACK_DEPTHS) - if_debug2('!', "[!][es=%d os=%d]\n", + if_debug2m('!', imemory, "[!][es=%d os=%d]\n", esp-i_ctx_p->exec_stack.stack.bot, osp-i_ctx_p->op_stack.stack.bot); #endif @@ -909,7 +909,7 @@ interp(i_ctx_t **pi_ctx_p /* context for execution, updated if resched */, if (iosp >= osbot && (r_type(iosp) == t__invalid || r_type(iosp) >= tx_next_op) ) { - lprintf("Invalid value on o-stack!\n"); + mlprintf(imemory, "Invalid value on o-stack!\n"); return_with_error_iref(e_Fatal); } if (gs_debug['I'] || @@ -923,18 +923,18 @@ interp(i_ctx_t **pi_ctx_p /* context for execution, updated if resched */, osp = iosp; esp = iesp; - dlprintf5("d%u,e%u<%u>0x%lx(%d): ", + dmlprintf5(imemory, "d%u,e%u<%u>0x%lx(%d): ", ref_stack_count(&d_stack), ref_stack_count(&e_stack), ref_stack_count(&o_stack), (ulong)IREF, icount); debug_print_ref(imemory, IREF); if (iosp >= osbot) { - dputs(" // "); + dmputs(imemory, " // "); debug_print_ref(imemory, iosp); } - dputc('\n'); + dmputc(imemory, '\n'); osp = save_osp; esp = save_esp; - dflush(); + dmflush(imemory); } #endif /* Objects that have attributes (arrays, dictionaries, files, and strings) */ diff --git a/gs/psi/ireclaim.c b/gs/psi/ireclaim.c index 653998f0a..e883505ce 100644 --- a/gs/psi/ireclaim.c +++ b/gs/psi/ireclaim.c @@ -69,8 +69,8 @@ ireclaim(gs_dual_memory_t * dmem, int space) } else { mem = dmem->spaces_indexed[space >> r_space_shift]; } - if_debug3('0', "[0]GC called, space=%d, requestor=%d, requested=%ld\n", - space, mem->space, (long)mem->gc_status.requested); + if_debug3m('0', (gs_memory_t *)mem, "[0]GC called, space=%d, requestor=%d, requested=%ld\n", + space, mem->space, (long)mem->gc_status.requested); global = mem->space != avm_local; /* Since dmem may move, reset the request now. */ ialloc_reset_requested(dmem); diff --git a/gs/psi/isave.c b/gs/psi/isave.c index 19d1073bd..30952b45a 100644 --- a/gs/psi/isave.c +++ b/gs/psi/isave.c @@ -236,27 +236,27 @@ gs_private_st_complex_only(st_alloc_change, alloc_change_t, "alloc_change", /* Debugging printout */ #ifdef DEBUG static void -alloc_save_print(alloc_change_t * cp, bool print_current) +alloc_save_print(const gs_memory_t *mem, alloc_change_t * cp, bool print_current) { - dprintf2(" 0x%lx: 0x%lx: ", (ulong) cp, (ulong) cp->where); + dmprintf2(mem, " 0x%lx: 0x%lx: ", (ulong) cp, (ulong) cp->where); if (r_is_packed(&cp->contents)) { if (print_current) - dprintf2("saved=%x cur=%x\n", *(ref_packed *) & cp->contents, - *cp->where); + dmprintf2(mem, "saved=%x cur=%x\n", *(ref_packed *) & cp->contents, + *cp->where); else - dprintf1("%x\n", *(ref_packed *) & cp->contents); + dmprintf1(mem, "%x\n", *(ref_packed *) & cp->contents); } else { if (print_current) - dprintf6("saved=%x %x %lx cur=%x %x %lx\n", - r_type_attrs(&cp->contents), r_size(&cp->contents), - (ulong) cp->contents.value.intval, - r_type_attrs((ref *) cp->where), - r_size((ref *) cp->where), - (ulong) ((ref *) cp->where)->value.intval); + dmprintf6(mem, "saved=%x %x %lx cur=%x %x %lx\n", + r_type_attrs(&cp->contents), r_size(&cp->contents), + (ulong) cp->contents.value.intval, + r_type_attrs((ref *) cp->where), + r_size((ref *) cp->where), + (ulong) ((ref *) cp->where)->value.intval); else - dprintf3("%x %x %lx\n", - r_type_attrs(&cp->contents), r_size(&cp->contents), - (ulong) cp->contents.value.intval); + dmprintf3(mem, "%x %x %lx\n", + r_type_attrs(&cp->contents), r_size(&cp->contents), + (ulong) cp->contents.value.intval); } } #endif @@ -415,8 +415,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid) break; /* maybe should fail */ alloc_init_chunk(inner, cp->cbot, cp->ctop, cp->sreloc != 0, cp); alloc_link_chunk(inner, mem); - if_debug2('u', "[u]inner chunk: cbot=0x%lx ctop=0x%lx\n", - (ulong) inner->cbot, (ulong) inner->ctop); + if_debug2m('u', (gs_memory_t *)mem, "[u]inner chunk: cbot=0x%lx ctop=0x%lx\n", + (ulong) inner->cbot, (ulong) inner->ctop); if (cp == save_mem.pcc) new_pcc = inner; } @@ -426,8 +426,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid) save = gs_alloc_struct((gs_memory_t *) mem, alloc_save_t, &st_alloc_save, "alloc_save_space(save)"); - if_debug2('u', "[u]save space %u at 0x%lx\n", - mem->space, (ulong) save); + if_debug2m('u', (gs_memory_t *)mem, "[u]save space %u at 0x%lx\n", + mem->space, (ulong) save); if (save == 0) { /* Free the inner chunk structures. This is the easiest way. */ restore_free(mem); @@ -440,8 +440,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid) save->is_current = (dmem->current == mem); save->id = sid; mem->saved = save; - if_debug2('u', "[u%u]file_save 0x%lx\n", - mem->space, (ulong) mem->streams); + if_debug2m('u', (gs_memory_t *)mem, "[u%u]file_save 0x%lx\n", + mem->space, (ulong) mem->streams); mem->streams = 0; mem->total_scanned = 0; mem->total_scanned_after_compacting = 0; @@ -486,8 +486,8 @@ alloc_save_change_in(gs_ref_memory_t *mem, const ref * pcont, mem->changes = cp; #ifdef DEBUG if (gs_debug_c('U')) { - dlprintf1("[U]save(%s)", client_name_string(cname)); - alloc_save_print(cp, false); + dmlprintf1((const gs_memory_t *)mem, "[U]save(%s)", client_name_string(cname)); + alloc_save_print((const gs_memory_t *)mem, cp, false); } #endif return 0; @@ -605,8 +605,8 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save) const char *const ptr = (const char *)vptr; register const gs_ref_memory_t *mem = save->space_local; - if_debug2('U', "[U]is_since_save 0x%lx, 0x%lx:\n", - (ulong) ptr, (ulong) save); + if_debug2m('U', (gs_memory_t *)mem, "[U]is_since_save 0x%lx, 0x%lx:\n", + (ulong) ptr, (ulong) save); if (mem->saved == 0) { /* This is a special case, the final 'restore' from */ /* alloc_restore_all. */ return true; @@ -616,15 +616,15 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save) for (;; mem = &mem->saved->state) { const chunk_t *cp; - if_debug1('U', "[U]checking mem=0x%lx\n", (ulong) mem); + if_debug1m('U', (gs_memory_t *)mem, "[U]checking mem=0x%lx\n", (ulong) mem); for (cp = mem->cfirst; cp != 0; cp = cp->cnext) { if (ptr_is_within_chunk(ptr, cp)) { - if_debug3('U', "[U+]in new chunk 0x%lx: 0x%lx, 0x%lx\n", - (ulong) cp, - (ulong) cp->cbase, (ulong) cp->cend); + if_debug3m('U', (gs_memory_t *)mem, "[U+]in new chunk 0x%lx: 0x%lx, 0x%lx\n", + (ulong) cp, + (ulong) cp->cbase, (ulong) cp->cend); return true; } - if_debug1('U', "[U-]not in 0x%lx\n", (ulong) cp); + if_debug1m('U', (gs_memory_t *)mem, "[U-]not in 0x%lx\n", (ulong) cp); } if (mem->saved == save) { /* We've checked all the more recent saves, */ /* must be OK. */ @@ -645,11 +645,11 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save) ) { const chunk_t *cp; - if_debug1('U', "[U]checking global mem=0x%lx\n", (ulong) mem); + if_debug1m('U', (gs_memory_t *)mem, "[U]checking global mem=0x%lx\n", (ulong) mem); for (cp = mem->cfirst; cp != 0; cp = cp->cnext) if (ptr_is_within_chunk(ptr, cp)) { - if_debug3('U', "[U+] new chunk 0x%lx: 0x%lx, 0x%lx\n", - (ulong) cp, (ulong) cp->cbase, (ulong) cp->cend); + if_debug3m('U', (gs_memory_t *)mem, "[U+] new chunk 0x%lx: 0x%lx, 0x%lx\n", + (ulong) cp, (ulong) cp->cbase, (ulong) cp->cend); return true; } } @@ -824,8 +824,8 @@ restore_space(gs_ref_memory_t * mem, gs_dual_memory_t *dmem) while (cp) { #ifdef DEBUG if (gs_debug_c('U')) { - dlputs("[U]restore"); - alloc_save_print(cp, true); + dmlputs((const gs_memory_t *)mem, "[U]restore"); + alloc_save_print((const gs_memory_t *)mem, cp, true); } #endif if (cp->offset == AC_OFFSET_ALLOCATED) @@ -939,9 +939,9 @@ restore_finalize(gs_ref_memory_t * mem) struct_proc_finalize((*finalize)) = pre->o_type->finalize; if (finalize != 0) { - if_debug2('u', "[u]restore finalizing %s 0x%lx\n", - struct_type_name_string(pre->o_type), - (ulong) (pre + 1)); + if_debug2m('u', (gs_memory_t *)mem, "[u]restore finalizing %s 0x%lx\n", + struct_type_name_string(pre->o_type), + (ulong) (pre + 1)); (*finalize) ((gs_memory_t *) mem, pre + 1); } END_OBJECTS_SCAN @@ -957,9 +957,9 @@ restore_resources(alloc_save_t * sprev, gs_ref_memory_t * mem) #ifdef DEBUG if (mem) { /* Note restoring of the file list. */ - if_debug4('u', "[u%u]file_restore 0x%lx => 0x%lx for 0x%lx\n", - mem->space, (ulong)mem->streams, - (ulong)sprev->state.streams, (ulong) sprev); + if_debug4m('u', (gs_memory_t *)mem, "[u%u]file_restore 0x%lx => 0x%lx for 0x%lx\n", + mem->space, (ulong)mem->streams, + (ulong)sprev->state.streams, (ulong) sprev); } #endif @@ -1134,7 +1134,7 @@ forget_changes(gs_ref_memory_t * mem) for (; chp; chp = next) { ref_packed *prp = chp->where; - if_debug1('U', "[U]forgetting change 0x%lx\n", (ulong) chp); + if_debug1m('U', (gs_memory_t *)mem, "[U]forgetting change 0x%lx\n", (ulong) chp); if (chp->offset == AC_OFFSET_ALLOCATED) DO_NOTHING; else @@ -1153,9 +1153,9 @@ file_forget_save(gs_ref_memory_t * mem) stream *streams = mem->streams; stream *saved_streams = save->state.streams; - if_debug4('u', "[u%d]file_forget_save 0x%lx + 0x%lx for 0x%lx\n", - mem->space, (ulong) streams, (ulong) saved_streams, - (ulong) save); + if_debug4m('u', (gs_memory_t *)mem, "[u%d]file_forget_save 0x%lx + 0x%lx for 0x%lx\n", + mem->space, (ulong) streams, (ulong) saved_streams, + (ulong) save); if (streams == 0) mem->streams = saved_streams; else if (saved_streams != 0) { @@ -1270,8 +1270,8 @@ save_set_new(gs_ref_memory_t * mem, bool to_new, bool set_limit, ulong *pscanned SCAN_CHUNK_OBJECTS(cp) DO_ALL - if_debug3('U', "[U]set_new scan(0x%lx(%u), %d)\n", - (ulong) pre, size, to_new); + if_debug3m('U', (gs_memory_t *)mem, "[U]set_new scan(0x%lx(%u), %d)\n", + (ulong) pre, size, to_new); if (pre->o_type == &st_refs) { /* These are refs, scan them. */ ref_packed *prp = (ref_packed *) (pre + 1); @@ -1288,8 +1288,8 @@ save_set_new(gs_ref_memory_t * mem, bool to_new, bool set_limit, ulong *pscanned } } END_CHUNKS_SCAN - if_debug2('u', "[u]set_new (%s) scanned %ld\n", - (to_new ? "restore" : "save"), scanned); + if_debug2m('u', (gs_memory_t *)mem, "[u]set_new (%s) scanned %ld\n", + (to_new ? "restore" : "save"), scanned); *pscanned = scanned; return 0; } @@ -1368,8 +1368,8 @@ save_set_new_changes(gs_ref_memory_t * mem, bool to_new, bool set_limit) } else { ref_packed *prp = chp->where; - if_debug3('U', "[U]set_new 0x%lx: (0x%lx, %d)\n", - (ulong)chp, (ulong)prp, new); + if_debug3m('U', (gs_memory_t *)mem, "[U]set_new 0x%lx: (0x%lx, %d)\n", + (ulong)chp, (ulong)prp, new); if (!r_is_packed(prp)) { ref *const rp = (ref *) prp; diff --git a/gs/psi/iscan.c b/gs/psi/iscan.c index 4f605120c..7d6ac2ddf 100644 --- a/gs/psi/iscan.c +++ b/gs/psi/iscan.c @@ -355,9 +355,9 @@ scan_comment(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate, /* Process as a DSC comment if requested. */ #ifdef DEBUG if (gs_debug_c('%')) { - dlprintf2("[%%%%%s%c]", sstr, (len >= 3 ? '+' : '-')); - debug_print_string(base, len); - dputs("\n"); + dmlprintf2(imemory, "[%%%%%s%c]", sstr, (len >= 3 ? '+' : '-')); + debug_print_string(imemory, base, len); + dmputs(imemory, "\n"); } #endif if (gs_scan_dsc_proc != NULL) { @@ -373,9 +373,9 @@ scan_comment(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate, #ifdef DEBUG else { if (gs_debug_c('%')) { - dlprintf2("[%% %s%c]", sstr, (len >= 2 ? '+' : '-')); - debug_print_string(base, len); - dputs("\n"); + dmlprintf2(imemory, "[%% %s%c]", sstr, (len >= 2 ? '+' : '-')); + debug_print_string(imemory, base, len); + dmputs(imemory, "\n"); } } #endif @@ -564,7 +564,7 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate) * If pstack != 0, myref = osp, and *osp is a valid slot. */ top:c = scan_getc(); - if_debug1('S', (c >= 32 && c <= 126 ? "`%c'" : c >= 0 ? "`\\%03o'" : "`%d'"), c); + if_debug1m('S', s->memory, (c >= 32 && c <= 126 ? "`%c'" : c >= 0 ? "`\\%03o'" : "`%d'"), c); switch (c) { case ' ': case '\f': @@ -680,8 +680,8 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate) } make_int(osp, pstack); pstack = ref_stack_count_inline(&o_stack); - if_debug3('S', "[S{]d=%d, s=%d->%d\n", - pdepth, (int)osp->value.intval, pstack); + if_debug3m('S', s->memory, "[S{]d=%d, s=%d->%d\n", + pdepth, (int)osp->value.intval, pstack); goto snext; case '>': if (scan_enable_level2) { @@ -701,11 +701,11 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate) uint size = ref_stack_count_inline(&o_stack) - pstack; ref arr; - if_debug4('S', "[S}]d=%d, s=%d->%d, c=%d\n", - pdepth, pstack, - (pstack == pdepth ? 0 : - ref_stack_index(&o_stack, size)->value.intval), - size + pstack); + if_debug4m('S', s->memory, "[S}]d=%d, s=%d->%d, c=%d\n", + pdepth, pstack, + (pstack == pdepth ? 0 : + ref_stack_index(&o_stack, size)->value.intval), + size + pstack); if (size > max_array_size) sreturn(e_limitcheck); myref = (pstack == pdepth ? pref : &arr); diff --git a/gs/psi/zcie.c b/gs/psi/zcie.c index 87d8b788b..cc44ae90b 100644 --- a/gs/psi/zcie.c +++ b/gs/psi/zcie.c @@ -792,8 +792,8 @@ cie_cache_finish_store(i_ctx_t *i_ctx_p, bool replicate) pcache = (cie_cache_floats *) (r_ptr(esp - 1, char) + esp->value.intval); pcache->params.is_identity = false; /* cache_set_linear computes this */ - if_debug3('c', "[c]cache 0x%lx base=%g, factor=%g:\n", - (ulong) pcache, pcache->params.base, pcache->params.factor); + if_debug3m('c', imemory, "[c]cache 0x%lx base=%g, factor=%g:\n", + (ulong) pcache, pcache->params.base, pcache->params.factor); if (replicate || (code = float_params(op, gx_cie_cache_size, &pcache->values[0])) < 0 ) { @@ -814,9 +814,9 @@ cie_cache_finish_store(i_ctx_t *i_ctx_p, bool replicate) int i; for (i = 0; i < gx_cie_cache_size; i += 4) - dlprintf5("[c] cache[%3d]=%g, %g, %g, %g\n", i, - pcache->values[i], pcache->values[i + 1], - pcache->values[i + 2], pcache->values[i + 3]); + dmlprintf5(imemory, "[c] cache[%3d]=%g, %g, %g, %g\n", i, + pcache->values[i], pcache->values[i + 1], + pcache->values[i + 2], pcache->values[i + 3]); } #endif ref_stack_pop(&o_stack, (replicate ? 1 : gx_cie_cache_size)); @@ -927,8 +927,8 @@ cie_create_icc(i_ctx_t *i_ctx_p) pcache = (cie_cache_floats *) (r_ptr(esp - 1, char) + esp->value.intval); pcache->params.is_identity = false; /* cache_set_linear computes this */ - if_debug3('c', "[c]icc_sample_proc 0x%lx base=%g, factor=%g:\n", - (ulong) pcache, pcache->params.base, pcache->params.factor); + if_debug3m('c', imemory, "[c]icc_sample_proc 0x%lx base=%g, factor=%g:\n", + (ulong) pcache, pcache->params.base, pcache->params.factor); if ((code = float_params(op, gx_cie_cache_size, &pcache->values[0])) < 0) { /* We might have underflowed the current stack block. */ /* Handle the parameters one-by-one. */ @@ -946,9 +946,9 @@ cie_create_icc(i_ctx_t *i_ctx_p) int i; for (i = 0; i < gx_cie_cache_size; i += 4) - dlprintf5("[c] icc_sample_proc[%3d]=%g, %g, %g, %g\n", i, - pcache->values[i], pcache->values[i + 1], - pcache->values[i + 2], pcache->values[i + 3]); + dmlprintf5(imemory, "[c] icc_sample_proc[%3d]=%g, %g, %g, %g\n", i, + pcache->values[i], pcache->values[i + 1], + pcache->values[i + 2], pcache->values[i + 3]); } #endif ref_stack_pop(&o_stack, gx_cie_cache_size); diff --git a/gs/psi/zcolor.c b/gs/psi/zcolor.c index d9f317664..6de917cf7 100644 --- a/gs/psi/zcolor.c +++ b/gs/psi/zcolor.c @@ -818,13 +818,13 @@ zcolor_test_all(i_ctx_t *i_ctx_p) cvbad[i] = 0; } - dprintf1("Number of components = %d\n", ncomp); - dprintf1("Depth = %d\n", dev->color_info.depth); - dprintf2("max_gray = %d dither_grays = %d\n", - dev->color_info.max_gray, dev->color_info.dither_grays); - dprintf2("max_color = %d dither_colors = %d\n", - dev->color_info.max_color, dev->color_info.dither_colors); - dprintf1("polarity = %s\n", + dmprintf1(dev->memory, "Number of components = %d\n", ncomp); + dmprintf1(dev->memory, "Depth = %d\n", dev->color_info.depth); + dmprintf2(dev->memory, "max_gray = %d dither_grays = %d\n", + dev->color_info.max_gray, dev->color_info.dither_grays); + dmprintf2(dev->memory, "max_color = %d dither_colors = %d\n", + dev->color_info.max_color, dev->color_info.dither_colors); + dmprintf1(dev->memory, "polarity = %s\n", dev->color_info.polarity == GX_CINFO_POLARITY_ADDITIVE ? "Additive" : dev->color_info.polarity == GX_CINFO_POLARITY_SUBTRACTIVE ?"Subtractive": "Unknown"); @@ -833,23 +833,23 @@ zcolor_test_all(i_ctx_t *i_ctx_p) cv[i] = 0; color = (*dev_proc(dev, encode_color)) (dev, cv); if (sizeof(color) <= sizeof(ulong)) - dprintf1("Zero color index: %8lx\n", (ulong)color); + dmprintf1(dev->memory, "Zero color index: %8lx\n", (ulong)color); else - dprintf2("Zero color index: %8lx%08lx\n", + dmprintf2(dev->memory, "Zero color index: %8lx%08lx\n", (ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color); - dprintf1("separable_and_linear = %s\n", + dmprintf1(dev->memory, "separable_and_linear = %s\n", linsep == GX_CINFO_SEP_LIN_NONE ? "No" : linsep == GX_CINFO_SEP_LIN ? "Yes" : "Unknown"); if (dev->color_info.gray_index == GX_CINFO_COMP_INDEX_UNKNOWN) - dprintf("gray_index is unknown\n"); + dmprintf(dev->memory, "gray_index is unknown\n"); else - dprintf1("gray_index = %d\n", dev->color_info.gray_index); + dmprintf1(dev->memory, "gray_index = %d\n", dev->color_info.gray_index); if (linsep) { - dprintf(" Shift Mask Bits\n"); + dmprintf(dev->memory, " Shift Mask Bits\n"); for (i = 0; i < ncomp; i++) { - dprintf3(" %5d %8x %4d\n", + dmprintf3(dev->memory, " %5d %8x %4d\n", (int)(dev->color_info.comp_shift[i]), (int)(dev->color_info.comp_mask[i]), (int)(dev->color_info.comp_bits[i])); @@ -866,11 +866,11 @@ zcolor_test_all(i_ctx_t *i_ctx_p) lscolor = gx_default_encode_color(dev, cv); if ((color != lscolor) && (linsepfailed < 5)) { linsepfailed++; - dprintf("Failed separable_and_linear for"); + dmprintf(dev->memory, "Failed separable_and_linear for"); for (i = 0; i < ncomp; i++) - dprintf1(" %d", cv[i]); - dprintf("\n"); - dprintf2("encode_color=%x gx_default_encode_color=%x\n", + dmprintf1(dev->memory, " %d", cv[i]); + dmprintf(dev->memory, "\n"); + dmprintf2(dev->memory, "encode_color=%x gx_default_encode_color=%x\n", (int)color, (int)lscolor); } } @@ -913,13 +913,13 @@ zcolor_test_all(i_ctx_t *i_ctx_p) finished = 1; } - dprintf2("Maximum error %g %s\n", + dmprintf2(dev->memory, "Maximum error %g %s\n", (float)maxerror / (float)gx_max_color_value, maxerror <= acceptable_error ? "is Ok" : maxerror <= 3*acceptable_error/2 ? "is POOR" : "FAILED"); if (linsep) - dprintf2("Maximum linear_and_separable error %g %s\n", + dmprintf2(dev->memory, "Maximum linear_and_separable error %g %s\n", (float)lsmaxerror / (float)gx_max_color_value, lsmaxerror <= acceptable_error ? "is Ok" : lsmaxerror <= 3*acceptable_error/2 ? "is POOR" : "FAILED"); diff --git a/gs/psi/zcontext.c b/gs/psi/zcontext.c index c459d149b..41dcd2dfb 100644 --- a/gs/psi/zcontext.c +++ b/gs/psi/zcontext.c @@ -1174,7 +1174,7 @@ context_create(gs_scheduler_t * psched, gs_context_t ** ppctx, *pte = pctx; *ppctx = pctx; if (gs_debug_c('\'') | gs_debug_c('"')) - dlprintf2("[']create %ld at 0x%lx\n", ctx_index, (ulong) pctx); + dmlprintf2(imemory, "[']create %ld at 0x%lx\n", ctx_index, (ulong) pctx); return 0; } @@ -1214,8 +1214,9 @@ context_destroy(gs_context_t * pctx) ppctx = &(*ppctx)->table_next; *ppctx = (*ppctx)->table_next; if (gs_debug_c('\'') | gs_debug_c('"')) - dlprintf3("[']destroy %ld at 0x%lx, status = %d\n", - pctx->index, (ulong) pctx, pctx->status); + dmlprintf3((const gs_memory_t *)mem, + "[']destroy %ld at 0x%lx, status = %d\n", + pctx->index, (ulong) pctx, pctx->status); if (!context_state_free(&pctx->state)) gs_free_object((gs_memory_t *) mem, pctx, "context_destroy"); } diff --git a/gs/psi/zdscpars.c b/gs/psi/zdscpars.c index bc854692e..a6f8fc930 100644 --- a/gs/psi/zdscpars.c +++ b/gs/psi/zdscpars.c @@ -457,7 +457,7 @@ zparse_dsc_comments(i_ctx_t *i_ctx_p) * location of the data area for the parser in our DSC dict. */ comment_code = dsc_scan_data(dsc_state->dsc_data_ptr, dsc_buffer, ssize + 1); - if_debug1('%', "[%%].parse_dsc_comments: code = %d\n", comment_code); + if_debug1m('%', imemory, "[%%].parse_dsc_comments: code = %d\n", comment_code); /* * We ignore any errors from Russell's parser. The only value that * it will return for an error is -1 so there is very little information. diff --git a/gs/psi/zfapi.c b/gs/psi/zfapi.c index 5cf98415b..d82c35713 100644 --- a/gs/psi/zfapi.c +++ b/gs/psi/zfapi.c @@ -2417,7 +2417,7 @@ retry_oversampling: glyphn = ref_to_string(&char_name, imemory, "FAPI_do_char"); if (glyphn) { - dprintf2(" Substituting .notdef for %s in the font %s \n", glyphn, pbfont->font_name.chars); + dmprintf2(imemory, " Substituting .notdef for %s in the font %s \n", glyphn, pbfont->font_name.chars); gs_free_string(imemory, (byte *)glyphn, strlen(glyphn) + 1, "FAPI_do_char"); } } @@ -2960,17 +2960,17 @@ static int do_FAPIpassfont(i_ctx_t *i_ctx_p, char *font_file_path, bool *success fapi_request = ref_to_string(&reqstr, imemory, "FAPI_do_char"); if (fapi_request) { - dprintf1("Requested FAPI plugin: %s ", fapi_request); + dmprintf1(imemory, "Requested FAPI plugin: %s ", fapi_request); while (h && (strncmp(h->I->d->type, "FAPI", 4) != 0 || strncmp(h->I->d->subtype, fapi_request, strlen(fapi_request)) != 0)) { h = h->next; } if (!h) { - dprintf("not found. Falling back to normal plugin search\n"); + dmprintf(imemory, "not found. Falling back to normal plugin search\n"); h = i_plugin_get_list(i_ctx_p); } else { - dprintf("found.\n"); + dmprintf(imemory, "found.\n"); do_restart = true; } gs_free_string(imemory, (byte *)fapi_request, strlen(fapi_request) + 1, "do_FAPIpassfont"); @@ -3005,7 +3005,7 @@ static int do_FAPIpassfont(i_ctx_t *i_ctx_p, char *font_file_path, bool *success /* renderer failed, continue search */ pbfont->FAPI = NULL; if (do_restart == true) { - dprintf1("Requested FAPI plugin %s failed, searching for alternative plugin\n", h->I->d->subtype); + dmprintf1(imemory, "Requested FAPI plugin %s failed, searching for alternative plugin\n", h->I->d->subtype); h = i_plugin_get_list(i_ctx_p); do_restart = false; } diff --git a/gs/psi/zfcid0.c b/gs/psi/zfcid0.c index 68a4bdf6b..014aa59e7 100644 --- a/gs/psi/zfcid0.c +++ b/gs/psi/zfcid0.c @@ -545,7 +545,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p) if (code < 0) { /* failed to load glyph data, put CID 0 */ int default_fallback_CID = 0 ; - if_debug2('J', "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %d\n", default_fallback_CID, op->value.intval); + if_debug2m('J', imemory, "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %d\n", default_fallback_CID, op->value.intval); op->value.intval = default_fallback_CID; @@ -556,7 +556,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p) &gdata, &fidx); if (code < 0) { - if_debug1('J', "[J]ztype9cidmap() could not load default glyph (CID %d)\n", op->value.intval); + if_debug1m('J', imemory, "[J]ztype9cidmap() could not load default glyph (CID %d)\n", op->value.intval); return_error(e_invalidfont); } diff --git a/gs/psi/zfile.c b/gs/psi/zfile.c index a7f94e3be..4011789ef 100644 --- a/gs/psi/zfile.c +++ b/gs/psi/zfile.c @@ -1088,7 +1088,7 @@ file_read_string(const byte *str, uint len, ref *pfile, gs_ref_memory_t *imem) int filter_report_error(stream_state * st, const char *str) { - if_debug1('s', "[s]stream error: %s\n", str); + if_debug1m('s', st->memory, "[s]stream error: %s\n", str); strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING); /* Ensure null termination. */ st->error_string[STREAM_MAX_ERROR_STRING] = 0; diff --git a/gs/psi/zfjbig2.c b/gs/psi/zfjbig2.c index a87163a31..88add3ab5 100644 --- a/gs/psi/zfjbig2.c +++ b/gs/psi/zfjbig2.c @@ -105,7 +105,7 @@ z_jbig2makeglobalctx(i_ctx_t * i_ctx_p) code = s_jbig2decode_make_global_data(data, size, &global); if (size > 0 && global == NULL) { - dlprintf("failed to create parsed JBIG2GLOBALS object."); + dmlprintf(imemory, "failed to create parsed JBIG2GLOBALS object."); return_error(e_unknownerror); } diff --git a/gs/psi/zfjpx.c b/gs/psi/zfjpx.c index 3f20884af..937d84bac 100644 --- a/gs/psi/zfjpx.c +++ b/gs/psi/zfjpx.c @@ -76,7 +76,7 @@ z_jpx_decode(i_ctx_t * i_ctx_p) /* use the name directly */ csname = sop; } else { - dprintf("warning: JPX ColorSpace value is an unhandled type!\n"); + dmprintf(imemory, "warning: JPX ColorSpace value is an unhandled type!\n"); } if (csname != NULL) { ref sref; @@ -114,8 +114,8 @@ z_jpx_decode(i_ctx_t * i_ctx_p) /* else guess based on the number of components */ if (state.colorspace == gs_jpx_cs_unset && dict_find_string(csdict, "N", &nref) > 0) { - if_debug1('w', "[w] JPX image has an external %d" - " channel colorspace\n", nref->value.intval); + if_debug1m('w', imemory, "[w] JPX image has an external %d" + " channel colorspace\n", nref->value.intval); switch (nref->value.intval) { case 1: state.colorspace = gs_jpx_cs_gray; break; @@ -128,7 +128,7 @@ z_jpx_decode(i_ctx_t * i_ctx_p) } } } else { - if_debug0('w', "[w] Couldn't read JPX ColorSpace key!\n"); + if_debug0m('w', imemory, "[w] Couldn't read JPX ColorSpace key!\n"); } } } diff --git a/gs/psi/zicc.c b/gs/psi/zicc.c index 6845892ee..cc30daccc 100644 --- a/gs/psi/zicc.c +++ b/gs/psi/zicc.c @@ -246,7 +246,7 @@ zset_outputintent(i_ctx_t * i_ctx_p) check_type(*op, t_dictionary); check_dict_read(*op); - if_debug0(gs_debug_flag_icc,"[icc] Using OutputIntent\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] Using OutputIntent\n"); /* Get the device structure */ code = dev_proc(dev, get_profile)(dev, &dev_profile); @@ -340,7 +340,7 @@ zset_outputintent(i_ctx_t * i_ctx_p) color management */ rc_assign(dev_profile->device_profile[0], picc_profile, "zset_outputintent"); - if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used for device profile\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used for device profile\n"); } else { if (dev_profile->proof_profile == NULL) { /* This means that we should use the OI profile as the proofing @@ -350,7 +350,7 @@ zset_outputintent(i_ctx_t * i_ctx_p) just for the source data below */ dev_profile->proof_profile = picc_profile; rc_increment(picc_profile); - if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used for proof profile\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used for proof profile\n"); } } /* Now the source colors. See which source color space needs to use the @@ -360,17 +360,17 @@ zset_outputintent(i_ctx_t * i_ctx_p) /* source_profile is currently the default. Set it to the OI profile */ switch (picc_profile->data_cs) { case gsGRAY: - if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source Gray\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source Gray\n"); rc_assign(icc_manager->default_gray, picc_profile, "zset_outputintent"); break; case gsRGB: - if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source RGB\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source RGB\n"); rc_assign(icc_manager->default_rgb, picc_profile, "zset_outputintent"); break; case gsCMYK: - if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source CMYK\n"); + if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source CMYK\n"); rc_assign(icc_manager->default_cmyk, picc_profile, "zset_outputintent"); break; diff --git a/gs/psi/zpcolor.c b/gs/psi/zpcolor.c index 490f9f1c2..546e6ccdc 100644 --- a/gs/psi/zpcolor.c +++ b/gs/psi/zpcolor.c @@ -242,7 +242,7 @@ pattern_paint_prepare(i_ctx_t *i_ctx_p) if (internal_accum) { gs_setdevice_no_init(pgs, (gx_device *)pdev); if (pinst->templat.uses_transparency) { - if_debug0('v', " pushing the pdf14 compositor device into this graphics state\n"); + if_debug0m('v', imemory, " pushing the pdf14 compositor device into this graphics state\n"); if ((code = gs_push_pdf14trans_device(pgs, true)) < 0) return code; } else { /* not transparent */ @@ -329,7 +329,7 @@ pattern_paint_finish(i_ctx_t *i_ctx_p) } if (o_stack_adjust > 0) { #if 0 - dlprintf1("PaintProc left %d extra on operator stack!\n", o_stack_adjust); + dmlprintf1(imemory, "PaintProc left %d extra on operator stack!\n", o_stack_adjust); #endif pop(o_stack_adjust); } diff --git a/gs/psi/zvmem.c b/gs/psi/zvmem.c index 32f938108..4ad8f9a20 100644 --- a/gs/psi/zvmem.c +++ b/gs/psi/zvmem.c @@ -84,8 +84,8 @@ zsave(i_ctx_t *i_ctx_p) ifree_object(vmsave, "zsave"); return_error(e_VMerror); } - if_debug2('u', "[u]vmsave 0x%lx, id = %lu\n", - (ulong) vmsave, (ulong) sid); + if_debug2m('u', imemory, "[u]vmsave 0x%lx, id = %lu\n", + (ulong) vmsave, (ulong) sid); code = gs_gsave_for_save(igs, &prev); if (code < 0) return code; @@ -115,9 +115,9 @@ zrestore(i_ctx_t *i_ctx_p) if (code < 0) return code; - if_debug2('u', "[u]vmrestore 0x%lx, id = %lu\n", - (ulong) alloc_save_client_data(asave), - (ulong) op->value.saveid); + if_debug2m('u', imemory, "[u]vmrestore 0x%lx, id = %lu\n", + (ulong) alloc_save_client_data(asave), + (ulong) op->value.saveid); if (I_VALIDATE_BEFORE_RESTORE) ivalidate_clean_spaces(i_ctx_p); /* Check the contents of the stacks. */ |