This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
output unknown bits in _stp_lookup_or_str
Hi, everyone
We are using _stp_lookup_or_str to translate flags into string now.
When flags include some unknown bits, they are ignored by _stp_lookup_or_str.
For example:
If fork_flags is set to CLONE_CHILD_CLEARTID | 0x00001000, It is translated
into:
"CLONE_CHILD_CLEARTID".
Maybe it is better to show the unknown bits too, For example:
"CLONE_CHILD_CLEARTID|0x00001000".
For the new flags added in latest kernel, I think the best way is to add them
to flag lists in tapset. But for _stp_lookup_or_str() itself, it is better to
show them to user.
This function can be done with following patch.
It will change output of functions that use _stp_lookup_or_str.
I am wondering use it or not. Is there any suggestion?
Signed-off-by: "Zhaolei" zhaolei@cn.fujitsu.com
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp
index 2bd2ced..5fd3440 100644
--- a/tapset/aux_syscalls.stp
+++ b/tapset/aux_syscalls.stp
@@ -1548,7 +1548,7 @@ void _stp_lookup_str(const _stp_val_array * const array, long val, char *ptr, in
}
void _stp_lookup_or_str(const _stp_val_array * const array, long val, char *ptr, int len)
{
- int i = 0, flag = 0;
+ int i = 0, flag = 0, slen;
if (val == 0) {
_stp_lookup_str(array, val, ptr, len);
@@ -1560,13 +1560,16 @@ void _stp_lookup_or_str(const _stp_val_array * const array, long val, char *ptr,
if (flag)
strlcat(ptr, "|", len);
strlcat(ptr, array[i].name, len);
+ val = val & (~array[i].val);
flag = 1;
}
i++;
}
- if (flag == 0) {
- int slen = strlen(ptr);
- _stp_snprintf(ptr + slen, len - slen, "0x%lx", val);
+ if (val) {
+ if (flag)
+ strlcat(ptr, "|", len);
+ slen = strlen(ptr);
+ _stp_snprintf(ptr + slen, len - slen, "0x%lx", val);
}
}
%}
Regards
Zhaolei