* Linux Kernel Markers format string idea
@ 2006-12-21 16:20 Mathieu Desnoyers
2006-12-26 19:48 ` Frank Ch. Eigler
0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2006-12-21 16:20 UTC (permalink / raw)
To: Frank Ch. Eigler, ltt-dev, systemtap, linux-sparse
Hi,
First, some context : I created the Linux Kernel Markers as a lightweight
code instrumentation mechanism with which we can connect a probe dynamically.
Type checking is done dynamically by comparing the string in the probe to the
string found at the instrumentation site. If we want to have strong type
checking with this mechanism, all the information used for typing must be in
the format string and validated. Frank showed some concerns about the use of
format strings regarding type checking. Here is a proposal to fix this.
I just had an idea about a format string extension that would help fix the
missing type checking with format strings for Linux Kernel Markers. It would
however imply that we extend the format string standard. One of the goals is
to keep backward compatibility with existing format strings.
The two sample cases I would like to "dynamically type check" are the
following :
- Passing a "struct mystruct *" as an argument.
- Passing a "__be64" as an argument
(typedef as "__u64 __bitwise", where __bitwise is undefined when compiled by
gcc but is defined as __attribute__((bitwise)) when compiled with __CHECKER__
for sparse).
(http://kernel.org/pub/linux/kernel/people/josh/sparse/)
The idea is to add the type between brackets after the conversion specifier.
For a pointer to a structure :
"%p[struct mystruct *]"
For a __be64 :
"%llu[__be64]"
The current format string validation of gcc will not perform more or less
validation than what is actually done, which is to verify that the type is a
pointer or a 64 bytes integer. Printing it through printk will show, for
instance :
0xfffffff[struct mystruct *]
1152921504606846976[__be64]
However, an enhanced format string verificator could check the type of the
pointer and the complete type of the __be64. It could start by being integrated
to the "checker", and only later make its way into gcc.
Comments on this idea are welcome.
Mathieu
--
OpenPGP public key: http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Linux Kernel Markers format string idea
2006-12-21 16:20 Linux Kernel Markers format string idea Mathieu Desnoyers
@ 2006-12-26 19:48 ` Frank Ch. Eigler
0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2006-12-26 19:48 UTC (permalink / raw)
To: Mathieu Desnoyers
Cc: Frank Ch. Eigler, ltt-dev, systemtap, linux-sparse,
michel.dagenais
Hi -
On Thu, Dec 21, 2006 at 11:20:35AM -0500, Mathieu Desnoyers wrote:
> [...] I just had an idea about a format string extension that would
> help fix the missing type checking with format strings for Linux
> Kernel Markers. [...] The idea is to add the type between brackets
> after the conversion specifier. For a pointer to a structure :
> "%p[struct mystruct *]" [...]
It's probably an improvement, though as it is still at the
programmers' discretion, it is less useful for checking and more as
documenting. I remain ambivalent about whether exposing this level of
detail (complex typing) is a good idea, or whether imposing a small
fixed set of types (string/number/blob) is better.
- FChE
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-26 19:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-21 16:20 Linux Kernel Markers format string idea Mathieu Desnoyers
2006-12-26 19:48 ` Frank Ch. Eigler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).