Hi,
Jose R. Santos wrote:
Hi folks,
My team is currently implementing a trace tool using SystemTap that
currently does logging by means of printf mechanism. We want to move to
a binary trace format but there is no such mechanism on SystemTap for
doing this. I've looked at what the folks at Hitachi have done with
BTI, but this seems to force a specific trace format that is not
suitable for what we need. Ideally, the trace format should be left to
the tapset using the interface not the BTI. I propose to slightly alter
the BTI from Hitachi to allow other trace implementations to use the
trace format that's most convenient for the people implementing them.
We had recognized the problems of previous BTI implementation. And we
have developed more generic method called gBTI (generic Binary Transport
Interface) which can be used with current ATI.
gBTI itself uses no formatted structure but an array of long (64bit integer).
It just transports those several binary data from tapset to user daemon. It
works like IP packet envelope.
To support this gBTI, I think, systemtap just introduce only three features below:
1. _stp_binary_write() function in runtime.
2. stpd enhancement to handle binary data correctly.
3. some wrapping functions for user scripts. (i.e. lket_trace(), binary_log(), etc)
So I think supporting gBTI is much easier and simpler than supporting other
method.
1. runtime function
gBTI provides a runtime function called _stp_binary_write() for tapsets.
_stp_binary_write() should be invoked with a number as the first argument and
variable argument lists. In other words, the synopsis is:
void _stp_binary_write(int num, ...);
The "num" argument specifies the number of arguments following this argument.
The type of other variables must be int64_t.
For example, you can use any format of followings;
_stp_binary_write(3, (int64_t)arg1, (int64_t)arg2, (int64_t)arg3);
_stp_binary_write(2, (int64_t)current->pid, (int64_t)current);
_stp_binary_write(5, (int64_t)lkst_header1(), (int64_t)lkst_header2(),
(int64_t)etype, (int64_t)arg1, (int64_t)arg2);
And so on.
The _stp_binary_write() function writes the data as a binary packet into a
relayfs channel which is shared by current ATI. The gBTI also share the
sequential-ID with the ATI by using _stp_seq_inc(). The packet format is
described below.
gBTI packet:
[seq-id][\0][num][arg1][arg2]....[arg(num-1)]
In the other hands, ATI packet is;
[seq-id][string][\0]
(Length of string is greater than 0, this is checked by runtime functions.)
Thus, gBTI can share the channel safely, because if the packet whose first
character of the string is '\0', it is binary data packet.