1 /* example usage: dtrace -q -s /path/to/messages.d */
2 /*
3  * %CopyrightBegin%
4  *
5  * Copyright Scott Lystig Fritchie 2011-2016. All Rights Reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * %CopyrightEnd%
20  */
21 
22 BEGIN
23 {
24     printf("\n");
25     printf("NOTE: message-queue message size 4294967295 means an external\n");
26     printf("      message that the code isn't smart enough to determine\n");
27     printf("      the actual size.\n");
28     printf("\n");
29 }
30 
31 erlang*:::message-send
32 /arg3 == 0 && arg4 == 0 && arg5 == 0/
33 {
34     printf("send:   %s -> %s: %d words\n",
35            copyinstr(arg0), copyinstr(arg1), arg2);
36 }
37 
38 erlang*:::message-send
39 /arg3 != 0 || arg4 != 0 || arg5 != 0/
40 {
41     printf("send:   %s label %d token {%d,%d} -> %s: %d words\n",
42            copyinstr(arg0),
43            arg3, arg4, arg5,
44            copyinstr(arg1), arg2);
45 }
46 
47 /*
48  * TODO:
49  * Weird, on my OS X box, beam says arg6 = 0 but this script says 4294967296.
50  */
51 
52 erlang*:::message-send-remote
53 /arg4 == 0 && arg5 == 0 && (arg6 == 0 || arg6 >= 4294967296)/
54 {
55     printf("send :  %s -> %s %s: %d words\n",
56            copyinstr(arg0), copyinstr(arg1), copyinstr(arg2), arg3);
57 }
58 
59 erlang*:::message-send-remote
60 /arg4 != 0 || arg5 != 0 || arg6 < 4294967296/
61 {
62     printf("send :  %s label %d token {%d,%d} -> %s %s: %d words\n",
63            copyinstr(arg0),
64            arg4, arg5, arg6,
65            copyinstr(arg1), copyinstr(arg2), arg3);
66 }
67 
68 erlang*:::message-queued
69 /arg3 == 0 && arg4 == 0 && arg5 == 0/
70 {
71     printf("queued: %s: %d words, queue len %d\n", copyinstr(arg0), arg1, arg2);
72 }
73 
74 erlang*:::message-queued
75 /arg3 != 0 || arg4 != 0 || arg5 != 0/
76 {
77     printf("queued: %s label %d token {%d,%d}: %d words, queue len %d\n",
78            copyinstr(arg0), arg3, arg4, arg5,
79            arg1, arg2);
80 }
81 
82 erlang*:::message-receive
83 /arg3 == 0 && arg4 == 0 && arg5 == 0/
84 {
85     printf("receive: %s: %d words, queue len %d\n",
86            copyinstr(arg0), arg1, arg2);
87 }
88 
89 erlang*:::message-receive
90 /arg3 != 0 || arg4 != 0 || arg5 != 0/
91 {
92     printf("receive: %s label %d token {%d,%d}: %d words, queue len %d\n",
93            copyinstr(arg0), arg3, arg4, arg5,
94            arg1, arg2);
95 }
96