Hi again,

Just an update (no patch yet).  Thanks for the advice.

 $ git clone git://git.ghostscript.com/ghostscript.git
 $ cd ghostscript/gs
 $ git apply debug-lx5000.patch
 $ autoreconf -fis
 $ ./configure
 $ make

| $ bin/gs -dSAFER -sDEVICE=lx5000 -sOutputFile=/dev/null /tmp/mozilla.ps
| GPL Ghostscript SVN PRE-RELEASE 9.01 (2010-09-14)
| Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
| This software comes with NO WARRANTY: see the file PUBLIC for details.
| Loading NimbusRomNo9L-Regu font from %rom%Resource/Font/NimbusRomNo9L-Regu... 
2592440 1272826 8750092 7452670 1 done
[...]
| Loading StandardSymL font from %rom%Resource/Font/StandardSymL... 3878968 
2514682 8850572 7498285 1 done.
| trace: refresh buffer, 4 colors.
| trace: color 0, pen 0: line 6663
| trace: color 1, pen 0: line 6663
| trace: color 2, pen 0: line 6663
| trace: color 3, pen 0: line 6663
| trace: first printable line: 6663
| trace: next line to get: 0
| trace: color 0: line 32
| trace: done getting lines.  next line to get: 288

A good start.

| trace: refresh buffer, 4 colors.
| trace: color 0, pen 0: line 32
| trace: color 1, pen 0: line 6663
| trace: color 2, pen 0: line 32
| trace: color 3, pen 0: line 32
| trace: first printable line: 32
| trace: next line to get: 288
| trace: done getting lines.  next line to get: 288

First line after margin: 32.  Three colors to print.

[...]
Some boring parts. ;-)
[...]

| trace: refresh buffer, 4 colors.
| trace: color 0, pen 0: line 6517
| trace: color 1, pen 0: line 6663
| trace: color 2, pen 0: line 6663
| trace: color 3, pen 0: line 6517
| trace: first printable line: 6517
| trace: next line to get: 6773
| trace: done getting lines.  next line to get: 6773

6773 > 6663.

> trace: refresh buffer, 4 colors.
> trace: color 0, pen 0: line 6517
> trace: color 1, pen 0: line 6663
> trace: color 2, pen 0: line 6663
> trace: color 3, pen 0: line 6551
> trace: first printable line: 6517
> trace: next line to get: 6773
> trace: done getting lines.  next line to get: 6773

And we loop on this state.

The next line to _print_ is 6517 (presumably less than pdev->height)
but the next line to get is greater than that.  The driver writes
empty swipes for some reason and hangs.

Jonathan
Date: Sat, 22 Jan 2011 15:34:13 -0600
Subject: lx5000: add some debugging printfs

---
 gs/contrib/gdevlx50.c |   65 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/gs/contrib/gdevlx50.c b/gs/contrib/gdevlx50.c
index 9d6b7da..154d780 100644
--- a/gs/contrib/gdevlx50.c
+++ b/gs/contrib/gdevlx50.c
@@ -228,11 +228,23 @@
  *                     I N C L U D E   F I L E S                       *
  ************************************************************************/
 #include "std.h"
+#include <stdarg.h>
 #include <unistd.h>
 #include "gdevprn.h"
 #include "gsparam.h"
 #include "gsmalloc.h"
 
+#undef stderr
+static void trace_printf(const char *fmt, ...)
+{
+       va_list params;
+
+       va_start(params, fmt);
+       vfprintf(stderr, fmt, params);
+       va_end(params);
+}
+#define stderr gs_stderr
+
 /************************************************************************
  *                  R C S   I D E N T   S T R I N G S                  *
  ************************************************************************/
