]> 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)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:53:23 +0000 (15:53 -0700)
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/aarch64-tdep.c

index 4918f736e02e8b7f0bf820b9fe6214437ec4a5dc..c805c50ac083266f29a73e0f3c93109ff2b0cbc9 100644 (file)
@@ -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.  */