Thursday, June 20, 2013

The Linux Programmer’s Toolbox

The Linux Programmer's Toolbox (Paperback) ~ John Fusco

Table of Contents



Prentice Hall Open Source Software Development Series


Who Should Read This Book

The Purpose of This Book

How to Read This Book

How This Book Is Organized


About the Author
Download ChapterDownload Chapter
1 TokenChapter 1. Downloading and Installing Open Source Tools

Section 1.1. Introduction

Section 1.2. What Is Open Source?
Section 1.3. What Does Open Source Mean to You?

Section 1.3.1. Finding Tools

Section 1.3.2. Distribution Formats
Section 1.4. An Introduction to Archive Files

Section 1.4.1. Identifying Archive Files

Section 1.4.2. Querying an Archive File

Section 1.4.3. Extracting Files from an Archive File
Section 1.5. Know Your Package Manager

Section 1.5.1. Choosing Source or Binary

Section 1.5.2. Working with Packages
Section 1.6. Some Words about Security and Packages

Section 1.6.1. The Need for Authentication

Section 1.6.2. Basic Package Authentication

Section 1.6.3. Package Authentication with Digital Signatures

Section 1.6.4. GPG Signatures with RPM

Section 1.6.5. When You Can’t Authenticate a Package
Section 1.7. Inspecting Package Contents

Section 1.7.1. How to Inspect Packages

Section 1.7.2. A Closer Look at RPM Packages

Section 1.7.3. A Closer Look at Debian Packages
Section 1.8. Keeping Packages up to Date

Section 1.8.1. Apt: Advanced Package Tool

Section 1.8.2. Yum: Yellowdog Updater Modified

Section 1.8.3. Synaptic: The GUI Front End for APT

Section 1.8.4. up2date: The Red Hat Package Updater
Section 1.9. Summary

Section 1.9.1. Tools Used in This Chapter

Section 1.9.2. Online References
Download ChapterDownload Chapter
1 TokenChapter 2. Building from Source

Section 2.1. Introduction
Section 2.2. Build Tools

Section 2.2.1. Background

Section 2.2.2. Understanding make

Section 2.2.3. How Programs Are Linked

Section 2.2.4. Understanding Libraries
Section 2.3. The Build Process

Section 2.3.1. The GNU Build Tools

Section 2.3.2. The configure Stage

Section 2.3.3. The Build Stage: make

Section 2.3.4. The Install Stage: make install
Section 2.4. Understanding Errors and Warnings
Section 2.4.1. Common Makefile Mistakes

Section Shell Commands

Section Missing Tabs

Section VPATH Confusion

Section 2.4.2. Errors during the configure Stage

Section 2.4.3. Errors during the Build Stage

Section 2.4.4. Understanding Compiler Errors

Section 2.4.5. Understanding Compiler Warnings

Section 2.4.6. Understanding Linker Errors
Section 2.5. Summary

Section 2.5.1. Tools Used in This Chapter

Section 2.5.2. Online References
Download ChapterDownload Chapter
1 TokenChapter 3. Finding Help

Section 3.1. Introduction
Section 3.2. Online Help Tools

Section 3.2.1. The man Page

Section 3.2.2. man Organization

Section 3.2.3. Searching the man Pages: apropos

Section 3.2.4. Getting the Right man Page: whatis

Section 3.2.5. Things to Look for in the man Page

Section 3.2.6. Some Recommended man Pages

Section 3.2.7. GNU info

Section 3.2.8. Viewing info Pages

Section 3.2.9. Searching info Pages

Section 3.2.10. Recommended info Pages

Section 3.2.11. Desktop Help Tools
Section 3.3. Other Places to Look

Section 3.3.1. /usr/share/doc

Section 3.3.2. Cross Referencing and Indexing

Section 3.3.3. Package Queries
Section 3.4. Documentation Formats

Section 3.4.1. TeX/LaTeX/DVI

Section 3.4.2. Texinfo

Section 3.4.3. DocBook

Section 3.4.4. HTML

