GDB (xrefs)

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