4 * Copyright (c) 2010-2013 Apple Inc. All rights reserved.
6 * @APPLE_APACHE_LICENSE_HEADER_START@
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * @APPLE_APACHE_LICENSE_HEADER_END@
24 * Usage: dispatch_trace.d -p [pid]
25 * traced process must have been executed with
26 * DYLD_LIBRARY_PATH=/usr/lib/system/introspection or with
27 * DYLD_IMAGE_SUFFIX=_profile or DYLD_IMAGE_SUFFIX=_debug
30 #pragma D option quiet
31 #pragma D option zdefs
32 #pragma D option bufsize=16m
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");
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/ {
44 start = walltimestamp;
48 * Trace queue push and pop operations:
50 * probe queue-push/-pop(dispatch_queue_t queue, const char *label,
51 * dispatch_object_t item, const char *kind,
52 * dispatch_function_t function, void *context)
54 dispatch$target:libdispatch*.dylib::queue-push,
55 dispatch$target:libdispatch*.dylib::queue-pop {
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);
64 * Trace callouts to client functions:
66 * probe callout-entry/-return(dispatch_queue_t queue, const char *label,
67 * dispatch_function_t function, void *context)
69 dispatch$target:libdispatch*.dylib::callout-entry,
70 dispatch$target:libdispatch*.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);