DOC HOME
SITE MAP
MAN PAGES
GNU INFO
SEARCH
PRINT BOOK
Programming Tools Guide
About this book
Using this guide
Using programming tools
Creating the source code
Archiving the code
Analyzing the code
Using cb
Using cscope
Using lint
Using cflow
Using cxref
Archiving changes made during the analysis
Compiling the code
Using make
Testing the code
Debugging the code
Using dbxtra
Testing the correction
Program structure and guidelines
Program structure
Header files
Error handling
C compilation system
Compiling and linking
Basic cc command line syntax
Commonly used cc command line options
Searching for a header file
Preparing your program for debugging
Preparing your program for profiling
Optimizing your program
Link editing
Linking with archive libraries
Linking with dynamically linked libraries
Linking with standard libraries
Creating and linking with archive and dynamically linked libraries
Specifying directories to be searched by the link editor
Specifying directories to be searched by the dynamic linker
Checking for run-time compatibility
Dynamic linking programming interface
Implementation
Guidelines for building dynamically linked libraries
Minimize the library's data segment
Minimize paging activity
Maintenance
Multiply defined symbols
Quick-reference guide
Libraries and header files
Header files
How to use library functions
C library (libc)
Standard I/O routines
String, character, environment and memory routines
System calls
Math library (libm)
General purpose library (libgen)
Standard I/O
Standard files
Named files
Passing command line arguments
C language compiler
Compilation modes
Global behavior
Phases of translation
Source files and tokenization
Tokens
Identifiers
Keywords
Constants
Integral constants
Floating point constants
Character constants
Wide characters and multibyte characters
String literals
Wide string literals
Punctuators
Comments
Preprocessing
Trigraph sequences
Preprocessing tokens
Preprocessing numbers
Preprocessing directives
Preprocessing operators
Macro definition and expansion
File inclusion
Conditional compilation
Line control
Assertions
Version control
Pragmas
Error generation
Predefined names
Declarations and definitions
Basic types
Type qualifiers
Structures and unions
Enumerations
Scope
Storage duration
Storage class specifiers
Declarators
Pointer declarators
Array declarators
Function declarators
Function definitions
Conversions and expressions
Implicit conversions
Characters and integers
Signed and unsigned integers
Integral and floating
Float and double
Usual arithmetic conversions
Expressions
Objects and lvalues
Primary expressions
Operators
Unary operators
Cast operators -- explicit conversions
Multiplicative operators
Additive operators
Bitwise shift operators
Relational operators
Equality operators
Bitwise AND operator
Bitwise exclusive OR operator
Bitwise OR operator
Logical AND operator
Logical OR operator
Conditional operator
Assignment expressions
Comma operator
Structure operators
Associativity and precedence of operators
Constant expressions
Initialization
Statements
Expression statement
Compound statement
Selection statements
if
else
switch
Iteration statements
while
do-while
for
Jump statements
goto
break
continue
return
Portability considerations
COFF link editor
Sections
Memory configuration
Addresses
Binding
Object files
Link editor command language
Expressions
Assignment statements
Syntax
Interaction with source code
The location counter symbol
Pseudo-functions
Types of expression values
Specifying a memory configuration
Section definition directives
File specifications
Loading a section at a specified address
Aligning an output section
Grouping sections together
Creating holes within output sections
Creating and defining symbols at link-edit time
Allocating a section into named memory
Initialized section holes or .bss sections
Changing the entry point
Using archive libraries
The -l option
The -u option
Allocation algorithm
Incremental link editing
DSECT, COPY, NOLOAD, INFO, and OVERLAY sections
Output file blocking
Nonrelocatable input files
Syntax diagram for input directives
lint analyzer
Options and directives
lint and the compiler
Message formats
What lint does
Consistency checks
Portability checks
Suspicious constructs
Using lint
lint libraries
lint filters
Options and directives listed
Understanding lint-specific messages
dbXtra and dbxtra
Invoking dbXtra and dbxtra from the command line
The dbXtra interface
Configuring dbXtra X11 and Motif resources
The dbxtra interface
Screen mode
dbxtra keyboard interface
dbxtra screen functions
Sample key bindings
dbxtra tutorial session
Preparing files for dbxtra
Starting dbxtra
The dbxtra screen
The dbxtra help facility
Printing the value of variables
Viewing source code and aliasing
Viewing the call stack
Traversing the call stack
Monitoring the contents of variables
Analyzing the results
Examining a different function
Using a breakpoint
Continuing after a breakpoint
Exiting dbxtra
dbXtra and dbxtra commands
File menu: saving and quitting
Write Configuration File
Exit dbXtra
Events menu: managing execution time events
Events
Call
When
Stop
Trace
Interrupt
Catch
Ignore
Dbxtra
eXecute menu: executing the program being debugged
Run
Rerun
Continue
Skip
Next
Step
Goto
Jump
Return
Instruction
Source menu: accessing source files
Browse file
Source Path
Search
Function
DbXref
Up
Down
Info menu: debugging registers, memory locations, and expressions
Show
Where
Display
Assign
Which
Print
Xref
Variables
Registers
Memory
Options menu: controlling the debugging environment
C/C++
Preferences
Environment
The help menu
curses interface commands
forward/backward
keys
more
screen
sh and !
source
undisplay
version
Default command aliases
dbXtra and dbxtra expressions and conditions
Identifier resolution
Types and casting
C++ specific debugging features
Usage requirements
Overloaded functions and operators
The dbXtra and dbxtra cc command
Debugging child processes
Attaching to a running process
sdb: symbolic debugger
Using sdb
Printing a stack trace
Examining variables
Source file display and manipulation
Displaying the source file
Changing the current source file or function
Changing the current line in the source file
A controlled environment for program testing
Setting and deleting breakpoints
Running the program
Calling functions
Machine language debugging
Displaying machine language statements
Manipulating registers
Other commands
An sdb session
adb: absolute debugger
Starting adb
Starting adb with a core image file
Exiting adb
Displaying program instructions and data
Forming addresses
Forming expressions
Symbol names
adb variables
Current address
Register names
Operators
Choosing data formats
Using the = command
Using the ? and / commands
An example: simple formatting
Debugging program execution
Executing a program
Setting breakpoints
Displaying breakpoints
Continuing execution
Stopping a program with interrupt and quit
Single-stepping a program
Killing a program
Deleting breakpoints
Displaying the C stack backtrace
Displaying CPU registers
Displaying external variables
An example: tracing multiple functions
Using the adb memory maps
Displaying the memory maps
Giving segment numbers
Changing the memory map
Creating new map entries
Validating addresses
Miscellaneous features
Combining commands on a single line
Creating adb scripts
Setting output width
Setting the maximum offset
Setting default input format
Using UNIX commands
Computing numbers and displaying text
An example: directory and inode dumps
Patching binary files and memory
Locating values in a file
Writing to a file
Making changes to memory
C programmer's productivity tools
lprof
Creating a profiled version of a program
Running the profiled program
The
PROFOPTS
environment variable
Examples of using
PROFOPTS
Turning off profiling
Merging data files
Keeping data files in a separate directory
Profiling within a shell script
Profiling programs that fork
Interpreting profiling output
Viewing the profiled source listing
Showing unexecuted lines
Specifying program and data files to lprof
Files needed by lprof
Source files in a different directory
Source listing for a subset of files
Summary option
Merging option
Cautionary notes on using
lprof
Trouble at compile time
Non-terminating programs
Failure of data to merge
Trouble at the end of execution
No data collected
Data file not found
Using lprof with program generators
Using lprof with shared libraries
Improving performance with prof and lprof
Improving test coverage with lprof
Example 1: searching for untested features
Example 2: functions that are never called
cscope
Configuring the environment
Setting the terminal type
Choosing an editor
Choosing a browser
Using cscope
Searching for #include files
Searching for source files
Running cscope
The cross-reference file
A tutorial example: locating the source of the error message
Stacking cscope and editor calls
Conditional compilation directives
Examples of using cscope
Changing a text string
Adding an argument to a function
Changing the value of a variable
make
Basic features
Parallel make
Recursive makefiles
makefiles and substitutions
Dependency line syntax
Dependency information
Macro definitions
Executable commands
Output translations
Suffixes and transformation rules
Implicit rules
Archive libraries
Tildes in SCCS filenames
The null suffix
Creating new suffix rules
include files
Dynamic dependency parameters
Environment variables
Suggestions and warnings
Makefile example
Internal rules
Source code control system (SCCS)
SCCS for beginners
Terminology
Creating an SCCS file using admin
Retrieving a file by means of get
Recording changes by using delta
Additional information about get
Delta numbering
SCCS command conventions
x-files and z-files
SCCS commands
Error messages
help command
get command
Undoing a get -e
delta command
admin command
prs command
sact command
rmdel command
cdc command
what command
sccsdiff command
comb command
val command
vc command
SCCS files
Protection
Formatting
Auditing
lex
Writing lex programs
Rules section
Regular expressions
Actions
yytext, yyleng
ECHO
Definitions section
External definitions
#include statements
Abbreviations
The subroutines section
Advanced lex usage
Disambiguating rules
Context sensitivity
Trailing context
Starting state
lex I/O routines
Routines to reprocess input
yymore
yyless
REJECT
End-of-file processing with yywrap
Using lex with yacc
yylex()
Returning tokens
Using a symbol table
Using lex under UNIX systems
Running lex
Options
Compiling a lexical analyzer
Running the lexical analyzer
Using make with lex
yacc
yacc specifications
Terminal and non-terminal symbols
Rules
Literals and escape sequences
Alternation in grammar rules
Empty rules
Representing constructs as tokens or non-terminals
Erroneous specifications
Actions
Values of symbols
Default action
Actions in the middle of rules
Accessing left-context symbols
Parse trees
Declarations
Tokens
Start symbol
C declarations
Support for arbitrary value types
Other declarations
Subroutines
The yacc environment
Lexical analysis
lex and yylval
Token numbers
End-marker token
Reserved token names
Parsing
Compiling
Using
make
Running the parser
Parser operation
Shift action
Reduce and goto actions
Accept action
Error action
Interpreting the y.output file
Ambiguity and conflicts
Disambiguating rules
Precedence
Assigning a precedence to grammar rules
Error handling
Error token
Interactive error recovery
Hints for preparing specifications
Input style
Left recursion
Lexical tie-ins
Reserved words
Examples of using yacc
Simple example
Advanced example
Shared libraries
What is a shared library?
Shared libraries examples
Building an a.out file
Deciding whether to use a shared library
Space considerations
Saving space
Increase space usage in memory
Coding an application
Identifying a.out files that use shared libraries
Debugging a.out files that use shared libraries
Implementing shared libraries
The host library and target library
The branch table
Building a shared library
The building process
Step 1: choosing region addresses
Step 2: choosing the target library pathname
Step 3: selecting library contents
Step 4: rewriting existing library code
Step 5: writing the library specification file
Step 6: using
mkshlib
to build the host and target
Guidelines for writing shared library code
Choosing library members
Include large, frequently used routines
Exclude infrequently used routines
Exclude routines that use much static data
Exclude routines that complicate maintenance
Include routines the library itself needs
Changing existing code for the shared library
Minimize global data
Define text and global data in separate source files
Initialize global data
Using the specification file for compatibility
Preserve branch table order
Use #hide and #export to limit externally visible symbols
Importing symbols
Imported symbols that the library does not define
Imported symbols that users must be able to redefine
Mechanics of importing symbols
Pointer initialization fragments
Selectively loading imported symbols
Referencing symbols in a shared library from another shared library
Providing compatibility with non-shared libraries
Tuning the shared library code
Profile the code
Choose library contents
Organize to improve locality
Align for paging
Avoid hardware thrashing
Checking for compatibility
Checking versions of shared libraries using chkshlib(CP)
Dealing with incompatible libraries
An example
The original source
Choosing region addresses and the target pathname
Selecting library contents
Rewriting existing code
Writing the specification file
Building the shared library
Using the shared library
ANSI implementation-defined behavior
Translation
Environment
Identifiers
Characters
Integers
Floating point
Arrays and pointers
Registers
Structures, unions, enumerations, and bit-fields
Qualifiers
Declarators
Statements
Preprocessing directives
Pragmas
asm
comment
ident
int_to_unsigned
pack
weak
Library functions
Locale-specific behavior
C Implementation limits description
Translation limits
C compiler diagnostics
Message types and applicable options
Operator names in messages
Messages
Operator names
Other error messages
Index