comparison gcc/config/i386/w32-unwind.h @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents a06113de4d67
children
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 /* Definitions for Dwarf2 EH unwind support for Windows32 targets 1 /* Definitions for Dwarf2 EH unwind support for Windows32 targets
2 Copyright (C) 2007, 2009 2 Copyright (C) 2007, 2009, 2010
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Contributed by Pascal Obry <obry@adacore.com> 4 Contributed by Pascal Obry <obry@adacore.com>
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
127 void * ctx_cfa_ = (void *)(context->cfa); /* context frame address */ 127 void * ctx_cfa_ = (void *)(context->cfa); /* context frame address */
128 unsigned char * pc_ = (unsigned char *) ctx_ra_; 128 unsigned char * pc_ = (unsigned char *) ctx_ra_;
129 129
130 /* In the test below we look for two specific patterns found 130 /* In the test below we look for two specific patterns found
131 experimentally to be in the Windows signal handler. */ 131 experimentally to be in the Windows signal handler. */
132
133 if (SIG_PAT1 || SIG_PAT2 || SIG_SEH1 || SIG_SEH2) 132 if (SIG_PAT1 || SIG_PAT2 || SIG_SEH1 || SIG_SEH2)
134 { 133 {
135 PEXCEPTION_POINTERS weinfo_; 134 PEXCEPTION_POINTERS weinfo_;
136 PCONTEXT proc_ctx_; 135 PCONTEXT proc_ctx_;
137 long new_cfa_; 136 long new_cfa_;
145 weinfo_ = (PEXCEPTION_POINTERS) (*(int*)ctx_cfa_); 144 weinfo_ = (PEXCEPTION_POINTERS) (*(int*)ctx_cfa_);
146 proc_ctx_ = weinfo_->ContextRecord; 145 proc_ctx_ = weinfo_->ContextRecord;
147 } 146 }
148 147
149 /* The new context frame address is the stack pointer. */ 148 /* The new context frame address is the stack pointer. */
150
151 new_cfa_ = proc_ctx_->Esp; 149 new_cfa_ = proc_ctx_->Esp;
152 fs->regs.cfa_how = CFA_REG_OFFSET; 150 fs->regs.cfa_how = CFA_REG_OFFSET;
153 fs->regs.cfa_reg = __builtin_dwarf_sp_column(); 151 fs->regs.cfa_reg = __builtin_dwarf_sp_column();
154 fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_; 152 fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_;
155 153
156 /* Save some registers. */ 154 /* Restore registers. */
157
158 fs->regs.reg[0].how = REG_SAVED_OFFSET; 155 fs->regs.reg[0].how = REG_SAVED_OFFSET;
159 fs->regs.reg[0].loc.offset = (long)&proc_ctx_->Eax - new_cfa_; 156 fs->regs.reg[0].loc.offset = (long)&proc_ctx_->Eax - new_cfa_;
160 fs->regs.reg[3].how = REG_SAVED_OFFSET; 157 fs->regs.reg[3].how = REG_SAVED_OFFSET;
161 fs->regs.reg[3].loc.offset = (long)&proc_ctx_->Ebx - new_cfa_; 158 fs->regs.reg[3].loc.offset = (long)&proc_ctx_->Ebx - new_cfa_;
162 fs->regs.reg[1].how = REG_SAVED_OFFSET; 159 fs->regs.reg[1].how = REG_SAVED_OFFSET;
165 fs->regs.reg[2].loc.offset = (long)&proc_ctx_->Edx - new_cfa_; 162 fs->regs.reg[2].loc.offset = (long)&proc_ctx_->Edx - new_cfa_;
166 fs->regs.reg[6].how = REG_SAVED_OFFSET; 163 fs->regs.reg[6].how = REG_SAVED_OFFSET;
167 fs->regs.reg[6].loc.offset = (long)&proc_ctx_->Esi - new_cfa_; 164 fs->regs.reg[6].loc.offset = (long)&proc_ctx_->Esi - new_cfa_;
168 fs->regs.reg[7].how = REG_SAVED_OFFSET; 165 fs->regs.reg[7].how = REG_SAVED_OFFSET;
169 fs->regs.reg[7].loc.offset = (long)&proc_ctx_->Edi - new_cfa_; 166 fs->regs.reg[7].loc.offset = (long)&proc_ctx_->Edi - new_cfa_;
170 fs->regs.reg[9].how = REG_SAVED_OFFSET; 167 fs->regs.reg[5].how = REG_SAVED_OFFSET;
171 fs->regs.reg[9].loc.offset = (long)&proc_ctx_->Eip - new_cfa_; 168 fs->regs.reg[5].loc.offset = (long)&proc_ctx_->Ebp - new_cfa_;
172 fs->regs.reg[4].how = REG_SAVED_OFFSET;
173 fs->regs.reg[4].loc.offset = (long)&proc_ctx_->Ebp - new_cfa_;
174
175 /* Set the return address to Eip + 1. As we can be called multiple
176 times we use another register for this. */
177
178 proc_ctx_->Dr0 = proc_ctx_->Eip + 1;
179 fs->regs.reg[8].how = REG_SAVED_OFFSET; 169 fs->regs.reg[8].how = REG_SAVED_OFFSET;
180 fs->regs.reg[8].loc.offset = (long)&proc_ctx_->Dr0 - new_cfa_; 170 fs->regs.reg[8].loc.offset = (long)&proc_ctx_->Eip - new_cfa_;
181 fs->retaddr_column = 8; 171 fs->retaddr_column = 8;
172 fs->signal_frame = 1;
173
182 return _URC_NO_REASON; 174 return _URC_NO_REASON;
183 } 175 }
184 176
185 /* Unwinding through _alloca, propagating from a trap triggered by 177 /* Unwinding through _alloca, propagating from a trap triggered by
186 one of it's probes prior to the real SP adjustment. The only 178 one of it's probes prior to the real SP adjustment. The only
187 operations of interest performed is "pushl %ecx", followed by 179 operations of interest performed is "pushl %ecx", followed by
188 ecx clobbering. */ 180 ecx clobbering. */
189
190 else if (SIG_ALLOCA) 181 else if (SIG_ALLOCA)
191 { 182 {
192 /* Only one push between entry in _alloca and the probe trap. */ 183 /* Only one push between entry in _alloca and the probe trap. */
193 long new_cfa_ = (long) ctx_cfa_ + 4; 184 long new_cfa_ = (long) ctx_cfa_ + 4;
194 185
202 193
203 /* and what is stored at the CFA is the return address. */ 194 /* and what is stored at the CFA is the return address. */
204 fs->retaddr_column = 8; 195 fs->retaddr_column = 8;
205 fs->regs.reg[8].how = REG_SAVED_OFFSET; 196 fs->regs.reg[8].how = REG_SAVED_OFFSET;
206 fs->regs.reg[8].loc.offset = 0; 197 fs->regs.reg[8].loc.offset = 0;
207 198 fs->signal_frame = 1;
199
208 return _URC_NO_REASON; 200 return _URC_NO_REASON;
209 } 201 }
210 else 202 else
211 return _URC_END_OF_STACK; 203 return _URC_END_OF_STACK;
212 } 204 }