Computer System Laboratory

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

Computer System Laboratory
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
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.
One to One instructions Installing and configuring samba on Ubuntu Linux to enable Linux to share files and documents with Windows XP.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
COMPUTER SYSTEM LABORATORY Lab10 - Sensor II. Lab 10 Experimental Goal Learn how to write programs on the PTK development board (STM32F207). 2013/11/19/
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.
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.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
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.
Networking in Linux. ♦ Introduction A computer network is defined as a number of systems that are connected to each other and exchange information across.
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.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Linux Operations and Administration
Implementation of Embedded OS Lab3 Porting μC/OS-II.
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1.
Lab 1 Department of Computer Science and Information Engineering National Taiwan University Lab1 - Environment Setup 2015/9/15/ 30 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.
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
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.
LINUX Network Concepts M.S.Dibay Moghaddam Second Linux Festival Amir Kabir University of Technology Computer & IT Department.
Troubleshooting Directories and Files Debugging
DEBUG.
Computer System Laboratory
Computer System Laboratory
Implementation of Embedded OS
Development Environment
Network Configuration
Computer System Laboratory
CSE 374 Programming Concepts & Tools
Debugging with gdb gdb is the GNU debugger on our CS machines.
Lab 1 introduction, debrief
Computer Architecture “Bomb Lab Hints”
Lab: ssh, scp, gdb, valgrind
Getting Started: Developing Code with Cloud9
Computer System Laboratory
Computer System Laboratory
Computer System Laboratory
Computer System Laboratory
Video Notes.
Presentation transcript:

Computer System Laboratory Lab7 - Debugging I

Experimental Goal Build a cross debugger and learn how to do source-level remote debugging with GDB. 2013/10/22 / 29

Environment Host System Build System Target System Software Windows XP Build System VirtualBox + Ubuntu 8.04 Target System Creator XScale PXA270 Software GNU Debugger Compiled toolchain Test programs Red Hat GDB GUI (insight) You can download all software from RSWiki CSL Course Software 2013/10/22 / 29

Introduction to GDB How do you debug? GDB - GNU Debugger 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. 2013/10/22 / 29

Cross-Debugger Simulator Compilation (1/2) Step1: download GDB source codes. (gdb-6.6a.tar.gz) Step2: extract the source codes. Step3: set configuration options (check Lab3’s arm-elf-* toolchain path in PATH). % cd gdb-6.6 % ./configure --target=arm-elf --prefix=$HOME/<arm-elf –* toolchain path> --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. 2013/10/22 / 29

Cross-Debugger Simulator Compilation (2/2) Step4: compile cross-debugger. % make -j4 Step5: install cross-debugger. % make -j4 install Test your cross-debugger. % arm-elf-gdb -version 2013/10/22 / 29

