From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20320 invoked by alias); 17 Dec 2011 19:16:12 -0000 Received: (qmail 20302 invoked by uid 22791); 17 Dec 2011 19:16:10 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 17 Dec 2011 19:15:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBHJFmSv009707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 17 Dec 2011 14:15:49 -0500 Received: from host2.jankratochvil.net (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBHJFiKj013766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sat, 17 Dec 2011 14:15:47 -0500 Date: Sat, 17 Dec 2011 19:37:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: [patch] s390*: watchpoints regression [Re: [obv] s390*: Fix build regression] Message-ID: <20111217191543.GA5564@host2.jankratochvil.net> References: <20111217094753.GA20113@host2.jankratochvil.net> <201112171229.27796.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201112171229.27796.pedro@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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-12/txt/msg00577.txt.bz2 On Sat, 17 Dec 2011 13:29:27 +0100, Pedro Alves wrote: > Looks like we're trying to peek/poke at the shell process, > and failing? Yes. > I suspect that something like this pseudo patch: > > +s390_new_thread (struct lwp_info *lp) > +{ > + if (num_lwps (GET_PID (ptid)) > 1) > + s390_fix_watch_points (lp); > +} I can confirm it works. On x86* it now sets DR_CONTROL to 0 already for the wrapper shell. When there exist watchpoints they are suppressed so it still sets 0 and it works. But I do not think GDB should mess with watchpoint registers already for the wrapper shell. In the hypothetical case the wrapper shell sets DR registers they get inherited now by the inferior. Not that it needs to be handled but it IMO suggests DR_CONTROL should be rather set for the real inferior. But I do not see some easy enough way how to delay the DR setting till the new inferior so I just verified your code which works. OK to check it in this way? Thanks, Jan 2011-12-17 Pedro Alves Jan Kratochvil * s390-nat.c (s390_new_thread_lwp, s390_new_thread): New functions. (_initialize_s390_nat): Install now s390_new_thread, not s390_fix_watch_points. --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -667,6 +667,38 @@ s390_read_description (struct target_ops *ops) tdesc_s390_linux32); } +/* Helper for s390_new_thread. */ + +static int +s390_new_thread_lwp (struct lwp_info *lp, void *new_lp_voidp) +{ + struct lwp_info *new_lp = new_lp_voidp; + + if (lp == new_lp) + { + /* Continue traversal. */ + return 0; + } + + s390_fix_watch_points (new_lp); + + /* Stop traversal. */ + return 1; +} + +/* Execute s390_fix_watch_points only when there is at least one other LWP + besides the new one. This excludes the initial shell wrapper process which + works around a problem of s390x failing to PTRACE_POKEUSR_AREA when the + initial shell wrapper runs. s390_fix_watch_points is fortunately not needed + for the initial creation of a single threaded process - watchpoints are not + yet inserted into inferior in such case. */ + +static void +s390_new_thread (struct lwp_info *lp) +{ + iterate_over_lwps (pid_to_ptid (GET_PID (lp->ptid)), s390_new_thread_lwp, lp); +} + void _initialize_s390_nat (void); void @@ -695,5 +727,5 @@ _initialize_s390_nat (void) /* Register the target. */ linux_nat_add_target (t); - linux_nat_set_new_thread (t, s390_fix_watch_points); + linux_nat_set_new_thread (t, s390_new_thread); }