From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7828 invoked by alias); 12 Feb 2013 16:50:49 -0000 Received: (qmail 7814 invoked by uid 22791); 12 Feb 2013 16:50:46 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,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; Tue, 12 Feb 2013 16:50:36 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1CGoa9N017052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Feb 2013 11:50:36 -0500 Received: from host2.jankratochvil.net (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1CGoTi2016333 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 12 Feb 2013 11:50:33 -0500 Date: Tue, 12 Feb 2013 16:50:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [native x86 GNU/Linux] Access debug register mirror from the corresponding inferior. Message-ID: <20130212165029.GA1934@host2.jankratochvil.net> References: <20130207163339.19427.73350.stgit@brno.lan> <20130207165907.GB15297@host2.jankratochvil.net> <51195E18.1010008@redhat.com> <511A372F.80006@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <511A372F.80006@redhat.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: 2013-02/txt/msg00276.txt.bz2 On Tue, 12 Feb 2013 13:35:59 +0100, Pedro Alves wrote: > On 02/11/2013 09:09 PM, Pedro Alves wrote: > > In a nutshell, we decouple the watchpoints code from inferiors, making > > it track target processes instead. It looks really cleaner than waht it was. I haven't found there any real bug. [...] > --- a/gdb/i386-nat.c > +++ b/gdb/i386-nat.c > @@ -153,104 +153,102 @@ struct i386_dr_low_type i386_dr_low; > /* A macro to loop over all debug registers. */ > #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++) > > -/* Clear the reference counts and forget everything we knew about the > - debug registers. */ > +/* Per-process data. We don't bind this to a per-inferior registry > + because of targets like x86 GNU/Linux that need to keep track of > + processes that aren't bound to any inferior (e.g., fork children, > + checkpoints). */ > > -static void > -i386_init_dregs (struct i386_debug_reg_state *state) > +struct i386_process_info > { > - int i; > - > - ALL_DEBUG_REGISTERS (i) > - { > - state->dr_mirror[i] = 0; > - state->dr_ref_count[i] = 0; > - } > - state->dr_control_mirror = 0; > - state->dr_status_mirror = 0; > -} > + /* Linked list. */ > + struct i386_process_info *next; > > -/* Per-inferior data key. */ > -static const struct inferior_data *i386_inferior_data; > + /* The process identifier. */ > + int pid; style: Here and on many other places should be pid_t. > > -/* Per-inferior data. */ > -struct i386_inferior_data > -{ > - /* Copy of i386 hardware debug registers for performance reasons. */ > + /* Copy of i386 hardware debug registers. */ > struct i386_debug_reg_state state; > }; > > -/* Per-inferior hook for register_inferior_data_with_cleanup. */ > +struct i386_process_info *i386_process_list = NULL; Missing static. > > -static void > -i386_inferior_data_cleanup (struct inferior *inf, void *arg) > +/* Find process data for process PID. */ > + > +static struct i386_process_info * > +i386_find_process_pid (int pid) > { > - struct i386_inferior_data *inf_data = arg; > + struct i386_process_info *inf; style: The 'inf' name is confusing when it is not inferior. > + > + for (inf = i386_process_list; inf; inf = inf->next) > + if (inf->pid == pid) > + return inf; > > - xfree (inf_data); > + return NULL; > } > [...] > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -184,6 +184,13 @@ static struct target_ops linux_ops_saved; > /* The method to call, if any, when a new thread is attached. */ > static void (*linux_nat_new_thread) (struct lwp_info *); > > +/* The method to call, if any, when a new fork is attached. */ > +static void (*linux_nat_new_fork) (struct lwp_info *, int); style: The parameters could be named. > + > +/* The method to call, if any, when a process is no longer > + attached. */ > +static void (*linux_nat_forget_process_hook) (int); style: The parameter could be named. > + > /* Hook to call prior to resuming a thread. */ > static void (*linux_nat_prepare_to_resume) (struct lwp_info *); > [...] > --- a/gdb/linux-nat.h > +++ b/gdb/linux-nat.h [...] > @@ -176,6 +170,18 @@ void linux_nat_add_target (struct target_ops *); > /* Register a method to call whenever a new thread is attached. */ > void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *)); > > +/* Register a method to call whenever a new fork is attached. */ > +void linux_nat_set_new_fork (struct target_ops *, > + void (*) (struct lwp_info *, int)); > + > +/* Register a method to call whenever a process is killed or > + detached. */ > +void linux_nat_set_forget_process (struct target_ops *, void (*) (int)); style: Parameters could be named, I do not understand why to omit their names. > + > +/* Call the method registered with the function above. PID is the > + process to forget about. */ > +void linux_nat_forget_process (int pid); > + > /* Register a method that converts a siginfo object between the layout > that ptrace returns, and the layout in the architecture of the > inferior. */ [...] Thanks, Jan