2 * i386 signal handling routines
4 * Copyright 1999 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include <sys/types.h>
31 #define WIN32_NO_STATUS
33 #include "ntdll_misc.h"
34 #include "wine/exception.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(seh
);
38 WINE_DECLARE_DEBUG_CHANNEL(threadname
);
40 struct x86_thread_data
42 DWORD fs
; /* 1d4 TEB selector */
43 DWORD gs
; /* 1d8 libc selector; update winebuild if you move this! */
44 DWORD dr0
; /* 1dc debug registers */
50 void *exit_frame
; /* 1f4 exit frame pointer */
53 C_ASSERT( sizeof(struct x86_thread_data
) <= 16 * sizeof(void *) );
54 C_ASSERT( offsetof( TEB
, GdiTebBatch
) + offsetof( struct x86_thread_data
, gs
) == 0x1d8 );
55 C_ASSERT( offsetof( TEB
, GdiTebBatch
) + offsetof( struct x86_thread_data
, exit_frame
) == 0x1f4 );
57 static inline struct x86_thread_data
*x86_thread_data(void)
59 return (struct x86_thread_data
*)&NtCurrentTeb()->GdiTebBatch
;
62 /* Exception record for handling exceptions happening inside exception handlers */
65 EXCEPTION_REGISTRATION_RECORD frame
;
66 EXCEPTION_REGISTRATION_RECORD
*prevFrame
;
69 extern DWORD
EXC_CallHandler( EXCEPTION_RECORD
*record
, EXCEPTION_REGISTRATION_RECORD
*frame
,
70 CONTEXT
*context
, EXCEPTION_REGISTRATION_RECORD
**dispatcher
,
71 PEXCEPTION_HANDLER handler
, PEXCEPTION_HANDLER nested_handler
);
73 /*******************************************************************
76 static inline BOOL
is_valid_frame( void *frame
)
78 if ((ULONG_PTR
)frame
& 3) return FALSE
;
79 return (frame
>= NtCurrentTeb()->Tib
.StackLimit
&&
80 (void **)frame
< (void **)NtCurrentTeb()->Tib
.StackBase
- 1);
83 /*******************************************************************
86 * Handler for exceptions happening inside a handler.
88 static DWORD
raise_handler( EXCEPTION_RECORD
*rec
, EXCEPTION_REGISTRATION_RECORD
*frame
,
89 CONTEXT
*context
, EXCEPTION_REGISTRATION_RECORD
**dispatcher
)
91 if (rec
->ExceptionFlags
& (EH_UNWINDING
| EH_EXIT_UNWIND
))
92 return ExceptionContinueSearch
;
93 /* We shouldn't get here so we store faulty frame in dispatcher */
94 *dispatcher
= ((EXC_NESTED_FRAME
*)frame
)->prevFrame
;
95 return ExceptionNestedException
;
99 /*******************************************************************
102 * Handler for exceptions happening inside an unwind handler.
104 static DWORD
unwind_handler( EXCEPTION_RECORD
*rec
, EXCEPTION_REGISTRATION_RECORD
*frame
,
105 CONTEXT
*context
, EXCEPTION_REGISTRATION_RECORD
**dispatcher
)
107 if (!(rec
->ExceptionFlags
& (EH_UNWINDING
| EH_EXIT_UNWIND
)))
108 return ExceptionContinueSearch
;
109 /* We shouldn't get here so we store faulty frame in dispatcher */
110 *dispatcher
= ((EXC_NESTED_FRAME
*)frame
)->prevFrame
;
111 return ExceptionCollidedUnwind
;
115 /**********************************************************************
116 * call_stack_handlers
118 * Call the stack handlers chain.
120 static NTSTATUS
call_stack_handlers( EXCEPTION_RECORD
*rec
, CONTEXT
*context
)
122 EXCEPTION_REGISTRATION_RECORD
*frame
, *dispatch
, *nested_frame
;
125 frame
= NtCurrentTeb()->Tib
.ExceptionList
;
127 while (frame
!= (EXCEPTION_REGISTRATION_RECORD
*)~0UL)
129 /* Check frame address */
130 if (!is_valid_frame( frame
))
132 rec
->ExceptionFlags
|= EH_STACK_INVALID
;
137 TRACE( "calling handler at %p code=%lx flags=%lx\n",
138 frame
->Handler
, rec
->ExceptionCode
, rec
->ExceptionFlags
);
139 res
= EXC_CallHandler( rec
, frame
, context
, &dispatch
, frame
->Handler
, raise_handler
);
140 TRACE( "handler at %p returned %lx\n", frame
->Handler
, res
);
142 if (frame
== nested_frame
)
144 /* no longer nested */
146 rec
->ExceptionFlags
&= ~EH_NESTED_CALL
;
151 case ExceptionContinueExecution
:
152 if (!(rec
->ExceptionFlags
& EH_NONCONTINUABLE
)) return STATUS_SUCCESS
;
153 return STATUS_NONCONTINUABLE_EXCEPTION
;
154 case ExceptionContinueSearch
:
156 case ExceptionNestedException
:
157 if (nested_frame
< dispatch
) nested_frame
= dispatch
;
158 rec
->ExceptionFlags
|= EH_NESTED_CALL
;
161 return STATUS_INVALID_DISPOSITION
;
165 return STATUS_UNHANDLED_EXCEPTION
;
169 /*******************************************************************
170 * KiUserExceptionDispatcher (NTDLL.@)
172 NTSTATUS WINAPI
dispatch_exception( EXCEPTION_RECORD
*rec
, CONTEXT
*context
)
177 TRACE( "code=%lx flags=%lx addr=%p ip=%08lx\n",
178 rec
->ExceptionCode
, rec
->ExceptionFlags
, rec
->ExceptionAddress
, context
->Eip
);
179 for (c
= 0; c
< rec
->NumberParameters
; c
++)
180 TRACE( " info[%ld]=%08Ix\n", c
, rec
->ExceptionInformation
[c
] );
182 if (rec
->ExceptionCode
== EXCEPTION_WINE_STUB
)
184 if (rec
->ExceptionInformation
[1] >> 16)
185 MESSAGE( "wine: Call from %p to unimplemented function %s.%s, aborting\n",
186 rec
->ExceptionAddress
,
187 (char*)rec
->ExceptionInformation
[0], (char*)rec
->ExceptionInformation
[1] );
189 MESSAGE( "wine: Call from %p to unimplemented function %s.%Id, aborting\n",
190 rec
->ExceptionAddress
,
191 (char*)rec
->ExceptionInformation
[0], rec
->ExceptionInformation
[1] );
193 else if (rec
->ExceptionCode
== EXCEPTION_WINE_NAME_THREAD
&& rec
->ExceptionInformation
[0] == 0x1000)
195 if ((DWORD
)rec
->ExceptionInformation
[2] == -1)
196 WARN_(threadname
)( "Thread renamed to %s\n", debugstr_a((char *)rec
->ExceptionInformation
[1]) );
198 WARN_(threadname
)( "Thread ID %04lx renamed to %s\n", (DWORD
)rec
->ExceptionInformation
[2],
199 debugstr_a((char *)rec
->ExceptionInformation
[1]) );
201 set_native_thread_name((DWORD
)rec
->ExceptionInformation
[2], (char *)rec
->ExceptionInformation
[1]);
203 else if (rec
->ExceptionCode
== DBG_PRINTEXCEPTION_C
)
205 WARN( "%s\n", debugstr_an((char *)rec
->ExceptionInformation
[1], rec
->ExceptionInformation
[0] - 1) );
207 else if (rec
->ExceptionCode
== DBG_PRINTEXCEPTION_WIDE_C
)
209 WARN( "%s\n", debugstr_wn((WCHAR
*)rec
->ExceptionInformation
[1], rec
->ExceptionInformation
[0] - 1) );
213 if (rec
->ExceptionCode
== STATUS_ASSERTION_FAILURE
)
214 ERR( "%s exception (code=%lx) raised\n", debugstr_exception_code(rec
->ExceptionCode
), rec
->ExceptionCode
);
216 WARN( "%s exception (code=%lx) raised\n", debugstr_exception_code(rec
->ExceptionCode
), rec
->ExceptionCode
);
218 TRACE(" eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
219 context
->Eax
, context
->Ebx
, context
->Ecx
,
220 context
->Edx
, context
->Esi
, context
->Edi
);
221 TRACE(" ebp=%08lx esp=%08lx cs=%04lx ss=%04lx ds=%04lx es=%04lx fs=%04lx gs=%04lx flags=%08lx\n",
222 context
->Ebp
, context
->Esp
, context
->SegCs
, context
->SegSs
, context
->SegDs
,
223 context
->SegEs
, context
->SegFs
, context
->SegGs
, context
->EFlags
);
226 if (call_vectored_handlers( rec
, context
) == EXCEPTION_CONTINUE_EXECUTION
)
227 NtContinue( context
, FALSE
);
229 if ((status
= call_stack_handlers( rec
, context
)) == STATUS_SUCCESS
)
230 NtContinue( context
, FALSE
);
232 if (status
!= STATUS_UNHANDLED_EXCEPTION
) RtlRaiseStatus( status
);
233 return NtRaiseException( rec
, context
, FALSE
);
236 __ASM_STDCALL_FUNC( KiUserExceptionDispatcher
, 8,
239 "call " __ASM_STDCALL("dispatch_exception", 8) "\n\t"
243 /*******************************************************************
244 * KiUserApcDispatcher (NTDLL.@)
246 void WINAPI
KiUserApcDispatcher( CONTEXT
*context
, ULONG_PTR ctx
, ULONG_PTR arg1
, ULONG_PTR arg2
,
249 func( ctx
, arg1
, arg2
);
250 NtContinue( context
, TRUE
);
254 /*******************************************************************
255 * KiUserCallbackDispatcher (NTDLL.@)
257 void WINAPI
KiUserCallbackDispatcher( ULONG id
, void *args
, ULONG len
)
263 NTSTATUS (WINAPI
*func
)(void *, ULONG
) = ((void **)NtCurrentTeb()->Peb
->KernelCallbackTable
)[id
];
264 status
= NtCallbackReturn( NULL
, 0, func( args
, len
));
268 ERR_(seh
)( "ignoring exception\n" );
269 status
= NtCallbackReturn( 0, 0, 0 );
273 RtlRaiseStatus( status
);
277 /***********************************************************************
280 * Save the thread FPU context.
282 static inline void save_fpu( CONTEXT
*context
)
297 context
->ContextFlags
|= CONTEXT_FLOATING_POINT
;
298 __asm__
__volatile__( "fnsave %0; fwait" : "=m" (context
->FloatSave
) );
300 /* Reset unmasked exceptions status to avoid firing an exception. */
301 memcpy(&float_status
, &context
->FloatSave
, sizeof(float_status
));
302 float_status
.StatusWord
&= float_status
.ControlWord
| 0xffffff80;
304 __asm__
__volatile__( "fldenv %0" : : "m" (float_status
) );
309 /***********************************************************************
312 * Save the thread FPU extended context.
314 static inline void save_fpux( CONTEXT
*context
)
317 /* we have to enforce alignment by hand */
318 char buffer
[sizeof(XSAVE_FORMAT
) + 16];
319 XSAVE_FORMAT
*state
= (XSAVE_FORMAT
*)(((ULONG_PTR
)buffer
+ 15) & ~15);
321 context
->ContextFlags
|= CONTEXT_EXTENDED_REGISTERS
;
322 __asm__
__volatile__( "fxsave %0" : "=m" (*state
) );
323 memcpy( context
->ExtendedRegisters
, state
, sizeof(*state
) );
328 /***********************************************************************
329 * RtlCaptureContext (NTDLL.@)
331 __ASM_STDCALL_FUNC( RtlCaptureContext
, 4,
333 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
334 "movl 8(%esp),%eax\n\t" /* context */
335 "movl $0x10007,(%eax)\n\t" /* context->ContextFlags */
336 "movw %gs,0x8c(%eax)\n\t" /* context->SegGs */
337 "movw %fs,0x90(%eax)\n\t" /* context->SegFs */
338 "movw %es,0x94(%eax)\n\t" /* context->SegEs */
339 "movw %ds,0x98(%eax)\n\t" /* context->SegDs */
340 "movl %edi,0x9c(%eax)\n\t" /* context->Edi */
341 "movl %esi,0xa0(%eax)\n\t" /* context->Esi */
342 "movl %ebx,0xa4(%eax)\n\t" /* context->Ebx */
343 "movl %edx,0xa8(%eax)\n\t" /* context->Edx */
344 "movl %ecx,0xac(%eax)\n\t" /* context->Ecx */
345 "movl 0(%ebp),%edx\n\t"
346 "movl %edx,0xb4(%eax)\n\t" /* context->Ebp */
347 "movl 4(%ebp),%edx\n\t"
348 "movl %edx,0xb8(%eax)\n\t" /* context->Eip */
349 "movw %cs,0xbc(%eax)\n\t" /* context->SegCs */
351 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
352 "popl 0xc0(%eax)\n\t" /* context->EFlags */
353 __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
354 "leal 8(%ebp),%edx\n\t"
355 "movl %edx,0xc4(%eax)\n\t" /* context->Esp */
356 "movw %ss,0xc8(%eax)\n\t" /* context->SegSs */
357 "popl 0xb0(%eax)\n\t" /* context->Eax */
358 __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
361 /*******************************************************************
362 * RtlRestoreContext (NTDLL.@)
364 void CDECL
RtlRestoreContext( CONTEXT
*context
, EXCEPTION_RECORD
*rec
)
366 TRACE( "returning to %p stack %p\n", (void *)context
->Eip
, (void *)context
->Esp
);
367 NtContinue( context
, FALSE
);
370 /*******************************************************************
371 * RtlUnwind (NTDLL.@)
373 void WINAPI DECLSPEC_HIDDEN
__regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD
* pEndFrame
, PVOID targetIp
,
374 PEXCEPTION_RECORD pRecord
, PVOID retval
, CONTEXT
*context
)
376 EXCEPTION_RECORD record
;
377 EXCEPTION_REGISTRATION_RECORD
*frame
, *dispatch
;
380 context
->Eax
= (DWORD
)retval
;
382 /* build an exception record, if we do not have one */
385 record
.ExceptionCode
= STATUS_UNWIND
;
386 record
.ExceptionFlags
= 0;
387 record
.ExceptionRecord
= NULL
;
388 record
.ExceptionAddress
= (void *)context
->Eip
;
389 record
.NumberParameters
= 0;
393 pRecord
->ExceptionFlags
|= EH_UNWINDING
| (pEndFrame
? 0 : EH_EXIT_UNWIND
);
395 TRACE( "code=%lx flags=%lx\n", pRecord
->ExceptionCode
, pRecord
->ExceptionFlags
);
396 TRACE( "eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
397 context
->Eax
, context
->Ebx
, context
->Ecx
, context
->Edx
, context
->Esi
, context
->Edi
);
398 TRACE( "ebp=%08lx esp=%08lx eip=%08lx cs=%04x ds=%04x fs=%04x gs=%04x flags=%08lx\n",
399 context
->Ebp
, context
->Esp
, context
->Eip
, LOWORD(context
->SegCs
), LOWORD(context
->SegDs
),
400 LOWORD(context
->SegFs
), LOWORD(context
->SegGs
), context
->EFlags
);
402 /* get chain of exception frames */
403 frame
= NtCurrentTeb()->Tib
.ExceptionList
;
404 while ((frame
!= (EXCEPTION_REGISTRATION_RECORD
*)~0UL) && (frame
!= pEndFrame
))
406 /* Check frame address */
407 if (pEndFrame
&& (frame
> pEndFrame
))
408 raise_status( STATUS_INVALID_UNWIND_TARGET
, pRecord
);
410 if (!is_valid_frame( frame
)) raise_status( STATUS_BAD_STACK
, pRecord
);
413 TRACE( "calling handler at %p code=%lx flags=%lx\n",
414 frame
->Handler
, pRecord
->ExceptionCode
, pRecord
->ExceptionFlags
);
415 res
= EXC_CallHandler( pRecord
, frame
, context
, &dispatch
, frame
->Handler
, unwind_handler
);
416 TRACE( "handler at %p returned %lx\n", frame
->Handler
, res
);
420 case ExceptionContinueSearch
:
422 case ExceptionCollidedUnwind
:
426 raise_status( STATUS_INVALID_DISPOSITION
, pRecord
);
429 frame
= __wine_pop_frame( frame
);
431 NtContinue( context
, FALSE
);
433 __ASM_STDCALL_FUNC( RtlUnwind
, 16,
435 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
436 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
438 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
439 "leal -(0x2cc+8)(%esp),%esp\n\t" /* sizeof(CONTEXT) + alignment */
441 "leal 4(%esp),%eax\n\t" /* context */
442 "xchgl %eax,(%esp)\n\t"
443 "call " __ASM_STDCALL("RtlCaptureContext",4) "\n\t"
444 "leal 24(%ebp),%eax\n\t"
445 "movl %eax,0xc4(%esp)\n\t" /* context->Esp */
451 "call " __ASM_STDCALL("__regs_RtlUnwind",20) "\n\t"
453 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
454 __ASM_CFI(".cfi_same_value %ebp\n\t")
455 "ret $16" ) /* actually never returns */
458 /*******************************************************************
459 * raise_exception_full_context
461 * Raise an exception with the full CPU context.
463 void raise_exception_full_context( EXCEPTION_RECORD
*rec
, CONTEXT
*context
)
466 save_fpux( context
);
468 context
->Dr0
= x86_thread_data()->dr0
;
469 context
->Dr1
= x86_thread_data()->dr1
;
470 context
->Dr2
= x86_thread_data()->dr2
;
471 context
->Dr3
= x86_thread_data()->dr3
;
472 context
->Dr6
= x86_thread_data()->dr6
;
473 context
->Dr7
= x86_thread_data()->dr7
;
474 context
->ContextFlags
|= CONTEXT_DEBUG_REGISTERS
;
476 RtlRaiseStatus( NtRaiseException( rec
, context
, TRUE
));
480 /***********************************************************************
481 * RtlRaiseException (NTDLL.@)
483 __ASM_STDCALL_FUNC( RtlRaiseException
, 4,
485 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
486 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
488 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
489 "leal -0x2cc(%esp),%esp\n\t" /* sizeof(CONTEXT) */
490 "pushl %esp\n\t" /* context */
491 "call " __ASM_STDCALL("RtlCaptureContext",4) "\n\t"
492 "movl 4(%ebp),%eax\n\t" /* return address */
493 "movl 8(%ebp),%ecx\n\t" /* rec */
494 "movl %eax,12(%ecx)\n\t" /* rec->ExceptionAddress */
495 "leal 12(%ebp),%eax\n\t"
496 "movl %eax,0xc4(%esp)\n\t" /* context->Esp */
500 "call " __ASM_NAME("raise_exception_full_context") "\n\t"
502 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
503 __ASM_CFI(".cfi_same_value %ebp\n\t")
504 "ret $4" ) /* actually never returns */
507 /*************************************************************************
508 * RtlCaptureStackBackTrace (NTDLL.@)
510 USHORT WINAPI
RtlCaptureStackBackTrace( ULONG skip
, ULONG count
, PVOID
*buffer
, ULONG
*hash
)
516 RtlCaptureContext( &context
);
518 frame
= (ULONG
*)context
.Ebp
;
522 if (!is_valid_frame( frame
)) return 0;
523 frame
= (ULONG
*)*frame
;
526 for (i
= 0; i
< count
; i
++)
528 if (!is_valid_frame( frame
)) break;
529 buffer
[i
] = (void *)frame
[1];
530 if (hash
) *hash
+= frame
[1];
531 frame
= (ULONG
*)*frame
;
537 /***********************************************************************
538 * signal_start_thread
540 __ASM_GLOBAL_FUNC( signal_start_thread
,
541 "movl 4(%esp),%esi\n\t" /* context */
542 "leal -12(%esi),%edi\n\t"
543 /* clear the thread stack */
544 "andl $~0xfff,%edi\n\t" /* round down to page size */
545 "movl $0xf0000,%ecx\n\t"
551 /* switch to the initial context */
552 "leal -12(%esi),%esp\n\t"
553 "movl $1,4(%esp)\n\t"
554 "movl %esi,(%esp)\n\t"
555 "call " __ASM_STDCALL("NtContinue", 8) )
557 /**********************************************************************
558 * DbgBreakPoint (NTDLL.@)
560 __ASM_STDCALL_FUNC( DbgBreakPoint
, 0, "int $3; ret"
561 "\n\tnop; nop; nop; nop; nop; nop; nop; nop"
562 "\n\tnop; nop; nop; nop; nop; nop" );
564 /**********************************************************************
565 * DbgUserBreakPoint (NTDLL.@)
567 __ASM_STDCALL_FUNC( DbgUserBreakPoint
, 0, "int $3; ret"
568 "\n\tnop; nop; nop; nop; nop; nop; nop; nop"
569 "\n\tnop; nop; nop; nop; nop; nop" );
571 /**********************************************************************
572 * NtCurrentTeb (NTDLL.@)
574 __ASM_STDCALL_FUNC( NtCurrentTeb
, 0, ".byte 0x64\n\tmovl 0x18,%eax\n\tret" )
577 /**************************************************************************
580 __ASM_GLOBAL_FUNC( _chkstk
,
583 "xchgl %esp,%eax\n\t"
584 "movl 0(%eax),%eax\n\t" /* copy return address from old location */
585 "movl %eax,0(%esp)\n\t"
588 /**************************************************************************
589 * _alloca_probe (NTDLL.@)
591 __ASM_GLOBAL_FUNC( _alloca_probe
,
594 "xchgl %esp,%eax\n\t"
595 "movl 0(%eax),%eax\n\t" /* copy return address from old location */
596 "movl %eax,0(%esp)\n\t"
600 /**********************************************************************
601 * EXC_CallHandler (internal)
603 * Some exception handlers depend on EBP to have a fixed position relative to
604 * the exception frame.
605 * Shrinker depends on (*1) doing what it does,
606 * (*2) being the exact instruction it is and (*3) beginning with 0x64
607 * (i.e. the %fs prefix to the movl instruction). It also depends on the
608 * function calling the handler having only 5 parameters (*4).
610 __ASM_GLOBAL_FUNC( EXC_CallHandler
,
612 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
613 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
615 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
617 __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
618 "movl 28(%ebp), %edx\n\t" /* ugly hack to pass the 6th param needed because of Shrinker */
624 "call " __ASM_NAME("call_exception_handler") "\n\t"
626 __ASM_CFI(".cfi_same_value %ebx\n\t")
628 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
629 __ASM_CFI(".cfi_same_value %ebp\n\t")
631 __ASM_GLOBAL_FUNC(call_exception_handler
,
633 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
634 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
636 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
638 "pushl 12(%ebp)\n\t" /* make any exceptions in this... */
639 "pushl %edx\n\t" /* handler be handled by... */
641 "pushl (0)\n\t" /* nested_handler (passed in edx). */
643 "movl %esp,(0)\n\t" /* push the new exception frame onto the exception stack. */
648 "movl 24(%ebp), %ecx\n\t" /* (*1) */
649 "call *%ecx\n\t" /* call handler. (*2) */
651 "movl (0), %esp\n\t" /* restore previous... (*3) */
653 "popl (0)\n\t" /* exception frame. */
654 "movl %ebp, %esp\n\t" /* restore saved stack, in case it was corrupted */
656 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
657 __ASM_CFI(".cfi_same_value %ebp\n\t")
658 "ret $20" ) /* (*4) */
660 #endif /* __i386__ */