Re: Message codes (Re: [Announce] Linux-tiny project revival)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Rob Landley <rob@...>, Gross, Mark <mark.gross@...>
Cc: Alexey Dobriyan <adobriyan@...>, Michael Opdenacker <michael@...>, <linux-tiny@...>, CE Linux Developers List <celinux-dev@...>, linux kernel <linux-kernel@...>
Date: Friday, September 21, 2007 - 9:55 pm

On Fri, Sep 21, 2007 at 04:15:39PM -0500, Rob Landley wrote:
[]

{1} 


I tried to show, that keeping users in compete information vacuum is a
bad thing. Even without sources, _configuration_ makes another area of
mis-working and bugs, usually addressed by reinstalling.

That may be bad example, because here talk is about developers and
testers, who are not just ordinary users. And by applying Torvalds's Law,
all users are such in some degree. That's why {1} in your reply, Rob,
makes perfect sense.

If Mark have a bad experience with lusers only, then i just can say: what
a pity! AFAIK nobody can read somebody's plain-bin OOP output.

Anyway, anything must be opted by config options, even schedulers. But
maintenance and flame wars rule otherwise :).

What i can propose is form of binary-only "printk", where all info:
diagnostic, error, bug, statistics messages (in not debugging
environment, of course), is just fed right to output buffer (see,
pa, no kmallocs). Info itself must have structured content, that makes it
easy to extract and locate human-readable representation of both message
and data.

This doesn't address loglevels, though.

Implementation (seems) as easy as feeding output to `od` to have
unambiguous form of various troublesome bytes, like "0x00" and "0x0A",

Structuring, who is printing, i.e. arch code, fs, driver whatever, must be
agreed:

*  Profiles[0]: originator's ID of a message is a byte (or word, or double word)
   0x01 - arch, 0x02 - fs, 0x03 - net, 0x04 - hw drivers, etc.

*  Data itself can be sent in form of [0]

[0] Banana -- extendable protocol for sending and receiving s-expressions
    http://twistedmatrix.com/projects/core/documentation/specifications/banana.html

and having shell script with functions, that have names that correspond
to actual structured content:
_*_
olecom@flower:/tmp$ sh banana.sh < banana.c >bb
olecom@flower:/tmp$ sh -c '. ./bb ; _07080'
start
olecom@flower:/tmp$ sh -c '. ./bb ; _07081'
ti_startup - product 0000, num configurations 0, configuration value 0
olecom@flower:/tmp$ sh -c '. ./bb ; _07082'
not reached
olecom@flower:/tmp$
olecom@flower:/tmp$ sh -c '. ./bb ; _07081 777 7 8'
ti_startup - product 0x0309, num configurations 7, configuration value 8
olecom@flower:/tmp$

_(banana.c and banana.sh can be found in the ftp /upload on my server)_

From file linux/drivers/usb/serial/ti_usb*c with

[...]
        dbg("%s - product 0x%4X, num configurations %d, configuration value %d",
            __FUNCTION__, le16_to_cpu(dev->descriptor.idProduct),
            dev->descriptor.bNumConfigurations,
            dev->actconfig->desc.bConfigurationValue);
[...]


lets tacke one particular function (transformed a little bit):
_*_

#include <stdio.h>

#define dbg printf
#define ti_startup(foo)				main (int argc, char **argv)
#define dev_descriptor_idProduct		3
#define dev_descriptor_bNumConfigurations	4
#define dev_actconfig_desc_bConfigurationValue	5

/* declaration */
int ti_startup(void);

/* implementation */
int ti_startup(void)
{
	dbg("start\n");

	return dbg("%s - product %#.4x, num configurations %d, "
			"configuration value %d\n",
	__FUNCTION__, dev_descriptor_idProduct,
	dev_descriptor_bNumConfigurations,
	dev_actconfig_desc_bConfigurationValue);

	/* bla bla */
	dbg("not reached\n");
}
_*_

* Process this file with this script: *

_*_

# just as an example
USB_SERIAL_ID=07
TI_USB_ID=08
__FILE__="ti_usb_3410_5052.c" # possible
i=0

sed -n '
# finding function body
/^[[:alpha:]]/{
	# found, print it for __FUNCTION__ keyword
	s_[^ ]* *\([^ (]*\).*[^;]$_\1_p;
	t_func ; b ;
	# walking inside of a function
	:_func;
	# load next string from the input
	n;
	# while not the end of a function
	/^}/{
		# insert delimiter, i.e \n\n is the end of a function
		s_.*_\n_p;
		# go out
		b;
	};
	# find "dbg" (or printk, whatever) inside
	/dbg *(/{
		:_dbg;
		# while not the end of argumet list, i.e ";\n", add other line
		/;$/!{N ; b_dbg}
		# change C to sh
		s_dbg *(_@printf _;
		# clear beginnig of the string
		s_^[^@]*@__;

		# if there is a __FUNCTION__ or __func__ keyword
		/__[Ff]/{
			# NOTE: then first %s in format is replaced with $FUNC
			s_%s_$FUNC_
		}

		# strip "\n\tabs"
		s_\n[[:blank:]]*__g;
		# clear the end, i.e |..."format"/,.*//| or |.."format"/).*//|
		s_"[,)].*_"_;
		# print result
		p;
	}
	b_func;
}'| while read FUNC
do
    printf "_$USB_SERIAL_ID$TI_USB_ID(){
FUNC=$FUNC
}
"
    FUNC=_$USB_SERIAL_ID$TI_USB_ID
    while read -r PRINT
       do test "$PRINT" && printf "$FUNC$i() {
$FUNC
%s "'"$@"'"
}
" "$PRINT"
	  i=$(($i+1))
     done
