Add symbol::matches method
[binutils-gdb.git] / gdb / m68k-tdep.c
index 76046c0b1dd583e7740a6e22d51c09684b3ddad7..5b2a29a350e53d2a7d366dcfcd95213d57b63897 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Motorola 68000 series.
 
-   Copyright (C) 1990-2020 Free Software Foundation, Inc.
+   Copyright (C) 1990-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -70,7 +70,7 @@ typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint;
 static struct type *
 m68k_ps_type (struct gdbarch *gdbarch)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->m68k_ps_type)
     {
@@ -99,12 +99,15 @@ m68k_ps_type (struct gdbarch *gdbarch)
 static struct type *
 m68881_ext_type (struct gdbarch *gdbarch)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->m68881_ext_type)
-    tdep->m68881_ext_type
-      = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext",
-                        floatformats_m68881_ext);
+    {
+      type_allocator alloc (gdbarch);
+      tdep->m68881_ext_type
+       = init_float_type (alloc, -1, "builtin_type_m68881_ext",
+                          floatformats_m68881_ext);
+    }
 
   return tdep->m68881_ext_type;
 }
@@ -120,7 +123,7 @@ m68881_ext_type (struct gdbarch *gdbarch)
 static struct type *
 m68k_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->fpregs_present)
     {
@@ -171,12 +174,11 @@ static const char * const m68k_register_names[] = {
 static const char *
 m68k_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names))
-    internal_error (__FILE__, __LINE__,
-                   _("m68k_register_name: illegal register number %d"),
-                   regnum);
-  else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
-          && gdbarch_tdep (gdbarch)->fpregs_present == 0)
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+
+  gdb_static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
+  if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
+      && tdep->fpregs_present == 0)
     return "";
   else
     return m68k_register_names[regnum];
