Binary output with byte granularity

Mike Mason mmlnx@us.ibm.com
Mon Oct 15 21:07:00 GMT 2007


Frank Ch. Eigler wrote:
> Hi -
> 
>>>> Is there a way in SystemTap to output binary data with byte
>>>> granularity?  [...]
>>> printf ("%1b", value)
>> That prints one byte.  How do I print all the bytes of binary data in a 
>> buffer of arbitrary length?  [...]
> 
> Well, we don't have buffers of arbitrary length in the script
> language, so this issue doesn't arise there.  (But see bug #4706.)
> 
> If the buffer excluded \0, then one could use ordinary %s to format
> it; if we needed a programmable substring length, we could add a "*"
> width specifier as in libc -- printf("%*s", 40, "foo").  Worthwhile?

So would this work to print raw binary data:

function dump_binary (buffer:long, buflen:long)
{
	printf("%*b", buflen, buffer)
}

I don't want it formatted.  I just want the raw data.

Mike

> 
> - FChE



More information about the Systemtap mailing list