Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Utilizing the GDB debugger to analyze programs Background and application.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1.
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
Computer System Laboratory
Introduction Purpose Objectives Content Learning Time
COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards.
COMPUTER SYSTEM LABORATORY Lab4 - Bootloader. Lab 4 Experimental Goal Learn how to build U-Boot bootloader for PXA /10/8/ 142.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://
Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
Debugging techniques in Linux Debugging Techniques in Linux Chetan Kumar S Wipro Technologies.
U-Boot Debug using CCSv5 In this session we will cover fundamentals necessary to use CCSv5 and a JTAG to debug a TI SDK-based U-Boot on an EVM platform.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
Debugging Cluster Programs using symbolic debuggers.
Computer System Laboratory
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
Computer System Laboratory
Lab 11 Department of Computer Science and Information Engineering National Taiwan University Lab11 - Porting 2014/12/9/ 26 1.
Guideline: How to build AMSS source code? History: 01/02/ Make Draft 05/02/2010 – Release /02/2010 – Updated.
Lab 1 Department of Computer Science and Information Engineering National Taiwan University Lab1 - Sensor 2014/9/23/ 13 1.
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.
Active-HDL Interfaces Debugging C Code Course 10.
Lab 10 Department of Computer Science and Information Engineering National Taiwan University Lab10 – Debugging II 2014/12/2 1 /16.
COMPUTER SYSTEM LABORATORY Lab6 - Root Filesystem.
9/2/ CS171 -Math & Computer Science Department at Emory University.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
Lab 14 Department of Computer Science and Information Engineering National Taiwan University Lab14 – Camera 2014/12/30 1 /14.
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 SEEM3460 Tutorial Compiling and Debugging C programs.
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.
Data Display Debugger (DDD)
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Debugging 1/6/2016. Debugging 1/6/2016 Debugging  Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a program.
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.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1.
Lab 8 Department of Computer Science and Information Engineering National Taiwan University Lab8 - Root Filesystem 2015/11/10/ 22 1.
Ladebug Kernel Debugging Tutorial Bob Lidral. Introduction Kinds of kernel debugging How to use Ladebug for kernel debugging Not how to debug a kernel.
CMSC 104, Version 8/061L14AssignmentOps.ppt Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips Reading Section.
Implementation of Embedded OS
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 - OS Kernel 2014/10/21/ 16 1.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
The World Leader in High Performance Signal Processing Solutions Toolchain Basics.
 Wind River Systems, Inc Chapter - 4 CrossWind.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe.
