GDBTutorial

GDBTutorial - GDB Tutorial University of Waterloo Version...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: GDB Tutorial University of Waterloo Version 1.1 Caroline Kierstead and Peter A. Buhr c- 1993 May 1, 2000 Permission is granted to make copies for personal or educational use 2 GDB Tutorial Contents 1 Introduction 3 2 Before Using GDB 3 2.1 Debug Print Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3 Getting Started 5 4 Using GDB 5 4.1 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.2 Starting a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.3 Setting a Breakpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.4 Listing Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.5 Printing Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.6 Controlling Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.7 Controlling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.8 Changing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5 Debugging Example 1 10 6 Debugging Example 2 12 A Basic 15 B Factorial 15 C Strings 16 GDB Tutorial 3 1 Introduction This tutorial is designed to give a very basic introduction to the GNU Source-Level Debugger. It is organized with a basic introduction to the debugger commands and then two programs with several errors are debugged using the debugger. By working through the exercises, basic concept are introduced and can be practiced. The tutorial is not intended as a complete instructional guide. A manual on GDB is available. GDB can be used in and out of the Emacs environment. It is recommended that GDB be run within Emacs as it is easier to trace the execution of a program. While this tutorial uses GDB within Emacs, additional instructions are given on how to run GDB outside of Emacs; it is assumed that you are familiar with Emacs. As well, you should be familiar with the UNIX environment. (UNIX consultants are available in MC3011.) Throughout the tutorial, the following symbols are used: This symbol indicates that you are to perform the action marked by the arrow. This symbol indicates that the section explains a concept that may be unfamiliar even if you have some previ- ous experience using a computer (e.g., DOS). Make sure you understand this concept before advancing in the tutorial....
View Full Document

This note was uploaded on 09/22/2011 for the course CS 343 taught by Professor Peterbuhr during the Fall '11 term at Waterloo.

Page1 / 19

GDBTutorial - GDB Tutorial University of Waterloo Version...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online