comparison gcc/config/ia64/fde-vms.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents
children
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
1 /* Copyright (C) 2004, 2009 Free Software Foundation, Inc.
2 Contributed by Douglas B Rupp <rupp@gnat.com>
3
4 This file is part of GCC.
5
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)
9 any later version.
10
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.
15
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.
19
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/>. */
24
25 /* Locate the FDE entry for a given address, using VMS Starlet routines
26 to avoid register/deregister calls at DSO load/unload. */
27
28 #include "tconfig.h"
29 #include "tsystem.h"
30 #include "coretypes.h"
31 #include "tm.h"
32 #include <stddef.h>
33 #include <stdlib.h>
34 #include <stdio.h>
35 #include "unwind-ia64.h"
36
37 #define __int64 long
38 #include <vms/ossddef.h>
39 #ifndef SS$_NORMAL
40 #define SS$_NORMAL 1
41 #endif
42
43 typedef struct
44 {
45 unsigned long start_offset;
46 unsigned long end_offset;
47 unsigned long info_offset;
48 unsigned long gp_value;
49 } vms_unw_table_entry;
50
51 typedef unsigned long long uqword;
52
53 /* ENTRY is the unwind table entry found for a PC part of call chain we're
54 unwinding through. Return whether we should force the generic unwinder
55 to resort to "fallback" processing. */
56
57 static int
58 force_fallback_processing_for (void * pc, vms_unw_table_entry * entry)
59 {
60 static int eh_debug = -1;
61
62 uqword * unw_info_block = (uqword *)entry->info_offset;
63 uqword header = *unw_info_block;
64
65 /* We need to force fallback processing in two cases:
66
67 1/ The exception dispatch frame, since only our fallback
68 processing knows how to properly unwind through it, and
69
70 2/ A bottom of stack frame, since only our fallback processing
71 will ensure we don't try to unwind further past it, which
72 would get us into unknown territory and likely cause a severe
73 crash along the way.
74
75 The two cases are indicated by non-default values for specific
76 bits in the OS Specific Data (OSSD) General Information block
77 associated with such frames. */
78
79 ossddef * ossd;
80
81 if (eh_debug == -1)
82 {
83 char * EH_DEBUG = getenv ("EH_DEBUG");
84 eh_debug = EH_DEBUG ? atoi (EH_DEBUG) : 0;
85 }
86
87 if (eh_debug)
88 {
89 printf ("pc @ 0x%p, block @ 0x%p, header = 0x%016llx\n",
90 pc, unw_info_block, header);
91 printf ("mode = %d, length = %ld, handler = %d\n",
92 (int)UNW_IVMS_MODE (header), UNW_LENGTH (header),
93 UNW_FLAG_EHANDLER (header) || UNW_FLAG_EHANDLER (header));
94 }
95
96 /* An OSSD block is there for IVMS_MODE == 3 only. */
97 if (UNW_IVMS_MODE (header) != 3)
98 return 0;
99
100 /* The OSSD block is found past the header, unwind descriptor area
101 and condition handler pointer, if any. */
102 ossd = (ossddef *)
103 /* Beware: uqword pointer arithmetic below. */
104 (unw_info_block
105 + 1
106 + UNW_LENGTH (header)
107 + (UNW_FLAG_EHANDLER (header) || UNW_FLAG_EHANDLER (header)));
108
109 /* "A General Information segment may be omitted if all of its fields
110 would have their default values. If a General Information segment
111 is present, it must be the first in the OSSD area." So ... */
112
113 if (eh_debug)
114 printf ("ossd @ 0x%p\n", ossd);
115
116 if (eh_debug && ossd->ossd$v_type == OSSD$K_GENERAL_INFO)
117 printf ("exc_frame = %d - bot_frame = %d - base_frame = %d\n",
118 ossd->ossd$v_exception_frame,
119 ossd->ossd$v_bottom_of_stack,
120 ossd->ossd$v_base_frame);
121
122 return
123 ossd->ossd$v_type == OSSD$K_GENERAL_INFO
124 && (ossd->ossd$v_exception_frame
125 || ossd->ossd$v_bottom_of_stack || ossd->ossd$v_base_frame);
126 }
127
128 /* Return a pointer to the unwind table entry for the function
129 containing PC, 0 if we cannot find an entry or if the one we find
130 calls for fallback processing. */
131
132 struct unw_table_entry *
133 _Unwind_FindTableEntry (void *pc, unsigned long *segment_base,
134 unsigned long *gp, struct unw_table_entry *ent)
135 {
136 vms_unw_table_entry vueblock;
137
138 if (SYS$GET_UNWIND_ENTRY_INFO (pc, &vueblock, 0) != SS$_NORMAL)
139 return 0;
140
141 /* If there is no unwind information, use fallback. */
142 if (vueblock.info_offset == 0)
143 return 0;
144
145 /* If we need to force fallback processing, just pretend there is
146 no entry. */
147 if (force_fallback_processing_for (pc, &vueblock))
148 return 0;
149
150 *segment_base = 0; /* ??? Fixme. ??? */
151 *gp = vueblock.gp_value;
152 ent->start_offset = vueblock.start_offset;
153 ent->end_offset = vueblock.end_offset;
154 ent->info_offset = vueblock.info_offset;
155
156 return ent;
157 }