background preloader

C C++ Language

Facebook Twitter

Gdb Tutorial. Contents Introduction This tutorial was originally written for CS 342 at Washington University.

gdb Tutorial

It is still maintained by Andrew Gilpin. Who should read this? This tutorial is written to help a programmer who is new to the Unix environment to get started with using the gdb debugger. Source code To help illustrate some of the debugging principles I will use a running example of a buggy program. The code is very simple and consists of two class definitions, a node and a linked list. Preparations Environment settings gdb is in the gnu package on CEC machines. Debugging symbols gdb can only use debugging symbols that are generated by g++. Gdb is most effective when it is debugging a program that has debugging symbols linked in to it. Debugging When to use a debugger Debugging is something that can't be avoided.

Before a bug can be fixed, the source of the bug must be located. Go ahead and make the program for this tutorial, and run the program. Loading a program Inspecting crashes Stepping Notes. C++ Operator Overloading Guidelines. One of the nice features of C++ is that you can give special meanings to operators, when they are used with user-defined classes.

C++ Operator Overloading Guidelines

This is called operator overloading. You can implement C++ operator overloads by providing special member-functions on your classes that follow a particular naming convention. For example, to overload the + operator for your class, you would provide a member-function named operator+ on your class. The following set of operators is commonly overloaded for user-defined classes: = (assignment operator) + - * (binary arithmetic operators) += -= *= (compound assignment operators) == ! Here are some guidelines for implementing these operators. Assignment Operator = The assignment operator has a signature like this: Notice that the = operator takes a const-reference to the right hand side of the assignment. Also, you will notice that a reference is returned by the assignment operator. Int a, b, c, d, e; a = b = c = d = e = 42; This is interpreted by the compiler as: Make' GNU make This file documents the GNU make utility, which determines automatically which pieces of a large program need to be recompiled, and issues the commands to recompile them.

make'

This is Edition 0.72, last updated 9 October 2013, of The GNU Make Manual, for GNU make version 4.0. Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below.

A copy of the license is included in the section entitled “GNU Free Documentation License.” --- The Detailed Node Listing --- Overview of make An Introduction to Makefiles Writing Makefiles Writing Rules make .