UVA CS 4610 - Debuggers, Analysis Tools and Profilers

Unformatted text preview:

Debuggers, Analysis Tools and ProfilersWhat is a Debugger?What is a Debugger? (con't)Other Forms of DebuggingWhy use a Debugger?Why people don’t use a Debugger?Types of DebuggersDebuggers for Compiled LanguagesFunctions of a DebuggerDisassemblyExecution TracingSymbol InformationDebug vs. Release BuildsProfilersWhat are they?Slide 16How do they work?How do they work? (2)How do they work? (3)Why do I need a time profiler?Why do I need a space profiler?Some Profiler Examples – Timegprof sample data – Flat Profilegprof sample data – Call graphSome Profiler Examples – SpaceMassif sample data - basicMassif sample data – Space-time GraphAnalysis ToolsPurpose of Analysis ToolsSlide 30Two Types of Analysis ToolsStatic AnalysisSplintErrors Splint will detectErrors Splint will detect continued…What’s wrong with this code?What happens to the stack?Secure ProgrammingHow does Splint deal with false positives?Run-time AnalysisPurifyPurify continued…Types of errors found by PurifyStatic vs. Run-time AnalysisCons of Analysis Tools1Debuggers, Analysis Tools and ProfilersAaron BloomfieldCS 415Fall 20052What is a Debugger?“A software tool that is used to detect the source of program or script errors, by performing step-by-step execution of application code and viewing the content of code variables.”-MSDN3What is a Debugger? (con't)•A debugger is not an IDE–Though the two can be integrated, they are separate entities.•A debugger loads in a program (compiled executable, or interpreted source code) and allows the user to trace through the execution.•Debuggers typically can do disassembly, stack traces, expression watches, and more.4Other Forms of Debugging•Periodic printf/cout/print/write/etc.–Statements with relevant information•Assert statements•Desk Checking5Why use a Debugger?•No need for precognition of what the error might be.•Flexible–Allows for “live” error checking – no need to re-write and re-compile when you realize a certain type of error may be occuring–Dynamic–Can view the entire relevant scope6Why people don’t use a Debugger?•With simple errors, may not want to bother with starting up the debugger environment.–Obvious error–Simple to check using prints/asserts•Hard-to-use debugger environment•Error occurs in optimized code•Changes execution of program (error doesn’t occur while running debugger)7Types of Debuggers•Two types of debuggers (really, two types of languages)–Interpreted language debuggers–Compiled language debuggers•Which do you think is easier to write?8Debuggers for Compiled Languages•Harder to implement–Generally, would like information about source code (not normally included in compiled executables)–Work on a lower level•Need special “debug” executables.•More complex, and we'll focus on these.9Functions of a Debugger•Disassembly•Execution Tracing/Stack tracing•Symbol watches10Disassembly•Most basic form of debugging•Translating machine code into assembly instructions that are more easily understood by the user.•Typically implementable as a simple lookup table•No higher-level information (variable names, etc.)•Relatively easy to implement.11Execution Tracing•Follows the program through the execution. Users can step through line-by-line, or use breakpoints.•Typically allows for “watches” on – registers, memory locations, symbols•Allows for tracing up the stack of runtime errors (back traces)•Allows user to trace the causes of unexpected behavior and fix them12Symbol Information•Problem – a compiler/assembler translates variable names and other symbols into internally consistent memory addresses•How does a debugger know which location is denoted by a particular symbol?•We need a “debug” executable.13Debug vs. Release Builds•Debug builds usually are not optimized•Debug executables contain:–program's symbol tables–location of the source file–line number tags for assembly instuctions.14Profilers15What are they?Time Profilers:–Tells you where your program spent its time –Tells you which functions called which other functions while it was executing16What are they?Space Profiler:–Also called “heap profiling” or “memory profiling”–Space profiling is useful to help you reduce the amount of memory your program uses.17How do they work?Time profiler:–Profiling works by changing how every function in your program is compiled so that when it is called, it will stash away some information about where it was called from.–From this, the profiler can figure out what function called it, and can count how many times it was called18How do they work? (2)Space Profiler:–Stops execution and examines the stack–Stops execution when a page of memory is allocated–Collects Data about which function asked for the memory19How do they work? (3)•After the data is collected by the profiler, an interpreter must be run to display the data in an understandable format•Can be text-based or graphical20Why do I need a time profiler?•Find where the program is spending most of it’s time–That’s where you should focus optimization efforts•The program performs the proper functions, but is too slow–Important in real time systems–Important to web applications•The program is too large or too complex to analyze by reading the source21Why do I need a space profiler?•The program needs to use a fixed amount of memory•The program is too large to conceive of the overall memory usage or how often memory requests are made•Profilers can show the memory usage of libraries used by your program22Some Profiler Examples – Time•gprof – GNU Profiler–compile programs with the –pg option–execute program to generate data–run gprof to interpret the data23gprof sample data – Flat Profile Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 33.34 0.02 0.02 7208 0.00 0.00 open 16.67 0.03 0.01 244 0.04 0.12 offtime 16.67 0.04 0.01 8 1.25 1.25 memccpy 16.67 0.05 0.01 7 1.43 1.43 write 16.67 0.06 0.01 mcount 0.00


View Full Document

UVA CS 4610 - Debuggers, Analysis Tools and Profilers

Download Debuggers, Analysis Tools and Profilers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Debuggers, Analysis Tools and Profilers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Debuggers, Analysis Tools and Profilers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?