diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2015-06-24 13:28:36 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2015-06-24 13:28:36 +0000 |
commit | d9564ec70788039385f663f263ea66895add0518 (patch) | |
tree | fca77b544160be34a2cb3539ff4253669d1e7ca9 /filter | |
parent | 590e44a4d338a619c9f5b26ae3e994c2e59736aa (diff) | |
download | cups-d9564ec70788039385f663f263ea66895add0518.tar.gz |
Update libcupsimage to properly use DEBUG_ macros.
Add additional debug stuff for raster.
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12746 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'filter')
-rw-r--r-- | filter/error.c | 13 | ||||
-rw-r--r-- | filter/interpret.c | 97 | ||||
-rw-r--r-- | filter/raster.c | 28 | ||||
-rw-r--r-- | filter/testraster.c | 2 |
4 files changed, 82 insertions, 58 deletions
diff --git a/filter/error.c b/filter/error.c index 26d8511d4..8fca072ca 100644 --- a/filter/error.c +++ b/filter/error.c @@ -3,7 +3,7 @@ * * Raster error handling for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -185,7 +185,7 @@ get_error_buffer(void) * Initialize the global data exactly once... */ - DEBUG_puts("get_error_buffer()"); + DEBUG_puts("3get_error_buffer()"); pthread_once(&raster_key_once, raster_init); @@ -196,7 +196,7 @@ get_error_buffer(void) if ((buf = (_cups_raster_error_t *)pthread_getspecific(raster_key)) == NULL) { - DEBUG_puts("get_error_buffer: allocating memory for thread..."); + DEBUG_puts("4get_error_buffer: allocating memory for thread."); /* * No, allocate memory as set the pointer for the key... @@ -205,7 +205,7 @@ get_error_buffer(void) buf = calloc(1, sizeof(_cups_raster_error_t)); pthread_setspecific(raster_key, buf); - DEBUG_printf((" buf=%p\n", buf)); + DEBUG_printf(("4get_error_buffer: buf=%p", buf)); } /* @@ -225,8 +225,7 @@ raster_init(void) { pthread_key_create(&raster_key, raster_destructor); - DEBUG_printf(("raster_init(): raster_key=%x(%u)\n", (unsigned)raster_key, - (unsigned)raster_key)); + DEBUG_printf(("3raster_init(): raster_key=%x(%u)", (unsigned)raster_key, (unsigned)raster_key)); } @@ -241,7 +240,7 @@ raster_destructor(void *value) /* I - Data to free */ /* Error buffer */ - DEBUG_printf(("raster_destructor(value=%p)\n", value)); + DEBUG_printf(("3raster_destructor(value=%p)", value)); if (buf->start) free(buf->start); diff --git a/filter/interpret.c b/filter/interpret.c index 380fa1d55..c2bdc0315 100644 --- a/filter/interpret.c +++ b/filter/interpret.c @@ -3,7 +3,7 @@ * * PPD command interpreter for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 1993-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -91,8 +91,8 @@ static int setpagedevice(_cups_ps_stack_t *st, cups_page_header2_t *h, int *preferred_bits); #ifdef DEBUG -static void DEBUG_object(_cups_ps_obj_t *obj); -static void DEBUG_stack(_cups_ps_stack_t *st); +static void DEBUG_object(const char *prefix, _cups_ps_obj_t *obj); +static void DEBUG_stack(const char *prefix, _cups_ps_stack_t *st); #endif /* DEBUG */ @@ -547,8 +547,8 @@ _cupsRasterExecPS( while ((obj = scan_ps(st, &codeptr)) != NULL) { #ifdef DEBUG - DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)\n", st->num_objs)); - DEBUG_object(obj); + DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)", st->num_objs)); + DEBUG_object("_cupsRasterExecPS", obj); #endif /* DEBUG */ switch (obj->type) @@ -561,11 +561,11 @@ _cupsRasterExecPS( pop_stack(st); if (cleartomark_stack(st)) - _cupsRasterAddError("cleartomark: Stack underflow!\n"); + _cupsRasterAddError("cleartomark: Stack underflow.\n"); #ifdef DEBUG - DEBUG_puts(" dup: "); - DEBUG_stack(st); + DEBUG_puts("1_cupsRasterExecPS: dup"); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ break; @@ -577,7 +577,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: copy"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ } break; @@ -588,7 +588,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: dup"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ break; @@ -600,7 +600,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: index"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ } break; @@ -611,7 +611,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: pop"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ break; @@ -630,7 +630,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: roll"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ } } @@ -642,7 +642,7 @@ _cupsRasterExecPS( #ifdef DEBUG DEBUG_puts("_cupsRasterExecPS: setpagedevice"); - DEBUG_stack(st); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ break; @@ -653,10 +653,9 @@ _cupsRasterExecPS( break; case CUPS_PS_OTHER : - _cupsRasterAddError("Unknown operator \"%s\"!\n", obj->value.other); + _cupsRasterAddError("Unknown operator \"%s\".\n", obj->value.other); error = 1; - DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\"!\n", - obj->value.other)); + DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\".", obj->value.other)); break; } @@ -675,8 +674,8 @@ _cupsRasterExecPS( error_stack(st, "Stack not empty:"); #ifdef DEBUG - DEBUG_puts("_cupsRasterExecPS: Stack not empty:"); - DEBUG_stack(st); + DEBUG_puts("_cupsRasterExecPS: Stack not empty"); + DEBUG_stack("_cupsRasterExecPS", st); #endif /* DEBUG */ delete_stack(st); @@ -977,7 +976,7 @@ roll_stack(_cups_ps_stack_t *st, /* I - Stack */ int n; /* Index into array */ - DEBUG_printf((" roll_stack(st=%p, s=%d, c=%d)\n", st, s, c)); + DEBUG_printf(("3roll_stack(st=%p, s=%d, c=%d)", st, s, c)); /* * Range check input... @@ -1435,7 +1434,7 @@ setpagedevice( * Now pull /name and value pairs from the dictionary... */ - DEBUG_puts("setpagedevice: Dictionary:"); + DEBUG_puts("3setpagedevice: Dictionary:"); for (obj ++; obj < end; obj ++) { @@ -1450,8 +1449,8 @@ setpagedevice( obj ++; #ifdef DEBUG - DEBUG_printf(("setpagedevice: /%s ", name)); - DEBUG_object(obj); + DEBUG_printf(("4setpagedevice: /%s ", name)); + DEBUG_object("setpagedevice", obj); #endif /* DEBUG */ /* @@ -1601,7 +1600,7 @@ setpagedevice( * Ignore unknown name+value... */ - DEBUG_printf((" Unknown name (\"%s\") or value...\n", name)); + DEBUG_printf(("4setpagedevice: Unknown name (\"%s\") or value...\n", name)); while (obj[1].type != CUPS_PS_NAME && obj < end) obj ++; @@ -1618,91 +1617,92 @@ setpagedevice( */ static void -DEBUG_object(_cups_ps_obj_t *obj) /* I - Object to print */ +DEBUG_object(const char *prefix, /* I - Prefix string */ + _cups_ps_obj_t *obj) /* I - Object to print */ { switch (obj->type) { case CUPS_PS_NAME : - DEBUG_printf(("/%s\n", obj->value.name)); + DEBUG_printf(("4%s: /%s\n", prefix, obj->value.name)); break; case CUPS_PS_NUMBER : - DEBUG_printf(("%g\n", obj->value.number)); + DEBUG_printf(("4%s: %g\n", prefix, obj->value.number)); break; case CUPS_PS_STRING : - DEBUG_printf(("(%s)\n", obj->value.string)); + DEBUG_printf(("4%s: (%s)\n", prefix, obj->value.string)); break; case CUPS_PS_BOOLEAN : if (obj->value.boolean) - DEBUG_puts("true"); + DEBUG_printf(("4%s: true", prefix)); else - DEBUG_puts("false"); + DEBUG_printf(("4%s: false", prefix)); break; case CUPS_PS_NULL : - DEBUG_puts("null"); + DEBUG_printf(("4%s: null", prefix)); break; case CUPS_PS_START_ARRAY : - DEBUG_puts("["); + DEBUG_printf(("4%s: [", prefix)); break; case CUPS_PS_END_ARRAY : - DEBUG_puts("]"); + DEBUG_printf(("4%s: ]", prefix)); break; case CUPS_PS_START_DICT : - DEBUG_puts("<<"); + DEBUG_printf(("4%s: <<", prefix)); break; case CUPS_PS_END_DICT : - DEBUG_puts(">>"); + DEBUG_printf(("4%s: >>", prefix)); break; case CUPS_PS_START_PROC : - DEBUG_puts("{"); + DEBUG_printf(("4%s: {", prefix)); break; case CUPS_PS_END_PROC : - DEBUG_puts("}"); + DEBUG_printf(("4%s: }", prefix)); break; case CUPS_PS_CLEARTOMARK : - DEBUG_puts("--cleartomark--"); + DEBUG_printf(("4%s: --cleartomark--", prefix)); break; case CUPS_PS_COPY : - DEBUG_puts("--copy--"); + DEBUG_printf(("4%s: --copy--", prefix)); break; case CUPS_PS_DUP : - DEBUG_puts("--dup--"); + DEBUG_printf(("4%s: --dup--", prefix)); break; case CUPS_PS_INDEX : - DEBUG_puts("--index--"); + DEBUG_printf(("4%s: --index--", prefix)); break; case CUPS_PS_POP : - DEBUG_puts("--pop--"); + DEBUG_printf(("4%s: --pop--", prefix)); break; case CUPS_PS_ROLL : - DEBUG_puts("--roll--"); + DEBUG_printf(("4%s: --roll--", prefix)); break; case CUPS_PS_SETPAGEDEVICE : - DEBUG_puts("--setpagedevice--"); + DEBUG_printf(("4%s: --setpagedevice--", prefix)); break; case CUPS_PS_STOPPED : - DEBUG_puts("--stopped--"); + DEBUG_printf(("4%s: --stopped--", prefix)); break; case CUPS_PS_OTHER : - DEBUG_printf(("--%s--\n", obj->value.other)); + DEBUG_printf(("4%s: --%s--", prefix, obj->value.other)); break; } } @@ -1713,14 +1713,15 @@ DEBUG_object(_cups_ps_obj_t *obj) /* I - Object to print */ */ static void -DEBUG_stack(_cups_ps_stack_t *st) /* I - Stack */ +DEBUG_stack(const char *prefix, /* I - Prefix string */ + _cups_ps_stack_t *st) /* I - Stack */ { int c; /* Looping var */ _cups_ps_obj_t *obj; /* Current object on stack */ for (obj = st->objs, c = st->num_objs; c > 0; c --, obj ++) - DEBUG_object(obj); + DEBUG_object(prefix, obj); } #endif /* DEBUG */ diff --git a/filter/raster.c b/filter/raster.c index 66a0d64a2..ff729a956 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -50,6 +50,9 @@ struct _cups_raster_s /**** Raster stream data ****/ *bufptr, /* Current (read) position in buffer */ *bufend; /* End of current (read) buffer */ size_t bufsize; /* Buffer size */ +#ifdef DEBUG + size_t iocount; /* Number of bytes read/written */ +#endif /* DEBUG */ }; @@ -193,7 +196,7 @@ cupsRasterOpenIO( r->sync == CUPS_RASTER_REVSYNCv2) r->swapped = 1; - DEBUG_printf(("r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync)); + DEBUG_printf(("1cupsRasterOpenIO: r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync)); } else { @@ -944,6 +947,8 @@ cups_raster_read_header( if (r == NULL || r->mode != CUPS_RASTER_READ) return (0); + DEBUG_printf(("4cups_raster_read_header: r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount)); + /* * Get the length of the raster header... */ @@ -963,7 +968,7 @@ cups_raster_read_header( if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len) { - DEBUG_puts("4cups_raster_read_header: EOF"); + DEBUG_printf(("4cups_raster_read_header: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount)); return (0); } @@ -1030,6 +1035,10 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */ return (0); else if (count < 0) return (-1); + +#ifdef DEBUG + r->iocount += (size_t)count; +#endif /* DEBUG */ } return (total); @@ -1060,6 +1069,8 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ */ count = (ssize_t)(2 * r->header.cupsBytesPerLine); + if (count < 65536) + count = 65536; if ((size_t)count > r->bufsize) { @@ -1108,6 +1119,10 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ r->bufptr = r->buffer; r->bufend = r->buffer + remaining; + +#ifdef DEBUG + r->iocount += (size_t)remaining; +#endif /* DEBUG */ } else { @@ -1120,6 +1135,10 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */ if (count <= 0) return (0); +#ifdef DEBUG + r->iocount += (size_t)count; +#endif /* DEBUG */ + continue; } } @@ -1435,7 +1454,12 @@ cups_read_fd(void *ctx, /* I - File descriptor as pointer */ while ((count = read(fd, buf, bytes)) < 0) #endif /* WIN32 */ if (errno != EINTR && errno != EAGAIN) + { + DEBUG_printf(("4cups_read_fd: %s", strerror(errno))); return (-1); + } + + DEBUG_printf(("4cups_read_fd: Returning %d bytes.", (int)count)); return (count); } diff --git a/filter/testraster.c b/filter/testraster.c index efecfddd3..42f377c2f 100644 --- a/filter/testraster.c +++ b/filter/testraster.c @@ -3,7 +3,7 @@ * * Raster test program routines for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the |