-
Language:
English
-
Language:
English
Red Hat Training
A Red Hat training course is available for Red Hat Developer Toolset
User Guide
Installing and Using Red Hat Developer Toolset
Jaromír Hradílek
Matt Newsome
Abstract
Part I. Introduction
Chapter 1. Red Hat Developer Toolset
1.1. About Red Hat Developer Toolset
What Is New in Red Hat Developer Toolset 6.1
- The 64-bit ARM architecture (AArch64)
- IBM POWER, big endian
- IBM POWER, little endian
- IBM z Systems
Note
Table 1.1. Red Hat Developer Toolset Components
- Red Hat Developer Toolset can be used on multiple major and minor releases of Red Hat Enterprise Linux, as detailed in Section 1.3, “Compatibility”.
Important
/opt/
directory and is explicitly enabled by the user on demand using the scl
utility.
1.2. Main Features
- Red Hat Developer Toolset 6.1 adds support for Red Hat Enterprise Linux 6.9.
- The eu-readelf utility from package elfutils now allows showing just the symbol table of the given ELF section name instead of symbols from all symbol tables.
1.3. Compatibility

Figure 1.1. Red Hat Developer Toolset 6.1 Compatibility Matrix
1.4. Getting Access to Red Hat Developer Toolset
1.4.1. Using Red Hat Subscription Management
- Determine the pool ID of a subscription that provides Red Hat Software Collections (and thus also Red Hat Developer Toolset). To do so, type the following at a shell prompt as
root
to display a list of all subscriptions that are available for your system:subscription-manager list --available
For each available subscription, this command displays its name, unique identifier, expiration date, and other details related to your subscription. The pool ID is listed on a line beginning withPool ID
.For a complete list of subscriptions that provide access to Red Hat Developer Toolset, see https://access.redhat.com/solutions/472793. - Attach the appropriate subscription to your system by running the following command as
root
:subscription-manager attach --pool=pool_id
Replace pool_id with the pool ID you determined in the previous step. To verify the list of subscriptions your system has currently attached, at any time, run asroot
:subscription-manager list --consumed
- Determine the exact name of the Red Hat Software Collections repository. To do so, type the following at a shell prompt as
root
to retrieve repository metadata and to display a list of available Yum repositories:subscription-manager repos --list
The repository names depend on the specific version of Red Hat Enterprise Linux you are using and are in the following format:rhel-variant-rhscl-version-rpms rhel-variant-rhscl-version-debug-rpms rhel-variant-rhscl-version-source-rpms
In addition, certain packages, such as devtoolset-6-gcc-plugin-devel, depend on packages that are only available in the Optional channel. The repository names with these packages use the following format:rhel-version-variant-optional-rpms rhel-version-variant-optional-debug-rpms rhel-version-variant-optional-source-rpms
For both the regular repositories and optional repositories, replace variant with the Red Hat Enterprise Linux system variant (server
orworkstation
), and version with the Red Hat Enterprise Linux system version (6-eus
,6
, or7
). - Enable the repositories from step no. 3 by running the following command as
root
:subscription-manager repos --enable repository
Replace repository with the name of the repository to enable.
1.4.2. Using RHN Classic
- Determine the exact name of the Red Hat Software Collections channel. To do so, type the following at a shell prompt as
root
to display a list of all channels that are available to you:rhn-channel --available-channels
The name of the channel depends on the specific version of Red Hat Enterprise Linux you are using and is in the following format:rhel-x86_64-variant-version-rhscl-2
In addition, certain packages, such as devtoolset-6-gcc-plugin-devel, depend on packages that are only available in the Optional channel. The name of this channel uses the following format:rhel-x86_64-variant-optional-6
Replace variant with the Red Hat Enterprise Linux system variant (server
orworkstation
). - Subscribe the system to the channels from step no. 1 by running the following command as
root
:rhn-channel --add --channel=channel_name
Replace channel_name with the name of the channel to enable. - To verify the list of channels you are subscribed to, at any time, run as
root
:rhn-channel --list
1.5. Installing Red Hat Developer Toolset
Important
1.5.1. Installing All Available Components
root
:
yum install devtoolset-6
Note
scl
utility was installed along with the Red Hat Developer Toolset software collection.
1.5.2. Installing Individual Package Groups
Table 1.2. Red Hat Developer Toolset Meta Packages
Package Name | Description | Installed Components |
---|---|---|
devtoolset-6-perftools | Performance monitoring tools | SystemTap, Valgrind, OProfile, Dyninst |
devtoolset-6-toolchain | Development and debugging tools | GCC, make, GDB, binutils, elfutils, dwz, memstomp, strace, ltrace |
root
:
yum install package_name
root
:
~]# yum install devtoolset-6-toolchain
1.5.3. Installing Optional Packages
yum list available devtoolset-6-\*
root
:
yum install package_name
~]# yum install devtoolset-6-gdb-gdbserver devtoolset-6-gdb-doc
1.5.4. Installing Debugging Information
root
:
debuginfo-install package_name
~]# debuginfo-install devtoolset-6-dwz
rhel-variant-rhscl-version-debug-rpms
repository as described in Section 1.4.1, “Using Red Hat Subscription Management”. If your system is registered with RHN Classic, subscribe the system to the rhel-x86_64-variant-version-debuginfo
channel as described in Section 1.4.2, “Using RHN Classic”. For more information on how to get access to debuginfo packages, see https://access.redhat.com/site/solutions/9907.
Note
1.6. Updating Red Hat Developer Toolset
1.6.1. Updating to a Minor Version
root
to update your Red Hat Enterprise Linux installation:
yum update
Important
1.6.2. Updating to a Major Version
1.7. Uninstalling Red Hat Developer Toolset
root
:
yum remove devtoolset-6\* libasan libatomic libcilkrts libitm liblsan libtsan libubsan
Note
libatomic
and libitm
libraries, which the above command attempts to remove, because they are not required for a proper function of Red Hat Developer Toolset components on that system. Nevertheless, the above command works as expected even on Red Hat Enterprise Linux 7.
1.8. Using Red Hat Developer Toolset Container Images
Note
1.9. Additional Resources
Online Documentation
- Red Hat Subscription Management collection of guides — The Red Hat Subscription Management collection of guides provides detailed information on how to manage subscriptions on Red Hat Enterprise Linux.
- Red Hat Developer Toolset 6.1 Release Notes — The Release Notes for Red Hat Developer Toolset 6.1 contain more information.
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information on the Eclipse IDE, libraries and runtime support, compiling and building, debugging, and profiling on these systems.
- Red Hat Enterprise Linux 6 Installation Guide and Red Hat Enterprise Linux 7 Installation Guide — The Installation Guides for Red Hat Enterprise Linux 6 an 7 explain how to obtain, install, and update the system.
- Red Hat Enterprise Linux 6 Deployment Guide — The Deployment Guide for Red Hat Enterprise Linux 6 documents relevant information regarding the deployment, configuration, and administration of Red Hat Enterprise Linux 6.
- Red Hat Enterprise Linux 7 System Administrator's Guide — The System Administrator's Guide for Red Hat Enterprise Linux 7 documents relevant information regarding the deployment, configuration, and administration of Red Hat Enterprise Linux 7.
- Using Red Hat Software Collections Container Images — This book provides information on how to use container images based on Red Hat Software Collections. The available container images include applications, daemons, databases, as well as the Red Hat Developer Toolset container images. The images can be run on Red Hat Enterprise Linux 7 Server and Red Hat Enterprise Linux Atomic Host.
- Get Started with Docker Formatted Container Images on Red Hat Systems — The guide contains a comprehensive overview of information about building and using docker-formatted container images on Red Hat Enterprise Linux 7 and Red Hat Enterprise Linux Atomic.
See Also
- Appendix B, Changes in Version 6.1 provides a list of changes and improvements over the version of the GNU Compiler Collection and GNU Debugger in the previous version of Red Hat Developer Toolset.
Part II. Development Tools
Chapter 2. GNU Compiler Collection (GCC)
2.1. GNU C Compiler
2.1.1. Installing the C Compiler
2.1.2. Using the C Compiler
gcc
compiler as follows:
scl enable devtoolset-6 'gcc -o output_file source_file...'
-o
option is omitted, the compiler creates a file named a.out
by default.
scl enable devtoolset-6 'gcc -o object_file -c source_file'
-o
option is omitted, the compiler creates a file named after the source file with the .o
file extension. To link object files together and create a binary file, run:
scl enable devtoolset-6 'gcc -o output_file object_file...'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset gcc
as default:
scl enable devtoolset-6 'bash'
Note
gcc
you are using at any point, type the following at a shell prompt:
which gcc
gcc
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset gcc
:
gcc -v
Important
Note
-fcilkplus
option. A runtime library, libcilkrts
, is included in this release to support Cilk+. The libcilkrts
library has been a part of Red Hat Enterprise Linux since version 7.2, but the package is not included in all supported Red Hat Enterprise Linux releases. To enable dynamic linkage of binaries and libraries built with Red Hat Developer Toolset 6.1 GCC using Cilk+ features on supported Red Hat Enterprise Linux releases that do not contain libcilkrts
, install the libcilkrts.so
shared library from Red Hat Developer Toolset 6.1 with such binaries or libraries.
Example 2.1. Compiling a C Program on the Command Line
hello.c
with the following contents:
#include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, World!\n"); return 0; }
gcc
compiler from Red Hat Developer Toolset, type:
~]$ scl enable devtoolset-6 'gcc -o hello hello.c'
hello
in the current working directory.
2.1.3. Running a C Program
gcc
compiles a program, it creates an executable binary file. To run this program on the command line, change to the directory with the executable file and type:
./file_name
Example 2.2. Running a C Program on the Command Line
hello
binary file as shown in Example 2.1, “Compiling a C Program on the Command Line”, you can run it by typing the following at a shell prompt:
~]$ ./hello
Hello, World!
2.2. GNU C++ Compiler
2.2.1. Installing the C++ Compiler
2.2.2. Using the C++ Compiler
g++
compiler as follows:
scl enable devtoolset-6 'g++ -o output_file source_file...'
-o
option is omitted, the g++
compiler creates a file named a.out
by default.
scl enable devtoolset-6 'g++ -o object_file -c source_file'
-o
option is omitted, the g++
compiler creates a file named after the source file with the .o
file extension. To link object files together and create a binary file, run:
scl enable devtoolset-6 'g++ -o output_file object_file...'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset g++
as default:
scl enable devtoolset-6 'bash'
Note
g++
you are using at any point, type the following at a shell prompt:
which g++
g++
executable path will begin with /opt. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset g++
:
g++ -v
Important
Example 2.3. Compiling a C++ Program on the Command Line
hello.cpp
with the following contents:
#include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << "Hello, World!" << endl; return 0; }
g++
compiler from Red Hat Developer Toolset, type:
~]$ scl enable devtoolset-6 'g++ -o hello hello.cpp'
hello
in the current working directory.
2.2.3. Running a C++ Program
g++
compiles a program, it creates an executable binary file. To run this program on the command line, change to the directory with the executable file and type:
./file_name
Example 2.4. Running a C++ Program on the Command Line
hello
binary file as shown in Example 2.3, “Compiling a C++ Program on the Command Line”, you can run it by typing the following at a shell prompt:
~]$ ./hello
Hello, World!
2.2.4. C++ Compatibility
-std
mode are compatible with any other of those compilers in C++98 mode.
Important
2.2.4.1. C++ ABI
-std=c++98
or -std=gnu++98
can be freely mixed with binaries and shared libraries built by the Red Hat Enterprise Linux 5, 6 or 7 system toolchain GCC. Red Hat recommends use of the -std=c++98
or -std=gnu++98
modes for production software development.
-std=gnu++14
.
-std=c++11
, -std=gnu++11
, -std=c++14
, and -std=gnu++14
options cannot be guaranteed, and so is not supported.
Important
-std=c++0x
or -std=gnu++0x
flags, with those built with the -std=c++11
or -std=gnu++11
or -std=c++14
or -std=gnu++14
flags using the GCC in Red Hat Developer Toolset is explicitly not supported.
.o
/.a
files), the Red Hat Developer Toolset toolchain should be used for any linkage. This ensures any newer library features provided only by Red Hat Developer Toolset are resolved at link-time.
-Wabi
will now display a warning about code that uses the old mangling.
2.3. GNU Fortran Compiler
2.3.1. Installing the Fortran Compiler
2.3.2. Using the Fortran Compiler
gfortran
compiler as follows:
scl enable devtoolset-6 'gfortran -o output_file source_file...'
-o
option is omitted, the compiler creates a file named a.out
by default.
scl enable devtoolset-6 'gfortran -o object_file -c source_file'
-o
option is omitted, the compiler creates a file named after the source file with the .o
file extension. To link object files together and create a binary file, run:
scl enable devtoolset-6 'gfortran -o output_file object_file...'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset gfortran
as default:
scl enable devtoolset-6 'bash'
Note
gfortran
you are using at any point, type the following at a shell prompt:
which gfortran
gfortran
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset gfortran
:
gfortran -v
Important
Example 2.5. Compiling a Fortran Program on the Command Line
hello.f
with the following contents:
program hello print *, "Hello, World!" end program hello
gfortran
compiler from Red Hat Developer Toolset, type:
~]$ scl enable devtoolset-6 'gfortran -o hello hello.f'
hello
in the current working directory.
2.3.3. Running a Fortran Program
gfortran
compiles a program, it creates an executable binary file. To run this program on the command line, change to the directory with the executable file and type:
./file_name
Example 2.6. Running a Fortran Program on the Command Line
hello
binary file as shown in Example 2.5, “Compiling a Fortran Program on the Command Line”, you can run it by typing the following at a shell prompt:
~]$ ./hello
Hello, World!
2.4. Additional Resources
Installed Documentation
- gcc(1) — The manual page for the
gcc
compiler provides detailed information on its usage; with few exceptions,g++
accepts the same command line options asgcc
. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man gcc'
- gfortran(1) — The manual page for the
gfortran
compiler provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man gfortran'
- C++ Standard Library Documentation — Documentation on the C++ standard library can be optionally installed by typing the following at a shell prompt as
root
:yum install devtoolset-6-libstdc++-docs
Once installed, HTML documentation is available at/opt/rh/devtoolset-6/root/usr/share/doc/devtoolset-6-libstdc++-docs-6.3.1/html/index.html
.
Online Documentation
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide in-depth information about GCC.
- Using the GNU Compiler Collection — The official GCC manual provides an in-depth description of the GNU compilers and their usage.
- The GNU C++ Library — The GNU C++ library documentation provides detailed information about the GNU implementation of the standard C++ library.
- The GNU Fortran Compiler — The GNU Fortran compiler documentation provides detailed information on
gfortran
's usage.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 4, binutils explains how to use the binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils explains how to use elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 6, dwz explains how to use dwz to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
- Chapter 7, GNU Debugger (GDB) provides information on how to debug programs written in C, C++, and Fortran.
Chapter 3. GNU make
3.1. Installing make
3.2. Using make
make
tool as follows:
scl enable devtoolset-6 'make source_file_without_extension'
source_file_without_extension
in the current working directory.
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset make
as default:
scl enable devtoolset-6 'bash'
Note
make
you are using at any point, type the following at a shell prompt:
which make
make
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset make
:
make -v
Example 3.1. Building a C Program Using make
hello.c
with the following contents:
#include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, World!\n"); return 0; }
make
utility from Red Hat Developer Toolset, type:
~]$ scl enable devtoolset-6 'make hello'
cc hello.c -o hello
hello
in the current working directory.
3.3. Using Makefiles
GNUmakefile
, makefile
, or Makefile
in the current directory. To specify another file name, use:
make -f make_file
~]$ scl enable devtoolset-6 'info make'
Example 3.2. Building a C Program Using a Makefile
Makefile
for building the simple C program introduced in Example 3.1, “Building a C Program Using make”. The Makefile defines some variables and specifies four rules, which consist of targets and their recipes. Note that the lines with recipes must start with the TAB character:
CC=gcc CFLAGS=-c -Wall SOURCE=hello.c OBJ=$(SOURCE:.c=.o) EXE=hello all: $(SOURCE) $(EXE) $(EXE): $(OBJ) $(CC) $(OBJ) -o $@ .c.o: $(CC) $(CFLAGS) $< -o $@ clean: rm -rf $(OBJ) $(EXE)
hello.c
program using this Makefile, run the make
utility:
~]$ scl enable devtoolset-6 'make'
gcc -c -Wall hello.c -o hello.o
gcc hello.o -o hello
hello.o
and a new binary file called hello
in the current working directory.
~]$ scl enable devtoolset-6 'make clean'
rm -rf hello.o hello
3.4. Additional Resources
Installed Documentation
- make(1) — The manual page for the
make
utility provides information on its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man make'
- The full make manual, which includes detailed information about Makefile syntax, is also available in the Texinfo format. To display the info manual for the version included in Red Hat Developer Toolset, type:
scl enable devtoolset-6 'info make'
Online Documentation
- GNU make — The official GNU make manual provides an in-depth description of the GNU make utility, Makefile syntax, and their usage.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) explains how to use the GNU Compiler Collection, a portable compiler suite with support for a wide selection of programming languages.
- Chapter 4, binutils explains how to use the binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils explains how to use elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 6, dwz explains how to use dwz to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
- Chapter 7, GNU Debugger (GDB) provides information on how to debug programs written in C, C++, and Fortran.
Chapter 4. binutils
Table 4.1. Tools Included in binutils for Red Hat Developer Toolset
4.1. Installing binutils
4.2. Using the GNU Assembler
as
tool as follows:
scl enable devtoolset-6 'as [option...] -o object_file source_file'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset as
as default:
scl enable devtoolset-6 'bash'
Note
as
you are using at any point, type the following at a shell prompt:
which as
as
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset as
:
as -v
4.3. Using the GNU Linker
ld
tool as follows:
scl enable devtoolset-6 'ld [option...] -o output_file object_file...'
-o
option is omitted, the compiler creates a file named a.out
by default.
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset ld
as default:
scl enable devtoolset-6 'bash'
Note
ld
you are using at any point, type the following at a shell prompt:
which ld
ld
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset ld
:
ld -v
4.4. Using Other Binary Tools
scl enable devtoolset-6 'tool [option...] file_name'
objdump
tool to inspect an object file, type:
scl enable devtoolset-6 'objdump [option...] object_file'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset binary tools as default:
scl enable devtoolset-6 'bash'
Note
which objdump
objdump
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset objdump
:
objdump -v
4.5. Additional Resources
Installed Documentation
- as(1), ld(1), addr2line(1), ar(1), c++filt(1), dwp(1), elfedit(1), gprof(1), nm(1), objcopy(1), objdump(1), ranlib(1), readelf(1), size(1), strings(1), strip(1), — Manual pages for various binutils tools provide more information about their respective usage. To display a manual page for the version included in Red Hat Developer Toolset, type:
scl enable devtoolset-6 'man tool'
Online Documentation
- Documentation for binutils — The binutils documentation provides an in-depth description of the binary tools and their usage.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 5, elfutils explains how to use elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 2, GNU Compiler Collection (GCC) provides information on how to compile programs written in C, C++, and Fortran.
Chapter 5. elfutils
eu-objdump
, eu-readelf
, and other utilities that allow you to inspect and manipulate ELF files. See Table 5.1, “Tools Included in elfutils for Red Hat Developer Toolset” for a complete list of binary tools that are distributed with the Red Hat Developer Toolset version of elfutils.
Table 5.1. Tools Included in elfutils for Red Hat Developer Toolset
5.1. Installing elfutils
5.2. Using elfutils
scl enable devtoolset-6 'tool [option...] file_name'
eu-objdump
tool to inspect an object file, type:
scl enable devtoolset-6 'eu-objdump [option...] object_file'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset binary tools as default:
scl enable devtoolset-6 'bash'
Note
which eu-objdump
eu-objdump
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset eu-objdump
:
eu-objdump -V
5.3. Additional Resources
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) provides information on how to compile programs written in C, C++, and Fortran.
- Chapter 4, binutils explains how to use the binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 6, dwz explains how to use dwz to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
Chapter 6. dwz
dwz
replaces DWARF information representation with equivalent smaller representation where possible and reduces the amount of duplication by using techniques from Appendix E of the DWARF Standard.
6.1. Installing dwz
dwz
utility is provided by the devtoolset-6-dwz package and is automatically installed with devtoolset-6-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
6.2. Using dwz
dwz
tool as follows:
scl enable devtoolset-6 'dwz [option...] file_name'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset dwz
as default:
scl enable devtoolset-6 'bash'
Note
dwz
you are using at any point, type the following at a shell prompt:
which dwz
dwz
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset dwz
:
dwz -v
6.3. Additional Resources
Installed Documentation
- dwz(1) — The manual page for the
dwz
utility provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man dwz'
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) provides information on how to compile programs written in C, C++, and Fortran.
- Chapter 4, binutils explains how to use the binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils explains how to use elfutils, a collection of binary tools to inspect and manipulate ELF files.
Part III. Debugging Tools
Chapter 7. GNU Debugger (GDB)
7.1. Installing the GNU Debugger
7.2. Preparing a Program for Debugging
Compiling Programs with Debugging Information
gcc
compiler is run with the -g
option. To do so on the command line, use a command in the following form:
scl enable devtoolset-6 'gcc -g -o output_file input_file...'
scl enable devtoolset-6 'g++ -g -o output_file input_file...'
Example 7.1. Compiling a C Program With Debugging Information
fibonacci.c
that has the following contents:
#include <stdio.h> #include <limits.h> int main (int argc, char *argv[]) { unsigned long int a = 0; unsigned long int b = 1; unsigned long int sum; while (b < LONG_MAX) { printf("%ld ", b); sum = a + b; a = b; b = sum; } return 0; }
~]$ scl enable devtoolset-6 'gcc -g -o fibonacci fibonacci.c'
fibonacci
in the current working directory.
Installing Debugging Information for Existing Packages
root
:
debuginfo-install
package_name
debuginfo-install
utility to be available on your system.
Example 7.2. Installing Debugging Information for the glibc Package
~]# debuginfo-install glibc
Loaded plugins: product-id, refresh-packagekit, subscription-manager
--> Running transaction check
---> Package glibc-debuginfo.x86_64 0:2.17-105.el7 will be installed
...
7.3. Running the GNU Debugger
scl enable devtoolset-6 'gdb file_name'
gdb
debugger in interactive mode and displays the default prompt, (gdb)
. To quit the debugging session and return to the shell prompt, run the following command at any time:
quit
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset gdb
as default:
scl enable devtoolset-6 'bash'
Note
gdb
you are using at any point, type the following at a shell prompt:
which gdb
gdb
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset gdb
:
gdb -v
Example 7.3. Running the gdb Utility on the fibonacci Binary File
fibonacci
binary file as shown in Example 7.1, “Compiling a C Program With Debugging Information”, you can start debugging it with gdb
by typing the following at a shell prompt:
~]$ scl enable devtoolset-6 'gdb fibonacci'
GNU gdb (GDB) Red Hat Enterprise Linux (7.12.1-47.el7)
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
7.4. Listing Source Code
list
gdb
displays the first ten lines of the source code, and any subsequent use of this command lists another ten lines. Once you start the execution, gdb
displays the lines that are surrounding the line on which the execution stops, typically when you set a breakpoint.
list
[file_name:]line_number
list
[file_name:]function_name
list
command displays by running the following command:
set
listsize
number
Example 7.4. Listing the Source Code of the fibonacci Binary File
fibonacci.c
file listed in Example 7.1, “Compiling a C Program With Debugging Information” has exactly 17 lines. Assuming that you have compiled it with debugging information and you want the gdb
utility to be capable of listing the entire source code, you can run the following command to change the number of listed lines to 20:
(gdb) set listsize 20
list
command with no additional arguments:
(gdb) list
1 #include <stdio.h>
2 #include <limits.h>
3
4 int main (int argc, char *argv[]) {
5 unsigned long int a = 0;
6 unsigned long int b = 1;
7 unsigned long int sum;
8
9 while (b < LONG_MAX) {
10 printf("%ld ", b);
11 sum = a + b;
12 a = b;
13 b = sum;
14 }
15
16 return 0;
17 }
7.5. Setting Breakpoints
Setting a New Breakpoint
break
[file_name:]line_number
break
[file_name:]function_name
Example 7.5. Setting a New Breakpoint
fibonacci.c
file listed in Example 7.1, “Compiling a C Program With Debugging Information” with debugging information, you can set a new breakpoint at line 10 by running the following command:
(gdb) break 10
Breakpoint 1 at 0x4004e5: file fibonacci.c, line 10.
Listing Breakpoints
info
breakpoints
Example 7.6. Listing Breakpoints
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004004e5 in main at fibonacci.c:10
Deleting Existing Breakpoints
clear
line_number
clear
function_name
Example 7.7. Deleting an Existing Breakpoint
fibonacci.c
file listed in Example 7.1, “Compiling a C Program With Debugging Information” with debugging information, you can set a new breakpoint at line 7 by running the following command:
(gdb) break 7
Breakpoint 2 at 0x4004e3: file fibonacci.c, line 7.
(gdb) clear 7
Deleted breakpoint 2
7.6. Starting Execution
run
run
command:
run
argument…
Example 7.8. Executing the fibonacci Binary File
fibonacci
binary file by running the following command:
(gdb) run
Starting program: /home/john/fibonacci
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
7.7. Displaying Current Values
gdb
utility allows you to display the value of almost anything that is relevant to the program, from a variable of any complexity to a valid expression or even a library function. However, the most common task is to display the value of a variable.
print
variable_name
Example 7.9. Displaying the Current Values of Variables
fibonacci
binary stopped after reaching the breakpoint at line 10, you can display the current values of variables a
and b
as follows:
(gdb)print a
$1 = 0 (gdb)print b
$2 = 1
7.8. Continuing Execution
continue
continue
command in the following form:
continue
number
gdb
utility also allows you to stop the execution after executing a single line of code. To do so, run:
step
step
command in the following form:
step
number
Example 7.10. Continuing the Execution of the fibonacci Binary File
fibonacci
binary stopped after reaching the breakpoint at line 10, you can resume the execution by running the following command:
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
(gdb) step 3
13 b = sum;
sum
variable before it is assigned to b
:
(gdb) print sum
$3 = 2
7.9. Additional Resources
Online Documentation
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information on the GNU Debugger and debugging.
- GDB Documentation — The official GDB documentation includes the GDB User Manual and other reference material.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) provides further information on how to compile programs written in C, C++, and Fortran.
- Chapter 8, strace documents how to use the strace utility to monitor system calls that a program uses and signals it receives.
- Chapter 10, memstomp documents how to use the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 8. strace
8.1. Installing strace
strace
utility is provided by the devtoolset-6-strace package and is automatically installed with devtoolset-6-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
8.2. Using strace
strace
utility on a program you want to analyze, type the following at a shell prompt:
scl enable devtoolset-6 'strace program [argument...]'
-p
command line option followed by the process ID:
scl enable devtoolset-6 'strace -p process_id'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset strace
as default:
scl enable devtoolset-6 'bash'
Note
strace
you are using at any point, type the following at a shell prompt:
which strace
strace
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset strace
:
strace -V
8.2.1. Redirecting Output to a File
strace
prints the name of each system call, its arguments and the return value to standard error output. To redirect this output to a file, use the -o
command line option followed by the file name:
scl enable devtoolset-6 'strace -o file_name program [argument...]'
Example 8.1. Redirecting Output to a File
fibonacci
file from Example 7.1, “Compiling a C Program With Debugging Information”. This executable file displays the Fibonacci sequence and optionally allows you to specify how many members of this sequence to list. To run the strace
utility on this file and redirect the trace output to fibonacci.log
, type:
~]$ scl enable devtoolset-6 'strace -o fibonacci.log ./fibonacci 20'
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
fibonacci.log
in the current working directory.
8.2.2. Tracing Selected System Calls
strace
utility with the -e
command line option:
scl enable devtoolset-6 'strace -e expression program [argument...]'
Table 8.1. Commonly Used Values of the -e Option
Value | Description |
---|---|
file | System calls that accept a file name as an argument. |
process | System calls that are related to process management. |
network | System calls that are related to networking. |
signal | System calls that are related to signal management. |
ipc | System calls that are related to inter-process communication (IPC). |
desc | System calls that are related to file descriptors. |
Example 8.2. Tracing Selected System Calls
employee
file from Example 10.1, “Using memstomp”. To run the strace
utility on this executable file and trace only the mmap
and munmap
system calls, type:
~]$ scl enable devtoolset-6 'strace -e mmap,munmap ./employee'
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f896c744000
mmap(NULL, 61239, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f896c735000
mmap(0x3146a00000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3146a00000
mmap(0x3146d89000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3146d89000
mmap(0x3146d8e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3146d8e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f896c734000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f896c733000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f896c732000
munmap(0x7f896c735000, 61239) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f896c743000
John,john@example.comDoe,
+++ exited with 0 +++
8.2.3. Displaying Time Stamps
strace
utility with the -t
command line option:
scl enable devtoolset-6 'strace -t program [argument...]'
-t
option twice:
scl enable devtoolset-6 'strace -tt program [argument...]'
-r
command line option:
scl enable devtoolset-6 'strace -r program [argument...]'
Example 8.3. Displaying Time Stamps
pwd
. To run the strace
utility on this file and include time stamps in the output, type:
~]$ scl enable devtoolset-6 'strace -tt pwd'
19:43:28.011815 execve("./pwd", ["./pwd"], [/* 36 vars */]) = 0
19:43:28.012128 brk(0) = 0xcd3000
19:43:28.012174 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc869cb0000
19:43:28.012427 open("/etc/ld.so.cache", O_RDONLY) = 3
19:43:28.012446 fstat(3, {st_mode=S_IFREG|0644, st_size=61239, ...}) = 0
19:43:28.012464 mmap(NULL, 61239, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc869ca1000
19:43:28.012483 close(3) = 0
...
19:43:28.013410 +++ exited with 0 +++
8.2.4. Displaying a Summary
strace
utility with the -c
command line option:
scl enable devtoolset-6 'strace -c program [argument...]'
Example 8.4. Displaying a Summary
lsblk
. To run the strace
utility on this file and display a trace summary, type:
~]$ scl enable devtoolset-6 'strace -c lsblk > /dev/null'
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
80.88 0.000055 1 106 16 open
19.12 0.000013 0 140 munmap
0.00 0.000000 0 148 read
0.00 0.000000 0 1 write
0.00 0.000000 0 258 close
0.00 0.000000 0 37 2 stat
...
------ ----------- ----------- --------- --------- ----------------
100.00 0.000068 1790 35 total
8.3. Additional Resources
Installed Documentation
- strace(1) — The manual page for the
strace
utility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man strace'
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 9, ltrace provides information on how to trace program library calls using the ltrace tool.
- Chapter 7, GNU Debugger (GDB) provides information on how to debug programs written in C, C++, and Fortran.
- Chapter 10, memstomp documents how to use the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 9. ltrace
9.1. Installing ltrace
ltrace
utility is provided by the devtoolset-6-ltrace package and is automatically installed with devtoolset-6-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
9.2. Using ltrace
ltrace
utility on a program you want to analyze, type the following at a shell prompt:
scl enable devtoolset-6 'ltrace program [argument...]'
-p
command line option followed by the process ID:
scl enable devtoolset-6 'ltrace -p process_id'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset ltrace
as default:
scl enable devtoolset-6 'bash'
Note
ltrace
you are using at any point, type the following at a shell prompt:
which ltrace
ltrace
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset ltrace
:
ltrace -V
9.2.1. Redirecting Output to a File
ltrace
prints the name of each system call, its arguments and the return value to standard error output. To redirect this output to a file, use the -o
command line option followed by the file name:
scl enable devtoolset-6 'ltrace -o file_name program [argument...]'
Example 9.1. Redirecting Output to a File
fibonacci
file from Example 7.1, “Compiling a C Program With Debugging Information”. This executable file displays the Fibonacci sequence and optionally allows you to specify how many members of this sequence to list. To run the ltrace
utility on this file and redirect the trace output to fibonacci.log
, type:
~]$ scl enable devtoolset-6 'ltrace -o fibonacci.log ./fibonacci 20'
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
fibonacci.log
in the current working directory.
9.2.2. Tracing Selected Library Calls
ltrace
utility with the -e
command line option:
scl enable devtoolset-6 'ltrace -e expression program [argument...]'
malloc
or free
) and patterns that identify library SONAMEs (such as libc.so
). For example, to trace call to the malloc
and free
function but to omit those that are done by the libc
library, use:
scl enable devtoolset-6 'ltrace -e malloc+free-@libc.so* program
'
Example 9.2. Tracing Selected Library Calls
ls
command. To run the ltrace
utility on this program and trace only the opendir
, readdir
, and closedir
function calls, type:
~]$ scl enable devtoolset-6 'ltrace -e opendir+readdir+closedir ls'
ls->opendir(".") = { 3 }
ls->readdir({ 3 }) = { 61533, "." }
ls->readdir({ 3 }) = { 131, ".." }
ls->readdir({ 3 }) = { 67185100, "BUILDROOT" }
ls->readdir({ 3 }) = { 202390772, "SOURCES" }
ls->readdir({ 3 }) = { 60249, "SPECS" }
ls->readdir({ 3 }) = { 67130110, "BUILD" }
ls->readdir({ 3 }) = { 136599168, "RPMS" }
ls->readdir({ 3 }) = { 202383274, "SRPMS" }
ls->readdir({ 3 }) = nil
ls->closedir({ 3 }) = 0
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
+++ exited (status 0) +++
9.2.3. Displaying Time Stamps
ltrace
utility with the -t
command line option:
scl enable devtoolset-6 'ltrace -t program [argument...]'
-t
option twice:
scl enable devtoolset-6 'ltrace -tt program [argument...]'
-r
command line option:
scl enable devtoolset-6 'ltrace -r program [argument...]'
Example 9.3. Displaying Time Stamps
pwd
command. To run the ltrace
utility on this program and include time stamps in the output, type:
~]$ scl enable devtoolset-6 'ltrace -tt pwd'
13:27:19.631371 __libc_start_main([ "pwd" ] <unfinished ...>
13:27:19.632240 getenv("POSIXLY_CORRECT") = nil
13:27:19.632520 strrchr("pwd", '/') = nil
13:27:19.632786 setlocale(LC_ALL, "") = "en_US.UTF-8"
13:27:19.633220 bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale"
13:27:19.633471 textdomain("coreutils") = "coreutils"
...
13:27:19.637110 +++ exited (status 0) +++
9.2.4. Displaying a Summary
ltrace
utility with the -c
command line option:
scl enable devtoolset-6 'ltrace -c program [argument...]'
Example 9.4. Displaying a Summary
lsblk
command. To run the ltrace
utility on this program and display a trace summary, type:
~]$ scl enable devtoolset-6 'ltrace -c lsblk > /dev/null'
% time seconds usecs/call calls function
------ ----------- ----------- --------- --------------------
53.60 0.261644 261644 1 __libc_start_main
4.48 0.021848 58 374 mbrtowc
4.41 0.021524 57 374 wcwidth
4.39 0.021409 57 374 __ctype_get_mb_cur_max
4.38 0.021359 57 374 iswprint
4.06 0.019838 74 266 readdir64
3.21 0.015652 69 224 strlen
...
------ ----------- ----------- --------- --------------------
100.00 0.488135 3482 total
9.3. Additional Resources
Installed Documentation
- ltrace(1) — The manual page for the
ltrace
utility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man ltrace'
Online Documentation
- ltrace for RHEL 6 and 7 — This article on the Red Hat Developer Blog offers additional in-depth information (including practical examples) on how to use ltrace for application debugging.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 8, strace provides information on how to trace program system calls using the strace tool.
- Chapter 7, GNU Debugger (GDB) provides information on how to debug programs written in C, C++, and Fortran.
- Chapter 10, memstomp documents how to use the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 10. memstomp
memstomp
utility inspects applications without the need to recompile them. However, it is much faster than this tool and therefore serves as a convenient alternative to it.
Table 10.1. Function Calls Inspected by memstomp
Function | Description |
---|---|
memcpy | Copies n bytes from one memory area to another and returns a pointer to the second memory area. |
memccpy | Copies a maximum of n bytes from one memory area to another and stops when a certain character is found. It either returns a pointer to the byte following the last written byte, or NULL if the given character is not found. |
mempcpy | Copies n bytes from one memory area to another and returns a pointer to the byte following the last written byte. |
strcpy | Copies a string from one memory area to another and returns a pointer to the second string. |
stpcpy | Copies a string from one memory area to another and returns a pointer to the terminating null byte of the second string. |
strncpy | Copies a maximum of n characters from one string to another and returns a pointer to the second string. |
stpncpy | Copies a maximum of n characters from one string to another. It either returns a pointer to the terminating null byte of the second string, or if the string is not null-terminated, a pointer to the byte following the last written byte. |
strcat | Appends one string to another while overwriting the terminating null byte of the second string and adding a new one at its end. It returns a pointer to the new string. |
strncat | Appends a maximum of n characters from one string to another while overwriting the terminating null byte of the second string and adding a new one at its end. It returns a pointer to the new string. |
wmemcpy | The wide-character equivalent of the memcpy () function that copies n wide characters from one array to another and returns a pointer to the second array. |
wmempcpy | The wide-character equivalent of the mempcpy () function that copies n wide characters from one array to another and returns a pointer to the byte following the last written wide character. |
wcscpy | The wide-character equivalent of the strcpy () function that copies a wide-character string from one array to another and returns a pointer to the second array. |
wcsncpy | The wide-character equivalent of the strncpy () function that copies a maximum of n wide characters from one array to another and returns a pointer to the second string. |
wcscat | The wide-character equivalent of the strcat () function that appends one wide-character string to another while overwriting the terminating null byte of the second string and adding a new one at its end. It returns a pointer to the new string. |
wcsncat | The wide-character equivalent of the strncat () function that appends a maximum of n wide characters from one array to another while overwriting the terminating null byte of the second wide-character string and adding a new one at its end. It returns a pointer to the new string. |
10.1. Installing memstomp
memstomp
utility is provided by the devtoolset-6-memstomp package and is automatically installed with devtoolset-6-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
10.2. Using memstomp
memstomp
utility on a program you want to analyze, type the following at a shell prompt:
scl enable devtoolset-6 'memstomp program [argument...]'
--kill
(or -k
for short) command line option:
scl enable devtoolset-6 'memstomp --kill program [argument...]'
--kill
option is especially recommended if you are analyzing a multi-threaded program; the internal implementation of backtraces is not thread-safe and running the memstomp
utility on a multi-threaded program without this command line option can therefore produce unreliable results.
--debug-info
(or -d
) command line option to produce a more detailed backtrace:
scl enable devtoolset-6 'memstomp --debug-info program [argument...]'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset memstomp
as default:
scl enable devtoolset-6 'bash'
Example 10.1. Using memstomp
employee.c
with the following contents:
#include <stdio.h> #include <string.h> #define BUFSIZE 80 int main(int argc, char *argv[]) { char employee[BUFSIZE] = "John,Doe,john@example.com"; char name[BUFSIZE] = {0}; char surname[BUFSIZE] = {0}; char *email; size_t length; /* Extract the information: */ memccpy(name, employee, ',', BUFSIZE); length = strlen(name); memccpy(surname, employee + length, ',', BUFSIZE); length += strlen(surname); email = employee + length; /* Compose the new entry: */ strcat(employee, surname); strcpy(employee, name); strcat(employee, email); /* Print the result: */ puts(employee); return 0; }
employee
by using the following command:
~]$ scl enable devtoolset-6 'gcc -rdynamic -g -o employee employee.c'
~]$ scl enable devtoolset-6 'memstomp --debug-info ./employee'
memstomp: 0.1.4 successfully initialized for process employee (pid 14887).
strcat(dest=0x7fff13afc265, src=0x7fff13afc269, bytes=21) overlap for employee(14887)
??:0 strcpy()
??:0 strcpy()
??:0 _Exit()
??:0 strcat()
employee.c:26 main()
??:0 __libc_start_main()
??:0 _start()
John,john@example.comDoe,
10.3. Additional Resources
memstomp
and its features is beyond the scope of this book. For more information, see the resources listed below.
Installed Documentation
- memstomp(1) — The manual page for the
memstomp
utility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man memstomp'
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 7, GNU Debugger (GDB) provides information on how to debug programs written in C, C++, and Fortran.
- Chapter 8, strace documents how to use the strace utility to monitor system calls that a program uses and signals it receives.
- Chapter 12, Valgrind explains how to use Valgrind to profile applications and detect memory errors and memory management problems, such as the use of uninitialized memory, improper allocation and freeing of memory, and the use of improper arguments in system calls.
Part IV. Performance Monitoring Tools
Chapter 11. SystemTap
netstat
, ps
, top
, and iostat
, others include pretty-printed function callgraph traces or tools for working around security bugs.
Table 11.1. Tools Distributed with SystemTap for Red Hat Developer Toolset
11.1. Installing SystemTap
SystemTap
is provided by the devtoolset-6-systemtap package and is automatically installed with devtoolset-6-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.
Note
stap-prep
utility as follows:
scl enable devtoolset-6 'stap-prep'
root
user, the utility automatically offers the packages for installation. For more information on how to install these packages on your system, see the Red Hat Enterprise Linux 6 SystemTap Beginners Guide or the Red Hat Enterprise Linux 7 SystemTap Beginners Guide.
11.2. Using SystemTap
scl enable devtoolset-6 'tool [option...]'
stap
tool to build an instrumentation module, type:
scl enable devtoolset-6 'stap [option...] argument...'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset SystemTap as default:
scl enable devtoolset-6 'bash'
Note
which stap
stap
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset SystemTap:
stap -V
11.3. Additional Resources
Installed Documentation
- stap(1) — The manual page for the
stap
command provides detailed information on its usage, as well as references to other related manual pages. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man stap'
- staprun(8) — The manual page for the
staprun
command provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man staprun'
- SystemTap Tapset Reference Manual — HTML documentation on the most common tapset definitions is located at
/opt/rh/devtoolset-6/root/usr/share/doc/devtoolset-6-systemtap-client-2.8/index.html
.
Online Documentation
- Red Hat Enterprise Linux 6 SystemTap Beginners Guide and Red Hat Enterprise Linux 7 SystemTap Beginners Guide — The SystemTap Beginners Guides for Red Hat Enterprise Linux 6 and 7 provide an introduction to SystemTap and its usage.
- Red Hat Enterprise Linux 6 SystemTap Tapset Reference and Red Hat Enterprise Linux 7 SystemTap Tapset Reference — The SystemTap Tapset Reference for Red Hat Enterprise Linux 6 and 7 provides further details about SystemTap.
- The SystemTap Documentation — The official SystemTap documentation provides further documentation on SystemTap, as well as numerous examples of SystemTap scripts.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 12, Valgrind explains how to use Valgrind to profile applications and detect memory errors and memory management problems, such as the use of uninitialized memory, improper allocation and freeing of memory, and the use of improper arguments in system calls.
- Chapter 13, OProfile explains how to use OProfile to determine which sections of code consume the greatest amount of CPU time and why.
- Chapter 14, Dyninst documents how to use the Dyninst library to instrument a user-space executable.
Chapter 12. Valgrind
Table 12.1. Tools Distributed with Valgrind for Red Hat Developer Toolset
12.1. Installing Valgrind
Note
12.2. Using Valgrind
scl enable devtoolset-6 'valgrind [--tool=tool] program [argument...]'
--tool
command line option must be specified in lower case, and if this option is omitted, Valgrind uses Memcheck by default. For example, to run Cachegrind on a program to identify the sources of cache misses, type:
scl enable devtoolset-6 'valgrind --tool=cachegrind program [argument...]'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset Valgrind as default:
scl enable devtoolset-6 'bash'
Note
which valgrind
valgrind
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset Valgrind:
valgrind --version
12.3. Additional Resources
Installed Documentation
- valgrind(1) — The manual page for the
valgrind
utility provides detailed information on how to use Valgrind. To display the manual page for the version included in Red Hat Developer Toolset, type:scl enable devtoolset-6 'man valgrind'
- Valgrind Documentation — HTML documentation for Valgrind is located at
/opt/rh/devtoolset-6/root/usr/share/doc/devtoolset-6-valgrind-3.9.0/html/index.html
.
Online Documentation
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information about Valgrind and its Eclipse plug-in.
- Red Hat Enterprise Linux 6 Performance Tuning Guide Red Hat Enterprise Linux 7 Performance Tuning Guide — The Performance Tuning Guides for Red Hat Enterprise Linux 6 and 7 provide more detailed information about using Valgrind to profile applications.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 10, memstomp documents how to use the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
- Chapter 11, SystemTap provides an introduction to SystemTap and explains how to use it to monitor the activities of a running system.
- Chapter 13, OProfile explains how to use OProfile to determine which sections of code consume the greatest amount of CPU time and why.
- Chapter 14, Dyninst documents how to use the Dyninst library to instrument a user-space executable.
Chapter 13. OProfile
root
privileges to run.
Table 13.1. Tools Distributed with OProfile for Red Hat Developer Toolset
13.1. Installing OProfile
13.2. Using OProfile
root
:
scl enable devtoolset-6 'tool [option
...]'
ophelp
command to list available events in the XML format, type:
scl enable devtoolset-6 'ophelp -X'
scl
utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset OProfile as default:
scl enable devtoolset-6 'bash'
Note
which operf
operf
executable path will begin with /opt
. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset OProfile:
operf --version
13.3. Additional Resources
Installed Documentation
- oprofile(1) — The manual page named oprofile provides an overview of OProfile and available tools. To display the manual page for the version included in Red Hat Developer Toolset, type:
scl enable devtoolset-6 'man oprofile'
- opannotate(1), oparchive(1), operf(1), opgprof(1), ophelp(1), opimport(1), opreport(1) — Manual pages for various tools distributed with OProfile provide more information on their respective usage. To display the manual page for the version included in Red Hat Developer Toolset, type:
scl enable devtoolset-6 'man tool'
Online Documentation
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information on OProfile.
- Red Hat Enterprise Linux 6 Deployment Guide — The Deployment Guide for Red Hat Enterprise Linux 6 describes in detail how to install, configure, and start using OProfile on this system.
- Red Hat Enterprise Linux 7 System Administrator's Guide — The System Administrator's Guide for Red Hat Enterprise Linux 7 documents how to use the
operf
tool.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 11, SystemTap provides an introduction to SystemTap and explains how to use it to monitor the activities of a running system.
- Chapter 12, Valgrind explains how to use Valgrind to profile applications and detect memory errors and memory management problems, such as the use of uninitialized memory, improper allocation and freeing of memory, and the use of improper arguments in system calls.
- Chapter 14, Dyninst documents how to use the Dyninst library to instrument a user-space executable.
Chapter 14. Dyninst
root
users to instrument user-space executables.
14.1. Installing Dyninst
root
:
yum install devtoolset-6-dyninst-devel
root
:
yum install devtoolset-6-dyninst-doc
14.2. Using Dyninst
14.2.1. Using Dyninst with SystemTap
root
users to instrument user-space executables, run the stap
command with the --dyninst
(or --runtime=dyninst
) command line option. This tells stap
to translate a SystemTap script into C code that uses the Dyninst library, compile this C code into a shared library, and then load the shared library and run the script. Note that when executed like this, the stap
command also requires the -c
or -x
command line option to be specified.
scl enable devtoolset-6 "stap --dyninst
-c
'command' [option...] [argument...]"
scl enable devtoolset-6 "stap --dyninst
-x
process_id [option...] [argument...]"
Example 14.1. Using Dyninst with SystemTap
exercise.C
that has the following contents:
#include <stdio.h> void print_iteration(int value) { printf("Iteration number %d\n", value); } int main(int argc, char **argv) { int i; printf("Enter the starting number: "); scanf("%d", &i); for(; i>0; --i) print_iteration(i); return 0; }
print_iteration()
function for each iteration in order to print the number to the standard output. To compile this program on the command line using the g++
compiler from Red Hat Developer Toolset, type the following at a shell prompt:
~]$ scl enable devtoolset-6 'g++ -g -o exercise exercise.C'
count.stp
with the following contents:
#!/usr/bin/stap global count = 0 probe process.function("print_iteration") { count++ } probe end { printf("Function executed %d times.\n", count) }
print_iteration()
function was called during the execution of a process. To run this script on the exercise
binary file, type:
~]$scl enable devtoolset-6 "stap --dyninst -c './exercise' count.stp"
Enter the starting number:5
Iteration number 5 Iteration number 4 Iteration number 3 Iteration number 2 Iteration number 1 Function executed 5 times.
14.2.2. Using Dyninst as a Stand-alone Application
DYNINSTAPI_RT_LIB
environment variable to the path to the runtime library file. You can do so by typing the following at a shell prompt:
export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-6/root/usr/lib64/dyninst/libdyninstAPI_RT.so
DYNINSTAPI_RT_LIB
environment variable in the current shell session.
Example 14.2. Using Dyninst as a Stand-alone Application
exercise.C
source file from Example 14.1, “Using Dyninst with SystemTap”: this program prompts the user to enter a starting number and then counts down to 1, calling the print_iteration()
function for each iteration in order to print the number to standard output.
count.C
with the following contents:
#include <stdio.h> #include <fcntl.h> #include "BPatch.h" #include "BPatch_process.h" #include "BPatch_function.h" #include "BPatch_Vector.h" #include "BPatch_thread.h" #include "BPatch_point.h" void usage() { fprintf(stderr, "Usage: count <process_id> <function>\n"); } // Global information for counter BPatch_variableExpr *counter = NULL; void createCounter(BPatch_process *app, BPatch_image *appImage) { int zero = 0; counter = app->malloc(*appImage->findType("int")); counter->writeValue(&zero); } bool interceptfunc(BPatch_process *app, BPatch_image *appImage, char *funcName) { BPatch_Vector<BPatch_function *> func; appImage->findFunction(funcName, func); if(func.size() == 0) { fprintf(stderr, "Unable to find function to instrument()\n"); exit (-1); } BPatch_Vector<BPatch_snippet *> incCount; BPatch_Vector<BPatch_point *> *points; points = func[0]->findPoint(BPatch_entry); if ((*points).size() == 0) { exit (-1); } BPatch_arithExpr counterPlusOne(BPatch_plus, *counter, BPatch_constExpr(1)); BPatch_arithExpr addCounter(BPatch_assign, *counter, counterPlusOne); return app->insertSnippet(addCounter, *points); } void printCount(BPatch_thread *thread, BPatch_exitType) { int val = 0; counter->readValue(&val, sizeof(int)); fprintf(stderr, "Function executed %d times.\n", val); } int main(int argc, char *argv[]) { int pid; BPatch bpatch; if (argc != 3) { usage(); exit(1); } pid = atoi(argv[1]); BPatch_process *app = bpatch.processAttach(NULL, pid); if (!app) exit (-1); BPatch_image *appImage = app->getImage(); createCounter(app, appImage); fprintf(stderr, "Finding function %s(): ", argv[2]); BPatch_Vector<BPatch_function*> countFuncs; fprintf(stderr, "OK\nInstrumenting function %s(): ", argv[2]); interceptfunc(app, appImage, argv[2]); bpatch.registerExitCallback(printCount); fprintf(stderr, "OK\nWaiting for process %d to exit...\n", pid); app->continueExecution(); while (!app->isTerminated()) bpatch.waitForStatusChange(); return 0; }
Bpatch
objects before any of the Dyninst library destructors are called. Otherwise the mutator might terminate unexpectedly with a segmentation fault. To work around this problem, set the BPatch
object of the mutator as a local variable in the main()
function. Or, if you need to use BPatch
as a global variable, manually detach all the mutatee processes before the mutator exits.
Makefile
to build these two files:
DTS = /opt/rh/devtoolset-4/root CXXFLAGS = -g -I$(DTS)/usr/include/dyninst LBITS := $(shell getconf LONG_BIT) ifeq ($(LBITS),64) DYNINSTLIBS = $(DTS)/usr/lib64/dyninst else DYNINSTLIBS = $(DTS)/usr/lib/dyninst endif .PHONY: all all: count exercise count: count.C g++ $(CXXFLAGS) count.C -I /usr/include/dyninst -c g++ $(CXXFLAGS) count.o -L $(DYNINSTLIBS) -ldyninstAPI -o count exercise: exercise.C g++ $(CXXFLAGS) exercise.C -o exercise .PHONY: clean clean: rm -rf *~ *.o count exercise
g++
compiler from Red Hat Developer Toolset, run the make
utility as follows:
~]$ scl enable devtoolset-6 make
g++ -g -I/opt/rh/devtoolset-6/root/usr/include/dyninst count.C -c
g++ -g -I/opt/rh/devtoolset-6/root/usr/include/dyninst count.o -L /opt/rh/devtoolset-6/root/usr/lib64/dyninst -ldyninstAPI -o count
g++ -g -I/opt/rh/devtoolset-6/root/usr/include/dyninst exercise.C -o exercise
exercise
and count
in the current working directory.
exercise
binary file as follows and wait for it to prompt you to enter the starting number:
~]$ ./exercise
Enter the starting number:
DYNINSTAPI_RT_LIB
environment variable and execute the count
binary file:
~]$export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-6/root/usr/lib64/dyninst/libdyninstAPI_RT.so
~]$./count `pidof exercise` print_iteration
Finding function print_iteration(): OK Instrumenting function print_iteration(): OK Waiting for process 8607 to exit...
exercise
program. For example:
Enter the starting number: 5
Iteration number 5
Iteration number 4
Iteration number 3
Iteration number 2
Iteration number 1
exercise
program terminates, the count
program displays the number of times the print_iteration()
function was executed:
Function executed 5 times.
14.3. Additional Resources
Installed Documentation
/opt/rh/devtoolset-6/root/usr/share/doc/devtoolset-6-dyninst-doc-8.2.1/
directory:
- Dyninst Programmer's Guide — A detailed description of the Dyninst API is stored in the
DyninstAPI.pdf
file. - DynC API Programmer's Guide — An introduction to DynC API is stored in the
dynC_API.pdf
file. - ParseAPI Programmer's Guide — An introduction to the ParseAPI is stored in the
ParseAPI.pdf
file. - PatchAPI Programmer's Guide — An introduction to PatchAPI is stored in the
PatchAPI.pdf
file. - ProcControlAPI Programmer's Guide — A detailed description of ProcControlAPI is stored in the
ProcControlAPI.pdf
file. - StackwalkerAPI Programmer's Guide — A detailed description of StackwalkerAPI is stored in the
stackwalker.pdf
file. - SymtabAPI Programmer's Guide — An introduction to SymtabAPI is stored in the
SymtabAPI.pdf
file. - InstructionAPI Reference Manual — A detailed description of the InstructionAPI is stored in the
InstructionAPI.pdf
file.
Online Documentation
- Dyninst Home Page — The project home page provides links to additional documentation and related publications.
- Red Hat Enterprise Linux 6 SystemTap Beginners Guide — The SystemTap Beginners Guide for Red Hat Enterprise Linux 6 provides an introduction to SystemTap and its usage.
- Red Hat Enterprise Linux 7 SystemTap Beginners Guide — The SystemTap Beginners Guide for Red Hat Enterprise Linux 7 provides an introduction to SystemTap and its usage.
- Red Hat Enterprise Linux 6 SystemTap Tapset Reference — The SystemTap Tapset Reference for Red Hat Enterprise Linux 6 provides further details about SystemTap.
- Red Hat Enterprise Linux 7 SystemTap Tapset Reference — The SystemTap Tapset Reference for Red Hat Enterprise Linux 7 provides further details about SystemTap.
See Also
- Chapter 1, Red Hat Developer Toolset provides an overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 11, SystemTap provides an introduction to SystemTap and explains how to use it to monitor the activities of a running system.
- Chapter 12, Valgrind explains how to use Valgrind to profile applications and detect memory errors and memory management problems, such as the use of uninitialized memory, improper allocation and freeing of memory, and the use of improper arguments in system calls.
- Chapter 13, OProfile explains how to use OProfile to determine which sections of code consume the greatest amount of CPU time and why.
Part V. Getting Help
Chapter 15. Accessing Red Hat Product Documentation
Red Hat Developer Toolset
- Red Hat Developer Toolset 6.1 Release Notes — The Release Notes for Red Hat Developer Toolset 6.1 contain more information.
- Red Hat Software Collections Packaging Guide — The Software Collections Packaging Guide explains the concept of Software Collections and documents how to create, build, and extend them.
Red Hat Enterprise Linux
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information about libraries and runtime support, compiling and building, debugging, and profiling.
- Red Hat Enterprise Linux 6 Installation Guide — The Installation Guide for Red Hat Enterprise Linux 6 explains how to obtain, install, and update the system.
- Red Hat Enterprise Linux 6 Installation Guide and Red Hat Enterprise Linux 7 Installation Guide — The Installation Guides for Red Hat Enterprise Linux 6 an 7 explain how to obtain, install, and update the system.
- Red Hat Enterprise Linux 6 Deployment Guide — The Deployment Guide for Red Hat Enterprise Linux 6 documents relevant information regarding the deployment, configuration, and administration of Red Hat Enterprise Linux 6.
- Red Hat Enterprise Linux 7 System Administrator's Guide — The System Administrator's Guide for Red Hat Enterprise Linux 7 documents relevant information regarding the deployment, configuration, and administration of Red Hat Enterprise Linux 7.
Chapter 16. Contacting Global Support Services
16.1. Gathering Required Information
Background Information
- Hardware type, make, and model on which the product runs
- Software version
- Latest upgrades
- Any recent changes to the system
- An explanation of the problem and the symptoms
- Any messages or significant information about the issue
Note
Diagnostics
root
:
yum
install
sos
root
:
sosreport
Account and Contact Information
- Red Hat customer number or Red Hat Network (RHN) login name
- Company name
- Contact name
- Preferred method of contact (phone or email) and contact information (phone number or email address)
Issue Severity
- Severity 1 (urgent)
- A problem that severely impacts your use of the software for production purposes. It halts your business operations and has no procedural workaround.
- Severity 2 (high)
- A problem where the software is functioning, but production is severely reduced. It causes a high impact to business operations, and no workaround exists.
- Severity 3 (medium)
- A problem that involves partial, non-critical loss of the use of the software. There is a medium to low impact on your business, and business continues to function by utilizing a workaround.
- Severity 4 (low)
- A general usage question, report of a documentation error, or a recommendation for a future product improvement.
16.2. Escalating an Issue
- Technical escalation
- If an issue is not being resolved appropriately or if you need a more senior resource to attend to it.
- Management escalation
- If the issue has become more severe or you believe it requires a higher priority.
16.3. Re-opening a Service Request
Important
16.4. Additional Resources
Online Documentation
- Getting Started — The Getting Started page serves as a starting point for people who purchased a Red Hat subscription and offers the Red Hat Welcome Kit and the Quick Guide to Red Hat Support for download.
- How can a RHEL Self-Support subscription be used? — A Knowledgebase article for customers with a Self-Support subscription.
- Red Hat Global Support Services and public mailing lists — A Knowledgebase article that answers frequent questions about public Red Hat mailing lists.
Appendix A. Changes in Version 6.0
A.1. Changes in binutils
A.1.1. Changes Since Red Hat Enterprise Linux 6.8
as
), GNU linker (ld
), and other binary tools that are part of binutils are now released under the GNU General Public License, version 3.
A.1.1.1. GNU Linker
gold
, is now available in addition to ld
, the existing GNU linker. gold
is intended to be a drop-in replacement for ld
, so ld
's documentation is intended to be the reference documentation. gold
supports most of ld
's features, except notable ones such as MRI-compatible linker scripts, cross-reference reports (--cref
), and various other minor options. It also provides significantly improved link time with very large C++ applications.
gold
linker is not enabled by default. Users can explicitly switch between ld
and gold
by using the alternatives
mechanism.
A.1.1.1.1. New Features
- A new
INPUT_SECTION_FLAGS
keyword has been added to the linker script language. This keyword can be used to select input sections by section header flags. - A new
SORT_BY_INIT_PRIORITY
keyword has been added to the linker script language. This keyword can be used to sort sections by numerical value of the GCCinit_priority
attribute encoded in the section name. - A new
SORT_NONE
keyword has been added to the linker script language. This keyword can be used to disable section sorting. - A new linker-provided symbol,
__ehdr_start
, has been added. When producing ELF output, this symbol points to the ELF file header (and nearby program headers) in the program's memory image. - A new
--compress-debug-sections
command line option has been added to enable the generation of compressed DWARF debug information sections in the relocatable output file.
A.1.1.1.2. Compatibility Changes
- The
--copy-dt-needed-entries
command line option is no longer enabled by default. Instead,--no-copy-dt-needed-entries
is now the default option. - Evaluation of linker script expressions has been significantly improved. Note that this can negatively affect scripts that rely on undocumented behavior of the old expression evaluation.
A.1.1.2. GNU Assembler
A.1.1.2.1. New Features
- The GNU Assembler no longer requires double ampersands in macros.
- A new
--compress-debug-sections
command line option has been added to enable the generation of compressed DWARF debug information sections in the relocatable output file.Note that the setting of this option for the linker overrides the setting for the assembler. For example, if an object file contains a compressed debug section, but it is linked without--compress-debug-sections
being passed to the linker, then those sections will be uncompressed as they are copied into the output binary. - Support for
.bundle_align_mode
,.bundle_lock
, and.bundle_unlock
directives for x86 targets has been added.. - On x86 architectures, the GNU Assembler now allows
rep bsf
,rep bsr
, andrep ret
syntax.
A.1.1.3. Other Binary Tools
A.1.1.3.1. New Features
- Support for reading the optimized debug information generated by the
dwz -m
tool has been added. - The devtoolset-2-binutils-devel package now provides the
demangle.h
header file.
A.1.2. Changes Since Red Hat Developer Toolset 4.1
- Support has been added for generating and using compressed debug sections. This reduces the size of binaries but can cause problems when other tools, not from the binutils package, try to examine them. For this reason, the actual generation of the compressed sections requires an explicit command-line option to be passed to the assembler or linker.
A.1.2.1. GNU Linker
A.1.2.1.1. New Features
- The linker now automatically enables the read-only run-time relocations (option
-z relro
) unless explicitly told otherwise. This helps to enhance the security of executables. - The linker supports a new command-line option to define how orphan sections should be handled. Orphan sections are sections from input files whose placement in the output file is not defined by the linker script being used. The default behaviour is still maintained, but the option can be used to generate warning or error messages about them, or even to discard them entirely.
- The linker supports a new command line option,
--require-defined SYM
, which causes the linker to generate an error if SYM has not been defined by the time the end of the linking process has been reached. - The linker supports a new command line option,
-z nodynamic-undefined-weak
, which stops it from generating dynamic relocations against undefined weak symbols in the executable being created.
A.1.2.2. GNU Assembler
A.1.2.2.1. New Features
- The assembler now supports the ARM v8.1 and ARM v8-M architectures, including the Adv.SIMD, LOR, PAN, Security, and DSP extensions.
- The assembler now allows ELF section flags and types to be set using numeric values as well as textual names.
- The assembler now accepts symbol and label names enclosed in double quotes ("), which allows them to contain characters that are not part of valid symbol names in high-level languages.
A.2. Changes in elfutils
A.2.1. Changes Since Red Hat Developer Toolset 4.1
dwelf_strtab_init
, dwelf_strtab_add
, dwelf_strtab_add_len
, dwelf_strtab_finalize
, dwelf_strent_off
, dwelf_strent_str
, and dwelf_strtab_free
.
A.3. Changes in GCC
A.3.1. Changes Since Red Hat Developer Toolset 4.1
- The C++ compiler defaults to C++14 rather than C++98. Certain experimental C++17 language and runtime features have also been made available.
- Source locations are now tracked as ranges rather than points, which allows much richer diagnostics as well as "fixit" hints.
- New warnings have been implemented for statically detecting certain likely programming errors, including: negative shifts, shift overflow, tautological comparisons, null pointer dereferences, duplicated conditions, and misleading indentation.
- Various optimizer improvements have been added, particularly in alias analysis which helps to remove abstraction penalties for C++ code, improvements in the vectorizer, redundancy elimination, useless conditional elimination, and others.
- OpenMP 4.5 support for C and C++ has been added.
- Additional sanitizers to detect undefined behavior at runtime have been added.
- A new option,
-mfloat128
, has been implemented. It allows users to experiment with IEEE 128-bit floating point.The 64-bit IBM POWER architecture now supports IEEE 128-bit floating-point using the__float128
data type. Note that Red Hat Developer Toolset does not enable this support default, and__float128
is not supported by the Red Hat Enterprise Linux 7 runtime.
Platform-Specific Improvements
- Support has been added for Intel Skylake processors with support for the AVX-512 extensions and the following instruction sets: Foundation (F), Byte and Word (BW), Doubleword and Quadword (DQ), Vector Length Extensions (VL), and Conflict Detection (CD).
- Support has been added for 64-bit ARM (AArch64) LSE extensions and support for new implementations and code-generation tuning for those implementations of the AArch64 ISA.
- Early support has been added for IEEE 128-bit floating point.
- Support for the z13 processor of the IBM z Systems architecture has been added.
A.4. Changes in make
A.4.1. Changes Since Red Hat Enterprise Linux 6.8
- When the special target
.POSIX
is specified, make adheres to the POSIX requirements for handling backslash and newline. This changes how make handles backslash and newline in non-recipe lines:- Trailing spaces before the backslash are preserved
- Each backslash and newline, including subsequent white space, is converted to single space
- The BSD
!=
shell assignment operator is now supported as an alternative to the$(shell ...)
function. As a consequence, variable names ending in exclamation mark, defined asmyvariable!= somevalue
, are now interpreted as shell assignments. To restore the previous behaviour, add white space after the intended variable name, such asmyvariable! = somevalue
.
A.5. Changes in GDB
A.5.1. Changes Since Red Hat Developer Toolset 4.1
New Features
- Support for tracepoints and fast tracepoints has been added in GDBserver for the following architectures:
- IBM z Systems
- IBM System z9
- IBM POWER
The support includes JIT compiling of conditional expressions in bytecode of fast tracepoints into native code. - Support has been added for running interpreters on specified input and output devices.GDB now supports a new mechanism that allows frontends to provide fully-featured GDB console views as a better alternative to building such views on top of the
-interpreter-exec console
command. See also the newnew-ui
command below. With that command, frontends can now start GDB in the traditional command-line mode running in an embedded terminal-emulator widget and create a separate MI interpreter running on a specified I/O device. In this way, GDB handles line editing, history, tab completion, and other tasks in the console all by itself, and the GUI uses the separate MI interpreter for its own control and synchronization, invisible to the command line. - Support has been added for Fortran pointers to dynamic types.
- Support has been added for Fortran structures with fields of dynamic types and arrays of dynamic types.
- Support has been added to GDBserver for recording btrace without having to maintain an active GDB connection.
- Support has been added for a negative repeat count in the
x
command. This allows for examining memory backward from the given address. For example:(gdb)
bt
#0 Func1 (n=42, p=0x40061c "hogehoge") at main.cpp:4 #1 0x400580 in main (argc=1, argv=0x7fffffffe5c8) at main.cpp:8(gdb)
x/-5i 0x0000000000400580
0x40056a <main(int, char**)+8>: mov %edi,-0x4(%rbp) 0x40056d <main(int, char**)+11>: mov %rsi,-0x10(%rbp) 0x400571 <main(int, char**)+15>: mov $0x40061c,%esi 0x400576 <main(int, char**)+20>: mov $0x2a,%edi 0x40057b <main(int, char**)+25>: callq 0x400536 <Func1(int, char const*)> - Support has been added for multibit bitfields and enums in the target register descriptions.
- A new convenience function,
$_as_string(val)
, based on Python, which returns the textual representation of a value, has been added. The function is useful for obtaining the text label of an enum value. - Segmentation faults caused by Intel MPX boundary violations now display the type of violation (upper or lower), the memory address accessed, and the memory bounds, along with the signal received and code location. For example:
Program received signal SIGSEGV, Segmentation fault Upper bound violation while accessing address 0x7fffffffc3b3 Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3] 0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
New Commands
skip
,-file
fileskip
,-gfile
file-glob-patternskip
,-function
functionskip
-rfunction
regular-expression- A generalized form of the
skip
command, with new support for glob-style file names and regular expressions for function names. Additionally, a file spec and a function spec may now be combined. maint info line-table REGEXP
- Show the contents of the internal line-table data struture.
maint selftest
- Run all compiled in GDB unit tests.
new-ui INTERP TTY
- Start a new user interface instance running INTERP as interpreter, using the TTY file for input and output.
- When issued with the
group:
org:
prefix, thecatch syscall
command now supports catching groups of related system calls.
Python Scripting Support
- A new attribute,
pending
, has been added togdb.Breakpoint
objects, which indicates whether the breakpoint is pending. - Three new events related to breakpoints have been added:
gdb.breakpoint_created
,gdb.breakpoint_modified
, andgdb.breakpoint_deleted
.
Change in the Machine Interface Interpreter (GDB/MI)
- The
=record-started
async record now includes the method and format used for recording. For example:=record-started,thread-group="i1",method="btrace",format="bts"
- The
=thread-selected
async record now includes the frame field. For example:=thread-selected,id="3",frame={level="0",addr="0x00000000004007c0"}
A.6. Changes in OProfile
A.6.1. Changes Since Red Hat Developer Toolset 4.1
- Support has been added for the following processors:
- IBM z13 (only the
ocount
is supported) - Applied Micro X-Gene
- Event lists for IBM POWER8 processors have been updated.
- Support has been added for the following Intel processors:
- 2nd Generation Intel Atom (Goldmont)
- 6th Generation Intel Core, CPUID model 0x55 (Skylake)
- 7th Generation Intel Core (Kaby Lake)
- The search logic has been corrected to properly store data in an archive and make use of the archive data.
operf
now only starts the command to be measured if the performance monitoring hardware is properly set up. This fixes a bug that causedoperf
to start the command that is to be measured regardless of whether the performance monitoring set up was successful.
A.7. Changes in strace
A.8. Changes in SystemTap
A.8.1. Changes Since Red Hat Developer Toolset 4.1
- Experimental monitor and interactive modes.
- Optimized associative arrays.
- Two types of function overloading.
- Probe point brace-pattern expansion.
- Security band-aid samples.
- Improved string quoting and escaping.
- Pretty printing of array aggregates.
- Private scoping for variables.
Note
--compatible version
, where version is the version of SystemTap for which the script was written.
A.9. Changes in dyninst
A.9.1. Changes Since Red Hat Developer Toolset 4.1
- Expanded instruction support for x86 architectures to include the AVX, AVX2, and AVX-512 extensions, and many other fixes in x86 decoding.
- Fixed rewriting for position-independent executables (PIE).
- Improved
SymtabAPI
coverage using DWARF information. - Improved analysis of jump tables.
- Safety fixes for memory allocation and tramp guards in the
RTlib
library.
A.10. Changes in Valgrind
A.10.1. Changes Since Red Hat Developer Toolset 4.1
- Added meta mempool support for describing a custom allocator. This feature:
- Automatically frees all chunks assuming that destroying a pool destroys all objects in the pool.
- Uses itself to allocate other memory blocks.
- The maximum number of callers in a suppression entry is now equal to the maximum size for the
--num-callers
option (500). Note that setting the--gen-suppressions=yes|all
option similarly generates suppression containing up to--num-callers
frames. - The gdbserver provided by Valgrind now accepts the
catch syscall
command. - JIT has been improved to lower the cost of instrumenting code blocks for the most common use case (AMD64 and Intel 64 with Memcheck). The cost has been reduced by 10-15%.
- Limited support has been added for certain AMD64 FMA4 instructions.
- Support for the following architectures has been added:
- 64-bit ARM (AArch64)
- IBM System z9
Appendix B. Changes in Version 6.1
B.1. Changes in elfutils
B.1.1. Changes Since Red Hat Developer Toolset 6.0
- The eu-readelf utility now allows specifying the symbol table section by name with parameter
--symbols[=SECTION]
. This enables showing just the symbol table of the specified ELF section name instead of symbols from all symbol tables. - Return type of functions
gelf_newehdr
andgelf_newehdr
in the libelf library changed fromunsigned long int
tovoid*
. The new signatures are abi-compatible on all supported architectures. This change increases compatibility of code with implementations of libelf on other platforms. - The
DW_LANG_PL1
constant indwarf.h
header file from libdw has been changed toDW_LANG_PLI
. libdw still includes the old name as an alias.
- The devtoolset-6-elfutils-libs package provided the same shared library object names as the base RHEL elfutils-libs package. Consequently, if a package required one of the provided elfutils libraries (
libelf
,libdw
, orlibasm
), devtoolset-6-elfutils-libs was installed instead of the base Red Hat Enterprise Linux elfutils-libs package. With this update, devtoolset-6-elfutils-libs no longer provides the same library names as the system elfutils-libs package. As a result, when a package needs an elfutils-libs library, the system elfutils-libs package is correctly installed. (BZ#1412305)
B.2. Changes in GCC
B.3. Changes in GDB
B.4. Changes in devtoolset-6-toolchain-rhel7
B.4.1. Changes Since Red Hat Developer Toolset 6.0
B.5. Changes in devtoolset-6-perftools-rhel7
B.5.1. Changes Since Red Hat Developer Toolset 6.0
Appendix C. Revision History
Revision History | |||
---|---|---|---|
Revision 6.1-3 | Fri 26 May 2017 | Vladimír Slávik | |
| |||
Revision 6.1-2 | Wed 26 Apr 2017 | Vladimír Slávik | |
| |||
Revision 6.1-1 | Wed 05 Apr 2017 | Vladimír Slávik | |
| |||
Revision 6.0-9 | Tue 04 Apr 2017 | Lenka Špačková | |
| |||
Revision 6.0-8 | Fri 31 Mar 2017 | Vladimír Slávik | |
| |||
Revision 6.0-7 | Sun 13 Nov 2016 | Robert Krátký | |
| |||
Revision 0.0-36 | Tue 24 May 2016 | Robert Krátký | |
| |||
Revision 0.0-33 | Fri 13 Nov 2015 | Robert Krátký | |
| |||
Revision 0.0-29 | Wed 4 Nov 2015 | Robert Krátký | |
| |||
Revision 0.0-28 | Wed 14 Oct 2015 | Robert Krátký | |
| |||
Revision 0.0-25 | Thu 4 June 2015 | Robert Krátký | |
| |||
Revision 0.0-23 | Thu 23 Apr 2015 | Robert Krátký | |
| |||
Revision 0.0-17 | Tue 10 Mar 2015 | Robert Krátký | |
| |||
Revision 0.0-16 | Thu 13 Nov 2014 | Robert Krátký | |
| |||
Revision 0.0-14 | Thu 30 Oct 2014 | Robert Krátký | |
| |||
Revision 0.0-10 | Tue 07 Oct 2014 | Robert Krátký | |
| |||
Revision 0.0-8 | Tue Sep 09 2014 | Robert Krátký | |
|
Index
A
- addr2line
- features, New Features
- overview, binutils
- usage, Using Other Binary Tools
- ar
- overview, binutils
- usage, Using Other Binary Tools
- as (see GNU assembler)
- assembling (see GNU assembler)
B
- binutils
- documentation, Additional Resources
- installation, Installing binutils
- overview, binutils
- usage, Using the GNU Assembler, Using the GNU Linker, Using Other Binary Tools
- version, About Red Hat Developer Toolset, binutils
C
- C programming language
- compiling, Using the C Compiler, Preparing a Program for Debugging
- running, Running a C Program
- support, GNU C Compiler
- C++ programming language
- compatibility, C++ Compatibility
- compiling, Using the C++ Compiler, Preparing a Program for Debugging
- running, Running a C++ Program
- support, GNU C++ Compiler
- c++filt
- overview, binutils
- usage, Using Other Binary Tools
- Cachegrind
- overview, Valgrind
- usage, Using Valgrind
- Callgrind
- overview, Valgrind
- usage, Using Valgrind
- compatibility
- Red Hat Developer Toolset, Compatibility
- compiling (see GNU Compiler Collection)
D
- debugging (see GNU Debugger)
- Developer Toolset (see Red Hat Developer Toolset)
- documentation
- Red Hat Product Documentation, Accessing Red Hat Product Documentation
- DRD
- overview, Valgrind
- usage, Using Valgrind
- dwp
- overview, binutils
- usage, Using Other Binary Tools
- dwz
- documentation, Additional Resources
- installation, Installing dwz
- overview, dwz
- usage, Using dwz
- version, About Red Hat Developer Toolset, dwz
- Dyninst
- documentation, Additional Resources
- installation, Installing Dyninst
- overview, Dyninst
- usage, Using Dyninst
- version, About Red Hat Developer Toolset, Dyninst
E
- elfedit
- features, New Features
- overview, binutils
- usage, Using Other Binary Tools
- elfutils
- documentation, Additional Resources
- installation, Installing elfutils
- overview, elfutils
- usage, Using elfutils
- version, About Red Hat Developer Toolset, elfutils
- eu-addr2line
- overview, elfutils
- usage, Using elfutils
- eu-ar
- overview, elfutils
- usage, Using elfutils
- eu-elfcmp
- overview, elfutils
- usage, Using elfutils
- eu-elflint
- overview, elfutils
- usage, Using elfutils
- eu-findtextrel
- overview, elfutils
- usage, Using elfutils
- eu-make-debug-archive
- overview, elfutils
- usage, Using elfutils
- eu-nm
- overview, elfutils
- usage, Using elfutils
- eu-objdump
- overview, elfutils
- usage, Using elfutils
- eu-ranlib
- overview, elfutils
- usage, Using elfutils
- eu-readelf
- overview, elfutils
- usage, Using elfutils
- eu-size
- overview, elfutils
- usage, Using elfutils
- eu-stack
- overview, elfutils
- eu-strings
- overview, elfutils
- usage, Using elfutils
- eu-strip
- overview, elfutils
- usage, Using elfutils
- eu-unstrip
- overview, elfutils
- usage, Using elfutils
F
- Fortran programming language
- compiling, Using the Fortran Compiler
- running, Running a Fortran Program
- support, GNU Fortran Compiler
G
- g++ (see GNU Compiler Collection)
- GAS (see GNU assembler)
- GCC (see GNU Compiler Collection)
- gcc (see GNU Compiler Collection)
- GDB (see GNU Debugger)
- gfortran (see GNU Compiler Collection)
- Global Support Services
- contacting, Contacting Global Support Services
- GNU assembler
- documentation, Additional Resources
- installation, Installing binutils
- overview, binutils
- usage, Using the GNU Assembler
- GNU Binutils (see binutils)
- GNU Compiler Collection
- C support, GNU C Compiler
- C++ support, GNU C++ Compiler
- documentation, Additional Resources
- features, Main Features
- Fortran support, GNU Fortran Compiler
- installation, Installing the C Compiler, Installing the C++ Compiler, Installing the Fortran Compiler
- overview, GNU Compiler Collection (GCC)
- usage, Using the C Compiler, Using the C++ Compiler, Using the Fortran Compiler, Preparing a Program for Debugging
- version, About Red Hat Developer Toolset, GNU Compiler Collection (GCC)
- GNU Debugger
- documentation, Additional Resources
- features, Main Features
- installation, Installing the GNU Debugger
- overview, GNU Debugger (GDB)
- preparation, Preparing a Program for Debugging
- usage, Running the GNU Debugger, Listing Source Code, Setting Breakpoints, Starting Execution, Displaying Current Values, Continuing Execution
- version, About Red Hat Developer Toolset, GNU Debugger (GDB)
- GNU linker
- documentation, Additional Resources
- installation, Installing binutils
- overview, binutils
- usage, Using the GNU Linker
- GNU make
- documentation, Additional Resources
- installation, Installing make
- version, GNU make
- gprof
- overview, binutils
- usage, Using Other Binary Tools
- GSS (see Global Support Services)
H
- Helgrind
- overview, Valgrind
- usage, Using Valgrind
- help
- Global Support Services, Contacting Global Support Services
- Red Hat Product Documentation, Accessing Red Hat Product Documentation
L
- ld (see GNU linker)
- linking (see GNU linker)
- ltrace
- documentation, Additional Resources
- installation, Installing ltrace
- overview, ltrace
- usage, Using ltrace
- version, About Red Hat Developer Toolset, ltrace
M
- make
- building, Using make
- overview, GNU make
- version, About Red Hat Developer Toolset
- Makefile
- usage, Using Makefiles
- Massif
- overview, Valgrind
- usage, Using Valgrind
- Memcheck
- overview, Valgrind
- usage, Using Valgrind
- memstomp
- documentation, Additional Resources
- installation, Installing memstomp
- overview, memstomp
- usage, Using memstomp
- version, About Red Hat Developer Toolset
N
- nm
- overview, binutils
- usage, Using Other Binary Tools
O
- objcopy
- features, New Features
- overview, binutils
- usage, Using Other Binary Tools
- objdump
- features, New Features
- overview, binutils
- usage, Using Other Binary Tools
- ocount
- overview, OProfile
- opannotate
- overview, OProfile
- usage, Using OProfile
- oparchive
- overview, OProfile
- usage, Using OProfile
- operf
- overview, OProfile
- usage, Using OProfile
- opgprof
- overview, OProfile
- usage, Using OProfile
- ophelp
- overview, OProfile
- usage, Using OProfile
- opimport
- overview, OProfile
- usage, Using OProfile
- opjitconv
- overview, OProfile
- usage, Using OProfile
- opreport
- overview, OProfile
- usage, Using OProfile
- OProfile
- documentation, Additional Resources
- installation, Installing OProfile
- overview, OProfile
- usage, Using OProfile
- version, About Red Hat Developer Toolset, OProfile
- oprofiled
- overview, OProfile
R
- ranlib
- overview, binutils
- usage, Using Other Binary Tools
- readelf
- features, New Features
- overview, binutils
- usage, Using Other Binary Tools
- Red Hat Developer Toolset
- compatibility, Compatibility
- Container Images, Using Red Hat Developer Toolset Container Images
- Docker, Using Red Hat Developer Toolset Container Images
- Docker-formatted container images, Using Red Hat Developer Toolset Container Images
- Dockerfiles, Using Red Hat Developer Toolset Container Images
- documentation, Additional Resources, Accessing Red Hat Product Documentation
- features, Main Features
- installation, Installing Red Hat Developer Toolset
- overview, About Red Hat Developer Toolset
- subscription, Getting Access to Red Hat Developer Toolset
- support, About Red Hat Developer Toolset
- uninstallation, Uninstalling Red Hat Developer Toolset
- update, Updating Red Hat Developer Toolset
- Red Hat Enterprise Linux
- documentation, Additional Resources, Accessing Red Hat Product Documentation
- supported versions, Compatibility
- Red Hat Subscription Management
- subscription, Using Red Hat Subscription Management
- RHN Classic
- subscription, Using RHN Classic
S
- scl (see Software Collections)
- size
- overview, binutils
- usage, Using Other Binary Tools
- Software Collections
- documentation, Additional Resources, Accessing Red Hat Product Documentation
- overview, About Red Hat Developer Toolset
- stap
- overview, SystemTap
- usage, Using SystemTap, Using Dyninst with SystemTap
- stap-merge
- overview, SystemTap
- usage, Using SystemTap
- stap-prep
- overview, SystemTap
- usage, Installing SystemTap
- stap-report
- overview, SystemTap
- usage, Using SystemTap
- stap-server
- overview, SystemTap
- stapdyn
- overview, SystemTap
- staprun
- overview, SystemTap
- usage, Using SystemTap
- stapsh
- overview, SystemTap
- usage, Using SystemTap
- strace
- documentation, Additional Resources
- installation, Installing strace
- overview, strace
- usage, Using strace
- version, About Red Hat Developer Toolset, strace
- strings
- overview, binutils
- usage, Using Other Binary Tools
- strip
- overview, binutils
- usage, Using Other Binary Tools
- support
- Red Hat Developer Toolset, About Red Hat Developer Toolset
- SystemTap
- documentation, Additional Resources
- installation, Installing SystemTap
- overview, SystemTap
- usage, Using SystemTap, Using Dyninst with SystemTap
- version, About Red Hat Developer Toolset, SystemTap
V
- Valgrind
- documentation, Additional Resources
- installation, Installing Valgrind
- overview, Valgrind
- usage, Using Valgrind
- version, About Red Hat Developer Toolset, Valgrind
- version
- version, memstomp