Section 3.4.5. PostScript

Section 3.4.6. Portable Document Format (PDF)

Section 3.4.7. troff
Section 3.5. Internet Sources of Information

Section 3.5.1.

Section 3.5.2.

Section 3.5.3. The Linux Documentation Project

Section 3.5.4. Usenet

Section 3.5.5. Mailing Lists

Section 3.5.6. Other Forums
Section 3.6. Finding Information about the Linux Kernel

Section 3.6.1. The Kernel Build

Section 3.6.2. Kernel Modules

Section 3.6.3. Miscellaneous Documentation
Section 3.7. Summary

Section 3.7.1. Tools Used in This Chapter

Section 3.7.2. Online Resources
Download ChapterDownload Chapter
1 TokenChapter 4. Editing and Maintaining Source Files

Section 4.1. Introduction
Section 4.2. The Text Editor

Section 4.2.1. The Default Editor

Section 4.2.2. What to Look for in a Text Editor

Section 4.2.3. The Big Two: vi and Emacs

Section 4.2.4. Vim: vi Improved
Section 4.2.5. Emacs

Section Emacs Features

Section Modes? What Modes?

Section Emacs Commands and Shortcuts

Section Cursor Movement

Section Deleting, Cutting, and Pasting

Section Search and Replace

Section Browsing and Building Code with Emacs

Section Text Mode Menus

Section Customizing Emacs Settings

Section Emacs for vi Users

Section GUI Mode

Section The Bottom Line on Emacs

Section 4.2.6. Attack of the Clones

Section 4.2.7. Some GUI Text Editors at a Glance

Section 4.2.8. Memory Usage

Section 4.2.9. Editor Summary
Section 4.3. Revision Control

Section 4.3.1. Revision Control Basics
Section 4.3.2. Defining Revision Control Terms

Section Project

Section Add/Remove

Section Check In

Section Check Out

Section Branch

Section Merge

Section Label

Section In Summary

Section 4.3.3. Supporting Tools

Section 4.3.4. Introducing diff and patch

Section 4.3.5. Reviewing and Merging Changes
Section 4.4. Source Code Beautifiers and Browsers

Section 4.4.1. The Indent Code Beautifier

Section 4.4.2. Astyle Artistic Style

Section 4.4.3. Analyzing Code with cflow

Section 4.4.4. Analyzing Code with ctags

Section 4.4.5. Browsing Code with cscope

Section 4.4.6. Browsing and Documenting Code with Doxygen
Section 4.4.7. Using the Compiler to Analyze Code

Section Dependencies

Section Macro Expansions
Section 4.5. Summary

Section 4.5.1. Tools Used in This Chapter

Section 4.5.2. References

Section 4.5.3. Online Resources
Download ChapterDownload Chapter
1 TokenChapter 5. What Every Developer Should Know about the Kernel

Section 5.1. Introduction
Section 5.2. User Mode versus Kernel Mode

Section 5.2.1. System Calls

Section 5.2.2. Moving Data between User Space and Kernel Space
Section 5.3. The Process Scheduler

Section 5.3.1. A Scheduling Primer

Section 5.3.2. Blocking, Preemption, and Yielding

Section 5.3.3. Scheduling Priority and Fairness

Section 5.3.4. Priorities and Nice Value

Section 5.3.5. Real-Time Priorities

Section 5.3.6. Creating Real-Time Processes

Section 5.3.7. Process States
Section 5.3.8. How Time Is Measured

Section System Time Units

Section The Kernel Clock Tick

Section Timing Your Application
Section 5.4. Understanding Devices and Device Drivers

Section 5.4.1. Device Driver Types

Section 5.4.2. A Word about Kernel Modules

Section 5.4.3. Device Nodes

Section 5.4.4. Devices and I/O
Section 5.5. The I/O Scheduler

Section 5.5.1. The Linus Elevator (aka noop)

Section 5.5.2. Deadline I/O Scheduler

Section 5.5.3. Anticipatory I/O Scheduler

Section 5.5.4. Complete Fair Queuing I/O Scheduler

