Aarch64: Fix segfault when casting dummy calls
authorAlan Hayward <alan.hayward@arm.com>
Thu, 11 Oct 2018 13:47:30 +0000 (14:47 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Fri, 16 Nov 2018 13:45:38 +0000 (13:45 +0000)
commit38a72da0f1d968432ae6a2a9697ba55932dc075e
treeb25e8c746263a3201b2a32bf60f2bc094eb8f46f
parentcf84fa6bcf514157df8343d32885050bafc396f7
Aarch64: Fix segfault when casting dummy calls

The following will segfault on aarch64 if foo is in another object,
was compiled as c++ and has no debug symbols:
(gdb) p (int)foo()

This is because aarch64_push_dummy_call determines the return type
of the function and then does not check for null pointer.

A null pointer for the return type means the call has no debug
information.  For the code to get here, then the call must have
been cast, otherwise we'd error out sooner.  In the case of a
no-debug-info call cast, the return type is the type the user
had cast the call to, but we do not have that information
available here.

However, aarch64_push_dummy_call only requires the return type in
order to calculate lang_struct_return. This information is available
in the return_method enum. The fix is to simply use this instead.

Adds testcase to check calls across objects, with all combinations
of c, c++, debug and no debug.

gdb/ChangeLog:

PR gdb/22736:
* aarch64-tdep.c (aarch64_push_dummy_call): Remove
lang_struct_return code.

gdb/testsuite/ChangeLog:

PR gdb/22736:
* gdb.cp/infcall-nodebug-lib.c: New test.
* gdb.cp/infcall-nodebug-main.c: New test.
* gdb.cp/infcall-nodebug.exp: New file.
gdb/ChangeLog
gdb/aarch64-tdep.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/infcall-nodebug-lib.c [new file with mode: 0644]
gdb/testsuite/gdb.cp/infcall-nodebug-main.c [new file with mode: 0644]
gdb/testsuite/gdb.cp/infcall-nodebug.exp [new file with mode: 0644]