From patchwork Fri Dec 12 10:16:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 4212 Received: (qmail 28644 invoked by alias); 12 Dec 2014 10:18:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28633 invoked by uid 89); 12 Dec 2014 10:18:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp10.uk.ibm.com Received: from e06smtp10.uk.ibm.com (HELO e06smtp10.uk.ibm.com) (195.75.94.106) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 12 Dec 2014 10:18:52 +0000 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 12 Dec 2014 10:18:49 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 12 Dec 2014 10:18:47 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0FE9D1B0805F for ; Fri, 12 Dec 2014 10:19:09 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBCAIj2557868528 for ; Fri, 12 Dec 2014 10:18:45 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBCAIjBN012734 for ; Fri, 12 Dec 2014 03:18:45 -0700 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sBCAHDYB008771 for ; Fri, 12 Dec 2014 03:18:44 -0700 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH v4 3/4] gdbserver: Support read-only regsets in linux-low.c Date: Fri, 12 Dec 2014 11:16:40 +0100 Message-Id: <1418379431-14407-4-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1418379431-14407-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1418379431-14407-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121210-0041-0000-0000-0000027467EE X-IsSubscribed: yes For GNU/Linux targets using the regsets interface, this change supports regsets that can be read but not written. The S390 "last break" regset is an example. So far it had been defined with regset->set_request == PTRACE_GETREGSET, such that the respective ptrace call does not cause any harm. Now we just skip the whole read/modify/write sequence for regsets that do not define a fill_function. gdb/gdbserver/ChangeLog: * linux-low.c (regsets_store_inferior_registers): Skip regsets without a fill_function. * linux-s390-low.c (s390_fill_last_break): Remove. (s390_regsets): Set fill_function to NULL for NT_S390_LAST_BREAK. (s390_arch_setup): Use regset's size instead of fill_function for loop end condition. --- gdb/gdbserver/linux-low.c | 3 ++- gdb/gdbserver/linux-s390-low.c | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index c1b53ff..5f62010 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4293,7 +4293,8 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, void *buf, *data; int nt_type, res; - if (regset->size == 0 || regset_disabled (regsets_info, regset)) + if (regset->size == 0 || regset_disabled (regsets_info, regset) + || regset->fill_function == NULL) continue; buf = xmalloc (regset->size); diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c index 79fa6c0..9f77f30 100644 --- a/gdb/gdbserver/linux-s390-low.c +++ b/gdb/gdbserver/linux-s390-low.c @@ -290,12 +290,6 @@ s390_fill_gregset (struct regcache *regcache, void *buf) /* Fill and store functions for extended register sets. */ static void -s390_fill_last_break (struct regcache *regcache, void *buf) -{ - /* Last break address is read-only. */ -} - -static void s390_store_last_break (struct regcache *regcache, const void *buf) { const char *p; @@ -318,9 +312,9 @@ s390_store_system_call (struct regcache *regcache, const void *buf) static struct regset_info s390_regsets[] = { { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL }, - /* Last break address is read-only; do not attempt PTRACE_SETREGSET. */ - { PTRACE_GETREGSET, PTRACE_GETREGSET, NT_S390_LAST_BREAK, 0, - EXTENDED_REGS, s390_fill_last_break, s390_store_last_break }, + /* Last break address is read-only; no fill function. */ + { PTRACE_GETREGSET, -1, NT_S390_LAST_BREAK, 0, EXTENDED_REGS, + NULL, s390_store_last_break }, { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0, EXTENDED_REGS, s390_fill_system_call, s390_store_system_call }, { 0, 0, 0, -1, -1, NULL, NULL } @@ -485,7 +479,7 @@ s390_arch_setup (void) #endif /* Update target_regsets according to available register sets. */ - for (regset = s390_regsets; regset->fill_function != NULL; regset++) + for (regset = s390_regsets; regset->size >= 0; regset++) if (regset->get_request == PTRACE_GETREGSET) switch (regset->nt_type) {