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

Weimin Pan
2018-05-25T23:20:30Z

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().

Tested on aarch64-linux-gnu. No regressions.
---
gdb/ChangeLog | 6 ++++++
gdb/aarch64-tdep.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6f4153b..4c5691f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-23 Weimin Pan <weimin.pan@oracle.com>
+
+ PR gdb/22736:
+ * aarch64-tdep.c (aarch64_push_dummy_call): Do not call
+ language_pass_by_reference if return_type is NULL.
+
2018-05-14 Weimin Pan <weimin.pan@oracle.com>

* minsyms.h (lookup_minimal_symbol_and_objfile): Remove declaration.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 01566b4..b4633ff 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1426,7 +1426,9 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
given an additional initial argument, a hidden pointer to the
return slot in memory. */
return_type = TYPE_TARGET_TYPE (func_type);
- lang_struct_return = language_pass_by_reference (return_type);
+ lang_struct_return = (return_type != NULL
+ ? language_pass_by_reference (return_type)
+ : 0);

/* Set the return address. For the AArch64, the return breakpoint
is always at BP_ADDR. */
--
1.8.3.1