Section 5.5.5. Selecting an I/O Scheduler
Section 5.6. Memory Management in User Space

Section 5.6.1. Virtual Memory Explained
Section 5.6.2. Running out of Memory

Section When a Process Runs out of Memory

Section When the System Runs out of Memory

Section Locking Down Memory
Section 5.7. Summary

Section 5.7.1. Tools Used in This Chapter

Section 5.7.2. APIs Discussed in This Chapter

Section 5.7.3. Online References

Section 5.7.4. References
Download ChapterDownload Chapter
1 TokenChapter 6. Understanding Processes

Section 6.1. Introduction
Section 6.2. Where Processes Come From

Section 6.2.1. fork and vfork

Section 6.2.2. Copy on Write

Section 6.2.3. clone
Section 6.3. The exec Functions

Section 6.3.1. Executable Scripts

Section 6.3.2. Executable Object Files

Section 6.3.3. Miscellaneous Binaries

Section 6.4. Process Synchronization with wait
Section 6.5. The Process Footprint

Section 6.5.1. File Descriptors

Section 6.5.2. Stack

Section 6.5.3. Resident and Locked Memory

Section 6.6. Setting Process Limits

Section 6.7. Processes and procfs
Section 6.8. Tools for Managing Processes

Section 6.8.1. Displaying Process Information with ps

Section 6.8.2. Advanced Process Information Using Formats

Section 6.8.3. Finding Processes by Name with ps and pgrep

Section 6.8.4. Watching Process Memory Usage with pmap

Section 6.8.5. Sending Signals to Processes by Name
Section 6.9. Summary

Section 6.9.1. System Calls and APIs Used in This Chapter

Section 6.9.2. Tools Used in This Chapter

Section 6.9.3. Online Resources
Download ChapterDownload Chapter
1 TokenChapter 7. Communication between Processes

Section 7.1. Introduction
Section 7.2. IPC Using Plain Files

Section 7.2.1. File Locking

Section 7.2.2. Drawbacks of Using Files for IPC
Section 7.3. Shared Memory

Section 7.3.1. Shared Memory with the POSIX API

Section 7.3.2. Shared Memory with the System V API
Section 7.4. Signals

Section 7.4.1. Sending Signals to a Process

Section 7.4.2. Handling a Signal

Section 7.4.3. The Signal Mask and Signal Handling

Section 7.4.4. Real-Time Signals

Section 7.4.5. Advanced Signals with sigqueue and sigaction

Section 7.5. Pipes
Section 7.6. Sockets
Section 7.6.1. Creating Sockets

Section Socket Domains

Section Socket Types

Section Socket Protocols

Section 7.6.2. Local Socket Example Using socketpair

Section 7.6.3. Client/Server Example Using Local Sockets

Section 7.6.4. Client Server Using Network Sockets
Section 7.7. Message Queues

Section 7.7.1. The System V Message Queue

Section 7.7.2. The POSIX Message Queue

Section 7.7.3. Difference between POSIX Message Queues and System V Message Queues
Section 7.8. Semaphores

Section 7.8.1. Semaphores with the POSIX API

Section 7.8.2. Semaphores with the System V API
Section 7.9. Summary

Section 7.9.1. System Calls and APIs Used in This Chapter

Section 7.9.2. References

Section 7.9.3. Online Resources
Download ChapterDownload Chapter
1 TokenChapter 8. Debugging IPC with Shell Commands

Section 8.1. Introduction
Section 8.2. Tools for Working with Open Files

Section 8.2.1. lsof

Section 8.2.2. fuser

Section 8.2.3. ls

Section 8.2.4. file

Section 8.2.5. stat
Section 8.3. Dumping Data from a File

Section 8.3.1. The strings Command

Section 8.3.2. The xxd Command

Section 8.3.3. The hexdump Command

Section 8.3.4. The od Command
Section 8.4. Shell Tools for System V IPC

Section 8.4.1. System V Shared Memory

Section 8.4.2. System V Message Queues

