ntdll: Fix CONTEXT definition for ARM.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-12-05 09:22:16 +01:00
parent be20dc51a3
commit eb337adcc2
5 changed files with 74 additions and 68 deletions

View File

@ -39,7 +39,7 @@ static BOOL arm_get_addr(HANDLE hThread, const CONTEXT* ctx,
#ifdef __arm__
case cpu_addr_pc: addr->Offset = ctx->Pc; return TRUE;
case cpu_addr_stack: addr->Offset = ctx->Sp; return TRUE;
case cpu_addr_frame: addr->Offset = ctx->Fp; return TRUE;
case cpu_addr_frame: addr->Offset = ctx->R11; return TRUE;
#endif
default: addr->Mode = -1;
return FALSE;
@ -122,7 +122,7 @@ static BOOL arm_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame, CON
/* set frame information */
frame->AddrStack.Offset = context->Sp;
frame->AddrReturn.Offset = context->Lr;
frame->AddrFrame.Offset = context->Fp;
frame->AddrFrame.Offset = context->R11;
frame->AddrPC.Offset = context->Pc;
frame->Far = TRUE;
@ -175,8 +175,8 @@ static void* arm_fetch_context_reg(CONTEXT* ctx, unsigned regno, unsigned* size)
case CV_ARM_R0 + 8: *size = sizeof(ctx->R8); return &ctx->R8;
case CV_ARM_R0 + 9: *size = sizeof(ctx->R9); return &ctx->R9;
case CV_ARM_R0 + 10: *size = sizeof(ctx->R10); return &ctx->R10;
case CV_ARM_R0 + 11: *size = sizeof(ctx->Fp); return &ctx->Fp;
case CV_ARM_R0 + 12: *size = sizeof(ctx->Ip); return &ctx->Ip;
case CV_ARM_R0 + 11: *size = sizeof(ctx->R11); return &ctx->R11;
case CV_ARM_R0 + 12: *size = sizeof(ctx->R12); return &ctx->R12;
case CV_ARM_SP: *size = sizeof(ctx->Sp); return &ctx->Sp;
case CV_ARM_LR: *size = sizeof(ctx->Lr); return &ctx->Lr;

View File

@ -201,8 +201,8 @@ static void save_context( CONTEXT *context, const ucontext_t *sigcontext )
context->Lr = LR_sig(sigcontext); /* Link register */
context->Pc = PC_sig(sigcontext); /* Program Counter */
context->Cpsr = CPSR_sig(sigcontext); /* Current State Register */
context->Ip = IP_sig(sigcontext); /* Intra-Procedure-call scratch register */
context->Fp = FP_sig(sigcontext); /* Frame pointer */
context->R11 = FP_sig(sigcontext); /* Frame pointer */
context->R12 = IP_sig(sigcontext); /* Intra-Procedure-call scratch register */
}
@ -222,8 +222,8 @@ static void restore_context( const CONTEXT *context, ucontext_t *sigcontext )
LR_sig(sigcontext) = context->Lr ; /* Link register */
PC_sig(sigcontext) = context->Pc; /* Program Counter */
CPSR_sig(sigcontext) = context->Cpsr; /* Current State Register */
IP_sig(sigcontext) = context->Ip; /* Intra-Procedure-call scratch register */
FP_sig(sigcontext) = context->Fp; /* Frame pointer */
FP_sig(sigcontext) = context->R11; /* Frame pointer */
IP_sig(sigcontext) = context->R12; /* Intra-Procedure-call scratch register */
}
@ -278,8 +278,8 @@ __ASM_STDCALL_FUNC( RtlCaptureContext, 4,
"str r8, [r0, #0x24]\n\t" /* context->R8 */
"str r9, [r0, #0x28]\n\t" /* context->R9 */
"str r10, [r0, #0x2c]\n\t" /* context->R10 */
"str r11, [r0, #0x30]\n\t" /* context->Fp */
"str IP, [r0, #0x34]\n\t" /* context->Ip */
"str r11, [r0, #0x30]\n\t" /* context->R11 */
"str IP, [r0, #0x34]\n\t" /* context->R12 */
"str SP, [r0, #0x38]\n\t" /* context->Sp */
"str LR, [r0, #0x3c]\n\t" /* context->Lr */
"str PC, [r0, #0x40]\n\t" /* context->Pc */
@ -309,8 +309,8 @@ __ASM_GLOBAL_FUNC( set_cpu_context,
"ldr r8, [IP, #0x24]\n\t" /* context->R8 */
"ldr r9, [IP, #0x28]\n\t" /* context->R9 */
"ldr r10, [IP, #0x2c]\n\t" /* context->R10 */
"ldr r11, [IP, #0x30]\n\t" /* context->Fp */
"ldr SP, [IP, #0x38]\n\t" /* context->Sp */
"ldr r11, [IP, #0x30]\n\t" /* context->R11 */
"ldr SP, [IP, #0x38]\n\t" /* context->R12 */
"ldr LR, [IP, #0x3c]\n\t" /* context->Lr */
"ldr PC, [IP, #0x40]\n\t" /* context->Pc */
)
@ -344,8 +344,8 @@ static void copy_context( CONTEXT *to, const CONTEXT *from, DWORD flags )
to->R8 = from->R8;
to->R9 = from->R9;
to->R10 = from->R10;
to->Ip = from->Ip;
to->Fp = from->Fp;
to->R11 = from->R11;
to->R12 = from->R12;
}
}
@ -384,8 +384,8 @@ NTSTATUS context_to_server( context_t *to, const CONTEXT *from )
to->integer.arm_regs.r[8] = from->R8;
to->integer.arm_regs.r[9] = from->R9;
to->integer.arm_regs.r[10] = from->R10;
to->integer.arm_regs.r[11] = from->Fp;
to->integer.arm_regs.r[12] = from->Ip;
to->integer.arm_regs.r[11] = from->R11;
to->integer.arm_regs.r[12] = from->R12;
}
return STATUS_SUCCESS;
}
@ -423,8 +423,8 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from )
to->R8 = from->integer.arm_regs.r[8];
to->R9 = from->integer.arm_regs.r[9];
to->R10 = from->integer.arm_regs.r[10];
to->Fp = from->integer.arm_regs.r[11];
to->Ip = from->integer.arm_regs.r[12];
to->R11 = from->integer.arm_regs.r[11];
to->R12 = from->integer.arm_regs.r[12];
}
return STATUS_SUCCESS;
}
@ -633,10 +633,10 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
{
TRACE( " r0=%08x r1=%08x r2=%08x r3=%08x r4=%08x r5=%08x\n",
context->R0, context->R1, context->R2, context->R3, context->R4, context->R5 );
TRACE( " r6=%08x r7=%08x r8=%08x r9=%08x r10=%08x fp=%08x\n",
context->R6, context->R7, context->R8, context->R9, context->R10, context->Fp );
TRACE( " ip=%08x sp=%08x lr=%08x pc=%08x cpsr=%08x\n",
context->Ip, context->Sp, context->Lr, context->Pc, context->Cpsr );
TRACE( " r6=%08x r7=%08x r8=%08x r9=%08x r10=%08x r11=%08x\n",
context->R6, context->R7, context->R8, context->R9, context->R10, context->R11 );
TRACE( " r12=%08x sp=%08x lr=%08x pc=%08x cpsr=%08x\n",
context->R12, context->Sp, context->Lr, context->Pc, context->Cpsr );
}
status = send_debug_event( rec, TRUE, context );

