public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: Pedro Alves <palves@redhat.com>
Cc: John Gilmore <gnu@toad.com>, gdb@sourceware.org
Subject: Re: PR13901
Date: Wed, 04 Apr 2012 14:47:00 -0000	[thread overview]
Message-ID: <454D631A-B8E3-42DD-860F-9B5F5A485810@adacore.com> (raw)
In-Reply-To: <4F7C593E.5040708@redhat.com>


On Apr 4, 2012, at 4:22 PM, Pedro Alves wrote:

> 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...

Welcome in the Darwin team :-)

I was thinking about a slightly better way (IMHO): just call darwin_set_sstep when
the single-step flag is set or was just cleared.  This should improve performance.

There might be subtile difference for signal handling, but I am not even sure 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.

> 
> 2012-04-04  Pedro Alves  <palves@redhat.com>
> 
> 	* 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) <starting_up>: 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;
> 

  reply	other threads:[~2012-04-04 14:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 13:42 PR13901 Jack Howarth
2012-03-30 14:19 ` PR13901 Tristan Gingold
2012-04-02 10:44 ` PR13901 Tristan Gingold
2012-04-02 11:57   ` PR13901 Tristan Gingold
2012-04-02 13:17     ` PR13901 Jack Howarth
2012-04-02 13:22       ` PR13901 Tristan Gingold
2012-04-02 13:56     ` PR13901 Pedro Alves
2012-04-02 14:07       ` PR13901 Tristan Gingold
2012-04-02 14:17         ` PR13901 Pedro Alves
2012-04-02 14:25           ` PR13901 Tristan Gingold
2012-04-02 14:59           ` PR13901 Andreas Schwab
2012-04-02 15:08             ` PR13901 Tristan Gingold
2012-04-02 15:23             ` PR13901 Pedro Alves
2012-04-02 16:22               ` PR13901 Andreas Schwab
2012-04-02 16:31                 ` PR13901 Pedro Alves
2012-04-02 17:28                   ` PR13901 Andreas Schwab
2012-04-03  7:28       ` PR13901 John Gilmore
2012-04-04 14:23         ` PR13901 Pedro Alves
2012-04-04 14:47           ` Tristan Gingold [this message]
2012-04-04 15:01             ` PR13901 Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=454D631A-B8E3-42DD-860F-9B5F5A485810@adacore.com \
    --to=gingold@adacore.com \
    --cc=gdb@sourceware.org \
    --cc=gnu@toad.com \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).