public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output
@ 2022-02-22 23:43 Disconnect3d
  2022-02-23 14:09 ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Disconnect3d @ 2022-02-22 23:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Disconnect3d

Fixes #28914 and so it adds a 'Perms' (permissions) column to the
'info proc mappings' command output. This will allow users to know
the memory pages permissions right away from GDB instead of having
to fetch them from the /proc/$pid/maps file (which is also what GDB
does internally, but it just did not print that column).

Below I am also showing how an example output looks like before and
after this commit in case someone wonders.

On i386 targets - before this commit:
```
(gdb) info proc mappings
process 3461464
Mapped address spaces:

    Start Addr   End Addr        Size     Offset objfile
    0x56555000 0x56556000      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
    0x56556000 0x56557000      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
    0x56557000 0x56558000      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
    0x56558000 0x5655a000      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
    0xf7fc4000 0xf7fc8000      0x4000        0x0 [vvar]
    0xf7fc8000 0xf7fca000      0x2000        0x0 [vdso]
    0xf7fca000 0xf7fcb000      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7fcb000 0xf7fee000     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7fee000 0xf7ffb000      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7ffb000 0xf7ffe000      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xfffdc000 0xffffe000     0x22000        0x0 [stack]
(gdb)
```

On i386 targets - after this commit:
```
(gdb) info proc mappings
process 3461464
Mapped address spaces:

    Start Addr   End Addr   Perms       Size     Offset objfile
    0x56555000 0x56556000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
    0x56556000 0x56557000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
    0x56557000 0x56558000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
    0x56558000 0x5655a000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
    0xf7fc4000 0xf7fc8000   r--p      0x4000        0x0 [vvar]
    0xf7fc8000 0xf7fca000   r-xp      0x2000        0x0 [vdso]
    0xf7fca000 0xf7fcb000   r--p      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7fcb000 0xf7fee000   r-xp     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7fee000 0xf7ffb000   r--p      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xf7ffb000 0xf7ffe000   rw-p      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
    0xfffdc000 0xffffe000   rw-p     0x22000        0x0 [stack]
(gdb)
```

On amd64 targets - after this commit:
```
(gdb) info proc mappings
process 3461869
Mapped address spaces:

          Start Addr           End Addr   Perms       Size     Offset objfile
      0x555555554000     0x555555555000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
      0x555555555000     0x555555556000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
      0x555555556000     0x555555557000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
      0x555555557000     0x555555559000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
      0x7ffff7fc3000     0x7ffff7fc7000   r--p      0x4000        0x0 [vvar]
      0x7ffff7fc7000     0x7ffff7fc9000   r-xp      0x2000        0x0 [vdso]
      0x7ffff7fc9000     0x7ffff7fca000   r--p      0x1000        0x0 /usr/lib/x86_64-linux-gnu/ld-2.33.so
      0x7ffff7fca000     0x7ffff7ff1000   r-xp     0x27000     0x1000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
      0x7ffff7ff1000     0x7ffff7ffb000   r--p      0xa000    0x28000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
      0x7ffff7ffb000     0x7ffff7fff000   rw-p      0x4000    0x31000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
      0x7ffffffdd000     0x7ffffffff000   rw-p     0x22000        0x0 [stack]
  0xffffffffff600000 0xffffffffff601000   --xp      0x1000        0x0 [vsyscall]
(gdb)
```

Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
---
 ChangeLog        |  6 ++++++
 gdb/linux-tdep.c | 16 ++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 18e8b6835da..c7b723fc8c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-01-23 Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
