Skip to main content

ltrace

ltrace

概述

ltrace是一个调试程序,可在它退出之前执行指定命令来拦截和记录动态库调用和信号接收过程。它还可拦截并打印系统调用及直接在二进制文件上使用。

命令介绍

ltrace是一个仅运行指定命令后直到退出的程序。它截获并记录由执行的过程调用的动态库调用以及该过程接收的信号,它还可以拦截并打印程序执行的系统调用,它和strace的使用十分相似。

在终端界面,执行dnf install ltrace ltrace-help(仅e版中存在ltrace-help)命令,安装ltrace和ltrace-help包。执行man ltrace命令,可查看其他更多参数及其含义。

LTRACE(1) User Commands LTRACE(1) NAME ltrace-A Library call tracer SYNOPSIS Ltrace [-efilter-L」[-l--Librarylbrary pattern]xfilter][-][-b eltsl [-s strsize] [-C|--dmangle] [-a-align colum [-n-inentnr] [-o-utput filename][-D)-dug mask [-username][-f][-ppid][-- com- mand [arg...1 Ltrace-[-e filter|-L] [-1|--Library=library_patter] [-xfilter] [-s][-o|--utput filename][-f][-ppid][[--]conand arg.. Ltrace -V|--version ltrace -h|--help DESCRIPTION ltrace is a program that simp1y runs the specified comand until it exits,It intercepts and records the dynamic library calls which are called by th executed process and the signals which are received by that process.It can also intercept and print the system calls executed by the program Its use is very similar to strace(1). Ltrace shows parameters of invoked functions and system calls, o determine hatarquments each function has,it needs external declaration of functior prototypes.Those are stored in files called prototye Libraries-see trace.conf(5) for details on the syntax of these files,See the section PROTO TYPE LIBRARY DISCOVERY to learn how ltrace finds prototype libraries. OPTIONS -a,--align column Align return values in a specific column (default column is 5/8 of screen width). -A maxelts Maximum number of array elements to print before suppressing the rest with an ellpsis ("..),This also limits numberofrecursivetructure expansions. -b,--no-signals Disable printing of signals recieved by the traced process. Count time and calls for each library call and report a sumary on program exit. -C -C,--demangle Decode (demangle)ow-velsybo naes nto sereveaes,sdeemovgnytia decore prefix sed by th ym,this ake CH function names readable. Manual page ltrace(1) line 1(press h for help or g to quit) "Locahost.ocaldomain" 00:01 23-ay-20 [0]0:man*1:bash-2:bash)


### 功能测试

执行ltrace ls命令,显示跟踪ls系统调用的执行情况。

![](/img/docs/image181.png)