DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Debugging and analyzing C and C++ programs



Introduction to debugging and analyzing C and C++ programs
        Program debugging
        Program analysis
        Other tools

Using the command line interface of debug
        Philosophy
        Before you begin
        Programs used in the sessions
                The program macros
                The program sget
                The program walk
                The program traverse
        Single-process debugging
                Session 1: why is my program in an infinite loop?
                        Grabbing processes
                        Stack traces
                        Getting help
                        Printing symbols
                        Shorthand notations
                Session 2: why did it dump core?
                        Grabbing core files
                        Printing expressions
                        Examining the source file
                Session 3: where did that data structure go?
                        Create
                        Debugger variables
                        Events and command lists
                        Skipping the first n events
                        Variations on run and step
                Session 4: who stepped on my pointer?
                        Watchpoints, breakpoints, and general stop expressions
                Session 5: why didn't that signal handler work?
                        Signals
                        Changing the current context
        Multi-process debugging
                Session 6: why did the exec'd program fail?
                        ps and the current object
                        Fully qualified names
                        fork(2), exec(2), and system(3S)
                Session 7: can I ignore a forked process?
                        Releasing or ignoring processes and threads
                Session 8: which end of the pipe is broken?
                        Jumping around in the program
                        Process lists (-p)
                        Foreground vs. background
        Debugging without -g
                Session 9: what can I do without -g?
                        What -g really means
                        Stopping on a function vs. stopping on an address
                        Global vs. static functions
                        System call events
                        Getting down to the machine level
                        Examining data with no type information
        Debugging a multithreaded program
                Session 10: traverse - a deadlocked program
                        Compiling the multithreaded program
                        Testing traverse
                        Grabbing the hung program
                        Examining the thread states
                        Viewing the stack traces of threads
                        Diagnosing the problem
                Some notes on multithread debugging
                        Threads off the LWP
                        Creating traverse within debug
                        Spawning the threads
                        Examining the thread states
                        Setting a breakpoint for a specific thread
                        Simplifying your command input
        Technical tips
                Aliases with arguments
                Script command
                Defaults file
                Change command
                Redirecting process input/output
                Reading the address map
                Debugging C++ programs
                        Expressions
                        Displaying expressions
                        Creating events
                        Exception handling
                        Templates
                Code in header files
        Debugger command summary
        Debugger variable description

Using the graphical interface of debug
        Invoking the debugger
        Learning to use the graphical debugger
                A glimpse at the program macros
                The debugging session
                        1. Starting the graphical Debugger
                        2. Choosing the program to debug
                        3. Creating events
                        4. Running the program
                        5. Examining symbols
                        6. Associating commands with events
                        7. Repeating the debugging session
                        8. Removing events
                        9. Creating an event on the nth call
                        10. Stepping through the program
                        11. Analyzing insert
                        12. Exiting the debugger
        Exploring the debugger's panes
                Command pane
                Disassembly pane
                Event pane
                Process pane
                Registers pane
                Source pane
                Stack pane
                Status pane
                Symbol pane
        Menu options
                File menu
                        Change Directory
                        Close Window
                        Exit
                        Move
                        New Source
                        New Window Set
                        Open Source
                        Save
                        Save As
                        Save Layout
                        Script
                        Sources
                        Window Sets
                        Windows
                Debug menu
                        Create
                        Grab core
                        Grab process
                        Release
                Edit menu
                        Copy
                        Cut
                        Delete event
                        Delete text
                        Disable
                        Enable
                        Export
                        Input
                        Interrupt
                        Paste
                        Pin
                        Set current
                        Undo
                        Unpin
                View menu
                        Dump
                        Map
                        Search
                        Set value
                        Show Function Dis
                        Show Function Source
                        Show Line
                        Show Location
                        Show Type
                        Show Value
                Control menu
                        Animate Disassembly
                        Animate Source
                        Jump
                        Halt
                        Next Instruction
                        Next Statement
                        Return
                        Run
                        Run Until
                        Step
                        Step Instruction
                        Step Statement
                Event menu
                        Cancel
                        Change
                        Delete Breakpoint
                        Destroy
                        Exception
                        Ignore Exceptions
                        Ignore Signals
                        Kill
                        On Stop
                        Set Breakpoint
                        Set Watchpoint
                        Signal
                        Stop
                        Stop on Function
                        Syscall
                Properties menu
                        Animation
                        Button Configuration
                        Disassembly Mode
                        Frame Direction
                        Granularity
                        Language
                        Output Action
                        Source Path
                        Symbols
                Help menu
                        Pane Help
                        Table of Contents
                        Version
                Miscellaneous options
                        Debug command
                        Exec command
        Customization
                Resource settings
                Configuration
        Technical tips
                Using help
                Debugging a graphics application
                Debugging multiple processes
                Debugging multithreaded applications
                        Getting started
                        What are the thread states?
                        Selections for multiple threads
                        Multithread versus multiprocess
                        Creating a window set for each thread
                        Granularity default settings
                        Granularity, events and window sets
                        Streamlining threads debugging
                When the debugger doesn't respond
                Using selections in the process pane
                Source editing
                        Selecting text
                        Using the Edit menu
                        Using the editing keys
                        Saving text
                Searching in lists

Analyzing run-time behavior
        Profiling utilities
                How to use the profilers
        Using lprof
                Compiling the program for use with lprof
                Running the -ql 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
                Invoking lprof
                Searching for source files
                Source listing output
                Highlighting unexecuted lines
                Summary report
                Merged data
                Profiling archive or shared object library code with lprof
                Profiling C++ programs with lprof
                Technical tips
                        Trouble at run time
                        Data File cannot be found
        Using prof
                Compiling the program for use with prof
                Running the -p profiled program
                Invoking prof
                profiling C++ programs with prof
                Profiling archive or shared object library code with prof
        Using fprof
                Compiling the program
                Starting the experiment
                During the experiment
                Analyzing the results of the experiment
                        Utilizing flow-profile results for locality of reference tuning
                        Statistical analysis of flow-profile data
                        Analyzing flow-profile results for analysis of run-time flow
        Using fur to perform block profiling
                Relinking the program
                Running the experiment
                Analyzing the results of the experiment
        Improving program performance by programmer analysis
                A sample session using flow profiling
                prof and lprof on lprof
        Improving program performance by automated analysis
        Improving test coverage
                Searching for undocumented options
                Functions that are never called
                Hard to produce error conditions

Browsing through your code with cscope
        How cscope works
        How to use cscope
                Step 1: set up the environment
                Step 2: invoke cscope
                Step 3: locate the code
                Step 4: edit the code
                Command line options
                Using viewpaths
                Stacking cscope and editor calls
                Examples
                        Changing a constant to a preprocessor symbol
                        Adding an argument to a function
                        Changing the value of a variable
        Troubleshooting
                Unknown terminal type
                Command line syntax for editors