+
+	gdb: extend the 'info proc mappings' command output with 'Perms' column
+	that display the memory maps permissions as taken from /proc/$pid/maps
+	file.
+
 2022-01-22  Nick Clifton  <nickc@redhat.com>
 
 	* 2.38 release branch created.
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 1b48b7fef25..060f60e753a 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -879,16 +879,14 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
 	  printf_filtered (_("Mapped address spaces:\n\n"));
 	  if (gdbarch_addr_bit (gdbarch) == 32)
 	    {
-	      printf_filtered ("\t%10s %10s %10s %10s %s\n",
-			   "Start Addr",
-			   "  End Addr",
+	      printf_filtered ("\t%10s %10s %7s %10s %10s %s\n",
+			   "Start Addr", "  End Addr", "Perms",
 			   "      Size", "    Offset", "objfile");
 	    }
 	  else
 	    {
-	      printf_filtered ("  %18s %18s %10s %10s %s\n",
-			   "Start Addr",
-			   "  End Addr",
+	      printf_filtered ("  %18s %18s %7s %10s %10s %s\n",
+			   "Start Addr", "  End Addr", "Perms",
 			   "      Size", "    Offset", "objfile");
 	    }
 
@@ -908,18 +906,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
 
 	      if (gdbarch_addr_bit (gdbarch) == 32)
 		{
-		  printf_filtered ("\t%10s %10s %10s %10s %s\n",
+		  printf_filtered ("\t%10s %10s %7.5s %10s %10s %s\n",
 				   paddress (gdbarch, addr),
 				   paddress (gdbarch, endaddr),
+				   permissions,
 				   hex_string (endaddr - addr),
 				   hex_string (offset),
 				   *mapping_filename ? mapping_filename : "");
 		}
 	      else
 		{
-		  printf_filtered ("  %18s %18s %10s %10s %s\n",
+		  printf_filtered ("  %18s %18s %7.5s %10s %10s %s\n",
 				   paddress (gdbarch, addr),
 				   paddress (gdbarch, endaddr),
+				   permissions,
 				   hex_string (endaddr - addr),
 				   hex_string (offset),
 				   *mapping_filename ? mapping_filename : "");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output
  2022-02-22 23:43 [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output Disconnect3d
@ 2022-02-23 14:09 ` Simon Marchi
  2022-02-23 21:27   ` Simon Marchi
  2022-02-23 21:27   ` Simon Marchi
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Marchi @ 2022-02-23 14:09 UTC (permalink / raw)
  To: Disconnect3d, gdb-patches

On 2022-02-22 18:43, Disconnect3d via Gdb-patches wrote:
> Fixes #28914 and so it adds a 'Perms' (permissions) column to the
> 'info proc mappings' command output. This will allow users to know
> the memory pages permissions right away from GDB instead of having
> to fetch them from the /proc/$pid/maps file (which is also what GDB
> does internally, but it just did not print that column).
> 
> Below I am also showing how an example output looks like before and
> after this commit in case someone wonders.
> 
> On i386 targets - before this commit:
> ```
> (gdb) info proc mappings
> process 3461464
> Mapped address spaces:
> 
>     Start Addr   End Addr        Size     Offset objfile
>     0x56555000 0x56556000      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>     0x56556000 0x56557000      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>     0x56557000 0x56558000      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>     0x56558000 0x5655a000      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>     0xf7fc4000 0xf7fc8000      0x4000        0x0 [vvar]
>     0xf7fc8000 0xf7fca000      0x2000        0x0 [vdso]
>     0xf7fca000 0xf7fcb000      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7fcb000 0xf7fee000     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7fee000 0xf7ffb000      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7ffb000 0xf7ffe000      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xfffdc000 0xffffe000     0x22000        0x0 [stack]
> (gdb)
> ```
> 
> On i386 targets - after this commit:
> ```
> (gdb) info proc mappings
> process 3461464
> Mapped address spaces:
> 
>     Start Addr   End Addr   Perms       Size     Offset objfile
>     0x56555000 0x56556000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>     0x56556000 0x56557000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>     0x56557000 0x56558000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>     0x56558000 0x5655a000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>     0xf7fc4000 0xf7fc8000   r--p      0x4000        0x0 [vvar]
>     0xf7fc8000 0xf7fca000   r-xp      0x2000        0x0 [vdso]
>     0xf7fca000 0xf7fcb000   r--p      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7fcb000 0xf7fee000   r-xp     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7fee000 0xf7ffb000   r--p      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xf7ffb000 0xf7ffe000   rw-p      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>     0xfffdc000 0xffffe000   rw-p     0x22000        0x0 [stack]
> (gdb)
> ```
> 
> On amd64 targets - after this commit:
> ```
> (gdb) info proc mappings
> process 3461869
> Mapped address spaces:
> 
>           Start Addr           End Addr   Perms       Size     Offset objfile
>       0x555555554000     0x555555555000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>       0x555555555000     0x555555556000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>       0x555555556000     0x555555557000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>       0x555555557000     0x555555559000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>       0x7ffff7fc3000     0x7ffff7fc7000   r--p      0x4000        0x0 [vvar]
>       0x7ffff7fc7000     0x7ffff7fc9000   r-xp      0x2000        0x0 [vdso]
>       0x7ffff7fc9000     0x7ffff7fca000   r--p      0x1000        0x0 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>       0x7ffff7fca000     0x7ffff7ff1000   r-xp     0x27000     0x1000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>       0x7ffff7ff1000     0x7ffff7ffb000   r--p      0xa000    0x28000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>       0x7ffff7ffb000     0x7ffff7fff000   rw-p      0x4000    0x31000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>       0x7ffffffdd000     0x7ffffffff000   rw-p     0x22000        0x0 [stack]
>   0xffffffffff600000 0xffffffffff601000   --xp      0x1000        0x0 [vsyscall]
> (gdb)
> ```
> 
> Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>

Thanks for the great commit message.

> ---
>  ChangeLog        |  6 ++++++
>  gdb/linux-tdep.c | 16 ++++++++--------
>  2 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 18e8b6835da..c7b723fc8c9 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2022-01-23 Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
> +
> +	gdb: extend the 'info proc mappings' command output with 'Perms' column
> +	that display the memory maps permissions as taken from /proc/$pid/maps
> +	file.
> +
>  2022-01-22  Nick Clifton  <nickc@redhat.com>
>  
>  	* 2.38 release branch created.
> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
> index 1b48b7fef25..060f60e753a 100644
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -879,16 +879,14 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>  	  printf_filtered (_("Mapped address spaces:\n\n"));
>  	  if (gdbarch_addr_bit (gdbarch) == 32)
>  	    {
> -	      printf_filtered ("\t%10s %10s %10s %10s %s\n",
> -			   "Start Addr",
> -			   "  End Addr",
> +	      printf_filtered ("\t%10s %10s %7s %10s %10s %s\n",
> +			   "Start Addr", "  End Addr", "Perms",
>  			   "      Size", "    Offset", "objfile");
>  	    }
>  	  else
>  	    {
> -	      printf_filtered ("  %18s %18s %10s %10s %s\n",
> -			   "Start Addr",
> -			   "  End Addr",
> +	      printf_filtered ("  %18s %18s %7s %10s %10s %s\n",
> +			   "Start Addr", "  End Addr", "Perms",
>  			   "      Size", "    Offset", "objfile");
>  	    }
>  
> @@ -908,18 +906,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>  
>  	      if (gdbarch_addr_bit (gdbarch) == 32)
>  		{
> -		  printf_filtered ("\t%10s %10s %10s %10s %s\n",
> +		  printf_filtered ("\t%10s %10s %7.5s %10s %10s %s\n",
>  				   paddress (gdbarch, addr),
>  				   paddress (gdbarch, endaddr),
> +				   permissions,
>  				   hex_string (endaddr - addr),
>  				   hex_string (offset),
>  				   *mapping_filename ? mapping_filename : "");
>  		}
>  	      else
>  		{
> -		  printf_filtered ("  %18s %18s %10s %10s %s\n",
> +		  printf_filtered ("  %18s %18s %7.5s %10s %10s %s\n",
>  				   paddress (gdbarch, addr),
>  				   paddress (gdbarch, endaddr),
> +				   permissions,
>  				   hex_string (endaddr - addr),
>  				   hex_string (offset),
>  				   *mapping_filename ? mapping_filename : "");

This is ok, I will push the patch.  Note that GDB does not use
ChangeLogs anymore, so I will strip this part (previously, this would
have gone in gdb/ChangeLog).

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output
  2022-02-23 14:09 ` Simon Marchi
@ 2022-02-23 21:27   ` Simon Marchi
  2022-02-23 21:27   ` Simon Marchi
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2022-02-23 21:27 UTC (permalink / raw)
  To: Disconnect3d, gdb-patches

So, this patch broke the test gdb.base/info-proc.exp, this patch fixes it:


On 2022-02-23 09:09, Simon Marchi via Gdb-patches wrote:
> On 2022-02-22 18:43, Disconnect3d via Gdb-patches wrote:
>> Fixes #28914 and so it adds a 'Perms' (permissions) column to the
>> 'info proc mappings' command output. This will allow users to know
>> the memory pages permissions right away from GDB instead of having
>> to fetch them from the /proc/$pid/maps file (which is also what GDB
>> does internally, but it just did not print that column).
>>
>> Below I am also showing how an example output looks like before and
>> after this commit in case someone wonders.
>>
>> On i386 targets - before this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461464
>> Mapped address spaces:
>>
>>     Start Addr   End Addr        Size     Offset objfile
>>     0x56555000 0x56556000      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>     0x56556000 0x56557000      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56557000 0x56558000      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56558000 0x5655a000      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0xf7fc4000 0xf7fc8000      0x4000        0x0 [vvar]
>>     0xf7fc8000 0xf7fca000      0x2000        0x0 [vdso]
>>     0xf7fca000 0xf7fcb000      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fcb000 0xf7fee000     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fee000 0xf7ffb000      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7ffb000 0xf7ffe000      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xfffdc000 0xffffe000     0x22000        0x0 [stack]
>> (gdb)
>> ```
>>
>> On i386 targets - after this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461464
>> Mapped address spaces:
>>
>>     Start Addr   End Addr   Perms       Size     Offset objfile
>>     0x56555000 0x56556000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>     0x56556000 0x56557000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56557000 0x56558000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56558000 0x5655a000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0xf7fc4000 0xf7fc8000   r--p      0x4000        0x0 [vvar]
>>     0xf7fc8000 0xf7fca000   r-xp      0x2000        0x0 [vdso]
>>     0xf7fca000 0xf7fcb000   r--p      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fcb000 0xf7fee000   r-xp     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fee000 0xf7ffb000   r--p      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7ffb000 0xf7ffe000   rw-p      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xfffdc000 0xffffe000   rw-p     0x22000        0x0 [stack]
>> (gdb)
>> ```
>>
>> On amd64 targets - after this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461869
>> Mapped address spaces:
>>
>>           Start Addr           End Addr   Perms       Size     Offset objfile
>>       0x555555554000     0x555555555000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555555000     0x555555556000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555556000     0x555555557000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555557000     0x555555559000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>       0x7ffff7fc3000     0x7ffff7fc7000   r--p      0x4000        0x0 [vvar]
>>       0x7ffff7fc7000     0x7ffff7fc9000   r-xp      0x2000        0x0 [vdso]
>>       0x7ffff7fc9000     0x7ffff7fca000   r--p      0x1000        0x0 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7fca000     0x7ffff7ff1000   r-xp     0x27000     0x1000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7ff1000     0x7ffff7ffb000   r--p      0xa000    0x28000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7ffb000     0x7ffff7fff000   rw-p      0x4000    0x31000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffffffdd000     0x7ffffffff000   rw-p     0x22000        0x0 [stack]
>>   0xffffffffff600000 0xffffffffff601000   --xp      0x1000        0x0 [vsyscall]
>> (gdb)
>> ```
>>
>> Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
> 
> Thanks for the great commit message.
> 
>> ---
>>  ChangeLog        |  6 ++++++
>>  gdb/linux-tdep.c | 16 ++++++++--------
>>  2 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/ChangeLog b/ChangeLog
>> index 18e8b6835da..c7b723fc8c9 100644
>> --- a/ChangeLog
>> +++ b/ChangeLog
>> @@ -1,3 +1,9 @@
>> +2022-01-23 Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
>> +
>> +	gdb: extend the 'info proc mappings' command output with 'Perms' column
>> +	that display the memory maps permissions as taken from /proc/$pid/maps
>> +	file.
>> +
>>  2022-01-22  Nick Clifton  <nickc@redhat.com>
>>  
>>  	* 2.38 release branch created.
>> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
>> index 1b48b7fef25..060f60e753a 100644
>> --- a/gdb/linux-tdep.c
>> +++ b/gdb/linux-tdep.c
>> @@ -879,16 +879,14 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>>  	  printf_filtered (_("Mapped address spaces:\n\n"));
>>  	  if (gdbarch_addr_bit (gdbarch) == 32)
>>  	    {
>> -	      printf_filtered ("\t%10s %10s %10s %10s %s\n",
>> -			   "Start Addr",
>> -			   "  End Addr",
>> +	      printf_filtered ("\t%10s %10s %7s %10s %10s %s\n",
>> +			   "Start Addr", "  End Addr", "Perms",
>>  			   "      Size", "    Offset", "objfile");
>>  	    }
>>  	  else
>>  	    {
>> -	      printf_filtered ("  %18s %18s %10s %10s %s\n",
>> -			   "Start Addr",
>> -			   "  End Addr",
>> +	      printf_filtered ("  %18s %18s %7s %10s %10s %s\n",
>> +			   "Start Addr", "  End Addr", "Perms",
>>  			   "      Size", "    Offset", "objfile");
>>  	    }
>>  
>> @@ -908,18 +906,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>>  
>>  	      if (gdbarch_addr_bit (gdbarch) == 32)
>>  		{
>> -		  printf_filtered ("\t%10s %10s %10s %10s %s\n",
>> +		  printf_filtered ("\t%10s %10s %7.5s %10s %10s %s\n",
>>  				   paddress (gdbarch, addr),
>>  				   paddress (gdbarch, endaddr),
>> +				   permissions,
>>  				   hex_string (endaddr - addr),
>>  				   hex_string (offset),
>>  				   *mapping_filename ? mapping_filename : "");
>>  		}
>>  	      else
>>  		{
>> -		  printf_filtered ("  %18s %18s %10s %10s %s\n",
>> +		  printf_filtered ("  %18s %18s %7.5s %10s %10s %s\n",
>>  				   paddress (gdbarch, addr),
>>  				   paddress (gdbarch, endaddr),
>> +				   permissions,
>>  				   hex_string (endaddr - addr),
>>  				   hex_string (offset),
>>  				   *mapping_filename ? mapping_filename : "");
> 
> This is ok, I will push the patch.  Note that GDB does not use
> ChangeLogs anymore, so I will strip this part (previously, this would
> have gone in gdb/ChangeLog).
> 
> Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output
  2022-02-23 14:09 ` Simon Marchi
  2022-02-23 21:27   ` Simon Marchi
@ 2022-02-23 21:27   ` Simon Marchi
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2022-02-23 21:27 UTC (permalink / raw)
  To: Disconnect3d, gdb-patches

So, this patch broke the test gdb.base/info-proc.exp, this patch fixes it:

https://sourceware.org/pipermail/gdb-patches/2022-February/186083.html

Simon

On 2022-02-23 09:09, Simon Marchi via Gdb-patches wrote:
> On 2022-02-22 18:43, Disconnect3d via Gdb-patches wrote:
>> Fixes #28914 and so it adds a 'Perms' (permissions) column to the
>> 'info proc mappings' command output. This will allow users to know
>> the memory pages permissions right away from GDB instead of having
>> to fetch them from the /proc/$pid/maps file (which is also what GDB
>> does internally, but it just did not print that column).
>>
>> Below I am also showing how an example output looks like before and
>> after this commit in case someone wonders.
>>
>> On i386 targets - before this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461464
>> Mapped address spaces:
>>
>>     Start Addr   End Addr        Size     Offset objfile
>>     0x56555000 0x56556000      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>     0x56556000 0x56557000      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56557000 0x56558000      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56558000 0x5655a000      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0xf7fc4000 0xf7fc8000      0x4000        0x0 [vvar]
>>     0xf7fc8000 0xf7fca000      0x2000        0x0 [vdso]
>>     0xf7fca000 0xf7fcb000      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fcb000 0xf7fee000     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fee000 0xf7ffb000      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7ffb000 0xf7ffe000      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xfffdc000 0xffffe000     0x22000        0x0 [stack]
>> (gdb)
>> ```
>>
>> On i386 targets - after this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461464
>> Mapped address spaces:
>>
>>     Start Addr   End Addr   Perms       Size     Offset objfile
>>     0x56555000 0x56556000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>     0x56556000 0x56557000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56557000 0x56558000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0x56558000 0x5655a000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>     0xf7fc4000 0xf7fc8000   r--p      0x4000        0x0 [vvar]
>>     0xf7fc8000 0xf7fca000   r-xp      0x2000        0x0 [vdso]
>>     0xf7fca000 0xf7fcb000   r--p      0x1000        0x0 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fcb000 0xf7fee000   r-xp     0x23000     0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7fee000 0xf7ffb000   r--p      0xd000    0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xf7ffb000 0xf7ffe000   rw-p      0x3000    0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so
>>     0xfffdc000 0xffffe000   rw-p     0x22000        0x0 [stack]
>> (gdb)
>> ```
>>
>> On amd64 targets - after this commit:
>> ```
>> (gdb) info proc mappings
>> process 3461869
>> Mapped address spaces:
>>
>>           Start Addr           End Addr   Perms       Size     Offset objfile
>>       0x555555554000     0x555555555000   r--p      0x1000        0x0 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555555000     0x555555556000   r-xp      0x1000     0x1000 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555556000     0x555555557000   r--p      0x1000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>       0x555555557000     0x555555559000   rw-p      0x2000     0x2000 /home/dc/src/binutils-gdb/build/a.out
>>       0x7ffff7fc3000     0x7ffff7fc7000   r--p      0x4000        0x0 [vvar]
>>       0x7ffff7fc7000     0x7ffff7fc9000   r-xp      0x2000        0x0 [vdso]
>>       0x7ffff7fc9000     0x7ffff7fca000   r--p      0x1000        0x0 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7fca000     0x7ffff7ff1000   r-xp     0x27000     0x1000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7ff1000     0x7ffff7ffb000   r--p      0xa000    0x28000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffff7ffb000     0x7ffff7fff000   rw-p      0x4000    0x31000 /usr/lib/x86_64-linux-gnu/ld-2.33.so
>>       0x7ffffffdd000     0x7ffffffff000   rw-p     0x22000        0x0 [stack]
>>   0xffffffffff600000 0xffffffffff601000   --xp      0x1000        0x0 [vsyscall]
>> (gdb)
>> ```
>>
>> Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
> 
> Thanks for the great commit message.
> 
>> ---
>>  ChangeLog        |  6 ++++++
>>  gdb/linux-tdep.c | 16 ++++++++--------
>>  2 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/ChangeLog b/ChangeLog
>> index 18e8b6835da..c7b723fc8c9 100644
>> --- a/ChangeLog
>> +++ b/ChangeLog
>> @@ -1,3 +1,9 @@
>> +2022-01-23 Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
>> +
>> +	gdb: extend the 'info proc mappings' command output with 'Perms' column
>> +	that display the memory maps permissions as taken from /proc/$pid/maps
>> +	file.
>> +
>>  2022-01-22  Nick Clifton  <nickc@redhat.com>
>>  
>>  	* 2.38 release branch created.
>> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
>> index 1b48b7fef25..060f60e753a 100644
>> --- a/gdb/linux-tdep.c
>> +++ b/gdb/linux-tdep.c
>> @@ -879,16 +879,14 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>>  	  printf_filtered (_("Mapped address spaces:\n\n"));
>>  	  if (gdbarch_addr_bit (gdbarch) == 32)
>>  	    {
>> -	      printf_filtered ("\t%10s %10s %10s %10s %s\n",
>> -			   "Start Addr",
>> -			   "  End Addr",
>> +	      printf_filtered ("\t%10s %10s %7s %10s %10s %s\n",
>> +			   "Start Addr", "  End Addr", "Perms",
>>  			   "      Size", "    Offset", "objfile");
>>  	    }
>>  	  else
>>  	    {
>> -	      printf_filtered ("  %18s %18s %10s %10s %s\n",
>> -			   "Start Addr",
>> -			   "  End Addr",
>> +	      printf_filtered ("  %18s %18s %7s %10s %10s %s\n",
>> +			   "Start Addr", "  End Addr", "Perms",
>>  			   "      Size", "    Offset", "objfile");
>>  	    }
>>  
>> @@ -908,18 +906,20 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
>>  
>>  	      if (gdbarch_addr_bit (gdbarch) == 32)
>>  		{
>> -		  printf_filtered ("\t%10s %10s %10s %10s %s\n",
>> +		  printf_filtered ("\t%10s %10s %7.5s %10s %10s %s\n",
>>  				   paddress (gdbarch, addr),
>>  				   paddress (gdbarch, endaddr),
>> +				   permissions,
>>  				   hex_string (endaddr - addr),
>>  				   hex_string (offset),
>>  				   *mapping_filename ? mapping_filename : "");
>>  		}
>>  	      else
>>  		{
>> -		  printf_filtered ("  %18s %18s %10s %10s %s\n",
>> +		  printf_filtered ("  %18s %18s %7.5s %10s %10s %s\n",
>>  				   paddress (gdbarch, addr),
>>  				   paddress (gdbarch, endaddr),
>> +				   permissions,
>>  				   hex_string (endaddr - addr),
>>  				   hex_string (offset),
>>  				   *mapping_filename ? mapping_filename : "");
> 
> This is ok, I will push the patch.  Note that GDB does not use
> ChangeLogs anymore, so I will strip this part (previously, this would
> have gone in gdb/ChangeLog).
> 
> Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-23 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 23:43 [PATCH] gdb/linux-tdep.c: Add Perms to the 'info proc mappings' output Disconnect3d
2022-02-23 14:09 ` Simon Marchi
2022-02-23 21:27   ` Simon Marchi
2022-02-23 21:27   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).