DEBUG.
Computer System Laboratory
Implementation of Embedded OS
Development Environment
Computer System Laboratory
CSE 374 Programming Concepts & Tools
Debugging with gdb gdb is the GNU debugger on our CS machines.
Lab 1 introduction, debrief
Lab: ssh, scp, gdb, valgrind
Getting Started: Developing Code with Cloud9
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
Computer System Laboratory
Computer System Laboratory
Computer System Laboratory
Computer System Laboratory
Video Notes.
Debugging.
Presentation transcript:

Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Build a cross debugger and learn how to do source-level remote debugging with GDB. 2014/11/4/ 28 2

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Host System  Windows XP  Build System  VirtualBox + Ubuntu 8.04  Target System  Creator XScale PXA270  Software  GNU Debugger  Test program foo  Red Hat GDB GUI (insight)  Buggy Program pi-agm  You can find all software on CSL Course Software.CSL Course Software 2014/11/4/ 28 3

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  How do you debug?  Human brain compiler  printf printf printf …  GDB - GNU Debugger  Allows you to see what is going on inside your program while it is executing.  Start your program, specifying anything that might affect its behavior.  Make your program stop on specified conditions.  Examine what has happened, when your program has stopped.  Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another. 2014/11/4/ 28 4

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download GDB source codes. (gdb-6.6a.tar.gz)  Step 2: extract the source codes.  Step 3: set configuration options (check Lab4’s arm-elf-* toolchain path in PATH).  % cd gdb-6.6  %./configure --target=arm-elf --prefix=$HOME/ --enable-sim  We configure --enable-sim to build a simulator for ARM.  We recommend to place cross-debugger and cross-toolchain in the same directory, but it is optional. 2014/11/4/ 28 5

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 4: compile cross-debugger.  % make  It needs libncurses5-dev package when compiling.  Step 5: install cross-debugger.  % make install  Test your cross-debugger.  % arm-elf-gdb -version 2014/11/4/ 28 6

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  (gdb) file [executable_name]  (gdb) target [mode]  (gdb) load [executable_name]  (gdb) break [line_number]  (gdb) run  (gdb) next  (gdb) step  (gdb) print [expression]  (gdb) where  (gdb) quit  (gdb) help 2014/11/4/ 28 7 Setting the break point Start execution Next Step in Print the value Print the backtrace of the stack frame Use sim/remote as the mode

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  GDB Documentation:   GDB User Manual:   GDB basic command:   Use the help command in GDB interactive shell.  (gdb) help  Tips:  GDB provide history & auto-complete facility.  You can use the kill command to kill current debugging process and reload it by the file command. 2014/11/4/ 28 8

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download test program. (foo.c)  Step 2: compile the test program.  % arm-elf-gcc foo.c -g -static -o foo1  -g : add debug symbol into the executable.  -static : build the executable with static library.  Step 3: connect to simulator.  % arm-elf-gdb foo1  (gdb) target sim  Step 4: download file from the host to the target (simulator).  (gdb) load foo1  Step 5: set breakpoint at line 7.  (gdb) break /11/4/ 28 9

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 6: execute the program.  (gdb) run  Now, you can use info, print, etc. commands in GDB to debug your program. For example, if we want to watch the variables b and c in foo.c.  (gdb) print c  (gdb) print b  (gdb) print &b  Recall the line 6 in foo.c.  c = &b;  Since we set the breakpoint at line7, the result in GDB shows that c = &b = 0x1fffe /11/4/ 28 10

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Now, we will cross-compile a cross-debugger to do remote debugging on PXA270 from the same GDB source codes.  Step 1: delete all temporary files in GDB source codes.  % cd gdb-6.6  % make distclean  Step 2: set configuration options.  %./configure --target=arm-unknown-linux-gnu --prefix=$HOME/  Step 3: compile cross-debugger.  % make 2014/11/4/ 28 11

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 4: install cross-debugger.  % make install  Test.  % arm-unknown-linux-gnu-gdb -version 2014/11/4/ 28 12

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  To do remote debugging, we need to build a server for GDB on PXA270.  Step 1: set configuration options.  % cd gdb-6.6/gdb/gdbserver  % CFLAGS="-g -O2 -static"./configure --host=arm-unknown-linux-gnu --target=arm-unknown-linux-gnu  Step 2: compile the gdbserver.  % make 2014/11/4/ 28 13

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  The resulting gdbserver is the program we want.  You can use file to check the executable. 2014/11/4/ 28 14

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  To do remote debugging, we can build a LAN environment.  Please check the network configuration as below figure.  Target system (PXA270):  Host system (Windows XP):  Build system (Ubuntu 8.04):  Recall in Lab2, we have configured the network of all systems. 2014/11/4/ GDB Server GDB Client ethernet cable Target System Host System Build System

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 1: compile test program.  % arm-unknown-linux-gnu-gcc foo.c -g -static -o foo2  Step 2: copy gdbserver & foo2 to Linux on PXA270.  Do not forget to change permission of these executable.  Step 3: execute gdbserver with port 1234 on PXA270.  $./gdbserver :1234 foo2 2014/11/4/ 28 16

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 4: connect to target from build system.  % arm-unknown-linux-gnu-gdb foo2  (gdb) target remote : /11/4/ Target System Build System

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 5: now, you can follow previous slides to set breakpoints for debugging, e.g., set to line 7.  (gdb) break 7  Step 6: continue executing the program.  (gdb) continue  You must use the “ continue ” command instead of the “ run ” command in GDB remote debugging because the program is already running on the remote system when you set remote target.  If you type “ run ”, GDB is attempting to run the program itself, thus dropping the existing target setting, i.e. connection.  Running the ARM executable on the i386 machine tends to yield the don’t know how to run error. 2014/11/4/ 28 18

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  As slide10 does, if we want to watch the variables b and c, the print command can help you.slide10  You can see that c = &b = 0xbe896ce0 on PXA270.  The root filesystem is the 20M one. 2014/11/4/ 28 19

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Insight is a graphical user interface to GDB written in Tcl/Tk by people working at Red Hat.   You can follow previous slides to compile insight (insight-6.6.tar.bz2) by both arm-elf-* and arm-unknown-linux-gnu-* toolchains.  You should install libx11-dev package before compiling.  % arm-elf-insight -version 2014/11/4/ 28 20

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  There are three modes of insight:  command-line mode:  % arm-elf-insight -nw  Text-based UI mode:  % arm-elf-insight -tui 2014/11/4/ command-line mode (like GDB) text-based UI mode

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  GUI mode:  % arm-elf-insight  “File”  “Open”  Choose your executable, e.g., foo1.  “Run”  “Connect to target”  Choose your target, e.g., simulator.  Click the source codes to set breakpoints.  “Run”  “Run” 2014/11/4/ breakpoint

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  “View” can help you see related debug information.  Please refer to for more information /11/4/ local variables console registers

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  You also can follow previous slides to do remote debugging by insight.  % arm-unknown-linux-gnu-insight foo2  “Run”  “Connect to target”  Target  GDBServer/TCP  Hostname   Port  1234  Now, you can start to debug.  Do not forget to use continue to execute. 2014/11/4/ continue

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download the test program (pi-agm.tar.gz).  The program is used to compute digits of.  Step 2: try to cross-compile the program for PXA270.  Please compile with “ntt-gen” configuration.  i.e., type “ make ntt-gen ” in the directory pi-agm/src.  Do not forget to change your compiler and add -static and -g flags.  Step 3: transfer the resulting binary pi-agm and configuration pi.ini to PXA270.  Step 4: execute the binary.  $./pi-agm 2014/11/4/ 28 25

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  However, we will get negative execution time from the results.  Please use GDB to find why we get the negative execution time and try to fix it. 2014/11/4/ ?

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  GNU DDD is a graphical front-end for command-line debuggers such as GDB, DBX, WDB, Ladebug, JDB, XDB, the Perl debugger, the bash debugger bashdb, the GNU Make debugger remake, or the Python debugger pydb. GNU DDD GDBDBXLadebugthe Perl debuggerbashdbremakepydb  We do not ask you to use this GUI, and you can try it by yourself. 2014/11/4/ 28 27

Lab 9 Department of Computer Science and Information Engineering National Taiwan University  Show how you find and correct the bug of pi-agm. 2014/11/4/ 28 28