Re: [PATCH v4 2/2] gdb: Keep original IFUNC return type when target type is unknown
Andrew Burgess <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Muhammad Kamran <[email protected]> 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 <[email protected]> Thanks, Andrew