mq: Properly print mq_flags field
mq_flags field of struct mq_attr can contain only O_NONBLOCK flag (other flags are treated as invalid by mq_getsetattr). Moreover, this field is ignored by mq_open at all (O_NONBLOCK is set via oflag, not via attr attribute). * xlat/mq_attr_flags.in: New file. * print_mq_attr.c: Include xlat/mq_attr_flags.h. (printmqattr): New parameter, bool decode_flags; cast members of struct mq_attr to long long type; use mq_attr_flags xlat for printing mq_flags; print mq_flags as flags only in case decode_flags parameter is set to true. * mq.c (SYS_FUNC(mq_open)): Specify value of false for decode_flags parameter of printmqattr call. (SYS_FUNC(mq_getsetattr)): Specify value of true for decode_flags parameter of printmqattr call. * tests/mq.expected: Update expected output.
This commit is contained in:
parent
0302a3186e
commit
3e22464ec7
6
mq.c
6
mq.c
@ -40,7 +40,7 @@ SYS_FUNC(mq_open)
|
||||
tprints(", ");
|
||||
print_numeric_umode_t(tcp->u_arg[2]);
|
||||
tprints(", ");
|
||||
printmqattr(tcp, tcp->u_arg[3]);
|
||||
printmqattr(tcp, tcp->u_arg[3], false);
|
||||
}
|
||||
return RVAL_DECODED;
|
||||
}
|
||||
@ -84,10 +84,10 @@ SYS_FUNC(mq_getsetattr)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
tprintf("%d, ", (int) tcp->u_arg[0]);
|
||||
printmqattr(tcp, tcp->u_arg[1]);
|
||||
printmqattr(tcp, tcp->u_arg[1], true);
|
||||
tprints(", ");
|
||||
} else {
|
||||
printmqattr(tcp, tcp->u_arg[2]);
|
||||
printmqattr(tcp, tcp->u_arg[2], true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,19 +39,28 @@ typedef struct mq_attr mq_attr_t;
|
||||
typedef struct mq_attr mq_attr_t;
|
||||
#endif
|
||||
|
||||
#include "xlat/mq_attr_flags.h"
|
||||
|
||||
#include MPERS_DEFS
|
||||
|
||||
MPERS_PRINTER_DECL(void, printmqattr, struct tcb *tcp, const long addr)
|
||||
MPERS_PRINTER_DECL(void, printmqattr, struct tcb *tcp, const long addr,
|
||||
bool decode_flags)
|
||||
{
|
||||
#if defined HAVE_MQUEUE_H || defined HAVE_LINUX_MQUEUE_H
|
||||
mq_attr_t attr;
|
||||
if (umove_or_printaddr(tcp, addr, &attr))
|
||||
return;
|
||||
tprints("{mq_flags=");
|
||||
tprint_open_modes(attr.mq_flags);
|
||||
tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsgs=%ld}",
|
||||
(long) attr.mq_maxmsg, (long) attr.mq_msgsize,
|
||||
(long) attr.mq_curmsgs);
|
||||
if (decode_flags)
|
||||
printflags64(mq_attr_flags,
|
||||
zero_extend_signed_to_ull(attr.mq_flags),
|
||||
"/* O_??? */");
|
||||
else
|
||||
tprintf("%#llx", zero_extend_signed_to_ull(attr.mq_flags));
|
||||
tprintf(", mq_maxmsg=%lld, mq_msgsize=%lld, mq_curmsgs=%lld}",
|
||||
sign_extend_unsigned_to_ll(attr.mq_maxmsg),
|
||||
sign_extend_unsigned_to_ll(attr.mq_msgsize),
|
||||
sign_extend_unsigned_to_ll(attr.mq_curmsgs));
|
||||
#else
|
||||
printaddr(addr);
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
mq_open\("strace-mq.test", O_RDONLY\|O_CREAT, 0700, NULL\) += 0
|
||||
mq_getsetattr\(0, NULL, \{mq_flags=O_RDONLY, mq_maxmsg=[1-9][0-9]*, mq_msgsize=[1-9][0-9]*, mq_curmsgs=0\}\) += 0
|
||||
mq_getsetattr\(0, \{mq_flags=O_RDONLY, mq_maxmsg=[1-9][0-9]*, mq_msgsize=[1-9][0-9]*, mq_curmsgs=0\}, NULL\) += 0
|
||||
mq_getsetattr\(0, NULL, \{mq_flags=0, mq_maxmsg=[1-9][0-9]*, mq_msgsize=[1-9][0-9]*, mq_curmsgs=0\}\) += 0
|
||||
mq_getsetattr\(0, \{mq_flags=0, mq_maxmsg=[1-9][0-9]*, mq_msgsize=[1-9][0-9]*, mq_curmsgs=0\}, NULL\) += 0
|
||||
mq_unlink\("strace-mq.test"\) += 0
|
||||
|
1
xlat/mq_attr_flags.in
Normal file
1
xlat/mq_attr_flags.in
Normal file
@ -0,0 +1 @@
|
||||
O_NONBLOCK
|
Loading…
Reference in New Issue
Block a user