[Gs-devel] RE: -Z switchs for debug messages (Re: refine MDRC patch)
Igor V. Melichev
igor at artifex.com
Wed Apr 18 13:21:00 PDT 2001
Dear Mr. Toshiya Suzuki,
> From: mpsuzuki at hiroshima-u.ac.jp
> Sent: 18 ????? 2001 ?. 16:59
> To: igor at artifex.com
> Cc: gs-devel at ghostscript.com; mpsuzuki at hiroshima-u.ac.jp
> Subject: -Z switchs for debug messages (Re: refine MDRC patch)
> But, debug_dump_bytes() is used for detailed dump of memory region
> (print addresses and stored values), and debug_print_string() is
> used to print ASCII string, not suitable for binary data.
I see.
IMHO overloading GS code with low useful functions is
worse than an ugly trace file, but I have no strong preference.
There are 2 ways to resolve :
- use debug_dump_bytes(), or
- code a *private* function, improving your code like this :
private void
gs_dbgprt_b_len(const byte *str, const int length)
{
int i;
if (NULL == str) {
if_debug0('q', "(NULL)");
} else {
for (i = 0 ; i < length ; i++) {
if_debug1('q', "%02x", str[i]);
}
}
}
.....
int
gs_multidim_cmp_range(const byte *str,
const byte *prefix,
const byte *key_lo, const byte *key_hi,
int prefix_size, int key_size)
{
int i;
if (gs_debug_c('q')) {
if_debug0('q', "\n");
if_debug0('q', "[q]gmcr() checks ");
gs_dbgprt_b_len(str, prefix_size + key_size);
if_debug0('q', " in ");
gs_dbgprt_b_len(prefix, prefix_size);
gs_dbgprt_b_len(key_lo, key_size);
if_debug0('q', " - ");
gs_dbgprt_b_len(prefix, prefix_size);
gs_dbgprt_b_len(key_hi, key_size);
if_debug0('q', "\n");
}
Note that I inserted common check for better performance.
> I want a function in the middle of these 2 debugging functions.
> Can I add such function into src/gsmisc.c?
I don't think that we need to change gsmisc.c, since this function is only
useful for one module. We need to keep changes local as possible.
Also I'd suggest renaming gs_dbgprt_b_len with gs_dbgprt_hex_string.
--
Another thing missed from my old remarks : please check which
functions are not exported outside the module and add 'private'
to them (GS defines 'private' macro for 'static' keyword
for better portability).
--
> There's another issue of debug-printing in my MDRC patch
> I have to ask. Now I'm using 'q' as a switch to trace MDRC's
> CMap decoding procedure. According to doc/Use.htm#Debugging,
> it conflicts with the switch to trace clipping, I must change.
Right you are. Thank you for detecting this.
> Taking a glance on the switches listed in Use.html, 'j' looks
> most suitable switch. I will clean unneccessary debug messages
> and rewrite them for 'j'.
OK.
> But, when I developped MDRC patch, the debug messages by 'j'
> were already too many. If there's another switch is available,
> I want to use it. However, it seems that most characters are
> already in-use. There's any plan to extend the switchings of
> debug-printing?
Unfortunately GS has more features that the number of ASCII characters.
We don't have enough characters for each patch. Also extension
of debug key set requires multiple changes to code and manuals,
which we cannot handle in nearest future. We still have lot of
work to be done besides this. The life is so.
I would suggest you to use a visual debugger tool instead
trace output. But I don't know for sure, which platform do
you use, so as I cannot recommend a specific tool.
Usually I work with MS Developer Studio on Windows.
It allows to break C program at any point and view current
values of variables. Using it, trace output is less necessity.
Igor.
More information about the gs-devel
mailing list