1 Class #509 The Heisenberg Principal of Debugging A Method for Recording Execution and Program State in a Live Embedded System, for Later Playback and.

Slides:



Advertisements
Similar presentations
Gdb: GNU Debugger Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users” Third Edition, Prentice-Hall,
Advertisements

Welcome to E-Prime E-Prime refers to the Experimenter’s Prime (best) development studio for the creation of computerized behavioral research. E-Prime is.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
CIT 590 Debugging. Find a laptop Please take a moment to open up your laptop and open up Eclipse. If you do not have a laptop, please find a friend. If.
OllyDbg Debuger.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Debugging applications, using properties Jim Warren – COMPSCI 280 S Enterprise Software Development.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Instructor Notes GPU debugging is still immature, but being improved daily. You should definitely check to see the latest options available before giving.
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
Debugging and Profiling With some help from Software Carpentry resources.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
CSE 332: C++ debugging Why Debug a Program? When your program crashes –Finding out where it crashed –Examining program memory at that point When a bug.
Debugging Xin Tong. GDB GNU Project debugger Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing.
1 4-Development Environment Development processor  The processor on which we write and debug our programs Usually a PC Target processor  The processor.
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
S OME USEFUL D EBUG C OMMANDS FOR C LEAR -S PEED S OFTWARE D EVELOPMENT K IT -- COMMANDS FROM CHAP.7 By: Pallav Laskar.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
5.01 Understand Different Types of Programming Errors
Source Level Debugging of Parallel Programs Roland Wismüller LRR-TUM, TU München Germany.
© 2002 IBM Corporation Confidential | Date | Other Information, if necessary Copyright © 2009 Ericsson, Made available under the Eclipse Public License.
CSE 332: C++ expressions Expressions: Operators and Operands Operators obey arity, associativity, and precedence int result = 2 * 3 + 5; // assigns 11.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
DEBUG.
5.01 Understand Different Types of Programming Errors
ME 142 Engineering Computation I
CS1101X Programming Methodology
Testing and Debugging.
Debugging with gdb gdb is the GNU debugger on our CS machines.
Debugging CMSC 202.
Kernel Tracing David Ferry, Chris Gill
Testing Key Revision Points.
gdb gdb is the GNU debugger on our CS machines.
Using Visual Studio with C#
Important terms Black-box testing White-box testing Regression testing
CS 240 – Lecture 11 Pseudocode.
DEBUGGING.
Important terms Black-box testing White-box testing Regression testing
5.01 Understand Different Types of Programming Errors
Debugging with Eclipse
Debuggers.
Common C Programming Errors, GDB Debugging
Welcome to E-Prime E-Prime refers to the Experimenter’s Prime (best) development studio for the creation of computerized behavioral research. E-Prime is.
Tonga Institute of Higher Education
CSE 403 Lecture 18 Debugging.
Using a Debugger 1-Jan-19.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
When your program crashes
Debuggers and Debugging
Debugging Taken from notes by Dr. Neil Moore
Code Composer Essentials 3.0
Chapter 15 Debugging.
Debugging.
Dynamic Binary Translators and Instrumenters
Debugging with Eclipse
Chapter 15 Debugging.
Presentation transcript:

1 Class #509 The Heisenberg Principal of Debugging A Method for Recording Execution and Program State in a Live Embedded System, for Later Playback and Debugging.

Embedded Systems Conference - September Why Trace Debugging?  Stopping a real-time program may change its behavior.  It may also have real-world, mechanical consequences!  Motors overrunning their limits.  Holding tanks overflowing.  Disk heads crashing.  Cars not stopping.  Some types of events that you would like to debug:  happen only when running at native speed.  happen over very short time intervals.  happen over very long time intervals.  are difficult to predict, reproduce, and capture.  happen only in actual field conditions.  Stopping a real-time program may change its behavior.  It may also have real-world, mechanical consequences!  Motors overrunning their limits.  Holding tanks overflowing.  Disk heads crashing.  Cars not stopping.  Some types of events that you would like to debug:  happen only when running at native speed.  happen over very short time intervals.  happen over very long time intervals.  are difficult to predict, reproduce, and capture.  happen only in actual field conditions.

