From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id EEF743858029; Thu, 24 Feb 2022 12:29:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEF743858029 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/linux-tdep: move "Perms" column right X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 11659552768f6b915a6bf5aa98dfb11ba0f004d0 X-Git-Newrev: 0b313e95a73ad567915c9c1135d3d49f39236325 Message-Id: <20220224122934.EEF743858029@sourceware.org> Date: Thu, 24 Feb 2022 12:29:34 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 12:29:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0b313e95a73a= d567915c9c1135d3d49f39236325 commit 0b313e95a73ad567915c9c1135d3d49f39236325 Author: Simon Marchi Date: Wed Feb 23 16:26:17 2022 -0500 gdb/linux-tdep: move "Perms" column right =20 Commit 29ef4c0699e1 ("gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output") has broken test gdb.base/info-proc.exp on Linux, because it changes the output of "info proc mappings" in a way that the test does not expect (my bad for not testing before pushing). =20 I looked at how FreeBSD handles this, since I remembered it did show permission flags. It looks like this: =20 Start Addr End Addr Size Offset Flags = File 0x200000 0x243000 0x43000 0x0 r-- CN--= /usr/local/bin/tmux =20 (I think that `Flags` and the flags not being aligned is not intentional) =20 The test passes on FreeBSD, because the test looks for four hex numbers in a row and ignores the rest: =20 ".*Mapped address spaces:.*${hex}${ws}${hex}${ws}${hex}${ws}${hex}.= *" =20 I suggest fixing it on Linux by moving the flags column to the same place as in the FreeBSD output. It makes things a bit more consistent between OSes, and we don't have to touch the test. =20 At the same time, make use of the actual length of the permission's string to specify the number of characters to print. =20 Before this patch, the output looks like: =20 Start Addr End Addr Perms Size Offset o= bjfile 0x55dd4b544000 0x55dd4b546000 r--p 0x2000 0x0 /= usr/bin/sleep =20 and after, it looks like: =20 Start Addr End Addr Size Offset Perms o= bjfile 0x5622ae662000 0x5622ae664000 0x2000 0x0 r--p /= usr/bin/sleep =20 Change-Id: If0fc167b010b25f97a3c54e2f491df4973ccde8f Diff: --- gdb/linux-tdep.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 83bd4237286..d4868902ac3 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -892,15 +892,15 @@ linux_info_proc (struct gdbarch *gdbarch, const char = *args, printf_filtered (_("Mapped address spaces:\n\n")); if (gdbarch_addr_bit (gdbarch) =3D=3D 32) { - printf_filtered ("\t%10s %10s %7s %10s %10s %s\n", - "Start Addr", " End Addr", "Perms", - " Size", " Offset", "objfile"); + printf_filtered ("\t%10s %10s %10s %10s %s %s\n", + "Start Addr", " End Addr", " Size", + " Offset", "Perms ", "objfile"); } else { - printf_filtered (" %18s %18s %7s %10s %10s %s\n", - "Start Addr", " End Addr", "Perms", - " Size", " Offset", "objfile"); + printf_filtered (" %18s %18s %10s %10s %s %s\n", + "Start Addr", " End Addr", " Size", + " Offset", "Perms ", "objfile"); } =20 char *saveptr; @@ -912,22 +912,24 @@ linux_info_proc (struct gdbarch *gdbarch, const char = *args, =20 if (gdbarch_addr_bit (gdbarch) =3D=3D 32) { - printf_filtered ("\t%10s %10s %7.5s %10s %10s %s\n", + printf_filtered ("\t%10s %10s %10s %10s %-5.*s %s\n", paddress (gdbarch, m.addr), paddress (gdbarch, m.endaddr), - m.permissions.data (), hex_string (m.endaddr - m.addr), hex_string (m.offset), + (int) m.permissions.size (), + m.permissions.data (), m.filename); } else { - printf_filtered (" %18s %18s %7.5s %10s %10s %s\n", + printf_filtered (" %18s %18s %10s %10s %-5.*s %s\n", paddress (gdbarch, m.addr), paddress (gdbarch, m.endaddr), - m.permissions.data (), hex_string (m.endaddr - m.addr), hex_string (m.offset), + (int) m.permissions.size (), + m.permissions.data (), m.filename); } }