1 /* Copyright (C) 2004-2024 Free Software Foundation, Inc.
2 Contributed by Douglas B Rupp <rupp@gnat.com>
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* Locate the FDE entry for a given address, using VMS Starlet routines
26 to avoid register/deregister calls at DSO load/unload. */
30 #include "coretypes.h"
32 #include "libgcc_tm.h"
36 #include "unwind-ia64.h"
43 #define UNW_IVMS_MODE(HEADER) (((HEADER) >> 44) & 0x3L)
47 unw_word start_offset
;
51 } vms_unw_table_entry
;
53 typedef unsigned long long uqword
;
55 /* ENTRY is the unwind table entry found for a PC part of call chain we're
56 unwinding through. Return whether we should force the generic unwinder
57 to resort to "fallback" processing. */
60 force_fallback_processing_for (void * pc
, vms_unw_table_entry
* entry
)
62 static int eh_debug
= -1;
64 uqword
* unw_info_block
= (uqword
*)entry
->info_offset
;
65 uqword header
= *unw_info_block
;
67 /* We need to force fallback processing in two cases:
69 1/ The exception dispatch frame, since only our fallback
70 processing knows how to properly unwind through it, and
72 2/ A bottom of stack frame, since only our fallback processing
73 will ensure we don't try to unwind further past it, which
74 would get us into unknown territory and likely cause a severe
77 The two cases are indicated by non-default values for specific
78 bits in the OS Specific Data (OSSD) General Information block
79 associated with such frames. */
85 char * EH_DEBUG
= getenv ("EH_DEBUG");
86 eh_debug
= EH_DEBUG
? atoi (EH_DEBUG
) : 0;
91 printf ("pc @ 0x%p, block @ 0x%p, header = 0x%016llx\n",
92 pc
, unw_info_block
, header
);
93 printf ("mode = %d, length = %ld, handler = %d\n",
94 (int)UNW_IVMS_MODE (header
), UNW_LENGTH (header
),
95 UNW_FLAG_EHANDLER (header
) || UNW_FLAG_EHANDLER (header
));
98 /* An OSSD block is there for IVMS_MODE == 3 only. */
99 if (UNW_IVMS_MODE (header
) != 3)
102 /* The OSSD block is found past the header, unwind descriptor area
103 and condition handler pointer, if any. */
105 /* Beware: uqword pointer arithmetic below. */
108 + UNW_LENGTH (header
)
109 + (UNW_FLAG_EHANDLER (header
) || UNW_FLAG_EHANDLER (header
)));
111 /* "A General Information segment may be omitted if all of its fields
112 would have their default values. If a General Information segment
113 is present, it must be the first in the OSSD area." So ... */
116 printf ("ossd @ 0x%p\n", ossd
);
118 if (eh_debug
&& ossd
->ossd$v_type
== OSSD$K_GENERAL_INFO
)
119 printf ("exc_frame = %d - bot_frame = %d - base_frame = %d\n",
120 ossd
->ossd$v_exception_frame
,
121 ossd
->ossd$v_bottom_of_stack
,
122 ossd
->ossd$v_base_frame
);
125 ossd
->ossd$v_type
== OSSD$K_GENERAL_INFO
126 && (ossd
->ossd$v_exception_frame
127 || ossd
->ossd$v_bottom_of_stack
|| ossd
->ossd$v_base_frame
);
130 /* Return a pointer to the unwind table entry for the function
131 containing PC, 0 if we cannot find an entry or if the one we find
132 calls for fallback processing. */
134 struct unw_table_entry
*
135 _Unwind_FindTableEntry (void *pc
, unw_word
*segment_base
,
136 unw_word
*gp
, struct unw_table_entry
*ent
)
138 vms_unw_table_entry vueblock
;
140 if (SYS$
GET_UNWIND_ENTRY_INFO (pc
, &vueblock
, 0) != SS$_NORMAL
)
143 /* If there is no unwind information, use fallback. */
144 if (vueblock
.info_offset
== 0)
147 /* If we need to force fallback processing, just pretend there is
149 if (force_fallback_processing_for (pc
, &vueblock
))
152 *segment_base
= 0; /* ??? Fixme. ??? */
153 *gp
= vueblock
.gp_value
;
154 ent
->start_offset
= vueblock
.start_offset
;
155 ent
->end_offset
= vueblock
.end_offset
;
156 ent
->info_offset
= vueblock
.info_offset
;