gdb/ia64-vms-tdep.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Target-dependent code for OpenVMS IA-64.

  2.    Copyright (C) 2012-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "frame-unwind.h"
  16. #include "ia64-tdep.h"
  17. #include "osabi.h"
  18. #include "gdbtypes.h"
  19. #include "gdbcore.h"

  20. #ifdef HAVE_LIBUNWIND_IA64_H

  21. /* Libunwind callback accessor function to acquire procedure unwind-info.  */

  22. static int
  23. ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
  24.                            unw_proc_info_t *pi,
  25.                            int need_unwind_info, void *arg)
  26. {
  27.   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
  28.   unw_dyn_info_t di;
  29.   int ret;
  30.   gdb_byte buf[32];
  31.   const char *annex = core_addr_to_string (ip);
  32.   LONGEST res;
  33.   CORE_ADDR table_addr;
  34.   unsigned int info_len;

  35.   res = target_read (&current_target, TARGET_OBJECT_OPENVMS_UIB,
  36.                      annex + 2, buf, 0, sizeof (buf));

  37.   if (res != sizeof (buf))
  38.     return -UNW_ENOINFO;

  39.   pi->format = UNW_INFO_FORMAT_REMOTE_TABLE;
  40.   pi->start_ip = extract_unsigned_integer (buf + 0, 8, byte_order);
  41.   pi->end_ip = extract_unsigned_integer (buf + 8, 8, byte_order);
  42.   pi->gp = extract_unsigned_integer (buf + 24, 8, byte_order);
  43.   table_addr = extract_unsigned_integer (buf + 16, 8, byte_order);

  44.   if (table_addr == 0)
  45.     {
  46.       /* No unwind data.  */
  47.       pi->unwind_info = NULL;
  48.       pi->unwind_info_size = 0;
  49.       return 0;
  50.     }

  51.   res = target_read_memory (table_addr, buf, 8);
  52.   if (res != 0)
  53.     return -UNW_ENOINFO;

  54.   /* Check version.  */
  55.   if (extract_unsigned_integer (buf + 6, 2, byte_order) != 1)
  56.     return -UNW_EBADVERSION;
  57.   info_len = extract_unsigned_integer (buf + 0, 4, byte_order);
  58.   pi->unwind_info_size = 8 * info_len;

  59.   /* Read info.  */
  60.   pi->unwind_info = xmalloc (pi->unwind_info_size);

  61.   res = target_read_memory (table_addr + 8,
  62.                             pi->unwind_info, pi->unwind_info_size);
  63.   if (res != 0)
  64.     {
  65.       xfree (pi->unwind_info);
  66.       pi->unwind_info = NULL;
  67.       return -UNW_ENOINFO;
  68.     }

  69.   /* FIXME: Handle OSSD (OS Specific Data).  This extension to ia64 unwind
  70.      information by OpenVMS is currently not handled by libunwind, but
  71.      looks to be used only in very specific context, and is not generated by
  72.      GCC.  */

  73.   pi->lsda = table_addr + 8 + pi->unwind_info_size;
  74.   if (extract_unsigned_integer (buf + 4, 2, byte_order) & 3)
  75.     {
  76.       pi->lsda += 8;
  77.       /* There might be an handler, but this is not used for unwinding.  */
  78.       pi->handler = 0;
  79.     }

  80.   return 0;
  81. }

  82. /* Libunwind callback accessor function for cleanup.  */

  83. static void
  84. ia64_vms_put_unwind_info (unw_addr_space_t as,
  85.                           unw_proc_info_t *pip, void *arg)
  86. {
  87.   /* Nothing required for now.  */
  88. }

  89. /* Libunwind callback accessor function to get head of the dynamic
  90.    unwind-info registration list.  */

  91. static int
  92. ia64_vms_get_dyn_info_list (unw_addr_space_t as,
  93.                             unw_word_t *dilap, void *arg)
  94. {
  95.   return -UNW_ENOINFO;
  96. }

  97. /* Set of libunwind callback acccessor functions.  */
  98. static unw_accessors_t ia64_vms_unw_accessors;
  99. static unw_accessors_t ia64_vms_unw_rse_accessors;

  100. /* Set of ia64-libunwind-tdep gdb callbacks and data for generic
  101.    ia64-libunwind-tdep code to use.  */
  102. static struct libunwind_descr ia64_vms_libunwind_descr;

  103. #endif /* HAVE_LIBUNWIND_IA64_H */

  104. static void
  105. ia64_openvms_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  106. {
  107.   set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);

  108. #ifdef HAVE_LIBUNWIND_IA64_H
  109.   /* Override the default descriptor.  */
  110.   ia64_vms_unw_accessors = ia64_unw_accessors;
  111.   ia64_vms_unw_accessors.find_proc_info = ia64_vms_find_proc_info_x;
  112.   ia64_vms_unw_accessors.put_unwind_info = ia64_vms_put_unwind_info;
  113.   ia64_vms_unw_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;

  114.   ia64_vms_unw_rse_accessors = ia64_unw_rse_accessors;
  115.   ia64_vms_unw_rse_accessors.find_proc_info = ia64_vms_find_proc_info_x;
  116.   ia64_vms_unw_rse_accessors.put_unwind_info = ia64_vms_put_unwind_info;
  117.   ia64_vms_unw_rse_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;

  118.   ia64_vms_libunwind_descr = ia64_libunwind_descr;
  119.   ia64_vms_libunwind_descr.accessors = &ia64_vms_unw_accessors;
  120.   ia64_vms_libunwind_descr.special_accessors = &ia64_vms_unw_rse_accessors;

  121.   libunwind_frame_set_descr (gdbarch, &ia64_vms_libunwind_descr);
  122. #endif
  123. }

  124. /* Provide a prototype to silence -Wmissing-prototypes.  */
  125. extern initialize_file_ftype _initialize_ia64_vms_tdep;

  126. void
  127. _initialize_ia64_vms_tdep (void)
  128. {
  129.   gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_OPENVMS,
  130.                           ia64_openvms_init_abi);
  131. }