kdb
[Top] [All Lists]

Re: binary garbage in kdb md output

To: Olaf Hering <olh@xxxxxxx>
Subject: Re: binary garbage in kdb md output
From: Keith Owens <kaos@xxxxxxx>
Date: Tue, 22 Mar 2005 08:08:44 +1100
Cc: kdb@xxxxxxxxxxx
In-reply-to: Your message of "Mon, 21 Mar 2005 19:52:33 BST." <20050321185233.GA7525@xxxxxxx>
Sender: kdb-bounce@xxxxxxxxxxx
On Mon, 21 Mar 2005 19:52:33 +0100, 
Olaf Hering <olh@xxxxxxx> wrote:
>Keith,
>
>what do you see with this testapp? I get an ugly dotted square, which
>usually confuses copy&paste into a bugzilla. Also the mirroring between
>various bugzilla screws it up even more. All output should be either
>plain ASCII or UTF-8. I'm sure kdb should not care about any locale
>other than ASCII, so its better to just mask the non-printable bytes.
>
>#include <stdio.h>
>int main(void)
>{
>        unsigned char buf[2];
>        buf[0] = 0xc0;
>        buf[1] = '\0';
>        printf("%s\n", buf);
>        return 0;
>}
>
>
>
>
>The kernel considers 0xc0-0xff as printable chars, this leads to
>binary garbage. Just mask it to ASCII.
>
>Signed-off-by: Olaf Hering <olh@xxxxxxx>
>
>Index: linux-2.6.5/kdb/kdbmain.c
>===================================================================
>--- linux-2.6.5.orig/kdb/kdbmain.c
>+++ linux-2.6.5/kdb/kdbmain.c
>@@ -2091,7 +2091,7 @@ kdb_md_line(const char *fmtstr, kdb_mach
>                       cp = wc.c;
> #endif
>                       wc.word = word;
>-#define printable_char(c) ({unsigned char __c = c; isprint(__c) ? __c : '.';})
>+#define printable_char(c) ({unsigned char __c = toascii(c); isalnum(__c) ? 
>__c : '.';})
>                       switch (bytesperword) {
>                       case 8:
>                               *c++ = printable_char(*cp++);
>

A better question is why the kernel considers characters above 0x80 to
be printable.  kdb, like other parts of the kernel, uses the standard
function isprint().  I can change kdb to do 'isascii(c) && isprint(c)'
which will restrict kdb to characters below 0x80, but the rest of the
kernel will still treat characters above 0x80 as printable.

---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.
<Prev in Thread] Current Thread [Next in Thread>