| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ |
| 3 |
]> |
| 4 |
|
| 5 |
|
| 6 |
<section id="sockettracesect"> |
| 7 |
<title>Tracing Functions Called in Network Socket Code</title> |
| 8 |
<indexterm> |
| 9 |
<primary>script examples</primary> |
| 10 |
<secondary>tracing functions called in network socket code</secondary> |
| 11 |
</indexterm> |
| 12 |
|
| 13 |
<indexterm> |
| 14 |
<primary>examples of SystemTap scripts</primary> |
| 15 |
<secondary>tracing functions called in network socket code</secondary> |
| 16 |
</indexterm> |
| 17 |
|
| 18 |
<indexterm> |
| 19 |
<primary>tracing functions called in network socket code</primary> |
| 20 |
<secondary>examples of SystemTap scripts</secondary> |
| 21 |
</indexterm> |
| 22 |
<indexterm> |
| 23 |
<primary>network socket code, tracing functions called in</primary> |
| 24 |
<secondary>examples of SystemTap scripts</secondary> |
| 25 |
</indexterm> |
| 26 |
<indexterm> |
| 27 |
<primary>functions called in network socket code, tracing</primary> |
| 28 |
<secondary>examples of SystemTap scripts</secondary> |
| 29 |
</indexterm> |
| 30 |
<remark> |
| 31 |
http://sourceware.org/systemtap/examples/network/socket-trace.stp |
| 32 |
</remark> |
| 33 |
|
| 34 |
<indexterm> |
| 35 |
<primary>script examples</primary> |
| 36 |
<secondary>net/socket.c, tracing functions from</secondary> |
| 37 |
</indexterm> |
| 38 |
|
| 39 |
<indexterm> |
| 40 |
<primary>examples of SystemTap scripts</primary> |
| 41 |
<secondary>net/socket.c, tracing functions from</secondary> |
| 42 |
</indexterm> |
| 43 |
|
| 44 |
<indexterm> |
| 45 |
<primary>net/socket.c, tracing functions from</primary> |
| 46 |
<secondary>examples of SystemTap scripts</secondary> |
| 47 |
</indexterm> |
| 48 |
<para>This section describes how to trace functions called from the kernel's <filename>net/socket.c</filename> file. This task helps you identify, in finer detail, how each process interacts with the network at the kernel level.</para> |
| 49 |
|
| 50 |
<formalpara id="sockettrace"> |
| 51 |
<title>socket-trace.stp</title> |
| 52 |
<para> |
| 53 |
<programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/network/socket-trace.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> |
| 54 |
</para> |
| 55 |
</formalpara> |
| 56 |
|
| 57 |
<para><xref linkend="sockettrace"/> is identical to <xref linkend="thread_indent"/>, which was earlier used in <xref linkend="systemtapscript-functions"/> to illustrate how <command>thread_indent()</command> works.</para> |
| 58 |
|
| 59 |
<example id="sockettraceoutput"> |
| 60 |
<title><xref linkend="sockettrace"/> Sample Output</title> |
| 61 |
<screen>[...] |
| 62 |
0 Xorg(3611): -> sock_poll |
| 63 |
3 Xorg(3611): <- sock_poll |
| 64 |
0 Xorg(3611): -> sock_poll |
| 65 |
3 Xorg(3611): <- sock_poll |
| 66 |
0 gnome-terminal(11106): -> sock_poll |
| 67 |
5 gnome-terminal(11106): <- sock_poll |
| 68 |
0 scim-bridge(3883): -> sock_poll |
| 69 |
3 scim-bridge(3883): <- sock_poll |
| 70 |
0 scim-bridge(3883): -> sys_socketcall |
| 71 |
4 scim-bridge(3883): -> sys_recv |
| 72 |
8 scim-bridge(3883): -> sys_recvfrom |
| 73 |
12 scim-bridge(3883):-> sock_from_file |
| 74 |
16 scim-bridge(3883):<- sock_from_file |
| 75 |
20 scim-bridge(3883):-> sock_recvmsg |
| 76 |
24 scim-bridge(3883):<- sock_recvmsg |
| 77 |
28 scim-bridge(3883): <- sys_recvfrom |
| 78 |
31 scim-bridge(3883): <- sys_recv |
| 79 |
35 scim-bridge(3883): <- sys_socketcall |
| 80 |
[...]</screen> |
| 81 |
</example> |
| 82 |
|
| 83 |
<para><xref linkend="sockettraceoutput"/> contains a 3-second excerpt of the output for <xref linkend="sockettrace"/>. For more information about the output of this script as provided by <command>thread_indent()</command>, refer to <xref linkend="systemtapscript-functions"/> <xref linkend="thread_indent"/>. </para> |
| 84 |
|
| 85 |
<!-- |
| 86 |
<para><xref linkend="sockettraceoutput"/> contains a 3-second excerpt of the output for <xref linkend="sockettrace"/>. Each line contains the following information, on the order that they appear:</para> |
| 87 |
|
| 88 |
<itemizedlist> |
| 89 |
<listitem><para>The time delta (in microseconds) since the previous entry; that is, the number of microseconds since the last traced function call.</para></listitem> |
| 90 |
|
| 91 |
<listitem><para>The process name (and its corresponding ID) that made the function call.</para></listitem> |
| 92 |
|
| 93 |
<listitem><para>An arrow signifying whether the call was an entry (<computeroutput><-</computeroutput>) or an exit (<computeroutput>-></computeroutput>); the indentations help you match specific function call entries with their corresponding exits.</para></listitem> |
| 94 |
|
| 95 |
<listitem><para>The name of the function called by the process.</para></listitem> |
| 96 |
</itemizedlist> --> |
| 97 |
<!-- |
| 98 |
probe kernel.function("*@net/socket.c").call { |
| 99 |
printf ("%s -> %s\n", thread_indent(1), probefunc()) |
| 100 |
} |
| 101 |
probe kernel.function("*@net/socket.c").return { |
| 102 |
printf ("%s <- %s\n", thread_indent(-1), probefunc()) |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
--> |
| 107 |
|
| 108 |
</section> |
| 109 |
|