gdb: add declaration for _initialize_gdbarch in gdbarch.sh
[deliverable/binutils-gdb.git] / gdb / ia64-vms-tdep.c
1 /* Target-dependent code for OpenVMS IA-64.
2
3 Copyright (C) 2012-2020 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #include "defs.h"
21 #include "frame-unwind.h"
22 #include "ia64-tdep.h"
23 #include "osabi.h"
24 #include "gdbtypes.h"
25 #include "gdbcore.h"
26 #include "gdbarch.h"
27
28 #ifdef HAVE_LIBUNWIND_IA64_H
29
30 /* Libunwind callback accessor function to acquire procedure unwind-info. */
31
32 static int
33 ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
34 unw_proc_info_t *pi,
35 int need_unwind_info, void *arg)
36 {
37 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
38 gdb_byte buf[32];
39 const char *annex = core_addr_to_string (ip);
40 LONGEST res;
41 CORE_ADDR table_addr;
42 unsigned int info_len;
43
44 res = target_read (current_top_target (), TARGET_OBJECT_OPENVMS_UIB,
45 annex + 2, buf, 0, sizeof (buf));
46
47 if (res != sizeof (buf))
48 return -UNW_ENOINFO;
49
50 pi->format = UNW_INFO_FORMAT_REMOTE_TABLE;
51 pi->start_ip = extract_unsigned_integer (buf + 0, 8, byte_order);
52 pi->end_ip = extract_unsigned_integer (buf + 8, 8, byte_order);
53 pi->gp = extract_unsigned_integer (buf + 24, 8, byte_order);
54 table_addr = extract_unsigned_integer (buf + 16, 8, byte_order);
55
56 if (table_addr == 0)
57 {
58 /* No unwind data. */
59 pi->unwind_info = NULL;
60 pi->unwind_info_size = 0;
61 return 0;
62 }
63
64 res = target_read_memory (table_addr, buf, 8);
65 if (res != 0)
66 return -UNW_ENOINFO;
67
68 /* Check version. */
69 if (extract_unsigned_integer (buf + 6, 2, byte_order) != 1)
70 return -UNW_EBADVERSION;
71 info_len = extract_unsigned_integer (buf + 0, 4, byte_order);
72 pi->unwind_info_size = 8 * info_len;
73
74 /* Read info. */
75 pi->unwind_info = xmalloc (pi->unwind_info_size);
76
77 res = target_read_memory (table_addr + 8,
78 (gdb_byte *) pi->unwind_info, pi->unwind_info_size);
79 if (res != 0)
80 {
81 xfree (pi->unwind_info);
82 pi->unwind_info = NULL;
83 return -UNW_ENOINFO;
84 }
85
86 /* FIXME: Handle OSSD (OS Specific Data). This extension to ia64 unwind
87 information by OpenVMS is currently not handled by libunwind, but
88 looks to be used only in very specific context, and is not generated by
89 GCC. */
90
91 pi->lsda = table_addr + 8 + pi->unwind_info_size;
92 if (extract_unsigned_integer (buf + 4, 2, byte_order) & 3)
93 {
94 pi->lsda += 8;
95 /* There might be an handler, but this is not used for unwinding. */
96 pi->handler = 0;
97 }
98
99 return 0;
100 }
101
102 /* Libunwind callback accessor function for cleanup. */
103
104 static void
105 ia64_vms_put_unwind_info (unw_addr_space_t as,
106 unw_proc_info_t *pip, void *arg)
107 {
108 /* Nothing required for now. */
109 }
110
111 /* Libunwind callback accessor function to get head of the dynamic
112 unwind-info registration list. */
113
114 static int
115 ia64_vms_get_dyn_info_list (unw_addr_space_t as,
116 unw_word_t *dilap, void *arg)
117 {
118 return -UNW_ENOINFO;
119 }
120
121 /* Set of libunwind callback acccessor functions. */
122 static unw_accessors_t ia64_vms_unw_accessors;
123 static unw_accessors_t ia64_vms_unw_rse_accessors;
124
125 /* Set of ia64-libunwind-tdep gdb callbacks and data for generic
126 ia64-libunwind-tdep code to use. */
127 static struct libunwind_descr ia64_vms_libunwind_descr;
128
129 #endif /* HAVE_LIBUNWIND_IA64_H */
130
131 static void
132 ia64_openvms_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
133 {
134 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
135
136 #ifdef HAVE_LIBUNWIND_IA64_H
137 /* Override the default descriptor. */
138 ia64_vms_unw_accessors = ia64_unw_accessors;
139 ia64_vms_unw_accessors.find_proc_info = ia64_vms_find_proc_info_x;
140 ia64_vms_unw_accessors.put_unwind_info = ia64_vms_put_unwind_info;
141 ia64_vms_unw_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
142
143 ia64_vms_unw_rse_accessors = ia64_unw_rse_accessors;
144 ia64_vms_unw_rse_accessors.find_proc_info = ia64_vms_find_proc_info_x;
145 ia64_vms_unw_rse_accessors.put_unwind_info = ia64_vms_put_unwind_info;
146 ia64_vms_unw_rse_accessors.get_dyn_info_list_addr = ia64_vms_get_dyn_info_list;
147
148 ia64_vms_libunwind_descr = ia64_libunwind_descr;
149 ia64_vms_libunwind_descr.accessors = &ia64_vms_unw_accessors;
150 ia64_vms_libunwind_descr.special_accessors = &ia64_vms_unw_rse_accessors;
151
152 libunwind_frame_set_descr (gdbarch, &ia64_vms_libunwind_descr);
153 #endif
154 }
155
156 void _initialize_ia64_vms_tdep ();
157 void
158 _initialize_ia64_vms_tdep ()
159 {
160 gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_OPENVMS,
161 ia64_openvms_init_abi);
162 }
This page took 0.034859 seconds and 4 git commands to generate.