On 12/7/06, Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx> wrote:
Ideally the format string would include the 'pretty print' format for
the post processing tools (e.g. put the strings as literals in a
separate segment and extract them later in the build process. That's not
attractive if we have to parse the strings at run time, though. It could
easily be fixed by pre-processing all source files with M4 or perl, but
I don't think we want to go there.
I should think that parsing the strings at runtime should be pretty
quick -- we don't have to actually make text out of them, we just need
to scan through looking for % tokens, determine the size, and copy to
the trace buffer.
We should be able to make more optimized tracing functions for hot
paths that copy data directly into the trace buffer.
Just for the record, my idea wan't that every single trace record
would have a struct associated with it. I think that for most trace
records, a list of u32 or u64 would work just fine. I was envisioning
a class of functions:
trace_1d(int type, u32 val1);
trace_2d(int type, u32 val1, u32 val2);
/* etc */
trace_nd(int type, int n, ...); /* Take N unsigned longs */
trace_1l(int type, u64 val1);
/* etc */
trace_v(int type, size_t bytes, char *data); /* Take a struct of
size 'bytes' */
The final one would only be used in cases where layout is important,
mainly where space is critical. An advantage of this method is that
we can use sub-byte-sized fields (e.g., 3 bits) and let the compiler
do the work of shifting things around.
If we adopt the format-string model, I suspect that in most cases, no
one is going to worry about bits anyway, but just put up "%d" (which
will probably translate to u32) even for data that only need 3 bits.
If we adopt the format-string model, we need to make sure it's
unambiguous. For instnace, does "%lx" translate to u32 on both 32-
and 64-bit builds? How do I specify u16 and u8? Can I print strings?
Pretty-printing might be nice, but I plan on using the binary format
anyway for my analysis tools, so it's not that big a deal to me.
-George
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|