From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31167 invoked by alias); 4 Apr 2012 14:23:14 -0000 Received: (qmail 31154 invoked by uid 22791); 4 Apr 2012 14:23:12 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Wed, 04 Apr 2012 14:22:56 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q34EMuVN013266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 4 Apr 2012 10:22:56 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q34EMsSL000625; Wed, 4 Apr 2012 10:22:55 -0400 Message-ID: <4F7C593E.5040708@redhat.com> Date: Wed, 04 Apr 2012 14:23:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: John Gilmore CC: gdb@sourceware.org Subject: Re: PR13901 References: <20120330134210.GA7869@bromo.med.uc.edu> <14D51CD4-4990-4B11-952C-64EB8F791306@adacore.com> <4F79AFF4.9000704@redhat.com> <201204030728.q337SMWD018124@new.toad.com> In-Reply-To: <201204030728.q337SMWD018124@new.toad.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg00041.txt.bz2 On 04/03/2012 08:28 AM, John Gilmore wrote: >> 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 shell >> 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 ... > > 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. > In the changes we made, I tried to reduce that tendency, and make > the code more modular and less fragile. Today, "just" adding a new > flag for this may be as simple as you hope. Oh, a challenge! ;-) I think this should work, but I'm not set up for testing it... 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. 2012-04-04 Pedro Alves * 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. --- gdb/darwin-nat.c | 18 ++++++++++++++---- gdb/darwin-nat.h | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) 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 = 1; } - /* Set single step. */ - inferior_debug (4, _("darwin_set_sstep (thread=%x, enable=%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=%x, enable=%d)\n"), + thread->gdb_port, step); + darwin_set_sstep (thread->gdb_port, step); + } thread->single_step = step; darwin_send_reply (inf, thread); @@ -1505,7 +1513,9 @@ darwin_ptrace_him (int pid) darwin_init_thread_list (inf); + inf->private->starting_up = 1; startup_inferior (START_INFERIOR_TRAPS_EXPECTED); + inf->private->starting_up = 0; } 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 /* 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;