1*0675664bSnaddy.\" $OpenBSD: ltrace.1,v 1.11 2023/09/30 13:03:40 naddy Exp $ 2ae398163Smiod.\" 3ae398163Smiod.\" Copyright (c) 2013 Miodrag Vallat. 4ae398163Smiod.\" 5ae398163Smiod.\" Permission to use, copy, modify, and distribute this software for any 6ae398163Smiod.\" purpose with or without fee is hereby granted, provided that the above 7ae398163Smiod.\" copyright notice and this permission notice appear in all copies. 8ae398163Smiod.\" 9ae398163Smiod.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10ae398163Smiod.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11ae398163Smiod.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12ae398163Smiod.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13ae398163Smiod.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14ae398163Smiod.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15ae398163Smiod.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16ae398163Smiod.\" 17ae398163Smiod.\" Copyright (c) 1990, 1993 18ae398163Smiod.\" The Regents of the University of California. All rights reserved. 19ae398163Smiod.\" 20ae398163Smiod.\" Redistribution and use in source and binary forms, with or without 21ae398163Smiod.\" modification, are permitted provided that the following conditions 22ae398163Smiod.\" are met: 23ae398163Smiod.\" 1. Redistributions of source code must retain the above copyright 24ae398163Smiod.\" notice, this list of conditions and the following disclaimer. 25ae398163Smiod.\" 2. Redistributions in binary form must reproduce the above copyright 26ae398163Smiod.\" notice, this list of conditions and the following disclaimer in the 27ae398163Smiod.\" documentation and/or other materials provided with the distribution. 28ae398163Smiod.\" 3. Neither the name of the University nor the names of its contributors 29ae398163Smiod.\" may be used to endorse or promote products derived from this software 30ae398163Smiod.\" without specific prior written permission. 31ae398163Smiod.\" 32ae398163Smiod.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 33ae398163Smiod.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34ae398163Smiod.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35ae398163Smiod.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 36ae398163Smiod.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37ae398163Smiod.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38ae398163Smiod.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39ae398163Smiod.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40ae398163Smiod.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41ae398163Smiod.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42ae398163Smiod.\" SUCH DAMAGE. 43ae398163Smiod.\" 44ae398163Smiod.\" from: @(#)ktrace.1 8.1 (Berkeley) 6/6/93 45ae398163Smiod.\" 46*0675664bSnaddy.Dd $Mdocdate: September 30 2023 $ 47ae398163Smiod.Dt LTRACE 1 48ae398163Smiod.Os 49ae398163Smiod.Sh NAME 50ae398163Smiod.Nm ltrace 51ae398163Smiod.Nd shared library function call tracer 52ae398163Smiod.Sh SYNOPSIS 53ae398163Smiod.Nm ltrace 54ae398163Smiod.Op Fl ai 55ae398163Smiod.Op Fl f Ar trfile 56f3144d5dSmiod.Op Fl t Ar trstr 57ae398163Smiod.Op Fl u Ar trspec 58ae398163Smiod.Ar command 59ae398163Smiod.Sh DESCRIPTION 60ae398163Smiod.Nm ltrace 61ae398163Smiodenables shared library function calls issued by the specified processes 62ae398163Smiodto be traced using the 63ae398163Smiod.Xr utrace 2 64ae398163Smioduser tracing facility. 65ae398163SmiodBy default, call trace data is logged to the file 66ae398163Smiod.Pa ktrace.out , 67ae398163Smiodunless overridden by the 68ae398163Smiod.Fl f 69ae398163Smiodoption. 70ae398163SmiodEach function call is traced as a pair of 71ae398163Smiod.Dv KTRFAC_USER 72ae398163Smiodentries; 73ae398163Smiodthe first entry contains the shared library containing the symbol being 74ae398163Smiodcalled, and the second entry contains the symbol name. 75ae398163Smiod.Pp 76ae398163SmiodOnce tracing is enabled on a process, trace data will be logged until 77ae398163Smiodeither the process exits or the trace point is cleared with 78ae398163Smiod.Xr ktrace 1 . 79ae398163SmiodA traced process can generate enormous amounts of log data quickly; 80ae398163Smiodit is strongly suggested that users memorize how to disable tracing before 81ae398163Smiodattempting to trace a process. 82ae398163SmiodThe following command is sufficient to disable tracing on all user owned 830870f47dSjmcprocesses and, if executed by root, all processes: 84ae398163Smiod.Pp 85ae398163Smiod.Dl $ ktrace -C 86ae398163Smiod.Pp 87ae398163SmiodThe trace file is not human-readable; use 88ae398163Smiod.Xr kdump 1 89ae398163Smiodto decode it. 90ae398163Smiod.Pp 91ae398163SmiodThe options are as follows: 92ae398163Smiod.Bl -tag -width 9n 93ae398163Smiod.It Fl a 94ae398163SmiodAppend to the trace file instead of recreating it. 95ae398163Smiod.It Fl f Ar trfile 96ae398163SmiodLog trace records to 97ae398163Smiod.Ar trfile 98ae398163Smiodinstead of 99ae398163Smiod.Pa ktrace.out . 100ae398163Smiod.It Fl i 101ae398163SmiodInherit; pass the trace flags to all future children of the designated 102ae398163Smiodprocesses. 103f3144d5dSmiod.It Fl t Ar trstr 104f3144d5dSmiodThe string argument represents the kernel trace points, one per letter. 105adacb5b9SguentherThe default is just 106adacb5b9Sguenther.Cm u . 107f3144d5dSmiodThe following table equates the letters with the trace points: 108f3144d5dSmiod.Pp 109f3144d5dSmiod.Bl -tag -width flag -offset indent -compact 110*0675664bSnaddy.\" Keep this list in sync with kdump(1) and ktrace(1). 111f3144d5dSmiod.It Cm c 112f3144d5dSmiodtrace system calls 113f3144d5dSmiod.It Cm i 114f3144d5dSmiodtrace I/O 115f3144d5dSmiod.It Cm n 116f3144d5dSmiodtrace namei translations 117adacb5b9Sguenther.It Cm p 118adacb5b9Sguenthertrace violation of 119adacb5b9Sguenther.Xr pledge 2 120adacb5b9Sguentherrestrictions 121f3144d5dSmiod.It Cm s 122f3144d5dSmiodtrace signal processing 123f3144d5dSmiod.It Cm t 124f3144d5dSmiodtrace various structures 125f3144d5dSmiod.It Cm u 126f3144d5dSmiodtrace user data coming from 127f3144d5dSmiod.Xr utrace 2 1285a6e456fSguenther.It Cm x 1295a6e456fSguenthertrace argument vector in 1305a6e456fSguenther.Xr execve 2 1315a6e456fSguenther.It Cm X 1325a6e456fSguenthertrace environment in 1335a6e456fSguenther.Xr execve 2 134f3144d5dSmiod.It Cm + 135f3144d5dSmiodtrace the default points 1365a6e456fSguenther.El 137ae398163Smiod.It Fl u Ar trspec 138ae398163SmiodRestrict the trace to a list of shared objects and/or function names, as 139ae398163Smiodspecified by the 140ae398163Smiod.Ar trspec 141ae398163Smiodargument. 142ae398163SmiodThe trace specification is a comma-separated list of library names, 143ae398163Smiodfollowed by a colon 14407c5909dSjmc.Pq :\& , 14507c5909dSjmcand a comma-separated list of function names. 146ae398163SmiodEach list can be empty. 14707c5909dSjmcEach list member may end with a star 148ae398163Smiod.Pq * 149ae398163Smiodto only match the beginning of a name. 15056744798SjmcAn exclamation mark at the beginning of a list turns it into a rejection list, 151ae398163Smiodcausing all unmatched names to be traced. 152ae398163SmiodLibrary names are compared without their version number and 153ae398163Smiod.Sq .so 154ae398163Smiodsuffix. 15507c5909dSjmc.It Ar command 15607c5909dSjmcExecute 15707c5909dSjmc.Ar command 15807c5909dSjmcwith the specified trace flags. 159ae398163Smiod.El 160ae398163Smiod.Sh FILES 16107c5909dSjmc.Bl -tag -width ktrace.outXXX -compact 162ae398163Smiod.It Pa ktrace.out 16307c5909dSjmcDefault 16407c5909dSjmc.Nm 16507c5909dSjmcdump file. 166ae398163Smiod.El 167ae398163Smiod.Sh EXAMPLES 168ae398163SmiodTrace all shared library function calls from 169ae398163Smiod.Xr wc 1 170ae398163Smiodreading the message of the day: 171ae398163Smiod.Dl $ ltrace wc -lh /etc/motd 172ae398163Smiod.Pp 173ae398163SmiodTrace only the shared library function calls in 174ae398163Smiod.Pa libutil.so : 175ae398163Smiod.Dl $ ltrace -u libutil wc -lh /etc/motd 176ae398163Smiod.Pp 177ae398163SmiodTrace all the shared library function calls but those in 178ae398163Smiod.Pa libc.so : 179ae398163Smiod.Dl $ ltrace -u \(dq!libc\(dq wc -lh /etc/motd 180ae398163Smiod.Pp 18107c5909dSjmcTrace all the shared library function calls with names starting 1825d1dcc4fSjmc.Qq fmt : 183ae398163Smiod.Dl $ ltrace -u \(dq:fmt*\(dq wc -lh /etc/motd 184f3144d5dSmiod.Pp 185f3144d5dSmiodTrace all shared library function calls, as well as all system calls: 186f3144d5dSmiod.Dl $ ltrace -t cu wc -lh /etc/motd 187ae398163Smiod.Sh SEE ALSO 188ae398163Smiod.Xr kdump 1 , 189ae398163Smiod.Xr ktrace 1 , 190ae398163Smiod.Xr ktrace 2 , 191ae398163Smiod.Xr utrace 2 192f3144d5dSmiod.Sh HISTORY 193f3144d5dSmiodThe 194f3144d5dSmiod.Nm ltrace 195f3144d5dSmiodcommand appeared in 196f3144d5dSmiod.Ox 5.4 . 197