Embedded Systems Conference - September Methods of Trace Debugging  Emulators  Logic Analyzers  Hand-instrumented code (“printf debugging”)  Automated code instrumentation systems  GDB with Introspect  Interactively instrument the binary image using the source language.  Specify the exact program data you want to collect.  Run program at nearly-native speed.  Replay execution trace and review collected data at leisure, using the full (and familiar) power and functionality of GDB.  Emulators  Logic Analyzers  Hand-instrumented code (“printf debugging”)  Automated code instrumentation systems  GDB with Introspect  Interactively instrument the binary image using the source language.  Specify the exact program data you want to collect.  Run program at nearly-native speed.  Replay execution trace and review collected data at leisure, using the full (and familiar) power and functionality of GDB.

Embedded Systems Conference - September A Typical Trace Debugging Session  Specify “tracepoints” (analogous to breakpoints).  trace tree.c:find  trace main.c:123  Specify variables, registers etc. to collect at each tracepoint.  collect tree->vector.p[tree->vector.n - 1]  collect $d1, $a2  Run the program.  Replay at leisure the sequence of tracepoint ‘hits’, examining the collected data using any GDB command.  tfind line 123  display tree->vector.p[tree->vector.n - 1]  tfind next  Specify “tracepoints” (analogous to breakpoints).  trace tree.c:find  trace main.c:123  Specify variables, registers etc. to collect at each tracepoint.  collect tree->vector.p[tree->vector.n - 1]  collect $d1, $a2  Run the program.  Replay at leisure the sequence of tracepoint ‘hits’, examining the collected data using any GDB command.  tfind line 123  display tree->vector.p[tree->vector.n - 1]  tfind next

Embedded Systems Conference - September Comparison: breakpoint vs. tracepoint

Embedded Systems Conference - September Breakpoints vs. Tracepoints  Breakpoint-style  Run until breakpoint  Note where it occurred  Look at current program state  Continue, step,...  Breakpoint-style  Run until breakpoint  Note where it occurred  Look at current program state  Continue, step,...  Tracepoint-style  Select a trace event  Note where it occurred  Look at collected values  Select another event  Tracepoint-style  Select a trace event  Note where it occurred  Look at collected values  Select another event

Embedded Systems Conference - September Comparison: step/continue vs. trace

Embedded Systems Conference - September Example: Walking a Tree struct point { double x, y; }; struct vector { int n; struct point *p; }; struct tree { struct tree *left, *right; int key; struct vector *vector; };

Embedded Systems Conference - September Example: Walking a Tree struct tree * find (struct tree *tree, int key) { if (! tree) return 0; if (key key) return find (tree->left, key); else if (key > tree->key) return find (tree->right, key); else return tree; }

Embedded Systems Conference - September Setting a Tracepoint (gdb) trace find (gdb) actions > collect $stack > collect $locals > collect *tree > collect tree->vector.p[tree->vector.n - 1] > end (gdb) (gdb) trace find (gdb) actions > collect $stack > collect $locals > collect *tree > collect tree->vector.p[tree->vector.n - 1] > end (gdb)

Embedded Systems Conference - September Running the Experiment (gdb) tstart (gdb) continute (gdb) tstart (gdb) continute

Embedded Systems Conference - September The Results: Selecting a Logged Event (gdb) tfind start Tracepoint 1, find (tree=0x8049a50, key=5) at tree.c:24 24 if (! tree) (gdb) tfind start Tracepoint 1, find (tree=0x8049a50, key=5) at tree.c:24 24 if (! tree)

Embedded Systems Conference - September The Results: Selecting a Logged Event (gdb) tfind start Tracepoint 1, find (tree=0x8049a50, key=5) at tree.c:24 24 if (! tree) (gdb) where #0 find (tree=0x8049a50, key=5) at tree.c:24 #1 0x in main () at main.c:8 (gdb) print *tree $1 = {left = 0x80499b0, right = 0x , key = 100, vector = 0x8049a68} (gdb) print tree->key $2 = 100 (gdb) tfind start Tracepoint 1, find (tree=0x8049a50, key=5) at tree.c:24 24 if (! tree) (gdb) where #0 find (tree=0x8049a50, key=5) at tree.c:24 #1 0x in main () at main.c:8 (gdb) print *tree $1 = {left = 0x80499b0, right = 0x , key = 100, vector = 0x8049a68} (gdb) print tree->key $2 = 100

Embedded Systems Conference - September The Results: Only What You Asked For (gdb) print tree->left $3 = (struct tree *) 0x80499b0 (gdb) print *tree->left Data not collected. (gdb) (gdb) print tree->left $3 = (struct tree *) 0x80499b0 (gdb) print *tree->left Data not collected. (gdb)

