X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/43866e378188c25dd1e2208016ab3cbeb086ae6c..91447636331957f3d9b5ca5b508f07c526b0074d:/osfmk/kern/profile.c?ds=sidebyside diff --git a/osfmk/kern/profile.c b/osfmk/kern/profile.c index 1b3bfa0c3..ee8e346b3 100644 --- a/osfmk/kern/profile.c +++ b/osfmk/kern/profile.c @@ -1,24 +1,21 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -59,9 +56,7 @@ #include #if MACH_PROF -#include #include -#include #include #include #include @@ -104,8 +99,6 @@ profile_thread(void) kern_return_t kr; int j; - thread_swappable(current_act(), FALSE); - /* Initialise the queue header for the prof_queue */ mpqueue_init(&prof_queue); @@ -337,9 +330,18 @@ pbuf_free( ***************************************************************************** */ +#if !MACH_PROF kern_return_t thread_sample( - thread_act_t thr_act, + __unused thread_t thread, + __unused ipc_port_t reply) +{ + return KERN_FAILURE; +} +#else +kern_return_t +thread_sample( + thread_t thread, ipc_port_t reply) { /* @@ -349,18 +351,15 @@ thread_sample( * we are going to use as a reply port to send out the samples resulting * from its execution. */ -#if !MACH_PROF - return KERN_FAILURE; -#else prof_data_t pbuf; vm_offset_t vmpbuf; if (reply != MACH_PORT_NULL) { - if (thr_act->act_profiled) /* yuck! */ + if (thread->profiled) /* yuck! */ return KERN_INVALID_ARGUMENT; /* Start profiling this activation, do the initialization. */ pbuf = pbuf_alloc(); - if ((thr_act->profil_buffer = pbuf) == NULLPROFDATA) { + if ((thread->profil_buffer = pbuf) == NULLPROFDATA) { printf("thread_sample: cannot allocate pbuf\n"); return KERN_RESOURCE_SHORTAGE; } @@ -372,29 +371,29 @@ thread_sample( reset_pbuf_area(pbuf); } pbuf->prof_port = reply; - thr_act->act_profiled = TRUE; - thr_act->act_profiled_own = TRUE; + thread->profiled = TRUE; + thread->profiled_own = TRUE; if (profile_thread_id == THREAD_NULL) profile_thread_id = kernel_thread(kernel_task, profile_thread); } else { - if (!thr_act->act_profiled) + if (!thread->profiled) return(KERN_INVALID_ARGUMENT); - thr_act->act_profiled = FALSE; + thread->profiled = FALSE; /* do not stop sampling if thread is not profiled by its own */ - if (!thr_act->act_profiled_own) + if (!thread->profiled_own) return KERN_SUCCESS; else - thr_act->act_profiled_own = FALSE; + thread->profiled_own = FALSE; - send_last_sample_buf(thr_act->profil_buffer); - pbuf_free(thr_act->profil_buffer); - thr_act->profil_buffer = NULLPROFDATA; + send_last_sample_buf(thread->profil_buffer); + pbuf_free(thread->profil_buffer); + thread->profil_buffer = NULLPROFDATA; } return KERN_SUCCESS; -#endif /* MACH_PROF */ } +#endif /* MACH_PROF */ /* ***************************************************************************** @@ -406,14 +405,20 @@ thread_sample( ***************************************************************************** */ +#if !MACH_PROF kern_return_t task_sample( - task_t task, - ipc_port_t reply) + __unused task_t task, + __unused ipc_port_t reply) { -#if !MACH_PROF return KERN_FAILURE; +} #else +kern_return_t +task_sample( + task_t task, + ipc_port_t reply) +{ prof_data_t pbuf=task->profil_buffer; vm_offset_t vmpbuf; boolean_t turnon = (reply != MACH_PORT_NULL); @@ -458,24 +463,24 @@ task_sample( if (turnon != task->task_profiled) { int actual, i; - thread_act_t thr_act; + thread_t thread; if (turnon && profile_thread_id == THREAD_NULL) /* 1st time thru? */ profile_thread_id = /* then start profile thread. */ kernel_thread(kernel_task, profile_thread); task->task_profiled = turnon; - actual = task->thr_act_count; - for (i = 0, thr_act = (thread_act_t)queue_first(&task->thr_acts); + actual = task->thread_count; + for (i = 0, thread = (thread_t)queue_first(&task->threads); i < actual; - i++, thr_act = (thread_act_t)queue_next(&thr_act->thr_acts)) { - if (!thr_act->act_profiled_own) { - thr_act->act_profiled = turnon; + i++, thread = (thread_t)queue_next(&thr_act->task_threads)) { + if (!thread->profiled_own) { + threadt->profiled = turnon; if (turnon) { - thr_act->profil_buffer = task->profil_buffer; - thr_act->act_profiled = TRUE; + threadt->profil_buffer = task->profil_buffer; + thread->profiled = TRUE; } else { - thr_act->act_profiled = FALSE; - thr_act->profil_buffer = NULLPROFDATA; + thread->profiled = FALSE; + thread->profil_buffer = NULLPROFDATA; } } } @@ -488,6 +493,6 @@ task_sample( task_unlock(task); return KERN_SUCCESS; -#endif /* MACH_PROF */ } +#endif /* MACH_PROF */