summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2022-03-04 16:54:00 +0000
committerRobin Watts <Robin.Watts@artifex.com>2022-03-08 10:42:21 +0000
commit3ba81aa81d256f5a31e89db2dd2aedab46794f6d (patch)
treef2f052f99422778d4a9478a2acb2fa7796142039
parenta9c7640b90bc583e04be7b1eebccd5c07e79c063 (diff)
downloadghostpdl-3ba81aa81d256f5a31e89db2dd2aedab46794f6d.tar.gz
Improve clist debugging output.
Firstly, at various points when writing the clist, we allocate a block (inside cmd_put_bits) under the name of 'end_run'. This is dutifully printed by the debugging code. We then rewrite that block so it's not an end_run at all, but rather something like a set_bits operation (or even 2 operations). The debugging printing is therefore confusing. It would be fairly tricky to neatly (and efficiently) get the printing correct, so we add some new prints to the debugging code, so that rewrites of these 'fake' end_runs are documented. Secondly, we update clist_change_tile to print out the params it reads back (enabling us to easily compare them to the ones printed during the writing phase). Finally, we update a deficiency with the debugging with cmd_read_data. The reading phase calls cmd_read_data to copy data out from the buffered stream into blocks of data (for example, for set_bits). This data is copied first from the buffer that the clist reader holds, but if more data is required than the buffer actually has it, bytes can be pulled direct from the stream itself. Unfortunately, in this latter case, this sidesteps the debug code's attempts to keep a correct record of the offset it has within the file, meaning that it's hard to match reading and writing debug prints up. We fix this here, by calling a function, with the pithy name 'new adjust_offset_map_for_skipped_data'.
-rw-r--r--base/gxclbits.c10
-rw-r--r--base/gxcldev.h1
-rw-r--r--base/gxclrast.c7
-rw-r--r--base/gxclread.c20
-rw-r--r--base/gxclrect.c62
5 files changed, 97 insertions, 3 deletions
diff --git a/base/gxclbits.c b/base/gxclbits.c
index 9fd0990ce..af234c14c 100644
--- a/base/gxclbits.c
+++ b/base/gxclbits.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -711,6 +711,8 @@ clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
if (extra) { /* Write the tile parameters before writing the bits. */
+ if_debug1m('L', cldev->memory,
+ "[L] fake end_run: really set_tile_size[%d]\n", extra);
cmd_store_tile_params(dp, &cldev->tile_params, depth,
extra, for_pattern, cldev->memory);
dp += extra;
@@ -721,6 +723,8 @@ clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (band_index > cldev->tile_known_max)
cldev->tile_known_max = band_index;
}
+ if_debug1m('L', cldev->memory,
+ "[L] fake end_run: really set_tile_bits[%d]\n", csize-extra);
*dp = cmd_count_op(cmd_opv_set_tile_bits, csize - extra, cldev->memory);
dp++;
dp = cmd_put_w(loc.index, dp);
@@ -801,6 +805,8 @@ clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
+ if_debug1m('L', cldev->memory,
+ "[L] fake end_run: really set_bits[%d]\n", csize);
*dp = cmd_count_op(cmd_opv_set_bits, csize, cldev->memory);
dp[1] = (depth << 2) + code;
dp += 2;
@@ -808,6 +814,8 @@ clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
dp = cmd_put_w(loc.tile->height, dp);
dp = cmd_put_w(loc.index, dp);
cmd_put_w(offset, dp);
+ if_debug6m('L', cldev->memory, " compress=%d depth=%d size=(%d,%d) index=%d offset=%d\n",
+ code, depth, loc.tile->width, loc.tile->height, loc.index, offset);
if (bit_pcls == NULL) {
memset(ts_mask(loc.tile), 0xff,
cldev->tile_band_mask_size);
diff --git a/base/gxcldev.h b/base/gxcldev.h
index bab7d9ed3..a14a32e85 100644
--- a/base/gxcldev.h
+++ b/base/gxcldev.h
@@ -871,6 +871,7 @@ int64_t clist_file_offset(const stream_state *st, uint buffer_offset);
void top_up_offset_map(stream_state * st, const byte *buf, const byte *ptr, const byte *end);
void offset_map_next_data_out_of_band(stream_state *st);
void clist_debug_op(gs_memory_t *mem, const unsigned char *op_ptr);
+void adjust_offset_map_for_skipped_data(stream_state *st, uint buffer_offset, uint skipped);
#endif
int clist_writer_push_no_cropping(gx_device_clist_writer *cdev);
diff --git a/base/gxclrast.c b/base/gxclrast.c
index 4fa3d79d1..35e2bcfcf 100644
--- a/base/gxclrast.c
+++ b/base/gxclrast.c
@@ -223,6 +223,13 @@ cmd_read_data(command_buf_t *pcb, byte *ptr, uint rsize, const byte *cbp)
memmove(ptr, cbp, cleft);
sgets(pcb->s, ptr + cleft, rleft, &rleft);
+#ifdef DEBUG
+ {
+ stream_state *st = pcb->s->state;
+
+ adjust_offset_map_for_skipped_data(st, (uint)(pcb->end - pcb->data), rleft);
+ }
+#endif
return pcb->end;
}
}
diff --git a/base/gxclread.c b/base/gxclread.c
index acc50c874..9ea9a7a6d 100644
--- a/base/gxclread.c
+++ b/base/gxclread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -365,6 +365,24 @@ top_up_offset_map(stream_state * st, const byte *buf, const byte *ptr, const byt
}
}
+/* This function is called when data is copied from the stream out into a separate
+ * buffer without going through the usual clist buffers. Essentially data for the
+ * id we are reading at buffer_offset within the buffer is skipped. */
+void adjust_offset_map_for_skipped_data(stream_state *st, uint buffer_offset, uint skipped)
+{
+ uint offset0;
+ stream_band_read_state *const ss = (stream_band_read_state *) st;
+ int i;
+
+ if (!gs_debug_c('L'))
+ return;
+
+ i = buffer_segment_index(ss, buffer_offset, &offset0);
+
+ ss->offset_map[i].buffered -= skipped;
+ ss->offset_map[i].file_offset += skipped;
+}
+
void
offset_map_next_data_out_of_band(stream_state *st)
{
diff --git a/base/gxclrect.c b/base/gxclrect.c
index d3ee98495..ce817ac81 100644
--- a/base/gxclrect.c
+++ b/base/gxclrect.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -890,9 +890,21 @@ copy:{
}
op += compress;
if (dx) {
+ if_debug0m('L', dev->memory,
+ "[L] fake end_run: really set_misc_data_x[2]\n");
*dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
+#ifdef DEBUG
+ if (gs_debug_c('L')) {
+ const char *const *sub = cmd_sub_op_names[op >> 4];
+
+ if (sub)
+ dmlprintf1(dev->memory, "[L] fake end_run: really %s\n", sub[op & 0xf]);
+ else
+ dmlprintf2(dev->memory, "[L] fake end_run: really %s %d\n", cmd_op_names[op >> 4], op & 0xf);
+ }
+#endif
*dp++ = cmd_count_op(op, csize, dev->memory);
/* Store the plane_height */
cmd_putw(0, &dp);
@@ -1012,9 +1024,21 @@ clist_copy_planes(gx_device * dev,
* cmd_put_bits fill the buffer up. */
dp2 = dp;
if (dx) {
+ if_debug0m('L', cdev->memory,
+ "[L] fake end_run: really set_misc_data_x[2]\n");
*dp2++ = cmd_count_op(cmd_opv_set_misc, 2, cdev->memory);
*dp2++ = cmd_set_misc_data_x + dx;
}
+#ifdef DEBUG
+ if (gs_debug_c('L')) {
+ const char *const *sub = cmd_sub_op_names[(op+code) >> 4];
+
+ if (sub)
+ dmlprintf1(cdev->memory, "[L] fake end_run: really %s\n", sub[(op+code) & 0xf]);
+ else
+ dmlprintf2(cdev->memory, "[L] fake end_run: really %s %d\n", cmd_op_names[(op+code) >> 4], (op+code) & 0xf);
+ }
+#endif
*dp2++ = cmd_count_op(op + code, csize, cdev->memory);
cmd_putw(plane_height, &dp2);
cmd_put2w(rx, re.y, &dp2);
@@ -1144,9 +1168,21 @@ copy:{
}
op += compress;
if (dx) {
+ if_debug0m('L', dev->memory,
+ "[L] fake end_run: really set_misc_data_x[2]\n");
*dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
+#ifdef DEBUG
+ if (gs_debug_c('L')) {
+ const char *const *sub = cmd_sub_op_names[op >> 4];
+
+ if (sub)
+ dmlprintf1(dev->memory, "[L] fake end_run: really %s\n", sub[op & 0xf]);
+ else
+ dmlprintf2(dev->memory, "[L] fake end_run: really %s %d\n", cmd_op_names[op >> 4], op & 0xf);
+ }
+#endif
*dp++ = cmd_count_op(op, csize, dev->memory);
cmd_put2w(rx, re.y, &dp);
cmd_put2w(w1, re.height, &dp);
@@ -1273,9 +1309,21 @@ copy:{
}
op += compress;
if (dx) {
+ if_debug0m('L', dev->memory,
+ "[L] fake end_run: really set_misc_data_x[2]\n");
*dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
+#ifdef DEBUG
+ if (gs_debug_c('L')) {
+ const char *const *sub = cmd_sub_op_names[op >> 4];
+
+ if (sub)
+ dmlprintf1(dev->memory, "[L] fake end_run: really %s\n", sub[op & 0xf]);
+ else
+ dmlprintf2(dev->memory, "[L] fake end_run: really %s %d\n", cmd_op_names[op >> 4], op & 0xf);
+ }
+#endif
*dp++ = cmd_count_op(op, csize, dev->memory);
*dp++ = depth;
cmd_put2w(rx, re.y, &dp);
@@ -1403,9 +1451,21 @@ copy:{
}
op += compress;
if (dx) {
+ if_debug0m('L', dev->memory,
+ "[L] fake end_run: really set_misc_data_x[2]\n");
*dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
+#ifdef DEBUG
+ if (gs_debug_c('L')) {
+ const char *const *sub = cmd_sub_op_names[op >> 4];
+
+ if (sub)
+ dmlprintf1(dev->memory, "[L] fake end_run: really %s\n", sub[op & 0xf]);
+ else
+ dmlprintf2(dev->memory, "[L] fake end_run: really %s %d\n", cmd_op_names[op >> 4], op & 0xf);
+ }
+#endif
*dp++ = cmd_count_op(op, csize, dev->memory);
*dp++ = depth;
cmd_put2w(rx, re.y, &dp);