From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20451 invoked by alias); 29 Sep 2011 03:58:45 -0000 Received: (qmail 20440 invoked by uid 22791); 29 Sep 2011 03:58:43 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_CP,TW_QX X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Sep 2011 03:58:26 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 5C92B1B401A; Thu, 29 Sep 2011 03:58:25 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Cc: Yao Qi , toolchain-devel@blackfin.uclinux.org Subject: [PATCH] gdbserver: add support for FDPIC loadmaps Date: Thu, 29 Sep 2011 04:07:00 -0000 Message-Id: <1317268705-29948-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00498.txt.bz2 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 gdb/gdbserver/: 2011-09-27 Mike Frysinger * 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 * 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