]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/sdt_x86.c
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* #pragma ident "@(#)sdt.c 1.9 08/07/01 SMI" */
30 #define _KERNEL /* Solaris vs. Darwin */
34 #define MACH__POSIX_C_SOURCE_PRIVATE 1 /* pulls in suitable savearea from mach/ppc/thread_status.h */
35 #include <kern/cpu_data.h>
36 #include <kern/thread.h>
37 #include <mach/thread_status.h>
38 #include <mach/vm_param.h>
40 #include <sys/dtrace.h>
41 #include <sys/dtrace_impl.h>
43 #include <sys/dtrace_glue.h>
45 #include <sys/sdt_impl.h>
47 extern sdt_probe_t
**sdt_probetab
;
52 sdt_invop(uintptr_t addr
, uintptr_t *stack
, uintptr_t eax
)
55 uintptr_t stack0
= 0, stack1
= 0, stack2
= 0, stack3
= 0, stack4
= 0;
56 sdt_probe_t
*sdt
= sdt_probetab
[SDT_ADDR2NDX(addr
)];
58 for (; sdt
!= NULL
; sdt
= sdt
->sdp_hashnext
) {
59 if ((uintptr_t)sdt
->sdp_patchpoint
== addr
) {
62 stacktop
= (uintptr_t *)dtrace_get_cpu_int_stack_top();
64 stacktop
= (uintptr_t *)(dtrace_get_kernel_stack(current_thread()) + kernel_stack_size
);
66 if (stack
<= stacktop
)
68 if (stack
<= stacktop
)
70 if (stack
<= stacktop
)
72 if (stack
<= stacktop
)
74 if (stack
<= stacktop
)
77 dtrace_probe(sdt
->sdp_id
, stack0
, stack1
, stack2
, stack3
, stack4
);
79 return (DTRACE_INVOP_NOP
);
85 #elif defined(__x86_64__)
88 sdt_invop(uintptr_t addr
, uintptr_t *stack
, uintptr_t eax
)
91 sdt_probe_t
*sdt
= sdt_probetab
[SDT_ADDR2NDX(addr
)];
93 for (; sdt
!= NULL
; sdt
= sdt
->sdp_hashnext
) {
94 if ((uintptr_t)sdt
->sdp_patchpoint
== addr
) {
95 x86_saved_state64_t
*regs
= (x86_saved_state64_t
*)stack
;
97 dtrace_probe(sdt
->sdp_id
, regs
->rdi
, regs
->rsi
, regs
->rdx
, regs
->rcx
, regs
->r8
);
99 return (DTRACE_INVOP_NOP
);