Use gdbpy_enter in gdbpy_before_prompt_hook
[binutils-gdb.git] / gdb / h8300-tdep.c
index 98343e0607300662adccbebe1cd6a2dd0f5e48e1..10ef7962e2f9255a5eadf8ad1fee9c9cd9218355 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-machine dependent code for Renesas H8/300, for GDB.
 
-   Copyright (C) 1988-2014 Free Software Foundation, Inc.
+   Copyright (C) 1988-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,7 +28,6 @@
 #include "regcache.h"
 #include "gdbcore.h"
 #include "objfiles.h"
-#include "gdb_assert.h"
 #include "dis-asm.h"
 #include "dwarf2-frame.h"
 #include "frame-base.h"
@@ -237,8 +236,6 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
        }
       else if (IS_MOVL_EXT (w2))
        {
-         int w3 = read_memory_integer (pc + 4, 2, byte_order);
-
          if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order)))
            {
              LONGEST disp = read_memory_integer (pc + 6, 4, byte_order);
@@ -433,7 +430,7 @@ h8300_frame_cache (struct frame_info *this_frame, void **this_cache)
   CORE_ADDR current_pc;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct h8300_frame_cache *) *this_cache;
 
   cache = FRAME_OBSTACK_ZALLOC (struct h8300_frame_cache);
   h8300_init_frame_cache (gdbarch, cache);
@@ -672,7 +669,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
       /* Pad the argument appropriately.  */
       int padded_len = align_up (len, wordsize);
-      gdb_byte *padded = xmalloc (padded_len);
+      gdb_byte *padded = (gdb_byte *) xmalloc (padded_len);
       back_to = make_cleanup (xfree, padded);
 
       memset (padded, 0, padded_len);
@@ -743,7 +740,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
 static void
 h8300_extract_return_value (struct type *type, struct regcache *regcache,
-                           void *valbuf)
+                           gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -761,7 +758,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
       store_unsigned_integer (valbuf, 2, byte_order, c);
       regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-      store_unsigned_integer ((void *)((char *) valbuf + 2), 2, byte_order, c);
+      store_unsigned_integer (valbuf + 2, 2, byte_order, c);
       break;
     case 8:                    /* long long is now 8 bytes.  */
       if (TYPE_CODE (type) == TYPE_CODE_INT)
@@ -780,7 +777,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
 
 static void
 h8300h_extract_return_value (struct type *type, struct regcache *regcache,
-                            void *valbuf)
+                            gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -800,8 +797,7 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache,
          regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
          store_unsigned_integer (valbuf, 4, byte_order, c);
          regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-         store_unsigned_integer ((void *) ((char *) valbuf + 4), 4,
-                                 byte_order, c);
+         store_unsigned_integer (valbuf + 4, 4, byte_order, c);
        }
       else
        {
@@ -846,7 +842,7 @@ h8300h_use_struct_convention (struct type *value_type)
 
 static void
 h8300_store_return_value (struct type *type, struct regcache *regcache,
-                         const void *valbuf)
+                         const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -875,7 +871,7 @@ h8300_store_return_value (struct type *type, struct regcache *regcache,
 
 static void
 h8300h_store_return_value (struct type *type, struct regcache *regcache,
-                          const void *valbuf)
+                          const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -937,8 +933,6 @@ h8300h_return_value (struct gdbarch *gdbarch, struct value *function,
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
-static struct cmd_list_element *setmachinelist;
-
 /* Implementation of 'register_sim_regno' gdbarch method.  */
 
 static int
@@ -1057,7 +1051,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
        fprintf_filtered (file, "u> ");
       if ((C | Z) == 1)
        fprintf_filtered (file, "u<= ");
-      if ((C == 0))
+      if (C == 0)
        fprintf_filtered (file, "u>= ");
       if (C == 1)
        fprintf_filtered (file, "u< ");
@@ -1248,39 +1242,20 @@ h8300s_dbg_reg_to_regnum (struct gdbarch *gdbarch, int regno)
   return regno;
 }
 
-static const unsigned char *
-h8300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
-                         int *lenptr)
-{
-  /*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
-  static unsigned char breakpoint[] = { 0x01, 0x80 };  /* Sleep */
+/*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
+constexpr gdb_byte h8300_break_insn[] = { 0x01, 0x80 };        /* Sleep */
 
-  *lenptr = sizeof (breakpoint);
-  return breakpoint;
-}
-
-static void
-h8300_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
-                       struct frame_info *frame, const char *args)
-{
-  fprintf_filtered (file, "\
-No floating-point info available for this processor.\n");
-}
+typedef BP_MANIPULATION (h8300_break_insn) h8300_breakpoint;
 
 static struct gdbarch *
 h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep = NULL;
   struct gdbarch *gdbarch;
 
   arches = gdbarch_list_lookup_by_info (arches, &info);
   if (arches != NULL)
     return arches->gdbarch;
 
-#if 0
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
-#endif
-
   if (info.bfd_arch_info->arch != bfd_arch_h8300)
     return NULL;
 
@@ -1378,7 +1353,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
   set_gdbarch_register_type (gdbarch, h8300_register_type);
   set_gdbarch_print_registers_info (gdbarch, h8300_print_registers_info);
-  set_gdbarch_print_float_info (gdbarch, h8300_print_float_info);
 
   /*
    * Frame Info
@@ -1397,7 +1371,10 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Stack grows up.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
-  set_gdbarch_breakpoint_from_pc (gdbarch, h8300_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+                                      h8300_breakpoint::kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+                                      h8300_breakpoint::bp_from_kind);
   set_gdbarch_push_dummy_call (gdbarch, h8300_push_dummy_call);
 
   set_gdbarch_char_signed (gdbarch, 0);