45 Pages

21-debuggers

Course: CS 415, Fall 2008
School: UVA
Rating:
 
 
 
 
 

Word Count: 1331

Document Preview

Analysis Debuggers, Tools and Profilers Aaron Bloomfield CS 415 Fall 2005 1 What 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." -MSDN 2 What is a Debugger? (con't) A debugger is not an IDE Though the two can be integrated, they are separate...

Register Now

Unformatted Document Excerpt

Coursehero >> Virginia >> UVA >> CS 415

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Analysis Debuggers, Tools and Profilers Aaron Bloomfield CS 415 Fall 2005 1 What 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." -MSDN 2 What 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. 3 Other Forms of Debugging Periodic printf/cout/print/write/etc. Statements with relevant information Assert statements Desk Checking NOTE: this is errors found in programs that are correct according to the syntax and grammar of the language. 4 Why 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 scope 5 Why 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) 6 Types 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? 7 Debuggers 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. 8 Functions of a Debugger Disassembly Execution Tracing/Stack tracing Symbol watches 9 Disassembly 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. 10 Execution Tracing Follows the program through the execution. Users can step through line-byline, 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 them 11 Symbol 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. 12 Debug 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. 13 Profilers 14 What are they? Time Profilers: How many people have used these? Tells you where your program spent its time Tells you which functions called which other functions while it was executing 15 What 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. 16 How 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 called 17 How 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 memory 18 How 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 graphical 19 Why 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 source 20 Why 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 program 21 Some Profiler Examples Time gprof GNU compile Profiler programs with the pg option execute program to generate data run gprof to interpret the data 22 gprof sample data Flat Profile Each sample counts as 0.01 seconds. % cumulative self time seconds seconds 33.34 16.67 16.67 16.67 16.67 0.00 0.00 0.02 0.03 0.04 0.05 0.06 0.06 0.06 0.02 0.01 0.01 0.01 0.01 0.00 0.00 236 192 0.00 0.00 0.00 0.00 self total calls ms/call ms/call name 7208 244 8 7 0.00 0.04 1.25 1.43 0.00 open 0.12 offtime 1.25 memccpy 1.43 write mcount tzset tolower 23 gprof sample data Call graph index % time self 0.00 [3] 100.0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 children 0.05 0.05 0.03 0.01 0.01 0.00 0.00 0.00 0.00 0.00 called 1/1 1 8/8 1/1 9/9 12/34 8/8 1/1 8/8 8/16 name main [2] report [3] timelocal [6] print [9] fgets [12] strncmp <cycle 1> [40] lookup [20] fopen [21] chewtime [24] skipspace [44] ----------------------------------------------- ----------------------------------------------- 24 Some Profiler Examples Space Massif Space Profiler for C and C++ Provides relative space data on 5 different areas: Heap blocks Heap administration blocks Stack sizes Code size Data size 25 Massif sample data - basic ==1012== Total spacetime: 917,098,589 ms.B ==1012== heap: 0.0% ==1012== heap admin: 0.0% ==1012== stack(s): 0.0% ==1012== static code: 44.4% ==1012== static data: 55.3% 26 Massif sample data Space-time Graph 27 Analysis Tools 28 Purpose of Analysis Tools Need for a feasible method to catch bugs in large projects. Formal verification techniques require unreasonable effort on large projects. Augment traditional debugging techniques without adding unreasonable burden to the development process. 29 30 Two Types of Analysis Tools Static Analysis Run-time (dynamic) Analysis 31 Static Analysis Examine a program for bugs without running the program. Examples: Splint (www.splint.org), PolySpace C Verifier (www.polyspace.com). 32 Splint Open Source Static Analysis Tool developed at U.Va by Professor Dave Evans. Based on Lint. 33 Errors Splint will detect Dereferencing a possibly null pointer. Using possibly undefined storage or returning storage that is not properly defined. Type mismatches, with greater precision and flexibility than provided by C compilers. Violations of information hiding. Memory management errors including uses of dangling references and memory leaks. Dangerous aliasing. 34 Errors Splint will detect continued... Modifications and global variable uses that are inconsistent with specified interfaces. Problematic control flow such as likely infinite loops. Buffer overflow vulnerabilities. Dangerous macro initializations and invocations. Violations of customized naming conventions. 35 What's wrong with this code? void strcpy(char* str1, char* str2) { while (str2 != 0) { *str1 = *str2; str1++; str2++; } str1 = 0; //null terminate...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UVA - CS - 445
Rendering PipelineAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)3D Polygon RenderingMany applications use rendering of 3D polygons with direct illumination23D Polygon RenderingMany ap
UVA - CS - 445
LightingAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Lighting Sogiven a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If were attempting to create a realistic image, we need
UVA - CS - 415
ScanningAaron Bloomfield CS 415 Fall 20051Parsing &amp; Scanning In real compilers the recognizer is split into two phases Scanner: translate input characters to tokens Also, report lexical errors like illegal characters and illegal symbols Pars
UVA - CS - 445
Rendering Pipeline and Graphics HardwareAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Overview Framebuffers How is the rasterized Rendering Pipeline scene kept in memory? Transformations Lighting Clipping Modeling Camera Vis
UVA - CS - 202
Set OperationsCS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield1Sets of ColorsMonitor gamut (M) Printer gamut (P) Pick any 3 &quot;primary&quot; colors Triangle shows mixable color range (gamut) the set of colors2Set operations: Union 1
UVA - CS - 415
In More Depth.Grammars Parsing(Slides copied liberally from Ruth Anderson, Hal Perkins and others)04/19/09CS415 - Fall 20051Parsing The syntax of most programming languages can be specified by a context-free grammar (CGF) Parsing: Given a
UVA - CS - 202
Nested QuantifiersCS/APMA 202, Spring 2005 Rosen, section 1.4 Aaron Bloomfield1Multiple quantifiersYou can have multiple quantifiers on a statement x y P(x, y) &quot;For all x, there exists a y such that P(x,y)&quot; Example: x y (x+y = 0) xy P(x,y)
UVA - CS - 445
CS 445 Introduction to Computer GraphicsFall 2006 Aaron BloomfieldOverviewIntroductionWhat is computer graphics? What is it good for? What will I learn in this course? How much work will there be?ApplicationsSyllabusCoursework
UVA - CS - 415
CS 415: Programming LanguagesAlgol Aaron Bloomfield Fall 2005Historical perspectiveBy mid/late 50s a lot of PLs were out there Interest in universal language European and American groups got together in Zurich Result was Algol 58 8 people spe
UVA - CS - 445
General-Purpose Computation on Graphics HardwareDavid LuebkeUniversity of VirginiaCourse Introduction The GPU on commodity video cards has evolved into an extremely flexible and powerful processor Programmability Precision Power We are in
UVA - CS - 445
RasterizationAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)The Rendering Pipeline: A TourTransform Illuminate Transform Clip Project RasterizeMode &amp; C e l am ra Param te e rsRe ring Pipe nde
UVA - CS - 202
FunctionsCS 202 Epp section ? Aaron Bloomfield1Definition of a function A function takes an element from a set and maps it to a UNIQUE element in another set2Function terminologyf maps R to Z Domain R f Z Co-domainf(4.3) 4.3 4Pre-image
UVA - CS - 202
Propositional EquivalencesCS/APMA 202, Spring 2005 Rosen, section 1.2 Aaron Bloomfield1Tautology and ContradictionA tautology is a statement that is always truep p will always be true(Negation Law)A contradiction is a statement that is al
UVA - CS - 415
Objective Caml (Ocaml)Aaron Bloomfield CS 415 Fall 20051ML history ML first developed in late 1970's Stands for Meta Langauage Not a &quot;pure&quot; function language Has functions with side effects, imperative programming capabilities Haskell is a
UVA - CS - 202
Methods of ProofCS 202 Rosen section 1.5 Aaron Bloomfield1In this slide set.Rules of inference for propositions Rules of inference for quantified statements Ten methods of proof2Proof methods in this slide setLogical equivalences Ten pro
UVA - CS - 202
Boolean LogicCS 202, Spring 2007 Epp, sections 1.1 and 1.2 Aaron Bloomfield1Administratrivia HW 1: due next Friday Section 1.1 # 49, 52 Section 1.2 # 34, 44, 46 Today's lecture will be somewhat of a review Next week we will see applications
UVA - CS - 445
Making MoviesAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Brogan)Making Movies Concept Storyboarding Sound Character Development Layout and look Effects Animation Lighting2Concept&quot;Not
UVA - CS - 101
GUI programmingGraphical user interfacebased programmingWindchill Windchill There are several formulas for calculating the windchill temperature twc The one provided by U.S. National Weather Service and is applicable for a windspeed greater tha
UVA - CS - 101
Fall 2004 - CS 101: Test 1Name _UVA Email ID _I. Computing and programming fundamentals1. (4 points) Give two examples of non-PC computing devices.Part I Part II Part III2. (4 points) What does Java program compilation do?Total3. (4 poin
UVA - CS - 101
Fall 2004 - CS 101: Test 3Name _UVA Email ID _Page 1 _ / 10 1. (Bonus 2 points) What is your section? 101 Page 4 _ / 17 101E Page 5 _ / 25 Page 6 _ / 20 Page 2 _ / 10 Page 3 _ / 18Total _ /100 2. (5 points) What is the output of the following c
UVA - CS - 101
CS 101 Exam 1 Spring 200Email Id _ Name _This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your goal
UVA - CS - 101
CS 101 / CS 101-Ehttp:/www.cs.virginia.edu/~cs101M/W 2:00-3:15 CHM 402 / MEC 205Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asbCS 101-E James Cohoon http:/www.cs.virginia.edu/~cohoonOffice: Olsson Hall, room 228D Office: O
UVA - CS - 101
Take care with floating-point valuesConsider double a = 1; double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 double c = .9999999999999999; Two true expressions! c = b b != a Two false expressions! a = b b != c Problem lies with th
UVA - CS - 101
Testing and ExceptionsException Abnormal event occurring during program execution Examples Manipulate nonexistent files File file = new File(s); Scanner fileIn = new Scanner(file); Improper array subscripting int[] a = new int[3]; a
UVA - CS - 101
BooleanvaluesGatewaytodecisionmakingBackground Ourproblemsolvingsolutionssofarhavethestraightlineproperty TheyexecutethesamestatementsforeveryrunoftheprogrampublicclassDisplayForecast /main():applicationentrypoint publicstaticvoidmain(String[]a
UVA - CS - 101
Cir cleKeeps on r ol l i ng Pr oblem design a cir cle r epr esent at ionSome possi bl e questi ons to ask What ki nd of ci r cl e? Why not use an exi sti ng ci r cl e r epr esentati on? What pl ans do you have for the ci r cl e? What
UVA - CS - 101
ClassesPreparation Scenesofarhasbeenbackgroundmaterialandexperience Computingsystemsandproblemsolving Variables Types Inputandoutput Expressions Assignments Objects StandardclassesandmethodsReady ExperiencewhatJavaisreallyabout Designa
UVA - CS - 101
Review for exam 1CS 101 Aaron Bloomfield1Todays lectureAn overview of the review sections of chapters 1-3 Stop me if you want me to go over something in more detail!2Material you may not be comfortable withConstructorsI know there is a
UVA - CS - 101
Iteration 1Java loopingOptions while dowhile for Allow programs to control how many times a statement list is executed 2AveragingProblem Extract a list of positive numbers from standard input and produce their average Number
UVA - CS - 101
Programming with methods and classes 1MethodsInstance (or member) method Operates on a object (i.e., and instance of the class)String s = new String(&quot;Help every cow reach its &quot; + &quot;potential!&quot;); int n = s.length(); Instance method
UVA - CS - 101
Using ObjectsChapter 3 Spring 2005 CS 101 Aaron Bloomfield 1About the assignment statementAssign the value 5 to the variable x int x; x = 5; 5 = x; NOT VALID! This is not a mathematical equals It's a Java assignment The variable you wan
UVA - CS - 101
JavabasicsInclassquiz What aretherule for an ide s ntifie in Java? r In what m thod doe a programbe What is there e s gin? turn typeof that m thod? What e param te doe it re e r(s) s quire ? What is thee xpone ntiation ope rator in Java? How do w
UVA - CS - 101
CS 101Chapter 1: Background Spring 2005 Aaron Bloomfield1Let's beginGoalTeach you how to program effectivelySkills and information to be acquired Mental model of computer and network behavior Problem solving Object-oriented design Jav
UVA - CS - 101
StaplesareourstapleBuilding upon our solutionWhydidthisprogramworkpublicclassStaplerSimulation{ publicstaticvoidmain(String[]args){ StaplermyStapler=newStapler(); System.out.println(myStapler); myStapler.fill(); System.out.println(myStapler); my
UVA - CS - 101
Arrays 1BackgroundProgrammer often need the ability to represent a group of values as a list List may be onedimensional or multidimensional Java provides arrays and the collection classes The Vector class is an example of a collection cla
UVA - CS - 101
ArraysContinued 1Consideredint[] v = new int[10]; int i = 7; int j = 2; int k = 4; v[0] = 1; v[i] = 5; v[j] = v[i] + 3; v[j+1] = v[i] + v[0]; v[v[j] = 12; System.out.println(v[2]); v[k] = stdin.nextInt();v 1v[0]0v[1]8v[2]6v[3]3v
UVA - CS - 101
Decisions,decisions,decisionsChapter5 Spring2005 CS101 AaronBloomfield1BackgroundOurproblemsolvingsolutionssofarhavethestraightlineproperty TheyexecutethesamestatementsforeveryrunoftheprogrampublicclassDisplayForecast /main():applicatione
UVA - CS - 101
Page 2Question 2 No partial creditQuestion 3 No partial creditQuestion 4 No partial creditQuestion 5 No partial creditQuestion 6 -1 if float instead of doubleQuestion 7 -1 if the word 'swap' was mentioned -3 if there are no words
UVA - CS - 101
A B CD E FThis file has 38 characters.
UVA - CS - 101
ABCDEFThisfilehas30characters.
UVA - CS - 415
Fortran lectureFortran history Why do we care? o Was one of the most influential programming languages of all time o It's development mirrors PL evolution o Was the de facto programming languages for many years o Was the first high level language
UVA - CS - 101
Spring 2007 CS 101EMichele CoBoolean Expressions, Precedence, and If StatementsDescription: The following questions demonstrate key concepts related to evaluating Boolean expressions and evaluation precedence. Directions: Discuss your reasoning
UVA - CS - 101
CS 101 Spring 2006 Final ExamName: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Unlike the midterm exams, you have a full 3 hours to work on this exam. Please sign the honor pledge here:Pa
UVA - CS - 101
CS 101 Spring 2007 Midterm 1Name: _Email ID: _You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be s
UVA - CS - 101
CS 101 Spring 2006 Midterm 3Name: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure to look over all the questions and plan your time accordingly
UVA - CS - 101
CS 101 Spring 2007 Midterm 2Name: _Email ID: _You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be s
UVA - CS - 101
CS 101 Fall 2006 Midterm 3Name: _Email ID: _You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sur
UVA - CS - 101
CS 101 Fall 2006 Final ExamName: _Email ID: _You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be su
UVA - CS - 101
CS 101 Fall 2006 Midterm 2Name: _Email ID: _You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sur
UVA - CS - 101
CS 101 &amp; 101-ESpring 2007 http:/www.cs.virginia.edu/~cs101 CS 101: M/W/F 3:00-3:50 in CHM 402 CS 101-E: M/W 2:00-3:15 in MEC 205Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asbCS 101-E Michele Co http:/www.cs.virginia.edu/~mc2z
UVA - CS - 101
Inheritance and PolymorphismChapter 11 Spring 2007 CS 101 Aaron Bloomfield 1This section is not required material!A note about inheritance. It's not normally covered in 101 It will be gone over in more detail in CS 201 Ask questions if yo
UVA - CS - 101
MethodsChapter 5 Spring 2007 CS 101 Aaron Bloomfield 1PreparationScene so far has been background material and experience Computing systems and problem solving Variables Types Input and output Expressions Assignments Using objects
UVA - CS - 101
Review for Midterm 3CS 101 Spring 2007 1Topic CoverageLoops Chapter 4 Methods Chapter 5 Classes Chapter 6, Designing and creating classes Chapter 9, Static fields and methods, wrapper classes Arrays Chapter 8 2ClassesCircl
UVA - CS - 101
ReviewforExam1Spring2007 CS101/CS101ETodaysclassAnoverviewofchapters13 Stop me if you want me to go over something in moredetail!2Chapter13IntroComputersthinkinbits(1or0)00101001=81Eightbitsperbyte 1024bytes=1Kb 1024
UVA - CS - 101
Course SummaryCourse Summary Spring 2007 CS 101 Aaron Bloomfield 1Course Reflection2Course goalsObjectives: Students who complete the course will: Understand fundamentals of programming such as variables, conditional and iterati
UVA - CS - 101
CS 101Chapter 1: Introduction Aaron Bloomfield Spring 2007 Let's beginGoalTeach you how to program effectivelySkills and information to be acquired What the heck all this means Problem solving Objectoriented design Java 2So,
UVA - CS - 101
CS 101 Exam 2 Spring 2005Email Id _ Name _This exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points, we recommend that you do not spend too
UVA - CS - 101
CS 101 Final Exam Fall 2004Email Id _Name _This exam is open book. Each question is worth 3 points.Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Total _ / 15 _ / 15 _ / 12 _ / 18 _ / 15 _ / 9 _ / 12 _ / 6 _ / 100 (maximum is 102)1. A
UVA - CS - 101
CS 101 Exam 1 Spring 200Email Id _ Name _This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your goal
UVA - CS - 101
CS 101 (Fall 05) Exam 1 Grading Guidelines Question 1: 2 points All or nothing Question 2: 2 points 1 point for each column Questions 3-8: 3 points -2 for type error -1 for math error -2 for associativity error -1 for forgetting the .0 for a float/do
UVA - CS - 101
CS 101 Final Exam Grading GuidelinesQuestions 1 &amp; 2: all or nothing Question 3 -1 for wrong modifiers (static, public, etc.) per variable to a max of -3 -4 for no head/tail variables -3 for missing a variable (head, tail, etc) if resulting class doe