[mainline/7.12.1] Create tdep->rl78_psw_type lazily

Message ID 20161209160543.GH13661@E107787-LIN
State New, archived
Headers

Commit Message

Yao Qi Dec. 9, 2016, 4:05 p.m. UTC
  On 16-12-09 12:52:41, Yao Qi wrote:
> gdb:
> 
> 2016-12-09  Yao Qi  <yao.qi@linaro.org>
> 
> 	PR tdep/20953
> 	* rl78-tdep.c (rl78_psw_type): New function.
> 	(rl78_register_type): Call rl78_psw_type.
> 	(rl78_gdbarch_init): Move code to rl78_psw_type.

Patch is pushed into 7.12 branch.  Patch is updated for
gdb.base/all-architectures.exp.in, and pushed into master
as below.
  

Patch

diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 95a26a5..0e88fbc 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -261,6 +261,30 @@  struct rl78_prologue
   int reg_offset[RL78_NUM_TOTAL_REGS];
 };
 
+/* Construct type for PSW register.  */
+
+static struct type *
+rl78_psw_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (tdep->rl78_psw_type == NULL)
+    {
+      tdep->rl78_psw_type = arch_flags_type (gdbarch,
+					     "builtin_type_rl78_psw", 1);
+      append_flags_type_flag (tdep->rl78_psw_type, 0, "CY");
+      append_flags_type_flag (tdep->rl78_psw_type, 1, "ISP0");
+      append_flags_type_flag (tdep->rl78_psw_type, 2, "ISP1");
+      append_flags_type_flag (tdep->rl78_psw_type, 3, "RBS0");
+      append_flags_type_flag (tdep->rl78_psw_type, 4, "AC");
+      append_flags_type_flag (tdep->rl78_psw_type, 5, "RBS1");
+      append_flags_type_flag (tdep->rl78_psw_type, 6, "Z");
+      append_flags_type_flag (tdep->rl78_psw_type, 7, "IE");
+    }
+
+  return tdep->rl78_psw_type;
+}
+
 /* Implement the "register_type" gdbarch method.  */
 
 static struct type *
@@ -273,7 +297,7 @@  rl78_register_type (struct gdbarch *gdbarch, int reg_nr)
   else if (reg_nr == RL78_RAW_PC_REGNUM)
     return tdep->rl78_uint32;
   else if (reg_nr == RL78_PSW_REGNUM)
-    return (tdep->rl78_psw_type);
+    return rl78_psw_type (gdbarch);
   else if (reg_nr <= RL78_MEM_REGNUM
            || (RL78_X_REGNUM <= reg_nr && reg_nr <= RL78_H_REGNUM)
 	   || (RL78_BANK0_R0_REGNUM <= reg_nr
@@ -1406,16 +1430,6 @@  rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->rl78_code_pointer
     = arch_pointer_type (gdbarch, 32, "rl78_code_addr_t", tdep->rl78_void);
 
-  tdep->rl78_psw_type = arch_flags_type (gdbarch, "builtin_type_rl78_psw", 1);
-  append_flags_type_flag (tdep->rl78_psw_type, 0, "CY");
-  append_flags_type_flag (tdep->rl78_psw_type, 1, "ISP0");
-  append_flags_type_flag (tdep->rl78_psw_type, 2, "ISP1");
-  append_flags_type_flag (tdep->rl78_psw_type, 3, "RBS0");
-  append_flags_type_flag (tdep->rl78_psw_type, 4, "AC");
-  append_flags_type_flag (tdep->rl78_psw_type, 5, "RBS1");
-  append_flags_type_flag (tdep->rl78_psw_type, 6, "Z");
-  append_flags_type_flag (tdep->rl78_psw_type, 7, "IE");
-
   /* Registers.  */
   set_gdbarch_num_regs (gdbarch, RL78_NUM_REGS);
   set_gdbarch_num_pseudo_regs (gdbarch, RL78_NUM_PSEUDO_REGS);
diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.in b/gdb/testsuite/gdb.base/all-architectures.exp.in
index 4a8099c..94bee2e 100644
--- a/gdb/testsuite/gdb.base/all-architectures.exp.in
+++ b/gdb/testsuite/gdb.base/all-architectures.exp.in
@@ -209,12 +209,6 @@  with_test_prefix "tests" {
 		continue
 	    }
 
-	    if {$arch == "rl78"} {
-		if {$want_tests_messages} {
-		    kfail "set architecture rl78" "gdb/20953"
-		}
-		continue
-	    }
 	    if {$arch == "rx"} {
 		if {$want_tests_messages} {
 		    kfail "set architecture rx" "gdb/20954"