1 /* Target-dependent code for OpenVMS IA-64.
3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "frame-unwind.h"
22 #include "ia64-tdep.h"
27 #ifdef HAVE_LIBUNWIND_IA64_H
29 /* Libunwind callback accessor function to acquire procedure unwind-info. */
32 ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
34 int need_unwind_info, void *arg)
36 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
38 const char *annex = core_addr_to_string (ip);
41 unsigned int info_len;
43 res = target_read (current_top_target (), TARGET_OBJECT_OPENVMS_UIB,
44 annex + 2, buf, 0, sizeof (buf));
46 if (res != sizeof (buf))
49 pi->format = UNW_INFO_FORMAT_REMOTE_TABLE;
50 pi->start_ip = extract_unsigned_integer (buf + 0, 8, byte_order);
51 pi->end_ip = extract_unsigned_integer (buf + 8, 8, byte_order);
52 pi->gp = extract_unsigned_integer (buf + 24, 8, byte_order);
53 table_addr = extract_unsigned_integer (buf + 16, 8, byte_order);
58 pi->unwind_info = NULL;
59 pi->unwind_info_size = 0;
63 res = target_read_memory (table_addr, buf, 8);
68 if (extract_unsigned_integer (buf + 6, 2, byte_order) != 1)
69 return -UNW_EBADVERSION;
70 info_len = extract_unsigned_integer (buf + 0, 4, byte_order);
71 pi->unwind_info_size = 8 * info_len;
74 pi->unwind_info = xmalloc (pi->unwind_info_size);
76 res = target_read_memory (table_addr + 8,
77 (gdb_byte *) pi->unwind_info, pi->unwind_info_size);
80 xfree (pi->unwind_info);
81 pi->unwind_info = NULL;
85 /* FIXME: Handle OSSD (OS Specific Data). This extension to ia64 unwind
86 information by OpenVMS is currently not handled by libunwind, but
87 looks to be used only in very specific context, and is not generated by
90 pi->lsda = table_addr + 8 + pi->unwind_info_size;
91 if (extract_unsigned_integer (buf + 4, 2, byte_order) & 3)
94 /* There might be an handler, but this is not used for unwinding. */
101 /* Libunwind callback accessor function for cleanup. */
104 ia64_vms_put_unwind_info (unw_addr_space_t as,
105 unw_proc_info_t *pip, void *arg)
107 /* Nothing required for now. */
110 /* Libunwind callback accessor function to get head of the dynamic
111 unwind-info registration list. */
114 ia64_vms_get_dyn_info_list (unw_addr_space_t as,
115 unw_word_t *dilap, void *arg)
120 /* Set of libunwind callback acccessor functions. */
121 static unw_accessors_t ia64_vms_unw_accessors;
122 static unw_accessors_t ia64_vms_unw_rse_accessors;
124 /* Set of ia64-libunwind-tdep gdb callbacks and data for generic
125 ia64-libunwind-tdep code to use. */
126 static struct libunwind_descr ia64_vms_libunwind_descr;
128 #endif /* HAVE_LIBUNWIND_IA64_H */
131 ia64_openvms_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
133 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
135 #ifdef HAVE_LIBUNWIND_IA64_H
136 /* Override the default descriptor. */
137 ia64_vms_unw_accessors = ia64_unw_accessors;
138 ia64_vms_unw_accessors.find_proc_info = ia64_vms_find_proc_info_x;
139 ia64_vms_unw_accessors.put_unwind_info = ia64_vms_put_unwind_info;
140 ia64_vms_unw_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
142 ia64_vms_unw_rse_accessors = ia64_unw_rse_accessors;
143 ia64_vms_unw_rse_accessors.find_proc_info = ia64_vms_find_proc_info_x;
144 ia64_vms_unw_rse_accessors.put_unwind_info = ia64_vms_put_unwind_info;
145 ia64_vms_unw_rse_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
147 ia64_vms_libunwind_descr = ia64_libunwind_descr;
148 ia64_vms_libunwind_descr.accessors = &ia64_vms_unw_accessors;
149 ia64_vms_libunwind_descr.special_accessors = &ia64_vms_unw_rse_accessors;
151 libunwind_frame_set_descr (gdbarch, &ia64_vms_libunwind_descr);
156 _initialize_ia64_vms_tdep (void)
158 gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_OPENVMS,
159 ia64_openvms_init_abi);