@@ -1367,17 +1379,26 @@ refreshBuffer( lx5000_device *lx5000dev,
     int                _1stPrintable;  /* Across all pens */
     int                numColours = lx5000dev->color_info.num_components;
 
+    trace_printf("trace: refresh buffer, %d colors.\n", numColours);
+
                                /* Establish the next line to print, if it
                                   is already in the buffer.            */
     _1stPrintable              = pens[YELLOW_X][LO_PEN].finalLine;
     for ( colour = 0; colour < numColours; colour++ )
     {
        for ( pen = 0; pen < lx5000dev->pensPerColour; pen++ )
-           if ( pens[ colour ][ pen ].nextPrintLine < _1stPrintable)
-               _1stPrintable = pens[ colour ][ pen ].nextPrintLine;
+       {
+           int line = pens[ colour ][ pen ].nextPrintLine;
+           trace_printf("trace: color %d, pen %d: line %d\n",
+                        colour, pen, line);
+           if ( line < _1stPrintable)
+               _1stPrintable = line;
+       }
     }
+    trace_printf("trace: first printable line: %d\n", _1stPrintable);
     *nextLineToPrint = _1stPrintable;
 
+    trace_printf("trace: next line to get: %d\n", *nextLineToGet);
     nextToGet = (uchar)(*nextLineToGet & COLOUR_BUF_MASK);
                                /* nextLineToPrint may be set high (i.e. not
                                   known), or may be a known print line. */
@@ -1429,6 +1450,9 @@ refreshBuffer( lx5000_device *lx5000dev,
                                   the lower pen. */
            if ( ! lineEmpty[colour][nextToGet] )
            {
+               if ( *nextLineToPrint > *nextLineToGet )
+                   trace_printf("trace: color %d: line %d\n",
+                                       colour, *nextLineToGet);
                if ( pens[colour][LO_PEN].nextPrintLine > *nextLineToGet )
                    pens[colour][LO_PEN].nextPrintLine = *nextLineToGet;
                if ( *nextLineToPrint > *nextLineToGet )
@@ -1440,25 +1464,32 @@ refreshBuffer( lx5000_device *lx5000dev,
                                   than just doing the increment, in case the
                                   buffer length changes.               */
     }
+    trace_printf("trace: done getting lines.  next line to get: %d\n", 
*nextLineToGet);
+
                                /* Check that no buffer padding is necessary */
     if ( *nextLineToPrint < lx5000dev->height )
     {
-       while ( ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
-       {                       /* Last refresh fell short of COLOUR_BUF_LINES
-                                  because last line of page was reached.
-                                  Pad the buffer to COLOUR_BUF_LINES with 0
-                                          (no print) bytes.  */
-           for ( colour = 0; colour < numColours; colour++ )
-           {                   /* Fill the colour line buffer, incl pad */
-               memset( colourBufs[colour]
-                       + ( lx5000dev->penLineLen * nextToGet ),
-                       0, lx5000dev->penLineLen );
-                               /* Set empty indicator - note that firstBit
-                                  is NOT set here. */
-               lineEmpty[colour][nextToGet] = true;
+       if ( ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
+       {
+           while ( ( *nextLineToGet - *nextLineToPrint ) < COLOUR_BUF_LINES )
+           {                   /* Last refresh fell short of COLOUR_BUF_LINES
+                                      because last line of page was reached.
+                                      Pad the buffer to COLOUR_BUF_LINES with 0
+                                              (no print) bytes.  */
+               for ( colour = 0; colour < numColours; colour++ )
+               {                       /* Fill the colour line buffer, incl 
pad */
+                   memset( colourBufs[colour]
+                           + ( lx5000dev->penLineLen * nextToGet ),
+                           0, lx5000dev->penLineLen );
+                                   /* Set empty indicator - note that firstBit
+                                      is NOT set here. */
+                   lineEmpty[colour][nextToGet] = true;
+               }
+               ++*nextLineToGet;
+               nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK );
            }
-           ++*nextLineToGet;
-           nextToGet = ( *nextLineToGet & COLOUR_BUF_MASK );
+           trace_printf("trace: buffer padding needed. next line to get: %d\n",
+                               *nextLineToGet);
        }
     }
 }
-- 
1.7.4.rc2

Reply via email to