@@ -189,7 +191,9 @@ static int
 m68k_convert_register_p (struct gdbarch *gdbarch,
                         int regnum, struct type *type)
 {
-  if (!gdbarch_tdep (gdbarch)->fpregs_present)
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+
+  if (!tdep->fpregs_present)
     return 0;
   return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
          /* We only support floating-point values.  */
@@ -201,7 +205,7 @@ m68k_convert_register_p (struct gdbarch *gdbarch,
    return its contents in TO.  */
 
 static int
-m68k_register_to_value (struct frame_info *frame, int regnum,
+m68k_register_to_value (frame_info_ptr frame, int regnum,
                        struct type *type, gdb_byte *to,
                        int *optimizedp, int *unavailablep)
 {
@@ -213,8 +217,10 @@ m68k_register_to_value (struct frame_info *frame, int regnum,
 
   /* Convert to TYPE.  */
   if (!get_frame_register_bytes (frame, regnum, 0,
-                                register_size (gdbarch, regnum),
-                                from, optimizedp, unavailablep))
+                                gdb::make_array_view (from,
+                                                      register_size (gdbarch,
+                                                                     regnum)),
+                                optimizedp, unavailablep))
     return 0;
 
   target_float_convert (from, fpreg_type, to, type);
@@ -226,7 +232,7 @@ m68k_register_to_value (struct frame_info *frame, int regnum,
    REGNUM in frame FRAME.  */
 
 static void
-m68k_value_to_register (struct frame_info *frame, int regnum,
+m68k_value_to_register (frame_info_ptr frame, int regnum,
                        struct type *type, const gdb_byte *from)
 {
   gdb_byte to[M68K_MAX_REGISTER_SIZE];
@@ -288,13 +294,13 @@ static void
 m68k_extract_return_value (struct type *type, struct regcache *regcache,
                           gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
 
   if (type->code () == TYPE_CODE_PTR && len == 4)
     {
       struct gdbarch *gdbarch = regcache->arch ();
-      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+      m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
       regcache->raw_read (tdep->pointer_result_regnum, valbuf);
     }
   else if (len <= 4)
@@ -309,8 +315,7 @@ m68k_extract_return_value (struct type *type, struct regcache *regcache,
       regcache->raw_read (M68K_D1_REGNUM, valbuf + (len - 4));
     }
   else
-    internal_error (__FILE__, __LINE__,
-                   _("Cannot extract return value of %d bytes long."), len);
+    internal_error (_("Cannot extract return value of %d bytes long."), len);
 }
 
 static void
@@ -319,7 +324,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
 {
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
   struct gdbarch *gdbarch = regcache->arch ();
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->float_return && type->code () == TYPE_CODE_FLT)
     {
@@ -337,12 +342,12 @@ static void
 m68k_store_return_value (struct type *type, struct regcache *regcache,
                         const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
 
   if (type->code () == TYPE_CODE_PTR && len == 4)
     {
       struct gdbarch *gdbarch = regcache->arch ();
-      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+      m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
       regcache->raw_write (tdep->pointer_result_regnum, valbuf);
       /* gdb historically also set D0 in the SVR4 case.  */
       if (tdep->pointer_result_regnum != M68K_D0_REGNUM)
@@ -356,8 +361,7 @@ m68k_store_return_value (struct type *type, struct regcache *regcache,
       regcache->raw_write (M68K_D1_REGNUM, valbuf + (len - 4));
     }
   else
-    internal_error (__FILE__, __LINE__,
-                   _("Cannot store return value of %d bytes long."), len);
+    internal_error (_("Cannot store return value of %d bytes long."), len);
 }
 
 static void
@@ -365,7 +369,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
                              const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->float_return && type->code () == TYPE_CODE_FLT)
     {
@@ -385,9 +389,9 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
 static int
 m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
   enum type_code code = type->code ();
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
 
   gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
              || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY);
@@ -398,7 +402,7 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
   const bool is_vector = code == TYPE_CODE_ARRAY && type->is_vector ();
 
   if (is_vector
-      && check_typedef (TYPE_TARGET_TYPE (type))->code () == TYPE_CODE_FLT)
+      && check_typedef (type->target_type ())->code () == TYPE_CODE_FLT)
     return 0;
 
   /* According to m68k_return_in_memory in the m68k GCC back-end,
@@ -432,18 +436,18 @@ m68k_return_value (struct gdbarch *gdbarch, struct value *function,
   if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
        || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
        && !m68k_reg_struct_return_p (gdbarch, type))
-      || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12))
+      || (code == TYPE_CODE_FLT && type->length () == 12))
     {
       /* The default on m68k is to return structures in static memory.
-         Consequently a function must return the address where we can
-         find the return value.  */
+        Consequently a function must return the address where we can
+        find the return value.  */
 
       if (readbuf)
        {
          ULONGEST addr;
 
          regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr);
-         read_memory (addr, readbuf, TYPE_LENGTH (type));
+         read_memory (addr, readbuf, type->length ());
        }
 
       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@@ -463,6 +467,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
                        gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum type_code code = type->code ();
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   /* Aggregates with a single member are always returned like their
      sole element.  */
@@ -478,9 +483,9 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
        || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY)
        && !m68k_reg_struct_return_p (gdbarch, type))
       /* GCC may return a `long double' in memory too.  */
-      || (!gdbarch_tdep (gdbarch)->float_return
+      || (!tdep->float_return
          && code == TYPE_CODE_FLT
-         && TYPE_LENGTH (type) == 12))
+         && type->length () == 12))
     {
       /* The System V ABI says that:
 
@@ -498,12 +503,11 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
 
       if (readbuf)
        {
-         struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
          ULONGEST addr;
 
          regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum,
                                      &addr);
-         read_memory (addr, readbuf, TYPE_LENGTH (type));
+         read_memory (addr, readbuf, type->length ());
        }
 
       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@@ -535,7 +539,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      function_call_return_method return_method,
                      CORE_ADDR struct_addr)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int i;
@@ -543,8 +547,8 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   /* Push arguments in reverse order.  */
   for (i = nargs - 1; i >= 0; i--)
     {
-      struct type *value_type = value_enclosing_type (args[i]);
-      int len = TYPE_LENGTH (value_type);
+      struct type *value_type = args[i]->enclosing_type ();
+      int len = value_type->length ();
       int container_len = (len + 3) & ~3;
       int offset;
 
@@ -558,7 +562,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       else
        offset = container_len - len;
       sp -= container_len;
-      write_memory (sp + offset, value_contents_all (args[i]), len);
+      write_memory (sp + offset, args[i]->contents_all ().data (), len);
     }
 
   /* Store struct value address.  */
@@ -590,13 +594,15 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 static int
 m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num)
 {
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+
   if (num < 8)
     /* d0..7 */
     return (num - 0) + M68K_D0_REGNUM;
   else if (num < 16)
     /* a0..7 */
     return (num - 8) + M68K_A0_REGNUM;
-  else if (num < 24 && gdbarch_tdep (gdbarch)->fpregs_present)
+  else if (num < 24 && tdep->fpregs_present)
     /* fp0..7 */
     return (num - 16) + M68K_FP0_REGNUM;
   else if (num == 25)
@@ -758,6 +764,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
                             struct m68k_frame_cache *cache)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (cache->locals >= 0)
     {
@@ -770,7 +777,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
        {
          op = read_memory_unsigned_integer (pc, 2, byte_order);
          if (op == P_FMOVEMX_SP
-             && gdbarch_tdep (gdbarch)->fpregs_present)
+             && tdep->fpregs_present)
            {
              /* fmovem.x REGS,-(%sp) */
              op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
@@ -892,7 +899,7 @@ m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 }
 
 static CORE_ADDR
-m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
+m68k_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
 {
   gdb_byte buf[8];
 
@@ -903,7 +910,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 /* Normal frames.  */
 
 static struct m68k_frame_cache *
-m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
+m68k_frame_cache (frame_info_ptr this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -968,7 +975,7 @@ m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
 }
 
 static void
-m68k_frame_this_id (struct frame_info *this_frame, void **this_cache,
+m68k_frame_this_id (frame_info_ptr this_frame, void **this_cache,
                    struct frame_id *this_id)
 {
   struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
@@ -982,7 +989,7 @@ m68k_frame_this_id (struct frame_info *this_frame, void **this_cache,
 }
 
 static struct value *
-m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache,
+m68k_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
                          int regnum)
 {
   struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
@@ -1001,6 +1008,7 @@ m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 
 static const struct frame_unwind m68k_frame_unwind =
 {
+  "m68k prologue",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   m68k_frame_this_id,
@@ -1010,7 +1018,7 @@ static const struct frame_unwind m68k_frame_unwind =
 };
 \f
 static CORE_ADDR
-m68k_frame_base_address (struct frame_info *this_frame, void **this_cache)
+m68k_frame_base_address (frame_info_ptr this_frame, void **this_cache)
 {
   struct m68k_frame_cache *cache = m68k_frame_cache (this_frame, this_cache);
 
@@ -1026,7 +1034,7 @@ static const struct frame_base m68k_frame_base =
 };
 
 static struct frame_id
-m68k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
+m68k_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
 {
   CORE_ADDR fp;
 
@@ -1043,18 +1051,17 @@ m68k_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
    This routine returns true on success.  */
 
 static int
-m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
+m68k_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
 {
   gdb_byte *buf;
   CORE_ADDR sp, jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   if (tdep->jb_pc < 0)
     {
-      internal_error (__FILE__, __LINE__,
-                     _("m68k_get_longjmp_target: not implemented"));
+      internal_error (_("m68k_get_longjmp_target: not implemented"));
       return 0;
     }
 
@@ -1094,7 +1101,7 @@ m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
 void
 m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   /* SVR4 uses a different calling convention.  */
   set_gdbarch_return_value (gdbarch, m68k_svr4_return_value);
@@ -1112,7 +1119,7 @@ m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   m68k_svr4_init_abi (info, gdbarch);
   tdep->pointer_result_regnum = M68K_D0_REGNUM;
@@ -1127,10 +1134,8 @@ m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static struct gdbarch *
 m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep = NULL;
-  struct gdbarch *gdbarch;
   struct gdbarch_list *best_arch;
-  struct tdesc_arch_data *tdesc_data = NULL;
+  tdesc_arch_data_up tdesc_data;
   int i;
   enum m68k_flavour flavour = m68k_no_flavour;
   int has_fp = 1;
@@ -1168,14 +1173,11 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
       valid_p = 1;
       for (i = 0; i <= M68K_PC_REGNUM; i++)
-       valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
+       valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
                                            m68k_register_names[i]);
 
       if (!valid_p)
-       {
-         tdesc_data_cleanup (tdesc_data);
-         return NULL;
-       }
+       return NULL;
 
       feature = tdesc_find_feature (info.target_desc,
                                    "org.gnu.gdb.coldfire.fp");
@@ -1183,13 +1185,10 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        {
          valid_p = 1;
          for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
-           valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
+           valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
                                                m68k_register_names[i]);
          if (!valid_p)
-           {
-             tdesc_data_cleanup (tdesc_data);
-             return NULL;
-           }
+           return NULL;
        }
       else
        has_fp = 0;
@@ -1233,27 +1232,28 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch != NULL;
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
-      if (flavour != gdbarch_tdep (best_arch->gdbarch)->flavour)
+      m68k_gdbarch_tdep *tdep
+       = gdbarch_tdep<m68k_gdbarch_tdep> (best_arch->gdbarch);
+
+      if (flavour != tdep->flavour)
        continue;
 
-      if (has_fp != gdbarch_tdep (best_arch->gdbarch)->fpregs_present)
+      if (has_fp != tdep->fpregs_present)
        continue;
 
-      if (float_return != gdbarch_tdep (best_arch->gdbarch)->float_return)
+      if (float_return != tdep->float_return)
        continue;
 
       break;
     }
 
   if (best_arch != NULL)
-    {
-      if (tdesc_data != NULL)
-       tdesc_data_cleanup (tdesc_data);
-      return best_arch->gdbarch;
-    }
+    return best_arch->gdbarch;
+
+  gdbarch *gdbarch
+    = gdbarch_alloc (&info, gdbarch_tdep_up (new m68k_gdbarch_tdep));
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
-  tdep = XCNEW (struct gdbarch_tdep);
-  gdbarch = gdbarch_alloc (&info, tdep);
   tdep->fpregs_present = has_fp;
   tdep->float_return = float_return;
   tdep->flavour = flavour;
@@ -1327,8 +1327,8 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   frame_unwind_append_unwinder (gdbarch, &m68k_frame_unwind);
 
-  if (tdesc_data)
-    tdesc_use_registers (gdbarch, info.target_desc, tdesc_data);
+  if (tdesc_data != nullptr)
+    tdesc_use_registers (gdbarch, info.target_desc, std::move (tdesc_data));
 
   return gdbarch;
 }
@@ -1337,7 +1337,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep == NULL)
     return;