From fdf86cccfeb4c3e09e024b3a35bbce6308f36412 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 9 Jun 2016 01:58:22 +0200 Subject: Allow setting x86 debug flags for the current thread * kern/thread.c (thread_get_state): Allow call for the current thread, without suspending it. (thread_set_status): Likewise. --- kern/thread.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'kern/thread.c') diff --git a/kern/thread.c b/kern/thread.c index a8211491..7db1f3d2 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1425,6 +1425,12 @@ kern_return_t thread_get_state( { kern_return_t ret; +#if defined(__i386__) || defined(__x86_64__) + if (flavor == i386_DEBUG_STATE && thread == current_thread()) + /* This state can be obtained directly for the curren thread. */ + return thread_getstatus(thread, flavor, old_state, old_state_count); +#endif + if (thread == THREAD_NULL || thread == current_thread()) { return KERN_INVALID_ARGUMENT; } @@ -1449,6 +1455,12 @@ kern_return_t thread_set_state( { kern_return_t ret; +#if defined(__i386__) || defined(__x86_64__) + if (flavor == i386_DEBUG_STATE && thread == current_thread()) + /* This state can be set directly for the curren thread. */ + return thread_setstatus(thread, flavor, new_state, new_state_count); +#endif + if (thread == THREAD_NULL || thread == current_thread()) { return KERN_INVALID_ARGUMENT; } -- cgit v1.2.3