Section 8.4.3. System V Semaphores
Section 8.5. Tools for Working with POSIX IPC

Section 8.5.1. POSIX Shared Memory

Section 8.5.2. POSIX Message Queues

Section 8.5.3. POSIX Semaphores

Section 8.6. Tools for Working with Signals
Section 8.7. Tools for Working with Pipes and Sockets

Section 8.7.1. Pipes and FIFOs

Section 8.7.2. Sockets

Section 8.8. Using Inodes to Identify Files and IPC Objects
Section 8.9. Summary

Section 8.9.1. Tools Used in This Chapter

Section 8.9.2. Online Resources
Download ChapterDownload Chapter
1 TokenChapter 9. Performance Tuning

Section 9.1. Introduction
Section 9.2. System Performance
Section 9.2.1. Memory Issues

Section Page Faults

Section Swapping

Section 9.2.2. CPU Utilization and Bus Contention

Section 9.2.3. Devices and Interrupts

Section 9.2.4. Tools for Finding System Performance Issues
Section 9.3. Application Performance

Section 9.3.1. The First Step with the time Command

Section 9.3.2. Understanding Your Processor Architecture with x86info

Section 9.3.3. Using Valgrind to Examine Instruction Efficiency

Section 9.3.4. Introducing ltrace

Section 9.3.5. Using strace to Monitor Program Performance

Section 9.3.6. Traditional Performance Tuning Tools: gcov and gprof

Section 9.3.7. Introducing OProfile
Section 9.4. Multiprocessor Performance

Section 9.4.1. Types of SMP Hardware

Section 9.4.2. Programming on an SMP Machine
Section 9.5. Summary

Section 9.5.1. Performance Issues in This Chapter

Section 9.5.2. Terms Introduced in This Chapter

Section 9.5.3. Tools Used in This Chapter

Section 9.5.4. Online Resources

Section 9.5.5. References
Download ChapterDownload Chapter
1 TokenChapter 10. Debugging

Section 10.1. Introduction
Section 10.2. The Most Basic Debugging Tool: printf

Section 10.2.1. Problems with Using printf

Section 10.2.2. Using printf Effectively

Section 10.2.3. Some Final Words on printf Debugging
Section 10.3. Getting Comfortable with the GNU Debugger: gdb

Section 10.3.1. Running Your Code with gdb

Section 10.3.2. Stopping and Restarting Execution
Section 10.3.3. Inspecting and Manipulating Data

Section print Expression Syntax

Section Print Examples

Section Calling Functions from gdb

Section Some Notes about the C++ and Templates

Section Some Notes about the C++ Standard Template Library

Section The display Command

Section 10.3.4. Attaching to a Running Process with gdb

Section 10.3.5. Debugging Core Files

Section 10.3.6. Debugging Multithreaded Programs with gdb

Section 10.3.7. Debugging Optimized Code
Section 10.4. Debugging Shared Objects

Section 10.4.1. When and Why to Use Shared Objects

Section 10.4.2. Creating Shared Objects

Section 10.4.3. Locating Shared Objects

Section 10.4.4. Overriding the Default Shared Object Locations

Section 10.4.5. Security Issues with Shared Objects

Section 10.4.6. Tools for Working with Shared Objects
Section 10.5. Looking for Memory Issues

Section 10.5.1. Double Free

Section 10.5.2. Memory Leaks

Section 10.5.3. Buffer Overflows

Section 10.5.4. glibc Tools

Section 10.5.5. Using Valgrind to Debug Memory Issues

Section 10.5.6. Looking for Overflows with Electric Fence
Section 10.6. Unconventional Techniques

Section 10.6.1. Creating Your Own Black Box

Section 10.6.2. Getting Backtraces at Runtime

Section 10.6.3. Forcing Core Dumps

Section 10.6.4. Using Signals

Section 10.6.5. Using procfs for Debugging
Section 10.7. Summary

Section 10.7.1. Tools Used in This Chapter

Section 10.7.2. Online Resources

Section 10.7.3. References

No comments: