From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8643 invoked by alias); 4 Apr 2012 14:47:19 -0000 Received: (qmail 8635 invoked by uid 22791); 4 Apr 2012 14:47:18 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Apr 2012 14:47:05 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D8D8729002E; Wed, 4 Apr 2012 16:47:08 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2zFx9dcxQS8J; Wed, 4 Apr 2012 16:47:08 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 9492329002D; Wed, 4 Apr 2012 16:47:08 +0200 (CEST) Subject: Re: PR13901 Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=iso-8859-1 From: Tristan Gingold In-Reply-To: <4F7C593E.5040708@redhat.com> Date: Wed, 04 Apr 2012 14:47:00 -0000 Cc: John Gilmore , gdb@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <454D631A-B8E3-42DD-860F-9B5F5A485810@adacore.com> References: <20120330134210.GA7869@bromo.med.uc.edu> <14D51CD4-4990-4B11-952C-64EB8F791306@adacore.com> <4F79AFF4.9000704@redhat.com> <201204030728.q337SMWD018124@new.toad.com> <4F7C593E.5040708@redhat.com> To: Pedro Alves X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00042.txt.bz2 On Apr 4, 2012, at 4:22 PM, Pedro Alves wrote: > On 04/03/2012 08:28 AM, John Gilmore wrote: >=20 >>> If we can't skip darwin_set_sstep for all continues that are not single= -steps, >>> we could at least skip those while starting up (when continuing the she= ll >>> until we see enough execs). That'd suggest a new flag like >>> darwin-nat.h:struct private_inferior->starting_up, set and cleared in >>> darwin_create_inferior, and then making darwin_resume_thread do ... >>=20 >> When I was maintaining GDB (many years ago), touching *anything* in >> the state machine that figured out what to do next when the inferior >> stopped was guaranteed to produce several bugs for every fix. >=20 >> In the changes we made, I tried to reduce that tendency, and make >=20 >> the code more modular and less fragile. Today, "just" adding a new >> flag for this may be as simple as you hope. >=20 >=20 > Oh, a challenge! ;-) >=20 > I think this should work, but I'm not set up for testing it... Welcome in the Darwin team :-) I was thinking about a slightly better way (IMHO): just call darwin_set_sst= ep when the single-step flag is set or was just cleared. This should improve perfo= rmance. There might be subtile difference for signal handling, but I am not even su= re that gdb behaviour is well defined in that case. WDYT ? > As noted in a comment below, this isn't just about the shell; a > "set exec-wrapper WRAPPER" wrapper of the wrong bitness should also > trigger the original problem. Sure. Tristan. >=20 > 2012-04-04 Pedro Alves >=20 > * darwin-nat.c (darwin_resume_thread): Don't set the thread to > single-step if the inferior is still starting up. > (darwin_ptrace_him): Set and clear the new starting_up flag. > * darwin-nat.h (struct private_inferior) : New flag. > --- >=20 > gdb/darwin-nat.c | 18 ++++++++++++++---- > gdb/darwin-nat.h | 4 ++++ > 2 files changed, 18 insertions(+), 4 deletions(-) >=20 > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index 010700c..bdd174b 100644 > --- a/gdb/darwin-nat.c > +++ b/gdb/darwin-nat.c > @@ -705,10 +705,18 @@ darwin_resume_thread (struct inferior *inf, darwin_= thread_t *thread, > thread->signaled =3D 1; > } >=20 > - /* Set single step. */ > - inferior_debug (4, _("darwin_set_sstep (thread=3D%x, enable=3D%d)\= n"), > - thread->gdb_port, step); > - darwin_set_sstep (thread->gdb_port, step); > + /* If our target process hasn't been exec'ed yet, when avoid > + accessing anything in the inferior (registers, memory, etc.). > + We might have spawned a 64-bit shell while debugging a 32-bit > + program. */ > + gdb_assert (!inf->private->starting_up || !step); > + if (!inf->private->starting_up) > + { > + /* Set single step. */ > + inferior_debug (4, _("darwin_set_sstep (thread=3D%x, enable=3D%d)\n"), > + thread->gdb_port, step); > + darwin_set_sstep (thread->gdb_port, step); > + } > thread->single_step =3D step; >=20 > darwin_send_reply (inf, thread); > @@ -1505,7 +1513,9 @@ darwin_ptrace_him (int pid) >=20 > darwin_init_thread_list (inf); >=20 > + inf->private->starting_up =3D 1; > startup_inferior (START_INFERIOR_TRAPS_EXPECTED); > + inf->private->starting_up =3D 0; > } >=20 > static void > diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h > index 6c89299..d9d4e33 100644 > --- a/gdb/darwin-nat.h > +++ b/gdb/darwin-nat.h > @@ -126,6 +126,10 @@ struct private_inferior >=20 > /* Sorted vector of known threads. */ > VEC(darwin_thread_t) *threads; > + > + /* True if starting up (going through the shell, or an > + exec-wrapper). */ > + int starting_up; > }; > typedef struct private_inferior darwin_inferior; >=20