Other Forms of diff Utility
7.6 Using ltrace and strace Utilities
The ltrace program is a tracing utility for library function calls. It runs a program and logs all library function calls by that program. You can also use this utility to log system calls made by a program. The utility can also monitor child processes created by fork or clone system calls. This utility is very useful to quickly trace the failure point of an executable program. The utility may also print the time at which a particular function call or system call is executed with a reso- lution of microseconds. Consider the simple single-line program that prints the string “Hello world” and then exits. Using ltrace with the executable of this program produces the following result. [rootboota ltrace] ltrace -S -tt .a.out 22:21:48.325970 SYS_uname0xbffff3b4 = 0 22:21:48.327037 SYS_brkNULL = 0x080495f8 22:21:48.327511 SYS_mmap0xbffff104, 0xcccccccd, 0x400165f8, 4096, 640 = 0x40017000 22:21:48.328212 SYS_openetcld.so.preload, 0, 010 = -2 22:21:48.329000 SYS_openetcld.so.cache, 0, 00 = 3 22:21:48.329657 SYS_1973, 0xbfffea64, 0, 0xbfffea64, 0 = 0 22:21:48.331719 SYS_mmap0xbfffea34, 0, 0x400165f8, 1, 3 = 0x40018000 22:21:48.332460 SYS_close3 = 0 22:21:48.332908 SYS_openlibi686libc.so.6, 0, 027777765514 = 3 22:21:48.333620 SYS_read3, \177ELF\001\001\001, 1024 = 1024 22:21:48.334256 SYS_1973, 0xbfffeaa4, 3, 0xbfffeaa4, 0 = 0 22:21:48.334917 SYS_mmap0xbfffe994, 0x0012f728, 0x400165f8, 0xbfffe9c0, 5 = 0x4002c000 22:21:48.335584 SYS_mprotect0x40152000, 38696, 0, 0x4002c000, 0x00126000 = 0 22:21:48.336209 SYS_mmap0xbfffe994, 24576, 0x400165f8, 0xbfffe9cc, 3 = 0x40152000 22:21:48.336953 SYS_mmap0xbfffe994, 0xbfffe9cc, 0x400165f8, 0x40158000, 14120 = 0x40158000 22:21:48.337642 SYS_close3 = 0 22:21:48.340431 SYS_munmap0x40018000, 77871 = 0 22:21:48.341060 SYS_getpid = 32540 22:21:48.341562 __libc_start_main0x08048460, 1, 0xbffff88c, 0x080482e4, 0x080484c0 unfinished ... 22:21:48.342232 __register_frame_info0x08049508, 0x080495e0, 0xbffff828, 0x0804838e, 0x080482e4 = 0x401575e0 22:21:48.343064 printfHello world\n unfinished ... 224 Chapter 7 • Miscellaneous Tools 22:21:48.343813 SYS_1971, 0xbfffeff0, 0x401569e4, 0x40154a60, 0x40154a60 = 0 22:21:48.344450 SYS_1920, 4096, 3, 34, -1 = 0x40018000 22:21:48.345154 SYS_ioctl1, 21505, 0xbfffef20, 0xbfffef80, 1024 = 0 22:21:48.345890 SYS_write1, Hello world\n, 12Hello world = 12 22:21:48.346542 ... printf resumed = 12 22:21:48.346878 __deregister_frame_info0x08049508, 0x4000d816, 0x400171ec, 0x40017310, 7 = 0x080495e0 22:21:48.347746 SYS_munmap0x40018000, 4096 = 0 22:21:48.348235 SYS_exit12 = void 22:21:48.348706 +++ exited status 12 +++ [rootboota ltrace] The first column in each row shows the current time followed by a number that shows microseconds. The remaining part of the line shows the system call of the library call used. By comparing the time in two consecutive lines, you can find out the time taken by a particular sys- tem call. By looking at the output, you can also find out if a program fails during a particular system call. This may be especially helpful when testing device drivers and reading or writing to these drivers fails for some reason. The most common options used with this utility are shown in Table 7-4. The command can also read options either from its configuration file etc ltrace.conf or from .ltrace.conf in the home directory of the user. The strace utility is a more comprehensive tool and it can be used to separate different system calls. For example, it can be used to display information about network related system Table 7-4 Common options used with the ltrace utility Option Description -d Debug. Displays extra information about trace. -f Trace child processes. -S Display system calls and library calls. -r Display time difference between successive lines. -tt Display time stamp with each line with a resolution to microseconds. -o filename Record output to a file. -V Display version. -h Display help.Parts
» the linux development platform 2003
» Requirement Gathering Life Cycle of a Software Development Project
» Writing Functional Specifications Life Cycle of a Software Development Project
» Creating Architecture and Design Documents
» Implementation and Coding Life Cycle of a Software Development Project
» Testing Life Cycle of a Software Development Project
» Technical documentation developed during the development process. This includes
» Technical documentation prepared for technical support staff. This includes technical
» End-user manuals and guides. This is the documentation for the end user to assist the
» Software Releases Support and New Features
» Hardware Platform Components of a Development System
» Operating System Components of a Development System
» Editors Components of a Development System
» Compilers and Assemblers Components of a Development System
» Debuggers Components of a Development System
» Version Control Systems Components of a Development System
» Selection Criteria for Hardware Platform Selection Criteria for Software Development Tools
» Creating Deadlines Managing Development Process
» Managing the Development Team
» Resolving Dependencies Managing Development Process
» Libraries Linux Development Platform Specifications LDPS and Linux
» Open Source Developers Network at http:www.osdn.org
» Extensibility What to Look for in an Editor
» References and Resources the linux development platform 2003
» Target machine. This is the machine for which the newly built compiler will generate
» Post-Installation Tasks Installing GNU Compiler
» Compiling to Intermediate Levels
» Compilation with Debug Support
» Compilation with Optimization Compiling a Program
» Compiling Source Code for Other Languages
» Linking a program Assembling a Program
» Creating Libraries the linux development platform 2003
» Standard Libraries the linux development platform 2003
» Compiling Fortran Programs the linux development platform 2003
» Smalltalk Oberon Other Compilers
» The target 2. Dependencies Basic Terminology
» The explicit rules 2. The implicit rules
» Input Files Introduction to GNU make
» Typical Contents of a Makefile
» Running make Introduction to GNU make
» Shell to Execute Commands Include Files
» The ftp server The The dnsresolver
» FTPOBJS OBJS Another Example of Makefile
» Explicit Rules The make Rules
» Implicit Rules The make Rules
» Defining Variables Types of Variables
» Pre-Defined Variables Automatic Variables
» Makefile in The Top Directory
» Makefile in common-dir Directory
» Makefile in the ftp-dir Directory
» Makefile in the tftp-dir Directory Makefile in the dns-dir Directory
» Building Everything Working with Multiple Makefiles and Directories
» The ifdef Directive Control Structures and Directives
» The ifndef Directive Control Structures and Directives
» Compilation Getting the Latest Version and Installation
» Most Commonly Used gdb Commands
» Passing Command Line Arguments to the Program Being Debugged
» The step and finish Commands
» Introduction to GDB Working with the Stack
» Displaying Program Variables Displaying Variables
» Automatic Displaying Variables with Each Command
» Displaying Environment Variables Displaying Variables
» Modifying Variables Displaying Variables
» Disabling Break Points Enabling Break Points
» Debugging Optimized Code the linux development platform 2003
» Debugging Running Processes the linux development platform 2003
» The kdbg Debugger Other Open Source Debuggers
» The ddd Debugger Other Open Source Debuggers
» The xxgdb Debugger Other Open Source Debuggers
» CVS Policies the linux development platform 2003
» Project Management and Communication
» Remote Repositories Checking out a Project
» Finding the Status of a Project
» Finding Differences Using the CVS Client
» Resolving Conflicts Using the CVS Client
» Checking the Project Back In Adding Files to a Project
» Removing Files from a Project
» Tags and Releases Using the CVS Client
» System Requirements Introduction to jCVS
» Installation Instructions Introduction to jCVS
» Using jCVS Introduction to jCVS
» Installing pcl-cvs Using Emacs with CVS
» Using pcl-cvs Using Emacs with CVS
» Have a shell account on the CVS server. 2. Create a publicprivate key pair on the client.
» Selecting Coding Styles Using indent Utility
» Formatting Braces Using indent Utility
» Formatting Declarations Using indent Utility
» Breaking Long Lines Using indent Utility
» Summary of Options Using indent Utility
» Using sed Utility Using cscope and cbrowser
» Generating C Function Prototypes from C Source Code Using cproto
» Using ltrace and strace Utilities
» Value 2. Type Name Using the nm Utility
» Using the ranlib Utility Using the strip Utility
» Using the strings Utility Using the addr2line Utility
» Host Machine Introduction to the Cross-Platform Development Process
» Target Machine Introduction to the Cross-Platform Development Process
» Cross Platform Development Cycle
» Embedded Systems and Moving Parts
» Embedded Systems and Power Consumption
» Embedded Operating Systems What are Embedded Systems?
» Knowledge of Target System Hardware
» Software Emulators Cross Compilations
» Using gdbserver with GNU Debugger
» Attaching to a Running Process Using gdbserver
» Arcom SBC-GX1 Board Hardware Used for Cross-Platform and Embedded Systems
» Artesyn PMPPC Mezzanine Card
» References the linux development platform 2003
» Java Compiler Java Virtual Machine
» Kaffe the linux development platform 2003
» The Jboss Java Development System
» Getting and Installing Java SDK from Sun Creating jar Files
» Creating Source Code File Compiling Java Code
» Running Java Applications Building Java Applications
» Using gcj to Build Java Applications
» Building Applets the linux development platform 2003
» Testing Applets with Netscape
» Jikes for Java the linux development platform 2003
Show more