public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/linux-nat: xfer_memory_partial return E_IO on error
@ 2022-05-25  9:29 Lancelot SIX
  2022-05-25 13:35 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Lancelot SIX @ 2022-05-25  9:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

When accessing /proc/PID/mem, if pread64/pwrite64/read/write encounters
an error and return -1, linux_proc_xfer_memory_partial return
TARGET_XFER_EOF.

I think it should return TARGET_XFER_E_IO in this case.  TARGET_XFER_EOF
is returned when pread64/pwrite64/read/frite returns 0, which indicates
that the address space is gone and the whole process has exited or
execed.

This patch makes this change.

Regression tested on x86_64-linux-gnu.

Change-Id: I6030412459663b8d7933483fdda22a6c2c5d7221
---
 gdb/linux-nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3b5400896bc..b9164e621db 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3917,7 +3917,7 @@ linux_proc_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
       linux_nat_debug_printf ("accessing fd %d for pid %d failed: %s (%d)",
 			      fd, inferior_ptid.pid (),
 			      safe_strerror (errno), errno);
-      return TARGET_XFER_EOF;
+      return TARGET_XFER_E_IO;
     }
   else if (ret == 0)
     {

base-commit: 51498ab9abc6122817428198e831d36923e293a4
-- 
2.25.1


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

* Re: [PATCH] gdb/linux-nat: xfer_memory_partial return E_IO on error
  2022-05-25  9:29 [PATCH] gdb/linux-nat: xfer_memory_partial return E_IO on error Lancelot SIX
@ 2022-05-25 13:35 ` Pedro Alves
  2022-05-26  8:54   ` Lancelot SIX
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2022-05-25 13:35 UTC (permalink / raw)
  To: Lancelot SIX, gdb-patches; +Cc: lsix

On 2022-05-25 10:29, Lancelot SIX via Gdb-patches wrote:
> When accessing /proc/PID/mem, if pread64/pwrite64/read/write encounters
> an error and return -1, linux_proc_xfer_memory_partial return
> TARGET_XFER_EOF.
> 
> I think it should return TARGET_XFER_E_IO in this case.  TARGET_XFER_EOF
> is returned when pread64/pwrite64/read/frite returns 0, which indicates
> that the address space is gone and the whole process has exited or
> execed.
> 
> This patch makes this change.
> 
> Regression tested on x86_64-linux-gnu.
> 

OK.

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

* Re: [PATCH] gdb/linux-nat: xfer_memory_partial return E_IO on error
  2022-05-25 13:35 ` Pedro Alves
@ 2022-05-26  8:54   ` Lancelot SIX
  0 siblings, 0 replies; 3+ messages in thread
From: Lancelot SIX @ 2022-05-26  8:54 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches; +Cc: lsix



On 25/05/2022 14:35, Pedro Alves wrote:
> [CAUTION: External Email]
> 
> On 2022-05-25 10:29, Lancelot SIX via Gdb-patches wrote:
>> When accessing /proc/PID/mem, if pread64/pwrite64/read/write encounters
>> an error and return -1, linux_proc_xfer_memory_partial return
>> TARGET_XFER_EOF.
>>
>> I think it should return TARGET_XFER_E_IO in this case.  TARGET_XFER_EOF
>> is returned when pread64/pwrite64/read/frite returns 0, which indicates
>> that the address space is gone and the whole process has exited or
>> execed.
>>
>> This patch makes this change.
>>
>> Regression tested on x86_64-linux-gnu.
>>
> 
> OK.

Thanks,

I just pushed this.

Lancelot.

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

end of thread, other threads:[~2022-05-26  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25  9:29 [PATCH] gdb/linux-nat: xfer_memory_partial return E_IO on error Lancelot SIX
2022-05-25 13:35 ` Pedro Alves
2022-05-26  8:54   ` Lancelot SIX

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).