[gdb/tdep] Only catch NO_ENTRY_VALUE_ERROR in ppc_sysv_get_return_buf_addr
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Function value_of_dwarf_reg_entry throws a NO_ENTRY_VALUE_ERROR if it cannot
resolve the parameter for any reason.
But in ppc_sysv_get_return_buf_addr we do:
...
try
{
return_val = value_as_address (value_of_dwarf_reg_entry (val_type,
cur_frame,
kind, kind_u));
}
catch (const gdb_exception_error &e)
{
warning ("Cannot determine the function return value.\n"
"Try compiling with -fvar-tracking.");
}
...
which catches any gdb_exception_error, not just NO_ENTRY_VALUE_ERROR.
Fix this by using dwarf_reg_on_entry.
Tested on ppc64le-linux.
---
gdb/dwarf2/loc.c | 22 ++++++++++++++++++++++
gdb/dwarf2/loc.h | 9 +++++++++
gdb/ppc-sysv-tdep.c | 25 +++++++------------------
gdb/s390-tdep.c | 23 -----------------------
4 files changed, 38 insertions(+), 41 deletions(-)
base-commit: d4efbce75f1f98db0837f3791a65d9cb433f7861
@@ -1382,6 +1382,28 @@ value_of_dwarf_reg_entry (struct type *type, const frame_info_ptr &frame,
return val;
}
+/* See dwarf2/loc.h. */
+
+struct value *
+dwarf_reg_on_entry (int dwarf_reg, struct type *val_type,
+ const frame_info_ptr &frame)
+{
+ enum call_site_parameter_kind kind = CALL_SITE_PARAMETER_DWARF_REG;
+ union call_site_parameter_u kind_u = { .dwarf_reg = dwarf_reg };
+
+ try
+ {
+ return value_of_dwarf_reg_entry (val_type, frame, kind, kind_u);
+ }
+ catch (const gdb_exception_error &e)
+ {
+ if (e.error == NO_ENTRY_VALUE_ERROR)
+ return nullptr;
+
+ throw;
+ }
+}
+
/* Read parameter of TYPE at (callee) FRAME's function entry. DATA and
SIZE are DWARF block used to match DW_AT_location at the caller's
DW_TAG_call_site_parameter.
@@ -308,4 +308,13 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type,
const frame_info_ptr &frame,
enum call_site_parameter_kind kind,
union call_site_parameter_u kind_u);
+
+/* Try to get the value of DWARF_REG in FRAME at function entry. If successful,
+ return it as value of type VAL_TYPE. Thin wrapper around
+ value_of_dwarf_reg_entry that catches NO_ENTRY_VALUE_ERROR. */
+
+extern struct value *dwarf_reg_on_entry (int dwarf_reg, struct type *val_type,
+ const frame_info_ptr &frame);
+
+
#endif /* GDB_DWARF2_LOC_H */
@@ -2178,28 +2178,17 @@ ppc_sysv_get_return_buf_addr (struct type *val_type,
function using the DW_OP_entry_value DWARF entries. This requires
compiling the user program with -fvar-tracking to resolve the
DW_TAG_call_sites in the binary file. */
+ int dwarf_reg = 3;
- union call_site_parameter_u kind_u;
- enum call_site_parameter_kind kind;
- CORE_ADDR return_val = 0;
+ struct value *val_on_entry
+ = dwarf_reg_on_entry (dwarf_reg, lookup_pointer_type (val_type), cur_frame);
- kind_u.dwarf_reg = 3; /* First passed arg/return value is in r3. */
- kind = CALL_SITE_PARAMETER_DWARF_REG;
-
- /* val_type is the type of the return value. Need the pointer type
- to the return value. */
- val_type = lookup_pointer_type (val_type);
-
- try
- {
- return_val = value_as_address (value_of_dwarf_reg_entry (val_type,
- cur_frame,
- kind, kind_u));
- }
- catch (const gdb_exception_error &e)
+ if (val_on_entry == nullptr)
{
warning ("Cannot determine the function return value.\n"
"Try compiling with -fvar-tracking.");
+ return 0;
}
- return return_val;
+
+ return value_as_address (val_on_entry);
}
@@ -2120,29 +2120,6 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function,
return rvc;
}
-/* Try to get the value of DWARF_REG in FRAME at function entry. If successful,
- return it as value of type VAL_TYPE. */
-
-static struct value *
-dwarf_reg_on_entry (int dwarf_reg, struct type *val_type,
- const frame_info_ptr &frame)
-{
- enum call_site_parameter_kind kind = CALL_SITE_PARAMETER_DWARF_REG;
- union call_site_parameter_u kind_u = { .dwarf_reg = dwarf_reg };
-
- try
- {
- return value_of_dwarf_reg_entry (val_type, frame, kind, kind_u);
- }
- catch (const gdb_exception_error &e)
- {
- if (e.error == NO_ENTRY_VALUE_ERROR)
- return nullptr;
-
- throw;
- }
-}
-
/* Both the 32-bit and 64-bit ABIs specify that values of some types are
returned in a storage buffer provided by the caller. Return the address of
that storage buffer, if possible. Implements the