diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2023-02-12 13:26:29 -0500 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-12 19:56:01 +0100 |
commit | feba9b7b1d88e505feb6579e41dc45e48c264e6f (patch) | |
tree | ac8fad36689f9c60ac51292992bde7927ed6a90f | |
parent | e09f2d9584375a0d9e06bbcadec1910b042df620 (diff) | |
download | gnumach-feba9b7b1d88e505feb6579e41dc45e48c264e6f.tar.gz gnumach-feba9b7b1d88e505feb6579e41dc45e48c264e6f.tar.bz2 gnumach-feba9b7b1d88e505feb6579e41dc45e48c264e6f.zip |
Add x86_64 registers to i386_thread_state
This is required to implement ptrace.
Message-Id: <Y+kvVSoC+5bvsazl@jupiter.tail36e24.ts.net>
-rw-r--r-- | i386/i386/pcb.c | 45 | ||||
-rw-r--r-- | i386/include/mach/i386/thread_status.h | 28 |
2 files changed, 71 insertions, 2 deletions
diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 3ae9e095..de30197e 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -500,6 +500,25 @@ kern_return_t thread_setstatus( /* * General registers */ +#if defined(__x86_64__) && !defined(USER32) + saved_state->r8 = state->r8; + saved_state->r9 = state->r9; + saved_state->r10 = state->r10; + saved_state->r11 = state->r11; + saved_state->r12 = state->r12; + saved_state->r13 = state->r13; + saved_state->r14 = state->r14; + saved_state->r15 = state->r15; + saved_state->edi = state->rdi; + saved_state->esi = state->rsi; + saved_state->ebp = state->rbp; + saved_state->uesp = state->ursp; + saved_state->ebx = state->rbx; + saved_state->edx = state->rdx; + saved_state->ecx = state->rcx; + saved_state->eax = state->rax; + saved_state->eip = state->rip; +#else saved_state->edi = state->edi; saved_state->esi = state->esi; saved_state->ebp = state->ebp; @@ -509,6 +528,7 @@ kern_return_t thread_setstatus( saved_state->ecx = state->ecx; saved_state->eax = state->eax; saved_state->eip = state->eip; +#endif /* __x86_64__ && !USER32 */ saved_state->efl = (state->efl & ~EFL_USER_CLEAR) | EFL_USER_SET; @@ -696,6 +716,26 @@ kern_return_t thread_getstatus( /* * General registers. */ +#if defined(__x86_64__) && !defined(USER32) + state->r8 = saved_state->r8; + state->r9 = saved_state->r9; + state->r10 = saved_state->r10; + state->r11 = saved_state->r11; + state->r12 = saved_state->r12; + state->r13 = saved_state->r13; + state->r14 = saved_state->r14; + state->r15 = saved_state->r15; + state->rdi = saved_state->edi; + state->rsi = saved_state->esi; + state->rbp = saved_state->ebp; + state->rbx = saved_state->ebx; + state->rdx = saved_state->edx; + state->rcx = saved_state->ecx; + state->rax = saved_state->eax; + state->rip = saved_state->eip; + state->ursp = saved_state->uesp; + state->rsp = 0; /* unused */ +#else state->edi = saved_state->edi; state->esi = saved_state->esi; state->ebp = saved_state->ebp; @@ -704,9 +744,10 @@ kern_return_t thread_getstatus( state->ecx = saved_state->ecx; state->eax = saved_state->eax; state->eip = saved_state->eip; - state->efl = saved_state->efl; state->uesp = saved_state->uesp; - state->esp = 0; /* unused */ + state->esp = 0; /* unused */ +#endif /* __x86_64__ && !USER32 */ + state->efl = saved_state->efl; state->cs = saved_state->cs; state->ss = saved_state->ss; diff --git a/i386/include/mach/i386/thread_status.h b/i386/include/mach/i386/thread_status.h index ba1e3dea..2d05947e 100644 --- a/i386/include/mach/i386/thread_status.h +++ b/i386/include/mach/i386/thread_status.h @@ -67,6 +67,26 @@ struct i386_thread_state { unsigned int fs; unsigned int es; unsigned int ds; + +#if defined(__x86_64__) && !defined(USER32) + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + uint64_t rdi; + uint64_t rsi; + uint64_t rbp; + uint64_t rsp; + uint64_t rbx; + uint64_t rdx; + uint64_t rcx; + uint64_t rax; + uint64_t rip; +#else unsigned int edi; unsigned int esi; unsigned int ebp; @@ -76,9 +96,17 @@ struct i386_thread_state { unsigned int ecx; unsigned int eax; unsigned int eip; +#endif /* __x86_64__ && !USER32 */ + unsigned int cs; +#if defined(__x86_64__) && !defined(USER32) + uint64_t efl; + uint64_t ursp; +#else unsigned int efl; unsigned int uesp; +#endif /* __x86_64__ and !USER32 */ + unsigned int ss; }; #define i386_THREAD_STATE_COUNT (sizeof (struct i386_thread_state)/sizeof(unsigned int)) |