aboutsummaryrefslogtreecommitdiff
path: root/gdb/nds32-tdep.c
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2017-04-26 09:57:15 +0100
committerAlan Hayward <alan.hayward@arm.com>2017-04-26 09:57:15 +0100
commit19c4559475791cd70e319eaf5c1e23d23d9ae81e (patch)
tree31d818dcb8e6cbbab7133b16889ba9ce1b8d64e5 /gdb/nds32-tdep.c
parent03def0812a9ee962d9dcfe9b0ba37783e58acfb8 (diff)
downloadgdb-19c4559475791cd70e319eaf5c1e23d23d9ae81e.zip
gdb-19c4559475791cd70e319eaf5c1e23d23d9ae81e.tar.gz
gdb-19c4559475791cd70e319eaf5c1e23d23d9ae81e.tar.bz2
nds32: Abort instead of returning REG_UNKNOWN
gdb/ * nds32-tdep.c (nds32_pseudo_register_read): Abort on errors. (nds32_pseudo_register_write): Likewise.
Diffstat (limited to 'gdb/nds32-tdep.c')
-rw-r--r--gdb/nds32-tdep.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index e0eea37..f942780 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -445,11 +445,12 @@ nds32_pseudo_register_read (struct gdbarch *gdbarch,
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
gdb_byte reg_buf[8];
int offset, fdr_regnum;
- enum register_status status = REG_UNKNOWN;
+ enum register_status status;
- /* Sanity check. */
- if (tdep->fpu_freg == -1 || tdep->use_pseudo_fsrs == 0)
- return status;
+ /* This function is registered in nds32_gdbarch_init only after these are
+ set. */
+ gdb_assert (tdep->fpu_freg != -1);
+ gdb_assert (tdep->use_pseudo_fsrs != 0);
regnum -= gdbarch_num_regs (gdbarch);
@@ -466,9 +467,11 @@ nds32_pseudo_register_read (struct gdbarch *gdbarch,
status = regcache_raw_read (regcache, fdr_regnum, reg_buf);
if (status == REG_VALID)
memcpy (buf, reg_buf + offset, 4);
+
+ return status;
}
- return status;
+ gdb_assert_not_reached ("invalid pseudo register number");
}
/* Implement the "pseudo_register_write" gdbarch method. */
@@ -482,9 +485,10 @@ nds32_pseudo_register_write (struct gdbarch *gdbarch,
gdb_byte reg_buf[8];
int offset, fdr_regnum;
- /* Sanity check. */
- if (tdep->fpu_freg == -1 || tdep->use_pseudo_fsrs == 0)
- return;
+ /* This function is registered in nds32_gdbarch_init only after these are
+ set. */
+ gdb_assert (tdep->fpu_freg != -1);
+ gdb_assert (tdep->use_pseudo_fsrs != 0);
regnum -= gdbarch_num_regs (gdbarch);
@@ -501,7 +505,10 @@ nds32_pseudo_register_write (struct gdbarch *gdbarch,
regcache_raw_read (regcache, fdr_regnum, reg_buf);
memcpy (reg_buf + offset, buf, 4);
regcache_raw_write (regcache, fdr_regnum, reg_buf);
+ return;
}
+
+ gdb_assert_not_reached ("invalid pseudo register number");
}
/* Helper function for NDS32 ABI. Return true if FPRs can be used