Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: Yao Qi <yao@codesourcery.com>,	toolchain-devel@blackfin.uclinux.org
Subject: [PATCH] gdbserver: add support for FDPIC loadmaps
Date: Thu, 29 Sep 2011 04:07:00 -0000	[thread overview]
Message-ID: <1317268705-29948-1-git-send-email-vapier@gentoo.org> (raw)

The DSBT support is very close to the FDPIC code, so extend the existing
loadmap support to work with FDPIC loadmaps too.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

gdb/gdbserver/:
2011-09-27  Mike Frysinger  <vapier@gentoo.org>

	* linux-low.c (target_loadseg): Add defined PTRACE_GETFDPIC to the
	ifdef check.
	(target_loadmap, PT_GETDSBT): Wrap in a defined PT_GETDSBT check.
	(target_loadmap, !PT_GETDSBT): New definition.
	(LINUX_LOADMAP, LINUX_LOADMAP_EXEC, LINUX_LOADMAP_INTERP): Define.
	(linux_read_loadmap): Change PTRACE_GETDSBT_EXEC to
	LINUX_LOADMAP_EXEC, PTRACE_GETDSBT_INTERP to LINUX_LOADMAP_INTERP,
	and PT_GETDSBT to LINUX_LOADMAP.
	(linux_read_loadmap, !PT_GETDSBT): Define to NULL.
	(linux_target_ops): Delete unnecessary ifdef PT_GETDSBT check.

gdb/common/:
2011-09-27  Mike Frysinger  <vapier@gentoo.org>

	* common/linux-ptrace.h (PTRACE_GETFDPIC, PTRACE_GETFDPIC_EXEC,
	PTRACE_GETFDPIC_INTERP): Define.
---
 gdb/common/linux-ptrace.h |    7 +++++++
 gdb/gdbserver/linux-low.c |   36 +++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/gdb/common/linux-ptrace.h b/gdb/common/linux-ptrace.h
index ea4ee0d..0f30430 100644
--- a/gdb/common/linux-ptrace.h
+++ b/gdb/common/linux-ptrace.h
@@ -51,6 +51,13 @@
 
 #endif /* PTRACE_EVENT_FORK */
 
+#if (defined __bfin__ || defined __frv__ || defined __sh__) && \
+    !defined PTRACE_GETFDPIC
+#define PTRACE_GETFDPIC		31
+#define PTRACE_GETFDPIC_EXEC	0
+#define PTRACE_GETFDPIC_INTERP	1
+#endif
+
 /* We can't always assume that this flag is available, but all systems
    with the ptrace event handlers also have __WALL, so it's safe to use
    in some contexts.  */
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 94f785c..5dfa59a 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4727,7 +4727,7 @@ linux_qxfer_spu (const char *annex, unsigned char *readbuf,
   return ret;
 }
 
-#if defined PT_GETDSBT
+#if defined PT_GETDSBT || defined PTRACE_GETFDPIC
 struct target_loadseg
 {
   /* Core address to which the segment is mapped.  */
@@ -4738,6 +4738,7 @@ struct target_loadseg
   Elf32_Word p_memsz;
 };
 
+# if defined PT_GETDSBT
 struct target_loadmap
 {
   /* Protocol version number, must be zero.  */
@@ -4750,9 +4751,24 @@ struct target_loadmap
   /* The actual memory map.  */
   struct target_loadseg segs[/*nsegs*/];
 };
-#endif
+#  define LINUX_LOADMAP		PT_GETDSBT
+#  define LINUX_LOADMAP_EXEC	PTRACE_GETDSBT_EXEC
+#  define LINUX_LOADMAP_INTERP	PTRACE_GETDSBT_INTERP
+# else
+struct target_loadmap
+{
+  /* Protocol version number, must be zero.  */
+  Elf32_Half version;
+  /* Number of segments in this map.  */
+  Elf32_Half nsegs;
+  /* The actual memory map.  */
+  struct target_loadseg segs[/*nsegs*/];
+};
+#  define LINUX_LOADMAP		PTRACE_GETFDPIC
+#  define LINUX_LOADMAP_EXEC	PTRACE_GETFDPIC_EXEC
+#  define LINUX_LOADMAP_INTERP	PTRACE_GETFDPIC_INTERP
+# endif
 
-#if defined PT_GETDSBT
 static int
 linux_read_loadmap (const char *annex, CORE_ADDR offset,
 		    unsigned char *myaddr, unsigned int len)
@@ -4763,13 +4779,13 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset,
   unsigned int actual_length, copy_length;
 
   if (strcmp (annex, "exec") == 0)
-    addr= (int) PTRACE_GETDSBT_EXEC;
+    addr = (int) LINUX_LOADMAP_EXEC;
   else if (strcmp (annex, "interp") == 0)
-    addr = (int) PTRACE_GETDSBT_INTERP;
+    addr = (int) LINUX_LOADMAP_INTERP;
   else
     return -1;
 
-  if (ptrace (PT_GETDSBT, pid, addr, &data) != 0)
+  if (ptrace (LINUX_LOADMAP, pid, addr, &data) != 0)
     return -1;
 
   if (data == NULL)
@@ -4785,7 +4801,9 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset,
   memcpy (myaddr, (char *) data + offset, copy_length);
   return copy_length;
 }
-#endif /* defined PT_GETDSBT */
+#else
+# define linux_read_loadmap NULL
+#endif /* defined PT_GETDSBT || defined PTRACE_GETFDPIC */
 
 static void
 linux_process_qsupported (const char *query)
@@ -4935,11 +4953,7 @@ static struct target_ops linux_target_ops = {
   NULL,
 #endif
   linux_common_core_of_thread,
-#if defined PT_GETDSBT
   linux_read_loadmap,
-#else
-  NULL,
-#endif
   linux_process_qsupported,
   linux_supports_tracepoints,
   linux_read_pc,
-- 
1.7.6.1


             reply	other threads:[~2011-09-29  3:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29  4:07 Mike Frysinger [this message]
2011-09-29  9:34 ` Yao Qi
2011-09-29 11:23   ` Pedro Alves
2011-09-29 14:35   ` Mike Frysinger
2011-09-30  1:10     ` Yao Qi
2011-09-29 11:25 ` Pedro Alves
2011-09-30  0:56   ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317268705-29948-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    --cc=toolchain-devel@blackfin.uclinux.org \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox