From patchwork Thu Sep 15 12:01:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 15665 Received: (qmail 54832 invoked by alias); 15 Sep 2016 12:02:05 -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 54756 invoked by uid 89); 15 Sep 2016 12:02:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=PER, H*Ad:U*uweigand, PAID, resume X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Sep 2016 12:01:55 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FBweph122519 for ; Thu, 15 Sep 2016 08:01:54 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 25fsbhdh5f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 08:01:53 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 13:01:51 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Sep 2016 13:01:49 +0100 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id B334417D8063 for ; Thu, 15 Sep 2016 13:03:44 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8FC1mkq6160684 for ; Thu, 15 Sep 2016 12:01:48 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8FC1mE8031083 for ; Thu, 15 Sep 2016 06:01:48 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-159.boeblingen.de.ibm.com [9.152.212.159]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u8FC1ln4031017; Thu, 15 Sep 2016 06:01:48 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH 4/6] S390: Enable "maint set show-debug-regs" Date: Thu, 15 Sep 2016 14:01:45 +0200 In-Reply-To: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091512-0040-0000-0000-000002D3A9AA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091512-0041-0000-0000-00001CFF6AEB Message-Id: <1473940907-4449-3-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-15_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609150162 X-IsSubscribed: yes Implement a new function for dumping the S390 "debug registers" (actually, the PER info) and invoke it at appropriate places. Respect the variable show_debug_regs and make it settable by the user. gdb/ChangeLog: * s390-linux-nat.c (gdbcmd.h): New include. (s390_show_debug_regs): New function. (s390_stopped_by_watchpoint): Call it, if show_debug_regs is set. (s390_prepare_to_resume): Likewise. (_initialize_s390_nat): Register the command "maint set show-debug-regs". --- gdb/s390-linux-nat.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index b549246..c5d9bd3 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -28,6 +28,7 @@ #include "gregset.h" #include "regset.h" #include "nat/linux-ptrace.h" +#include "gdbcmd.h" #include "s390-linux-tdep.h" #include "elf/common.h" @@ -565,6 +566,37 @@ s390_linux_new_fork (struct lwp_info *parent, pid_t child_pid) parent_state->watch_areas); } +/* Dump PER state. */ + +static void +s390_show_debug_regs (int tid, const char *where) +{ + per_struct per_info; + ptrace_area parea; + + parea.len = sizeof (per_info); + parea.process_addr = (addr_t) &per_info; + parea.kernel_addr = offsetof (struct user_regs_struct, per_info); + + if (ptrace (PTRACE_PEEKUSR_AREA, tid, &parea, 0) < 0) + perror_with_name (_("Couldn't retrieve debug regs")); + + debug_printf ("PER (debug) state for %d -- %s\n" + " cr9-11: %lx %lx %lx\n" + " start, end: %lx %lx\n" + " code/ATMID: %x address: %lx PAID: %x\n", + tid, + where, + per_info.control_regs.words.cr[0], + per_info.control_regs.words.cr[1], + per_info.control_regs.words.cr[2], + per_info.starting_addr, + per_info.ending_addr, + per_info.lowcore.words.perc_atmid, + per_info.lowcore.words.address, + per_info.lowcore.words.access_id); +} + static int s390_stopped_by_watchpoint (struct target_ops *ops) { @@ -574,6 +606,9 @@ s390_stopped_by_watchpoint (struct target_ops *ops) ptrace_area parea; int result; + if (show_debug_regs) + s390_show_debug_regs (s390_inferior_tid (), "stop"); + /* Speed up common case. */ if (VEC_empty (s390_watch_area, state->watch_areas)) return 0; @@ -653,6 +688,9 @@ s390_prepare_to_resume (struct lwp_info *lp) if (ptrace (PTRACE_POKEUSR_AREA, tid, &parea, 0) < 0) perror_with_name (_("Couldn't modify watchpoint status")); + + if (show_debug_regs) + s390_show_debug_regs (tid, "resume"); } /* Mark the PER info as changed, so the next resume will update it. */ @@ -882,4 +920,17 @@ _initialize_s390_nat (void) linux_nat_set_prepare_to_resume (t, s390_prepare_to_resume); linux_nat_set_forget_process (t, s390_forget_process); linux_nat_set_new_fork (t, s390_linux_new_fork); + + /* A maintenance command to enable showing the PER state. */ + add_setshow_boolean_cmd ("show-debug-regs", class_maintenance, + &show_debug_regs, _("\ +Set whether to show the PER (debug) hardware state."), _("\ +Show whether to show the PER (debug) hardware state."), _("\ +Use \"on\" to enable, \"off\" to disable.\n\ +If enabled, the PER state is shown after it is changed by GDB,\n\ +and when the inferior triggers a breakpoint or watchpoint."), + NULL, + NULL, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); }