This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Binary output with byte granularity


On Mon, 2007-10-15 at 14:06 -0700, Mike Mason wrote:

> So would this work to print raw binary data:
> 
> function dump_binary (buffer:long, buflen:long)
> {
> 	printf("%*b", buflen, buffer)
> }

That should work with minor changes to the runtime printf
and stap.  "*" field width is supported in the runtime but is untested
and doesn't look like it will work as-is with binary output. However,
stap does not recognize the syntax and will reject it.

You want to submit a PR?

For now, this should work:

function dump_binary (num:long, addr:long)
%{
	char *inptr = (char *)(unsigned long)THIS->addr;
        char *ptr = _stp_reserve_bytes(THIS->num);
        if (likely(ptr != NULL))
		memcpy(ptr, inptr, THIS->num);
%}

Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]