]>
Commit | Line | Data |
---|---|---|
e85f4437 A |
1 | #!/usr/sbin/dtrace -Z -s |
2 | ||
3 | /* | |
4 | * Copyright (c) 2010-2011 Apple Inc. All rights reserved. | |
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 | /* | |
24 | * Usage: dispatch_dtrace.d -p [pid] | |
25 | * traced process must have been executed with | |
26 | * DYLD_IMAGE_SUFFIX=_profile or DYLD_IMAGE_SUFFIX=_debug | |
27 | */ | |
28 | ||
29 | #pragma D option quiet | |
30 | #pragma D option bufsize=16m | |
31 | ||
32 | BEGIN { | |
33 | printf("%-8s %-3s %-8s %-35s%-15s%-?s %-43s%-?s %-14s%-?s %s\n", | |
34 | "Time us", "CPU", "Thread", "Function", "Probe", "Queue", "Label", | |
35 | "Item", "Kind", "Context", "Symbol"); | |
36 | } | |
37 | ||
38 | dispatch$target:libdispatch_profile.dylib::queue-push, | |
39 | dispatch$target:libdispatch_debug.dylib::queue-push, | |
40 | dispatch$target:libdispatch_profile.dylib::queue-pop, | |
41 | dispatch$target:libdispatch_debug.dylib::queue-pop, | |
42 | dispatch$target:libdispatch_profile.dylib::callout-entry, | |
43 | dispatch$target:libdispatch_debug.dylib::callout-entry, | |
44 | dispatch$target:libdispatch_profile.dylib::callout-return, | |
45 | dispatch$target:libdispatch_debug.dylib::callout-return /!start/ { | |
46 | start = walltimestamp; | |
47 | } | |
48 | ||
49 | /* probe queue-push/-pop(dispatch_queue_t queue, const char *label, | |
50 | * dispatch_object_t item, const char *kind, | |
51 | * dispatch_function_t function, void *context) | |
52 | */ | |
53 | dispatch$target:libdispatch_profile.dylib::queue-push, | |
54 | dispatch$target:libdispatch_debug.dylib::queue-push, | |
55 | dispatch$target:libdispatch_profile.dylib::queue-pop, | |
56 | dispatch$target:libdispatch_debug.dylib::queue-pop { | |
57 | printf("%-8d %-3d 0x%08p %-35s%-15s0x%0?p %-43s0x%0?p %-14s0x%0?p", | |
58 | (walltimestamp-start)/1000, cpu, tid, probefunc, probename, arg0, | |
59 | copyinstr(arg1, 42), arg2, copyinstr(arg3, 13), arg5); | |
60 | usym(arg4); | |
61 | printf("\n"); | |
62 | } | |
63 | ||
64 | /* probe callout-entry/-return(dispatch_queue_t queue, const char *label, | |
65 | * dispatch_function_t function, void *context) | |
66 | */ | |
67 | dispatch$target:libdispatch_profile.dylib::callout-entry, | |
68 | dispatch$target:libdispatch_debug.dylib::callout-entry, | |
69 | dispatch$target:libdispatch_profile.dylib::callout-return, | |
70 | dispatch$target:libdispatch_debug.dylib::callout-return { | |
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 | } |