summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-06-09 01:58:22 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-06-10 01:11:55 +0200
commitfdf86cccfeb4c3e09e024b3a35bbce6308f36412 (patch)
tree39094e5e7343fd72945812d571bd185496d28b09 /kern/thread.c
parenteebc8c484ef35f2d1d9935f20cde002ca2db23a7 (diff)
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.
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c12
1 files changed, 12 insertions, 0 deletions
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;
}