done
_*_

Now switch on imagination and see how printk just puts
'\007\010\params'

and userspace after some banana `od`dity just calls shell functions.

Yet another thing to export to the userspace. But surely only for those
who whats that.
--
-o--=O`C
 #oo'L O
<___=E M
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[Announce] Linux-tiny project revival, Tim Bird, (Wed Sep 19, 2:03 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 4:38 pm)
Re: [Announce] Linux-tiny project revival, Arnd Bergmann, (Thu Sep 27, 3:00 am)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 27, 8:06 pm)
Re: [Announce] Linux-tiny project revival, Indan Zupancic, (Thu Sep 27, 12:35 pm)
Re: [Announce] Linux-tiny project revival, Arnd Bergmann, (Thu Sep 27, 6:21 pm)
Re: [Announce] Linux-tiny project revival, Bernd Petrovitsch, (Fri Sep 28, 4:39 am)
Re: [Announce] Linux-tiny project revival, Jörn, (Sun Sep 30, 4:37 pm)
Re: [Announce] Linux-tiny project revival, Bill Davidsen, (Fri Sep 21, 8:27 am)
Re: [Announce] Linux-tiny project revival, Tim Bird, (Thu Sep 20, 5:58 pm)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Thu Sep 20, 6:14 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 8:28 pm)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Thu Sep 20, 8:03 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 7:11 pm)
Re: [Announce] Linux-tiny project revival, Indan Zupancic, (Thu Sep 20, 5:26 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 7:18 pm)
Re: [Announce] Linux-tiny project revival, Kyle Moffett, (Fri Sep 21, 5:34 pm)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Fri Sep 21, 6:05 pm)
Re: [Announce] Linux-tiny project revival, Kyle Moffett, (Fri Sep 21, 6:57 pm)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Fri Sep 21, 1:45 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Fri Sep 21, 7:05 pm)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Fri Sep 21, 7:08 pm)
Re: [Announce] Linux-tiny project revival, Indan Zupancic, (Thu Sep 20, 7:06 pm)
Re: [Announce] Linux-tiny project revival, Sam Ravnborg, (Fri Sep 21, 2:29 am)
Re: [Announce] Linux-tiny project revival, Adrian Bunk, (Mon Sep 24, 2:13 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Wed Sep 26, 2:24 am)
Re: [Announce] Linux-tiny project revival, Joe Perches, (Thu Sep 20, 4:16 pm)
Re: [Celinux-dev] Re: [Announce] Linux-tiny project revival, Geert Uytterhoeven, (Tue Sep 25, 7:43 am)
Re: [Announce] Linux-tiny project revival, Alexey Dobriyan, (Thu Sep 20, 3:58 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 6:02 pm)
Re: Message codes (Re: [Announce] Linux-tiny project revival), Oleg Verych, (Fri Sep 21, 9:55 pm)
Re: [Announce] Linux-tiny project revival, Jared Hulbert, (Thu Sep 20, 5:22 pm)
Re: [Announce] Linux-tiny project revival, Rob Landley, (Thu Sep 20, 6:53 pm)
Re: printk proposal - (was Linux-tiny project revival), Alexey Dobriyan, (Fri Sep 21, 3:07 pm)
Re: printk proposal - (was Linux-tiny project revival), Rob Landley, (Fri Sep 21, 4:53 pm)
Re: [Celinux-dev] [Announce] Linux-tiny project revival, Andrew Morton, (Wed Sep 19, 5:28 pm)
Re: [Celinux-dev] [Announce] Linux-tiny project revival, Michael Opdenacker, (Wed Sep 19, 6:38 pm)
Re: [Celinux-dev] [Announce] Linux-tiny project revival, Andy Whitcroft, (Thu Sep 20, 5:10 am)
Re: Monster switch for small size (was Linux-tiny revival), Christian MICHON, (Fri Sep 21, 2:35 am)
Re: [Announce] Linux-tiny project revival, Andi Kleen, (Wed Sep 19, 3:28 pm)
Re: [Announce] Linux-tiny project revival, Tim Bird, (Wed Sep 19, 3:41 pm)
Re: [Announce] Linux-tiny project revival, Tim Bird, (Wed Sep 19, 5:29 pm)
Re: [Announce] Linux-tiny project revival, Michael Opdenacker, (Wed Sep 19, 6:29 pm)
Re: [Announce] Linux-tiny project revival, Christian MICHON, (Wed Sep 19, 3:01 pm)
Re: [Announce] Linux-tiny project revival, Luis R. Rodriguez, (Wed Sep 19, 2:47 pm)
Re: [Announce] Linux-tiny project revival, Tim Bird, (Wed Sep 19, 3:31 pm)