Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Muhammad Kamran <muhammad.kamran@arm.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simark@simark.ca>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	Yury Khrustalev <Yury.Khrustalev@arm.com>,
	Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Carlos O'Donell <carlos@redhat.com>,
	Muhammad Kamran <muhammad.kamran@arm.com>
Subject: Re: [PATCH v4 2/2] gdb: Keep original IFUNC return type when target type is unknown
Date: Tue, 11 Aug 2026 11:09:38 +0100	[thread overview]
Message-ID: <871pc5kly5.fsf@redhat.com> (raw)
In-Reply-To: <20260630110443.12900-3-muhammad.kamran@arm.com>

Muhammad Kamran <muhammad.kamran@arm.com> writes:

> When find_function_addr resolves a GNU IFUNC, it tries to replace the
> original function type with the resolved target type, or with the type
> returned by the resolver.  If neither source provides a useful return
> type, keep the return type from the original function value.
>
> This matters for internal inferior calls such as
> find_function_in_inferior ("malloc"), where GDB creates a synthetic
> function type with a known fallback return type.
>
> Remove the guard from the IFUNC inferior-call test so the no-debug
> resolver/no-debug target variants are tested too.

It is probably worth adding the Bug: link from the previous commit here
too.

> ---
>  gdb/infcall.c                        | 12 ++++++++++--
>  gdb/testsuite/gdb.base/gnu-ifunc.exp |  7 -------
>  2 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/infcall.c b/gdb/infcall.c
> index e6b24ff5310..077407073ac 100644
> --- a/gdb/infcall.c
> +++ b/gdb/infcall.c
> @@ -395,6 +395,9 @@ find_function_addr (struct value *function,
>  	     FUNCTION_TYPE have been asked for.  */
>  	  if (retval_type != NULL || function_type != NULL)
>  	    {
> +	      /* Default to original function type's return type.  Target type
> +		 replaces this only if it provides a usable return type.  */
> +	      value_type = ftype->target_type ();
>  	      type *target_ftype = find_function_type (funaddr);
>  	      /* If we don't have debug info for the target function,
>  		 see if we can instead extract the target function's
> @@ -403,8 +406,13 @@ find_function_addr (struct value *function,
>  		target_ftype = find_gnu_ifunc_target_type (resolver_addr);
>  	      if (target_ftype != NULL)
>  		{
> -		  value_type = check_typedef (target_ftype)->target_type ();
> -		  ftype = target_ftype;
> +		  struct type *target_value_type

I think you should drop the 'struct' here.  Newer GDB code avoids the
'struct' where possible.  This function has a mix so I think adopting
the new style would be best.

> +		    = check_typedef (target_ftype)->target_type ();
> +		  if (target_value_type != NULL)

Replace 'NULL' with 'nullptr' in new code please.

With those minor fixes:

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


  reply	other threads:[~2026-08-11 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 11:04 [PATCH v4 0/2] gdb: Fix internal inferior calls through GNU IFUNCs Muhammad Kamran
2026-06-30 11:04 ` [PATCH v4 1/2] gdb: Preserve IFUNC marker when finding inferior functions Muhammad Kamran
2026-08-10 21:12   ` Andrew Burgess
2026-08-13 12:38     ` Muhammad Kamran
2026-06-30 11:04 ` [PATCH v4 2/2] gdb: Keep original IFUNC return type when target type is unknown Muhammad Kamran
2026-08-11 10:09   ` Andrew Burgess [this message]
2026-08-04  9:02 ` [PATCH v4 0/2] gdb: Fix internal inferior calls through GNU IFUNCs Muhammad Kamran

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=871pc5kly5.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=Yury.Khrustalev@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=muhammad.kamran@arm.com \
    --cc=simark@simark.ca \
    --cc=thiago.bauermann@linaro.org \
    /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