From: Luis Machado Date: Thu, 7 Jan 2021 15:21:29 +0000 (-0300) Subject: Handle unavailable LR/PC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9914a01926da197b2299125166f8d22750c34da;p=thirdparty%2Fbinutils-gdb.git Handle unavailable LR/PC This fixes a situation where LR/PC is not available, so we need to throw an error rather than continuing. gdb/ChangeLog: 2021-01-15 Luis Machado * aarch64-tdep.c (aarch64_prologue_prev_register) (aarch64_dwarf2_prev_register): Throw error if LR is optimized out. --- diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 4918f736e02..c805c50ac08 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1452,6 +1452,12 @@ aarch64_prologue_prev_register (struct frame_info *this_frame, struct value *lr_value = frame_unwind_register_value (this_frame, lr_regnum); + /* Make sure LR is available. If not, there is nothing we can do. */ + if (lr_value == nullptr || (lr_value != nullptr + && value_optimized_out (lr_value))) + throw_error (OPTIMIZED_OUT_ERROR, _("Register %d was not saved"), + prev_regnum); + /* Extract only the bottom 8 bytes of CLR. This truncates the capability to 8 bytes. For LR, this gets us the whole register. */ lr = extract_unsigned_integer (value_contents_all (lr_value).data (), 8, @@ -1648,7 +1654,13 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame, lr_regnum = tdep->cap_reg_clr; struct value *lr_value = frame_unwind_register_value (this_frame, - lr_regnum); + lr_regnum); + + /* Make sure LR is available. If not, there is nothing we can do. */ + if (lr_value == nullptr || (lr_value != nullptr + && value_optimized_out (lr_value))) + throw_error (OPTIMIZED_OUT_ERROR, _("Register %d was not saved"), + regnum); /* Extract only the bottom 8 bytes of CLR. This truncates the capability to 8 bytes. For LR, this gets us the whole register. */