Re: [PATCH PR gdb/22736] [aarch64] gdb crashes on a conditional breakpoint with cast return type

Wei-min Pan
2018-05-29T17:12:13Z

On 5/25/2018 6:14 PM, Simon Marchi wrote:
> On 2018-05-25 19:20, Weimin Pan wrote:
>> Don't call language_pass_by_reference() with function that has no
>> return type.
>>
>> Only call language_pass_by_reference(), which returns whether or not an
>> additional initial argument has been given, when return_type is not NULL
>> in function aarch64_push_dummy_call().
>
> Hi Weimin,
>
> Since Pedro's patch that makes GDB not assume that the return type of
> functions without debug info is int:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=7022349d5c86bae74b49225515f42d2e221bd368
>
>
> I think we will always know the return type of the function. Either
> it's in the debug info or it's provided by the user.Â  In
> call_function_by_hand_dummy, if the debug info doesn't provide the
> return type of the function, we use the type of the user-provided cast:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/infcall.c;h=cd3eedfeeb712b27234a68cf8af394558ce4f57d;hb=cd3eedfeeb712b27234a68cf8af394558ce4f57d#l870
>
>
> I think the default_return_type could be passed down to
> gdbarch_push_dummy_call and used the same way, so that we always have
> a return type.

Hi Simon,

Since call_function_by_hand_dummy () already calls
gdbarch_return_in_first_hidden_param_p() and sets
hidden_first_param_p accordingly. Instead of passing the
deault_return_type and having the target make
the same call again , I think we should just pass hidden_first_param_p
to gdbarch_push_dummy_call()?

>
> Also, could you add a test case for this?Â  I was able to create a
> simple C++ (not C) program made from an object file built with no
> debug info:
>
> int returns_two ()
> {
> Â  return 2;
> }
>
> and one built with debug info:
>
> int returns_two();
>
> void func()
> {
> }
>
> int main()
> {
> Â  func();
> Â  return 0;
> }
>
>
> Putting this breakpoint and running crashes GDB:
>
> (gdb) b func if (int)returns_two() == 2"

Yes, will do and maybe use the one you provided here.

Thanks for your comments.

Weimin

>
> Thanks,
>
> Simon