-->
Previous Table of Contents Next


Summary of gdb C++ Specific Commands

In addition to the gdb commands that have been added to support some of the new language features contained in C++, there are also some new set and show options. These options are listed in Table 27.3.

Table 27.3. gdb’s C++ set and show options.

Command Description

set print demangle Prints C++ names in their source form rather than in the encoded or mangled form that is passed to the assembler.
show print demangle Shows whether print demangle is on or off.
set demangle-style Sets the style of demangled output. The options are auto, gnu, lucid, and arm.
show demangle-style Shows which demangle style is being used.
set print object When displaying a pointer to an object, identifies the actual type of the object.
show print object Shows whether print object is turned on or off.
set print vtbl Prints C++ virtual function tables.
show print vtbl Shows whether print vtbl is turned on or off.

GNU C++ Class Libraries

GNU C++ comes packaged with an extensive class library. A class library is a reusable set of classes that can be used to perform a specified set of functions. Some typical examples of class libraries are class libraries that handle database access, class libraries that handle graphical user interface programming, and class libraries that implement data structures.

Other examples of graphical user interface class libraries are the Microsoft Foundation Classes and Borland’s Object Windows Library, both of which are class libraries used for developing Windows applications.

This section introduces several of the features that are offered by the GNU C++ class library.

Streams

The GNU iostream library, called libio, implements GNU C++’s standard input and output facilities. This library is similar to the I/O libraries that are supplied by other C++ compilers. The main parts of the iostream library are the input, output, and error streams. These correspond to the standard input, output, and error streams that are found in C and are called cin, cout, and cerr, respectively. The streams can be written to and read from using the << operator for output and the >> operator for input.

The following program uses the iostream library to perform its input and output:


#include <iostream.h>

int maim ()

{

        char name[10];

        cout << “Please enter your name.\n”;

        cin >> name;

        cout << “Hello “ << name << “ how is it going?\n”;

}

Strings

The GNU string class extends GNU C++’s string manipulation capabilities. The string class essentially replaces the character array definitions that existed in C and all the string functions that go along with the character arrays.

The string class adds UNIX shell type string operators to the C++ language, as well as a large number of additional operators. Table 27.4 lists many of the operators that are available with the string class.

Table 27.4. String class operators.

Operator Meaning

str1 == str2 Returns TRUE if str1 is equal to str2
str1 != str2 Returns TRUE if str1 is not equal to str2
str1 < str2 Returns TRUE if str1 is less than str2
str1 <= str2 Returns TRUE if str1 is less than or equal to str2
str1 > str2 Returns TRUE if str1 is greater than str2
str1 >= str2 Returns TRUE if str1 is greater than or equal to str2
compare(str1,str2) Compares str1 to str2 without considering the case of the characters
str3 = str1 + str2 Stores the result of str1 concatenated with str2 into str3

A number of other operators are available in the string class for performing different types of string comparisons, concatenations, and substring extraction and manipulation.

Random Numbers

Classes are provided in the GCC C++ class library that allow you to generate several different kinds of random numbers. The classes used to generate these numbers are the Random class and the RNG class.

Data Collection

The class library provides two different classes that perform data collection and analysis functions. The two classes are SampleStatistic and SampleHistogram. The SampleStatistic class provides a way of collecting samples and also provides numerous statistical functions that can perform calculations on the collected data. Some of the calculations that can be performed are mean, variance, standard deviation, minimum, and maximum.

The SampleHistogram class is derived from the SampleStatistic class and supports the collection and display of samples in bucketed intervals.


Previous Table of Contents Next