From 8e1f4254a75032b42e7974a5a0dbcb5db6b2feb1 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 10 Feb 2006 09:55:53 +0000 Subject: [PATCH] Get thread backtrace context on i386. --- .../src/archutils/Darwin/DarwinThreadHelpers.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp index a4faeef8d3..dcdfd1514c 100644 --- a/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp +++ b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp @@ -25,11 +25,11 @@ bool GetThreadBacktraceContext( uint64_t iID, BacktraceContext *ctx ) { /* Can't GetThreadBacktraceContext the current thread. */ ASSERT( iID != GetCurrentThreadId() ); + SuspendThread( iID ); + + thread_act_t thread = thread_act_t( iID ); #if defined(__ppc__) - SuspendThread( iID ); - - thread_act_t thread = thread_act_t( iID ); ppc_thread_state state; mach_msg_type_number_t count = PPC_THREAD_STATE_COUNT; @@ -38,6 +38,16 @@ bool GetThreadBacktraceContext( uint64_t iID, BacktraceContext *ctx ) ctx->FramePtr = (void *)state.r1; ctx->PC = (void *)state.srr0; return true; +#elif defined(__i386__) + i386_thread_state state; + mach_msg_type_number_t count = i386_THREAD_STATE_COUNT; + + if( thread_get_state(thread, i386_THREAD_STATE, thread_state_t(&state), &count) ) + return false; + ctx->ip = (void *)state.eip; + ctx->bp = (void *)state.ebp; + ctx->sp = (void *)state.esp; + return true; #else return false; #endif