Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[x86/Linux] Fix unsupported architecture in seh-unwind.cpp (#8262)
Browse files Browse the repository at this point in the history
Fix compile error for x86/Linux
- add ASSIGN_UNWIND_REGS in seh-unwind.cpp for x86
- add CONTEXT_EXCEPTION_ACTIVE in pal.h for x86
- add CONTEXT_XSTATE in pal.h for x86
  • Loading branch information
seanshpark authored and janvorli committed Nov 24, 2016
1 parent 876bb32 commit f85bf7c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,13 @@ QueueUserAPC(

#define MAXIMUM_SUPPORTED_EXTENSION 512

#define CONTEXT_XSTATE (CONTEXT_i386 | 0x40L)

#define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
#define CONTEXT_SERVICE_ACTIVE 0x10000000L
#define CONTEXT_EXCEPTION_REQUEST 0x40000000L
#define CONTEXT_EXCEPTION_REPORTING 0x80000000L

typedef struct _FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
Expand Down
27 changes: 27 additions & 0 deletions src/pal/src/exception/seh-unwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ Module Name:
ASSIGN_REG(X26) \
ASSIGN_REG(X27) \
ASSIGN_REG(X28)
#elif defined(_X86_)
#define ASSIGN_UNWIND_REGS \
ASSIGN_REG(Eip) \
ASSIGN_REG(Esp) \
ASSIGN_REG(Ebp) \
ASSIGN_REG(Ebx) \
ASSIGN_REG(Esi) \
ASSIGN_REG(Edi)
#else
#error unsupported architecture
#endif
Expand Down Expand Up @@ -122,6 +130,13 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor)
unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13);
unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14);
unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15);
#elif defined(_X86_)
unw_set_reg(cursor, UNW_REG_IP, winContext->Eip);
unw_set_reg(cursor, UNW_REG_SP, winContext->Esp);
unw_set_reg(cursor, UNW_X86_EBP, winContext->Ebp);
unw_set_reg(cursor, UNW_X86_EBX, winContext->Ebx);
unw_set_reg(cursor, UNW_X86_ESI, winContext->Esi);
unw_set_reg(cursor, UNW_X86_EDI, winContext->Edi);
#endif
}
#endif
Expand All @@ -137,6 +152,13 @@ static void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13);
unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14);
unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15);
#elif defined(_X86_)
unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip);
unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp);
unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp);
unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx);
unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi);
unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi);
#elif defined(_ARM_)
unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp);
unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc);
Expand Down Expand Up @@ -196,6 +218,11 @@ static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext,
GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13);
GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14);
GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15);
#elif defined(_X86_)
GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx);
GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp);
GetContextPointer(cursor, unwContext, UNW_X86_ESI, &contextPointers->Esi);
GetContextPointer(cursor, unwContext, UNW_X86_EDI, &contextPointers->Edi);
#elif defined(_ARM_)
GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4);
GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5);
Expand Down

0 comments on commit f85bf7c

Please sign in to comment.