]>
Commit | Line | Data |
---|---|---|
517da941 | 1 | #!/usr/sbin/dtrace -s |
e85f4437 A |
2 | |
3 | /* | |
517da941 | 4 | * Copyright (c) 2010-2013 Apple Inc. All rights reserved. |
e85f4437 A |
5 | * |
6 | * @APPLE_APACHE_LICENSE_HEADER_START@ | |
7 | * | |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
9 | * you may not use this file except in compliance with the License. | |
10 | * You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, software | |
15 | * distributed under the License is distributed on an "AS IS" BASIS, | |
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
17 | * See the License for the specific language governing permissions and | |
18 | * limitations under the License. | |
19 | * | |
20 | * @APPLE_APACHE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | ||
23 | /* | |
517da941 | 24 | * Usage: dispatch_trace.d -p [pid] |
e85f4437 | 25 | * traced process must have been executed with |
517da941 | 26 | * DYLD_LIBRARY_PATH=/usr/lib/system/introspection or with |
e85f4437 A |
27 | * DYLD_IMAGE_SUFFIX=_profile or DYLD_IMAGE_SUFFIX=_debug |
28 | */ | |
29 | ||
30 | #pragma D option quiet | |
517da941 | 31 | #pragma D option zdefs |
e85f4437 A |
32 | #pragma D option bufsize=16m |
33 | ||
34 | BEGIN { | |
35 | printf("%-8s %-3s %-8s %-35s%-15s%-?s %-43s%-?s %-14s%-?s %s\n", | |
36 | "Time us", "CPU", "Thread", "Function", "Probe", "Queue", "Label", | |
37 | "Item", "Kind", "Context", "Symbol"); | |
38 | } | |
39 | ||
517da941 A |
40 | dispatch$target:libdispatch*.dylib::queue-push, |
41 | dispatch$target:libdispatch*.dylib::queue-pop, | |
42 | dispatch$target:libdispatch*.dylib::callout-entry, | |
43 | dispatch$target:libdispatch*.dylib::callout-return /!start/ { | |
e85f4437 A |
44 | start = walltimestamp; |
45 | } | |
46 | ||
517da941 A |
47 | /* |
48 | * Trace queue push and pop operations: | |
49 | * | |
50 | * probe queue-push/-pop(dispatch_queue_t queue, const char *label, | |
e85f4437 A |
51 | * dispatch_object_t item, const char *kind, |
52 | * dispatch_function_t function, void *context) | |
53 | */ | |
517da941 A |
54 | dispatch$target:libdispatch*.dylib::queue-push, |
55 | dispatch$target:libdispatch*.dylib::queue-pop { | |
e85f4437 A |
56 | printf("%-8d %-3d 0x%08p %-35s%-15s0x%0?p %-43s0x%0?p %-14s0x%0?p", |
57 | (walltimestamp-start)/1000, cpu, tid, probefunc, probename, arg0, | |
58 | copyinstr(arg1, 42), arg2, copyinstr(arg3, 13), arg5); | |
59 | usym(arg4); | |
60 | printf("\n"); | |
61 | } | |
62 | ||
517da941 A |
63 | /* |
64 | * Trace callouts to client functions: | |
65 | * | |
66 | * probe callout-entry/-return(dispatch_queue_t queue, const char *label, | |
e85f4437 A |
67 | * dispatch_function_t function, void *context) |
68 | */ | |
517da941 A |
69 | dispatch$target:libdispatch*.dylib::callout-entry, |
70 | dispatch$target:libdispatch*.dylib::callout-return { | |
e85f4437 A |
71 | printf("%-8d %-3d 0x%08p %-35s%-15s0x%0?p %-43s%-?s %-14s0x%0?p", |
72 | (walltimestamp-start)/1000, cpu, tid, probefunc, probename, arg0, | |
73 | copyinstr(arg1, 42), "", "", arg3); | |
74 | usym(arg2); | |
75 | printf("\n"); | |
76 | } |