Embedded Systems Conference - September The Results: But Everything On The Way (gdb) print *tree->vector $4 = {n = 2, p = 0x8049a78} (gdb) print tree->vector.p[1] $5 = {x = 3, y = -46} (gdb) print tree->vector.p[0] Data not collected. (gdb) (gdb) print *tree->vector $4 = {n = 2, p = 0x8049a78} (gdb) print tree->vector.p[1] $5 = {x = 3, y = -46} (gdb) print tree->vector.p[0] Data not collected. (gdb)

Embedded Systems Conference - September left right key vectorn px,y The Results: What We Collected > collect *tree > collect tree->vector.p[tree->vector.n - 1]

Embedded Systems Conference - September The Results: Selecting Other Events (gdb) tfind Tracepoint 1, find (tree=0x80499b0, key = 5) at tree.c:24 24 if (! tree) (gdb) where #0 find (tree=0x80499b0, key=5) at tree.c:24 #1 0x80484fa in find (tree=0x80499b0, key=5) at tree.c:28 #2 0x in main () at main.c:8 (gdb) tfind Tracepoint 1, find (tree=0x80499b0, key = 5) at tree.c:24 24 if (! tree) (gdb) where #0 find (tree=0x80499b0, key=5) at tree.c:24 #1 0x80484fa in find (tree=0x80499b0, key=5) at tree.c:28 #2 0x in main () at main.c:8

Embedded Systems Conference - September The Results: Selecting Other Events (gdb) tfind Tracepoint 1, find (tree=0x80498f0, key=5) at samp.c:24 24 if (! tree) (gdb) where #0 find (tree=0x80498f0, key=5) at tree.c:24 #1 0x in find (tree=0x80499b0, key=5) at tree.c:30 #2 0x80484fa in find (tree=0x80499b0, key=5) at tree.c:28 #3 0x in main () at main.c:8 (gdb) tfind Tracepoint 1, find (tree=0x80498f0, key=5) at samp.c:24 24 if (! tree) (gdb) where #0 find (tree=0x80498f0, key=5) at tree.c:24 #1 0x in find (tree=0x80499b0, key=5) at tree.c:30 #2 0x80484fa in find (tree=0x80499b0, key=5) at tree.c:28 #3 0x in main () at main.c:8

Embedded Systems Conference - September The Results: Selecting Other Events (gdb) tfind Target failed to find requested trace event. (gdb) (gdb) tfind Target failed to find requested trace event. (gdb)

Embedded Systems Conference - September Implementation  All symbolic information is handled by the debugger.  A simplified, non-symbolic description of the tracepoints and data to be collected (including expressions) is downloaded to a debug agent on the target board.  Expressions are reduced to a byte-code form which the target debug agent can interpret at trace collection time.  Can ‘cut-and-paste’ expressions from the source code.  Debug agent collects all trace data into a local buffer at runtime, without any intervention from the debugger.  Debugger then queries the contents of the trace buffer as needed to satisfy user requests.  All symbolic information is handled by the debugger.  A simplified, non-symbolic description of the tracepoints and data to be collected (including expressions) is downloaded to a debug agent on the target board.  Expressions are reduced to a byte-code form which the target debug agent can interpret at trace collection time.  Can ‘cut-and-paste’ expressions from the source code.  Debug agent collects all trace data into a local buffer at runtime, without any intervention from the debugger.  Debugger then queries the contents of the trace buffer as needed to satisfy user requests.

Embedded Systems Conference - September Evaluating an Expression  To evaluate an expression like this:  tree->vector.p[tree->vector.n - 1]  we need to know:  the syntax of C  names of local variables, arguments, etc. (scopes)  physical locations of variables, etc.  types of variables  C expression semantics  To evaluate an expression like this:  tree->vector.p[tree->vector.n - 1]  we need to know:  the syntax of C  names of local variables, arguments, etc. (scopes)  physical locations of variables, etc.  types of variables  C expression semantics

Embedded Systems Conference - September Compiling Expressions to Bytecode  The C expression:  *tree  compiles to the bytecode sequence:  reg 8  const8 16  trace  end  The C expression:  *tree  compiles to the bytecode sequence:  reg 8  const8 16  trace  end

Embedded Systems Conference - September GDB Ready to Define a Tracepoint

Embedded Systems Conference - September Tracepoint Definition Dialog Boxes

Embedded Systems Conference - September Replaying the Trace Record

Embedded Systems Conference - September Expressions Window  ‘Live’ data  Collected data

Embedded Systems Conference - September Registers Window  ‘Live’ registers  Collected registers

Embedded Systems Conference - September ‘Where’ command, using collected stack

Embedded Systems Conference - September Trace Dump Window  Displays all collected data for current trace record.