]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle unavailable LR/PC
authorLuis Machado <luis.machado@linaro.org>
Thu, 7 Jan 2021 15:21:29 +0000 (12:21 -0300)
committerLuis Machado <luis.machado@linaro.org>
Fri, 15 Jan 2021 21:55:43 +0000 (18:55 -0300)
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  <luis.machado@arm.com>

* aarch64-tdep.c (aarch64_prologue_prev_register)
(aarch64_dwarf2_prev_register): Throw error if LR is optimized out.

gdb/ChangeLog
gdb/aarch64-tdep.c

index 760765b6ff3145e388fcfea4dd32ef32ff6bb755..f454cf3c1f23c460b7ef18a9432504b28befc077 100644 (file)
@@ -1,3 +1,8 @@
+2021-01-15  Luis Machado  <luis.machado@arm.com>
+
+       * aarch64-tdep.c (aarch64_prologue_prev_register)
+       (aarch64_dwarf2_prev_register): Throw error if LR is optimized out.
+
 2021-01-15  Luis Machado  <luis.machado@arm.com>
 
        * Makefile.in (HFILES_NO_SRCDIR): Add nat/aarch64-cap-linux.h.
index e1792e70a490a97c61e68ea0f54eb54da2acf195..d805040c86a0b00921e6e58665b06a05fc162a5a 100644 (file)
@@ -1413,6 +1413,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), 8,
@@ -1607,8 +1613,14 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame,
       else
        lr_regnum = tdep->cap_reg_clr;
 
-       struct value *lr_value = frame_unwind_register_value (this_frame,
-                                                            lr_regnum);
+      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"),
+                    regnum);
 
       /* Extract only the bottom 8 bytes of CLR.  This truncates the capability
         to 8 bytes.  For LR, this gets us the whole register.  */