When generating functions to print the arguments of system calls with

bitwise parameters (e.g. mmap), print the syscall parameter value first.
The resulting output looks like the %b specifier of printf(9).

Before:
mmap(0,0x8000,PROT_READ|PROT_WRITE,...
After:
mmap(0,0x8000,0x3<PROT_READ|PROT_WRITE>,...

Submitted by:	Norberto Lopes <nlopes.ml at gmail.com>
Idea from:	freebsd-arch/2006-April/005116.html
This commit is contained in:
Rui Paulo 2010-09-16 11:33:31 +00:00
parent 13e86ef7ee
commit 836450ab23
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,7 @@ void
$name (int arg)
{
int or = 0;
printf("%#x<", arg);
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
$include_dir/$file | \
@ -58,6 +59,7 @@ _EOF_
++i; \
printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
cat <<_EOF_
printf(">");
if (or == 0)
(void)printf("<invalid>%ld", (long)arg);
}
@ -432,6 +434,8 @@ sendrecvflagsname (int flags)
(void)printf("0");
return;
}
printf("%#x<", flags);
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+MSG_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \
awk '{ for (i = 1; i <= NF; i++) \
@ -440,6 +444,7 @@ egrep "^#[[:space:]]*define[[:space:]]+MSG_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]
++i; \
printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
cat <<_EOF_
printf(">");
}
_EOF_