binary garbage in kdb md output

Keith Owens kaos at sgi.com
Mon Mar 21 13:08:44 PST 2005


On Mon, 21 Mar 2005 19:52:33 +0100, 
Olaf Hering <olh at suse.de> 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 at suse.de>
>
>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.


More information about the kdb mailing list