<div dir="ltr"><div class="gmail_default" style="color:#000000">Hi Dmitry,</div><div class="gmail_default" style="color:#000000"><br></div><div class="gmail_default" style="color:#000000">Here is my updated patch. Let me know if this is what you had in mind.</div><div class="gmail_default" style="color:#000000"><br></div><div class="gmail_default" style="color:#000000">Regards,</div><div class="gmail_default" style="color:#000000">Shankara<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 23, 2019 at 10:01 AM shankarapailoor <<a href="mailto:shankarapailoor@gmail.com">shankarapailoor@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="color:rgb(0,0,0)">Hi Dmitry,</div><div class="gmail_default" style="color:rgb(0,0,0)"><br></div><div class="gmail_default" style="color:rgb(0,0,0)">Sorry for the late reply but when you say "explicit length" do you mean the long should be printed the same string length regardless of architecture?<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 17, 2019 at 3:42 PM Dmitry V. Levin <<a href="mailto:ldv@altlinux.org" target="_blank">ldv@altlinux.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Sun, Feb 17, 2019 at 12:43:59PM -0600, shankarapailoor wrote:<br>
> Hi,<br>
> <br>
> > I hope you understand that the output produced by your parser<br>
> > is different between big-endian and little-endian architectures.<br>
> <br>
> Yes I understood. How do you think we should decode the sa_mask field under<br>
> XLAT_RAW?<br>
<br>
There seems to be no obvious way of printing sa_mask under XLAT_RAW,<br>
so the question is how to print sa_mask under XLAT_RAW<br>
in the least confusing way.<br>
<br>
Since sa_mask is implemented as an array of target long integers,<br>
what if we printed sa_mask as an array of hexadecimal values with explicit<br>
length, e.g. tprintf("%#0*" PRI_klx, (int) elem_size * 2 + 2, elem_value)?<br>
<br>
> On Fri, Feb 8, 2019 at 1:46 PM Dmitry V. Levin <<a href="mailto:ldv@altlinux.org" target="_blank">ldv@altlinux.org</a>> wrote:<br>
> <br>
> > On Fri, Feb 08, 2019 at 10:32:52PM +0300, Dmitry V. Levin wrote:<br>
> > > Hi,<br>
> > ><br>
> > > On Sat, Jan 05, 2019 at 12:10:38PM -0800, shankarapailoor wrote:<br>
> > > > Hi,<br>
> > > ><br>
> > > > Strace doesn't handle xlat styles properly when decoding the sa_mask<br>
> > > > field of the sigaction struct, Attached is a patch which decodes the<br>
> > > > field as an array of bytes. Let me know what you think!<br>
> > > ><br>
> > > > Regards,<br>
> > > > Shankara Pailoor<br>
> > ><br>
> > > > From 41d7cac5cf000f4e8b6ee675d231038cb786d2e1 Mon Sep 17 00:00:00 2001<br>
> > > > From: Shankara Pailoor <<a href="mailto:shankarapailoor@gmail.com" target="_blank">shankarapailoor@gmail.com</a>><br>
> > > > Date: Sat, 5 Jan 2019 11:49:28 -0800<br>
> > > > Subject: [PATCH v1] properly handle xlat_styles when decoding<br>
> > sigaction mask<br>
> > > ><br>
> > > > * signal.c (sprintsigmask_n): Decode sigaction mask as array of bytes<br>
> > under XLAT_RAW, VERBOSE.<br>
> > > > * tests/printsamask.c: New file.<br>
> > > > * tests/printsamask-Xabbrev.c: Likewise.<br>
> > > > * tests/printsamask-Xraw.c: Likewise.<br>
> > > > * tests/printsamask-Xverbose.c: Likewise.<br>
> > > > * tests/pure_executables.list: Add printsamask-Xabbrev,<br>
> > printsamask-Xraw, printsamask-Xverbose.<br>
> > > > * tests/<a href="http://gen_tests.in" rel="noreferrer" target="_blank">gen_tests.in</a>: Likewise.<br>
> > > > ---<br>
> > > > signal.c | 32 +++++++++++++-<br>
> > > > tests/.gitignore | 3 ++<br>
> > > > tests/<a href="http://gen_tests.in" rel="noreferrer" target="_blank">gen_tests.in</a> | 3 ++<br>
> > > > tests/printsamask-Xabbrev.c | 1 +<br>
> > > > tests/printsamask-Xraw.c | 2 +<br>
> > > > tests/printsamask-Xverbose.c | 2 +<br>
> > > > tests/printsamask.c | 81 ++++++++++++++++++++++++++++++++++++<br>
> > > > tests/pure_executables.list | 3 ++<br>
> > > > 8 files changed, 126 insertions(+), 1 deletion(-)<br>
> > > > create mode 100644 tests/printsamask-Xabbrev.c<br>
> > > > create mode 100644 tests/printsamask-Xraw.c<br>
> > > > create mode 100644 tests/printsamask-Xverbose.c<br>
> > > > create mode 100644 tests/printsamask.c<br>
> > > ><br>
> > > > diff --git a/signal.c b/signal.c<br>
> > > > index 418905f0..e3c5d8c3 100644<br>
> > > > --- a/signal.c<br>
> > > > +++ b/signal.c<br>
> > > > @@ -166,8 +166,11 @@ sprintsigmask_n(const char *prefix, const void<br>
> > *sig_mask, unsigned int bytes)<br>
> > > > * Most of signal names have length 7,<br>
> > > > * average length of signal names is less than 7.<br>
> > > > * The length of prefix string does not exceed 16.<br>
> > > > + * Under xlat_verbose we may have at most NSIG_BYTES in<br>
> > > > + * the raw sa_mask array. We can safely allocate 8 bytes per entry<br>
> > > > */<br>
> > > > - static char outstr[128 + 8 * (NSIG_BYTES * 8 * 2 / 3)];<br>
> > > > + static char outstr[128 + 8 * (NSIG_BYTES * 8 * 2 / 3)<br>
> > > > + + 8 * NSIG_BYTES];<br>
> > > ><br>
> > > > char *s;<br>
> > > > const uint32_t *mask;<br>
> > > > @@ -178,6 +181,29 @@ sprintsigmask_n(const char *prefix, const void<br>
> > *sig_mask, unsigned int bytes)<br>
> > > ><br>
> > > > s = stpcpy(outstr, prefix);<br>
> > > ><br>
> > > > + if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) {<br>
> > > > + const char *mask = (char *) sig_mask;<br>
> > > > + const char *sep = "[";<br>
> > > > + unsigned int i, size;<br>
> > > > +<br>
> > > > + size = (bytes >= NSIG_BYTES) ? NSIG_BYTES : bytes;<br>
> > > > + for (i = 0; i < size; i++) {<br>
> > > > + s = xappendstr(outstr, s, "%s0x%02x", sep,<br>
> > mask[i]);<br>
> > > > + sep = ", ";<br>
> > > > + }<br>
> > ><br>
> > > I hope you understand that the output produced by your parser<br>
> > > is different between big-endian and little-endian architectures.<br>
> > ><br>
> > > [...]<br>
> > > > +int<br>
> > > > +main(void)<br>
> > > > +{<br>
> > > > + unsigned int set_size = NSIG / 8;<br>
> > > > + void *const k_set = tail_alloc(set_size);<br>
> > > > + void *const old_set = tail_alloc(set_size);<br>
> > > > + TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set);<br>
> > > > +<br>
> > > > + memset(k_set, 0, set_size);<br>
> > > > + sigemptyset(libc_set);<br>
> > > > + sigaddset(libc_set, SIGHUP);<br>
> > > > + memcpy(k_set, libc_set, set_size);<br>
> > > > +<br>
> > > > + int rc = k_sigprocmask(SIG_SETMASK, k_set, old_set, set_size);<br>
> > > > +#if XLAT_RAW<br>
> > > > + tprintf("rt_sigprocmask(0x2"<br>
> > > > + ", [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]"<br>
> > > > + ", [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]"<br>
> > > > + ", %u) = %s\n", set_size, sprintrc(rc));<br>
> > > > +#elif XLAT_VERBOSE<br>
> > > > + tprintf("rt_sigprocmask(0x2 /* SIG_SETMASK */"<br>
> > > > + ", [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] /*<br>
> > [HUP] */"<br>
> > > > + ", [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] /* []<br>
> > */, %u) = %s\n",<br>
> > > > + set_size, sprintrc(rc));<br>
> > > > +#else /* XLAT_ABBREV */<br>
> > > > + tprintf("rt_sigprocmask(SIG_SETMASK, [HUP], [], %u) = %s\n",<br>
> > > > + set_size, sprintrc(rc));<br>
> > > > +#endif<br>
> > ><br>
> > > Your test assumes that the output is produced on a big-endian<br>
> ><br>
> > s/big-endian/little-endian/<br>
> ><br>
> > > architecture, so it fails on big-endian architectures.<br>
<br>
<br>
-- <br>
ldv<br>
-- <br>
Strace-devel mailing list<br>
<a href="mailto:Strace-devel@lists.strace.io" target="_blank">Strace-devel@lists.strace.io</a><br>
<a href="https://lists.strace.io/mailman/listinfo/strace-devel" rel="noreferrer" target="_blank">https://lists.strace.io/mailman/listinfo/strace-devel</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail-m_2333666794912986063gmail_signature">Regards,<div>Shankara Pailoor</div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Regards,<div>Shankara Pailoor</div></div>