View File

@ -1648,6 +1648,9 @@ typedef struct _CONTEXT
#define EXCEPTION_WRITE_FAULT 1
#define EXCEPTION_EXECUTE_FAULT 8
#define ARM_MAX_BREAKPOINTS 8
#define ARM_MAX_WATCHPOINTS 1
typedef struct _RUNTIME_FUNCTION
{
DWORD BeginAddress;
@ -1687,46 +1690,49 @@ typedef struct _UNWIND_HISTORY_TABLE
UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
typedef struct _CONTEXT {
/* The flags values within this flag control the contents of
a CONTEXT record.
typedef struct _NEON128
{
ULONGLONG Low;
LONGLONG High;
} NEON128, *PNEON128;
If the context record is used as an input parameter, then
for each portion of the context record controlled by a flag
whose value is set, it is assumed that that portion of the
context record contains valid context. If the context record
is being used to modify a thread's context, then only that
portion of the threads context will be modified.
If the context record is used as an IN OUT parameter to capture
the context of a thread, then only those portions of the thread's
context corresponding to set flags will be returned.
The context record is never used as an OUT only parameter. */
ULONG ContextFlags;
/* This section is specified/returned if the ContextFlags word contains
the flag CONTEXT_INTEGER. */
ULONG R0;
ULONG R1;
ULONG R2;
ULONG R3;
ULONG R4;
ULONG R5;
ULONG R6;
ULONG R7;
ULONG R8;
ULONG R9;
ULONG R10;
ULONG Fp;
ULONG Ip;
/* These are selected by CONTEXT_CONTROL */
ULONG Sp;
ULONG Lr;
ULONG Pc;
ULONG Cpsr;
typedef struct _CONTEXT
{
ULONG ContextFlags; /* 000 */
/* CONTEXT_INTEGER */
ULONG R0; /* 004 */
ULONG R1; /* 008 */
ULONG R2; /* 00c */
ULONG R3; /* 010 */
ULONG R4; /* 014 */
ULONG R5; /* 018 */
ULONG R6; /* 01c */
ULONG R7; /* 020 */
ULONG R8; /* 024 */
ULONG R9; /* 028 */
ULONG R10; /* 02c */
ULONG R11; /* 030 */
ULONG R12; /* 034 */
/* CONTEXT_CONTROL */
ULONG Sp; /* 038 */
ULONG Lr; /* 03c */
ULONG Pc; /* 040 */
ULONG Cpsr; /* 044 */
/* CONTEXT_FLOATING_POINT */
ULONG Fpscr; /* 048 */
ULONG Padding; /* 04c */
union
{
NEON128 Q[16];
ULONGLONG D[32];
ULONG S[32];
} DUMMYUNIONNAME; /* 050 */
/* CONTEXT_DEBUG_REGISTERS */
ULONG Bvr[ARM_MAX_BREAKPOINTS]; /* 150 */
ULONG Bcr[ARM_MAX_BREAKPOINTS]; /* 170 */
ULONG Wvr[ARM_MAX_WATCHPOINTS]; /* 190 */
ULONG Wcr[ARM_MAX_WATCHPOINTS]; /* 194 */
ULONG Padding2[2]; /* 198 */
} CONTEXT;
BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD);

View File

@ -1668,7 +1668,7 @@ static BOOL be_arm_get_addr(HANDLE hThread, const CONTEXT* ctx,
case be_cpu_addr_stack:
return be_cpu_build_addr(hThread, ctx, addr, 0, ctx->Sp);
case be_cpu_addr_frame:
return be_cpu_build_addr(hThread, ctx, addr, 0, ctx->Fp);
return be_cpu_build_addr(hThread, ctx, addr, 0, ctx->R11);
}
return FALSE;
}
@ -1723,8 +1723,8 @@ static void be_arm_print_context(HANDLE hThread, const CONTEXT* ctx, int all_reg
ctx->R0, ctx->R1, ctx->R2, ctx->R3);
dbg_printf(" r4:%08x r5:%08x r6:%08x r7:%08x\n",
ctx->R4, ctx->R5, ctx->R6, ctx->R7);
dbg_printf(" r8:%08x r9:%08x r10:%08x Fp:%08x Ip:%08x\n",
ctx->R8, ctx->R9, ctx->R10, ctx->Fp, ctx->Ip);
dbg_printf(" r8:%08x r9:%08x r10:%08x r11:%08x r12:%08x\n",
ctx->R8, ctx->R9, ctx->R10, ctx->R11, ctx->R12);
if (all_regs) dbg_printf( "Floating point ARM dump not implemented\n" );
}
@ -1746,8 +1746,8 @@ static struct dbg_internal_var be_arm_ctx[] =
{CV_ARM_R0 + 8, "r8", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R8), dbg_itype_unsigned_int},
{CV_ARM_R0 + 9, "r9", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R9), dbg_itype_unsigned_int},
{CV_ARM_R0 + 10, "r10", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R10), dbg_itype_unsigned_int},
{CV_ARM_R0 + 11, "r11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Fp), dbg_itype_unsigned_int},
{CV_ARM_R0 + 12, "r12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Ip), dbg_itype_unsigned_int},
{CV_ARM_R0 + 11, "r11", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R11), dbg_itype_unsigned_int},
{CV_ARM_R0 + 12, "r12", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, R12), dbg_itype_unsigned_int},
{CV_ARM_SP, "sp", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Sp), dbg_itype_unsigned_int},
{CV_ARM_LR, "lr", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Lr), dbg_itype_unsigned_int},
{CV_ARM_PC, "pc", (DWORD_PTR*)FIELD_OFFSET(CONTEXT, Pc), dbg_itype_unsigned_int},

View File

@ -389,8 +389,8 @@ static struct cpu_register cpu_register_map[] = {
REG(R8, 4, CONTEXT_INTEGER),
REG(R9, 4, CONTEXT_INTEGER),
REG(R10, 4, CONTEXT_INTEGER),
REG(Fp, 4, CONTEXT_INTEGER),
REG(Ip, 4, CONTEXT_INTEGER),
REG(R11, 4, CONTEXT_INTEGER),
REG(R12, 4, CONTEXT_INTEGER),
REG(Sp, 4, CONTEXT_CONTROL),
REG(Lr, 4, CONTEXT_CONTROL),
REG(Pc, 4, CONTEXT_CONTROL),