From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3142 invoked by alias); 22 Mar 2011 09:34:39 -0000 Received: (qmail 2880 invoked by uid 22791); 22 Mar 2011 09:34:37 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_OC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Mar 2011 09:34:30 +0000 Received: (qmail 5951 invoked from network); 22 Mar 2011 09:34:28 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Mar 2011 09:34:28 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFC] Remove START_INFERIOR_TRAPS_EXPECTED macro from nm header Date: Tue, 22 Mar 2011 09:41:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.1; x86_64; ; ) Cc: "Pierre Muller" References: <003e01cbe825$321015a0$963040e0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <003e01cbe825$321015a0$963040e0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201103220934.26493.pedro@codesourcery.com> 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-03/txt/msg00983.txt.bz2 Why's this any better? I claim that it's worse. START_INFERIOR_TRAPS_EXPECTED isn't ever used by anything outside of the native target backend implementation --- it doesn't qualify in the set of macros that are evil for a multi-arch gdb. Then, nothing in common code _should_ know about how many internal traps are expected=20 during startup_inferior, but you've just exposed that detail with to_start_inferior_traps_expected. --=20 Pedro Alves On Tuesday 22 March 2011 00:07:55, Pierre Muller wrote: > This patch achieves the subject by > adding a new field to target_ops structure > called to_start_inferior_traps_expected. >=20 > The changes are otherwise quite straightforward, > but once again, I have no way to even check that this > compiles for the different native GDB that it affects... >=20 > Comments welcome, >=20 > Pierre Muller >=20 > 2011-03-22 Pierre Muller >=20 > Replace START_INFERIOR_TRAPS_EXPECTED macro by a new filed in > target_ops struct named to_start_inferior_traps_expected. > * config/alpha/alpha-osf3.mh: Set MH_CFLAGS to be able > to set to_start_inferior_traps_expected correctly. > config/alpha/nm-osf3.h: Remove START_INFERIOR_TRAPS_EXCEPTED macro. > * target.h (struct target_ops): Add to_start_inferior_traps_expected > field. > * target.c (update_current_target): Inherit field > to_start_inferior_traps_expected for beneath and set default to 2. > * alpha-nat.c (_initialize_alpha_nat): Set > to_start_inferior_traps_expected to 3 if macro _STARTUP_INF_3_TRAPS. > (darwin_ptrace_him): Use darwin_ops to_start_inferior_traps_expected > field for startup_inferior parameter. > * inf-ptrace.c (inf_ptrace_create_inferior): Adapt startup_inferior > call using ops->to=E8start_inferior_traps_expected. > inf-ttrace.c (inf_ttrace_him): Ditto. > * procfs.c (procfs_init_inferior): Ditto. >=20 > diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c > index 1a55ea9..bb77035 100644 > --- a/gdb/alpha-nat.c > +++ b/gdb/alpha-nat.c > @@ -197,6 +197,16 @@ _initialize_alpha_nat (void) > struct target_ops *t; >=20=20 > t =3D procfs_target (); > + > + /* OSF-3 needs three traps. */ > +#ifdef _STARTUP_INF_3_TRAPS > +/* Number of traps that happen between exec'ing the shell > + to run an inferior, and when we finally get to > + the inferior code. This is 2 on most implementations. */ > +/* was define START_INFERIOR_TRAPS_EXPECTED 3 */ > + t->to_start_inferior_traps_expected =3D 3; > +#endif > + > add_target (t); >=20=20 > deprecated_add_core_fns (&alpha_osf_core_fns); > diff --git a/gdb/config/alpha/alpha-osf3.mh b/gdb/config/alpha/alpha-osf3= .mh > index 8dc6f80..1ef7195 100644 > --- a/gdb/config/alpha/alpha-osf3.mh > +++ b/gdb/config/alpha/alpha-osf3.mh > @@ -1,5 +1,6 @@ > # Host: Little-endian Alpha running OSF/1-3.x and higher using procfs > NAT_FILE=3D nm-osf3.h > +MH_CFLAGS=3D-D_STARTUP_INF_3_TRAPS > NATDEPFILES=3D corelow.o alpha-nat.o fork-child.o \ > solib-osf.o solib.o procfs.o proc-api.o proc-events.o proc-flags.o \ > proc-why.o dec-thread.o > diff --git a/gdb/config/alpha/nm-osf3.h b/gdb/config/alpha/nm-osf3.h > index 626a497..56bf4d9 100644 > --- a/gdb/config/alpha/nm-osf3.h > +++ b/gdb/config/alpha/nm-osf3.h > @@ -16,11 +16,6 @@ > You should have received a copy of the GNU General Public License > along with this program. If not, see . > */ >=20=20 > -/* Number of traps that happen between exec'ing the shell > - to run an inferior, and when we finally get to > - the inferior code. This is 2 on most implementations. */ > -#define START_INFERIOR_TRAPS_EXPECTED 3 > - > /* Don't trace faults under OSF/1, rely on the posting of the appropriate > signal if fault tracing is disabled. > Tracing T_IFAULT under Alpha OSF/1 causes a `floating point enable' > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index 7be85d5..74c8b5a 100644 > --- a/gdb/darwin-nat.c > +++ b/gdb/darwin-nat.c > @@ -1485,7 +1485,7 @@ darwin_ptrace_him (int pid) >=20=20 > darwin_init_thread_list (inf); >=20=20 > - startup_inferior (START_INFERIOR_TRAPS_EXPECTED); > + startup_inferior (darwin_ops->to_start_inferior_traps_expected); > } >=20=20 > static void > diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c > index b5e1744..0a3f776 100644 > --- a/gdb/inf-ptrace.c > +++ b/gdb/inf-ptrace.c > @@ -142,7 +142,7 @@ inf_ptrace_create_inferior (struct target_ops *ops, > /* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h, and will > be 1 or 2 depending on whether we're starting without or with a > shell. */ > - startup_inferior (START_INFERIOR_TRAPS_EXPECTED); > + startup_inferior (ops->to_start_inferior_traps_expected); >=20=20 > /* On some targets, there must be some explicit actions taken after > the inferior has been started up. */ > diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c > index ab075db..7b9ee2d 100644 > --- a/gdb/inf-ttrace.c > +++ b/gdb/inf-ttrace.c > @@ -630,7 +630,7 @@ inf_ttrace_him (struct target_ops *ops, int pid) > /* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h, and will > be 1 or 2 depending on whether we're starting without or with a > shell. */ > - startup_inferior (START_INFERIOR_TRAPS_EXPECTED); > + startup_inferior (ops->to_start_inferior_traps_expected); >=20=20 > /* On some targets, there must be some explicit actions taken after > the inferior has been started up. */ > diff --git a/gdb/procfs.c b/gdb/procfs.c > index 5d7cb23..467af2c 100644 > --- a/gdb/procfs.c > +++ b/gdb/procfs.c > @@ -4710,7 +4710,7 @@ procfs_init_inferior (struct target_ops *ops, int p= id) >=20=20 > /* Typically two, one trap to exec the shell, one to exec the > program being debugged. Defined by "inferior.h". */ > - startup_inferior (START_INFERIOR_TRAPS_EXPECTED); > + startup_inferior (ops->to_start_inferior_traps_expected); >=20=20 > #ifdef SYS_syssgi > /* On mips-irix, we need to stop the inferior early enough during > diff --git a/gdb/target.c b/gdb/target.c > index 45259fd..3ab7248 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -677,6 +677,7 @@ update_current_target (void) > INHERIT (to_static_tracepoint_marker_at, t); > INHERIT (to_static_tracepoint_markers_by_strid, t); > INHERIT (to_traceframe_info, t); > + INHERIT (to_start_inferior_traps_expected, t); > INHERIT (to_magic, t); > /* Do not inherit to_memory_map. */ > /* Do not inherit to_flash_erase. */ > @@ -886,6 +887,7 @@ update_current_target (void) > de_fault (to_traceframe_info, > (struct traceframe_info * (*) (void)) > tcomplain); > + de_fault (to_start_inferior_traps_expected, 2); > #undef de_fault >=20=20 > /* Finally, position the target-stack beneath the squashed > diff --git a/gdb/target.h b/gdb/target.h > index 237d1aa..9842a0a 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -743,6 +743,9 @@ struct target_ops > re-fetching when necessary. */ > struct traceframe_info *(*to_traceframe_info) (void); >=20=20 > + /* Number of traps expected at startup of target. */ > + int to_start_inferior_traps_expected; > + > int to_magic; > /* Need sub-structure for target machine related rather than comm > related? > */ >=20 >=20