public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* why ptrace read failed to read debugging process memory?
@ 2022-03-10  6:40 周春明(日月)
  2022-03-10 10:05 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: 周春明(日月) @ 2022-03-10  6:40 UTC (permalink / raw)
  To: 周春明(日月),
	Simon Marchi, Gdb-patches, gdb-patches
  Cc: Louis-He, Dominique Quatravaux, Sam Warner

Hi GDB maintainers,
I tried update our gdb10 to gdb12, but I found new gdb seems cannot pread debugging process memory.

3897 linux_proc_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
3898  ULONGEST offset, LONGEST len,
3899  ULONGEST *xfered_len)
3900 {
3901  ssize_t ret;
3902  auto iter = proc_mem_file_map.find (inferior_ptid.pid ());
3903  if (iter == proc_mem_file_map.end ())
3904  return TARGET_XFER_EOF;
3905
3906  int fd = iter->second.fd ();
3907
3908  gdb_assert (fd != -1);
3909
3910  /* Use pread64/pwrite64 if available, since they save a syscall and can
3911   handle 64-bit offsets even on 32-bit platforms (for instance, SPARC
3912   debugging a SPARC64 application). */
3913 #ifdef HAVE_PREAD64
3914  ret = (readbuf ? pread64 (fd, readbuf, len, offset)
3915   : pwrite64 (fd, writebuf, len, offset));
3916 #else
3917  ret = lseek (fd, offset, SEEK_SET);
3918  if (ret != -1)
3919  ret = (readbuf ? read (fd, readbuf, len)
3920   : write (fd, writebuf, len));
3921 #endif
3922
3923  if (ret == -1)
3924  {
3925  printf ("accessing fd %d for pid %d failed: %s (%d)\n",         ================> here always returns -EIO (5) errno.
3926  fd, inferior_ptid.pid (),
3927  safe_strerror (errno), errno);
3928  return TARGET_XFER_EOF;
3929  }

any configure I missed in new GDB12? or new ptrace way needed?

Thanks very much,
-David

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

end of thread, other threads:[~2022-03-10 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10  6:40 why ptrace read failed to read debugging process memory? 周春明(日月)
2022-03-10 10:05 ` Pedro Alves
2022-03-10 10:34   ` 回复:why " 周春明(日月)

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