Basic Commands of GDB (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 Use sim/remote as the mode Setting the break point Start execution Next Step in Print the value Print the backtrace of the stack frame 2013/10/22 / 29

GDB References GDB Documentation: GDB User Manual: GDB basic command: http://www.gnu.org/software/gdb/documentation/ GDB User Manual: http://sourceware.org/gdb/current/onlinedocs/gdb/ GDB basic command: http://en.wikibooks.org/wiki/GCC_Debugging/gdb Use the help command in GDB interactive shell. (gdb) help Tip: GDB provide history & auto-complete facility. You can use the kill command to kill current debugging process and reload it by the file command. 2013/10/22 / 29

Verify the Simulator Debugging (1/2) Step1: download test program. (foo.c) Step2: 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. Step3: connect to simulator. % arm-elf-gdb foo1 (gdb) target sim Step4: download file from the host to the target (simulator). (gdb) load foo1 Step5: set breakpoint at line 7. (gdb) break 7 2013/10/22 / 29

Verify the Simulator Debugging (2/2) Step6: 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 = 0x1fffe0. 2013/10/22 / 29

Cross-Debugger Compilation (1/2) Now, we will cross-compile a cross-debugger to do remote debugging on PXA270 from the same GDB source codes. Step1: delete all temporary files in GDB source codes. % cd gdb-6.6 % make distclean Step2: set configuration options. % ./configure --target=arm-unknown-linux-gnu --prefix=$HOME/<arm- unknown-linux-gnu–* toolchain path> Step3: compile cross-debugger. % make -j4 2013/10/22 / 29

Cross-Debugger Compilation (2/2) Step4: install cross-debugger. % make -j4 install Test. % arm-unknown-linux-gnu-gdb -version 2013/10/22 / 29

GDBserver Compilation (1/2) To do remote debugging, we need to build a server for GDB on PXA270. Step1: set configuration options. % cd gdb-6.6/gdb/gdbserver % CFLAGS="-g -O2 -static" ./configure --host=arm-unknown-linux-gnu --target=arm-unknown-linux-gnu Step2: compile the gdbserver. % make -j4 2013/10/22 / 29

GDBserver Compilation (2/2) The resulting gdbserver is the program we want. You can use file to check the executable. 2013/10/22 / 29

Set Network Environment (1/2) To do remote debugging, we can build LAN environment. You can follow the network configuration as below figure. Target system (PXA270): 192.168.0.100 Host system (Windows XP): 192.168.0.10 Build system (Ubuntu 8.04): 192.168.0.101 Recall in Lab2, we have configured the network of target system and host system, now we only need to configure build system. ethernet cable GDB Server GDB Client 192.168.0.10 192.168.0.100 Host System Target System Build System 192.168.0.101 2013/10/22 / 29

Set Network Environment (2/2) Step1: configure Ubuntu IP (build system). % sudo vim /etc/network/interfaces auto eth0 iface eth0 inet static address <build-system-ip> netmask 255.255.255.0 gateway <host-system-ip> % sudo /etc/init.d/networking restart Step2: configure virtual machine network setting. “裝置”  “網路卡”  “網路” “附加到”  “橋接介面卡” Please configure correct network interface in“名稱”, i.e., the network interface connected to PXA270. Note that the network will be disconnected in build system after this configuration. If you want to reconnect to WAN, you can use dhclient command to get new DHCP address. 2013/10/22 / 29

Verify the Remote Debugging (1/4) Step1: compile test program. % arm-unknown-linux-gnu-gcc foo.c -g -static -o foo2 Step2: copy gdbserver & foo2 to Linux on PXA270. You can refer to Lab2 to transfer files to Linux. Do not forget to change permission of these executable. Step3: execute gdbserver with port 1234 on PXA270. $ ./gdbserver <build-system-ip>:1234 foo2 2013/10/22 / 29

Verify the Remote Debugging (2/4) Step4: connect to target from build system. % arm-unknown-linux-gnu-gdb foo2 (gdb) target remote <target-system-ip>:1234 Target System Build System 2013/10/22 / 29

Verify the Remote Debugging (3/4) Step5: now, you can follow previous slides to set breakpoints for debugging, e.g. set to line 7. (gdb) break 7 Step6: 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. 2013/10/22 / 29

Verify the Remote Debugging (4/4) As slide10 does, if we want to watch the variables b and c, the print command can help you. You can see that c = &b = 0xbe896ce0 on PXA270. The root filesystem is the 20M one. 2013/10/22 / 29

The GDB GUI – Insight (1/5) Insight is a graphical user interface to GDB written in Tcl/Tk by people working at Red Hat. http://sources.redhat.com/insight/ 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 2013/10/22 / 29

The GDB GUI – Insight (2/5) There are three modes of insight: command-line mode: % arm-elf-insight -nw Text-based UI mode: % arm-elf-insight -tui text-based UI mode command-line mode (like GDB) 2013/10/22 / 29

The GDB GUI – Insight (3/5) GUI mode: % arm-elf-insight “Run”  “Connect to target” Choose your target, e.g., simulator. “File”  “Open” Choose your executable, e.g., foo1. Click the source codes to set breakpoints. “Run”  “Run” breakpoint 2013/10/22 / 29

The GDB GUI – Insight (4/5) “View” can help you see related debug information. Please refer to http://sources.redhat.com/insight/index.php for more information. local variables console registers 2013/10/22 / 29

The GDB GUI – Insight (5/5) 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  192.168.0.100 Port  1234 Now, you can start to debug. Do not forget to use continue to execute. continue 2013/10/22 / 29

Debug Program (1/2) Step1: download the test program (pi-agm.tar.gz). The program is used to compute digits of 𝜋. Step2: 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. Step3: transfer the resulting binary pi-agm and configuration pi.ini to PXA270. Step4: execute the binary. $ ./pi-agm 2013/10/22 / 29

Debug Program (2/2) 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. ? 2013/10/22 / 29

Another GUI: GDB DDD (Optional) 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. We do not ask you use this GUI, and you can try it by yourself. 2013/10/22 / 29

Lab Requirement & Bonus Show how you find and correct the bug of pi-agm. Bonus: Answer the question of lab7 on RSWiki CSL course website. Write it in your report. Please send your report to both TAs. csiedatou@gmail.com, meenchen79@gmail.com Please use this title format: [CSL] G# Lab# Ver# E.g., [CSL] G13 Lab7 Ver1 2013/10/22 / 29