Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tromey@adacore.com>
Cc: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Always fetch Ada "main" name from the executable
Date: Fri, 07 Aug 2026 16:03:08 +0100	[thread overview]
Message-ID: <87ldaikm6r.fsf@redhat.com> (raw)
In-Reply-To: <87tsp6xcfo.fsf@tromey.com>

Tom Tromey <tromey@adacore.com> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew>     gdb/ada: avoid rereading stale main name data in edge case
>     
> Andrew> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> Andrew> index 906c5cd3465..174e04af04c 100644
> Andrew> --- a/gdb/ada-lang.c
> Andrew> +++ b/gdb/ada-lang.c
> Andrew> @@ -806,8 +806,7 @@ ada_main_name ()
> Andrew>  					      sections)
> Andrew>  	   == TARGET_XFER_OK)
> Andrew>  	  && xferred > 0
> Andrew> -	  && (strnlen ((char *) main_program_name, sizeof (main_program_name))
> Andrew> -	      < sizeof (main_program_name)))
> Andrew> +	  && (strnlen ((char *) main_program_name, xferred) < xferred))
> Andrew>  	return (char *) main_program_name;
> Andrew>      }
>
> Looks good to me.
>
> I suppose xferred < sizeof (main_program_name) and so the first strnlen

I did think about this, but the section_table_xfer_memory_partial call
is capped at 'sizeof (main_program_name)' so this check would really be
an assert.

But as the section_table_xfer_memory_partial call is part of this same
`if` condition we'd have to split the code like:

  if (section_table_xfer_memory_partial (....) == TARGET_XFER_OK)
    {
      gdb_assert (xferred < sizeof (main_program_name));

      if (xferred > 0
          && strnlen ((char *) main_program_name, xferred) < xferred)
        return (char *) main_program_name;
    }

And the extra complexity didn't seem worth it.

> is probably now redundant.  However this doesn't really matter, the main
> name is not examined very often.
>
> Approved-By: Tom Tromey <tom@tromey.com>

I've pushed the patch now.

Thanks,
Andrew


      reply	other threads:[~2026-08-07 15:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 17:03 Tom Tromey
2026-07-31 10:48 ` Pedro Alves
2026-08-05 17:07 ` Andrew Burgess
2026-08-07 13:55   ` Tom Tromey
2026-08-07 15:03     ` Andrew Burgess [this message]

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=87ldaikm6r.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.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