From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11529 invoked by alias); 20 Jun 2013 18:51:14 -0000 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 Received: (qmail 11510 invoked by uid 89); 20 Jun 2013 18:51:10 -0000 X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP,TW_QX autolearn=no version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 20 Jun 2013 18:51:08 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Upjwo-0006v1-S1 from Luis_Gustavo@mentor.com ; Thu, 20 Jun 2013 11:51:06 -0700 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by svr-orw-fem-01.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 20 Jun 2013 11:51:06 -0700 Received: from [172.30.14.165] ([172.30.14.165]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 20 Jun 2013 11:51:06 -0700 Message-ID: <51C34F14.8070803@codesourcery.com> Date: Thu, 20 Jun 2013 18:57:00 -0000 From: Luis Machado Reply-To: lgustavo@codesourcery.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "'gdb-patches@sourceware.org'" , Mike Frysinger , Yao Qi Subject: [PATCH, gdbserver] Further cleanup of FDPIC/DSBT divergences Content-Type: multipart/mixed; boundary="------------020104060602060504090307" X-Virus-Found: No X-SW-Source: 2013-06/txt/msg00560.txt.bz2 This is a multi-part message in MIME format. --------------020104060602060504090307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2383 Hi, At some point, c6x used different data structures for its DSBT-based loadmap. DSBT-based struct target_loadmap { /* Protocol version number, must be zero. */ Elf32_Word version; /* Pointer to the DSBT table, its size, and the DSBT index. */ unsigned *dsbt_table; unsigned dsbt_size, dsbt_index; /* Number of segments in this map. */ Elf32_Word nsegs; /* The actual memory map. */ struct target_loadseg segs[/*nsegs*/]; }; FDPIC-based 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*/]; }; We shared a little bit of code with FDPIC-based targets though... struct target_loadseg { /* Core address to which the segment is mapped. */ Elf32_Addr addr; /* VMA recorded in the program header. */ Elf32_Addr p_vaddr; /* Size of this segment in memory. */ Elf32_Word p_memsz; }; Things have changed, and c6x is now using the exact same data structures as FDPIC-based targets in uClibc. Please refer to http://lists.uclibc.org/pipermail/uclibc/2013-May/047789.html for the uClibc changes that led to this. Mark Salter, the author of the uClibc change, has agreed with the solution i proposed: http://lists.uclibc.org/pipermail/uclibc/2013-May/047790.html. It is all good, but we've been conditionalizing the c6x-specific target_loadmap data structure based on the presence of PT_GETDSBT. This has always been defined in uClibc and, since Mark's change, it doesn't work as a hint of whether to use the new or the old target_loadmap data structure anymore. Therefore we will/already have a potential problem with backwards compatibility. Bernhard has stated that backwards compatibility on uClibc's side is not a problem: http://lists.uclibc.org/pipermail/uclibc/2013-June/047801.html. With all that exposed, my proposed change to gdbserver is to drop all the DSBT-specific bits, remove their definitions and explicitly use FDPIC definitions instead, making things a little bit cleaner. In the following patch i also changed the code slightly to stop defining linux_read_loadmap to NULL and i switched to explicitly setting the target hook to NULL in the absence of the required definition. What do you think? Yao? Mike? Luis --------------020104060602060504090307 Content-Type: text/x-patch; name="dsbt_fdpic.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dsbt_fdpic.diff" Content-length: 3290 2013-06-20 Luis Machado * linux-low.c: Remove check for PT_GETDSBT. (target_loadmap): Remove data structure conditionalized by the presence of PT_GETDSBT. (LINUX_LOADMAP, LINUX_LOADMAP_EXEC, LINUX_LOADMAP_INTERP): Remove definitions. (linux_read_loadmap): Replace LINUX_LOADMAP_EXEC with PTRACE_GETFDPIC_EXEC, LINUX_LOADMAP_INTERP with PTRACE_GETFDPIC_INTERP and LINUX_LOADMAP with PTRACE_GETFDPIC. Do not set linux_read_loadmap to NULL in the absence of PTRACE_GETFDPIC. (linux_target_ops) : Only set to linux_read_loadmap in the presence of PTRACE_GETFDPIC. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index bb7298a..df53775 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5263,7 +5263,7 @@ linux_qxfer_spu (const char *annex, unsigned char *readbuf, return ret; } -#if defined PT_GETDSBT || defined PTRACE_GETFDPIC +#if defined PTRACE_GETFDPIC struct target_loadseg { /* Core address to which the segment is mapped. */ @@ -5274,23 +5274,6 @@ struct target_loadseg Elf32_Word p_memsz; }; -# if defined PT_GETDSBT -struct target_loadmap -{ - /* Protocol version number, must be zero. */ - Elf32_Word version; - /* Pointer to the DSBT table, its size, and the DSBT index. */ - unsigned *dsbt_table; - unsigned dsbt_size, dsbt_index; - /* Number of segments in this map. */ - Elf32_Word nsegs; - /* The actual memory map. */ - struct target_loadseg segs[/*nsegs*/]; -}; -# 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. */ @@ -5300,10 +5283,6 @@ struct target_loadmap /* 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 static int linux_read_loadmap (const char *annex, CORE_ADDR offset, @@ -5315,13 +5294,13 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset, unsigned int actual_length, copy_length; if (strcmp (annex, "exec") == 0) - addr = (int) LINUX_LOADMAP_EXEC; + addr = (int) PTRACE_GETFDPIC_EXEC; else if (strcmp (annex, "interp") == 0) - addr = (int) LINUX_LOADMAP_INTERP; + addr = (int) PTRACE_GETFDPIC_INTERP; else return -1; - if (ptrace (LINUX_LOADMAP, pid, addr, &data) != 0) + if (ptrace (PTRACE_GETFDPIC, pid, addr, &data) != 0) return -1; if (data == NULL) @@ -5337,9 +5316,7 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset, memcpy (myaddr, (char *) data + offset, copy_length); return copy_length; } -#else -# define linux_read_loadmap NULL -#endif /* defined PT_GETDSBT || defined PTRACE_GETFDPIC */ +#endif /* defined PTRACE_GETFDPIC */ static void linux_process_qsupported (const char *query) @@ -6037,7 +6014,11 @@ static struct target_ops linux_target_ops = { NULL, #endif linux_common_core_of_thread, +#if defined PTRACE_GETFDPIC linux_read_loadmap, +#else + NULL, +#endif /* defined PTRACE_GETFDPIC */ linux_process_qsupported, linux_supports_tracepoints, linux_read_pc, --------------020104060602060504090307--