此内容没有您所选择的语言版本。
User Guide
Installing and Using Red Hat Developer Toolset
Abstract
Making open source more inclusive 复制链接链接已复制到粘贴板!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Part I. Introduction 复制链接链接已复制到粘贴板!
Chapter 1. Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
1.1. About Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset is a Red Hat offering for developers on the Red Hat Enterprise Linux platform. It provides a complete set of development and performance analysis tools that can be installed and used on multiple versions of Red Hat Enterprise Linux. Executables built with the Red Hat Developer Toolset toolchain can then also be deployed and run on multiple versions of Red Hat Enterprise Linux. For detailed compatibility information, see Section 1.3, “Compatibility”.
Red Hat Developer Toolset does not replace the default system tools provided with Red Hat Enterprise Linux 7 when installed on those platforms. Instead, a parallel set of developer tools provides an alternative, newer version of those tools for optional use by developers. The default compiler and debugger, for example, remain those provided by the base Red Hat Enterprise Linux system.
What Is New in Red Hat Developer Toolset 10.1
Since Red Hat Developer Toolset 4.1, the Red Hat Developer Toolset content is also available in the ISO format together with the rest of Red Hat Software Collections content at https://access.redhat.com/downloads, specifically for Server and Workstation. Note that packages that require the Optional channel, which are discussed in Section 1.5.3, “Installing Optional Packages”, cannot be installed from the ISO image.
| Name | Version | Description |
|---|---|---|
| GCC | 10.2.1 | A portable compiler suite with support for C, C++, and Fortran. |
| binutils | 2.35 | A collection of binary tools and other utilities to inspect and manipulate object files and binaries. |
| elfutils | 0.182 | A collection of binary tools and other utilities to inspect and manipulate ELF files. |
| dwz | 0.12 | A tool to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size. |
| GDB | 9.2 | A command line debugger for programs written in C, C++, and Fortran. |
| ltrace | 0.7.91 | A debugging tool to display calls to dynamic libraries that a program makes. It can also monitor system calls executed by programs. |
| strace | 5.7 | A debugging tool to monitor system calls that a program uses and signals it receives. |
| memstomp | 0.1.5 | A debugging tool to identify calls to library functions with overlapping memory regions that are not allowed by various standards. |
| SystemTap | 4.4 | A tracing and probing tool to monitor the activities of the entire system without the need to instrument, recompile, install, and reboot. |
| Valgrind | 3.16.1 | An instrumentation framework and a number of tools to profile applications in order to detect memory errors, identify memory management problems, and report any use of improper arguments in system calls. |
| OProfile | 1.4.0 | A system-wide profiler that uses the performance monitoring hardware on the processor to retrieve information about the kernel and executables on the system. |
| Dyninst | 10.2.1 | A library for instrumenting and working with user-space executables during their execution. |
| make | 4.2.1 | A dependency-tracking build automation tool. |
| annobin | 9.23 | A build security checking tool. |
Red Hat Developer Toolset differs from "Technology Preview" compiler releases previously supplied in Red Hat Enterprise Linux in two important respects:
- 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”.
- Unlike Technology Preview compilers and other tools shipped in earlier Red Hat Enterprise Linux, Red Hat Developer Toolset is fully supported under Red Hat Enterprise Linux Subscription Level Agreements, is functionally complete, and is intended for production use.
Important bug fixes and security errata are issued to Red Hat Developer Toolset subscribers in a similar manner to Red Hat Enterprise Linux for two years from the release of each major version release. A new major version of Red Hat Developer Toolset is released annually, providing significant updates for existing components and adding major new components. A single minor release, issued six months after each new major version release, provides a smaller update of bug fixes, security errata, and new minor components.
Additionally, the Red Hat Enterprise Linux Application Compatibility Specification also applies to Red Hat Developer Toolset (subject to some constraints on the use of newer C++11 language features, detailed in Section 2.2.4, “C++ Compatibility”).
Applications and libraries provided by Red Hat Developer Toolset do not replace the Red Hat Enterprise Linux system versions, nor are they used in preference to the system versions. Using a framework called Software Collections, an additional set of developer tools is installed into the /opt/ directory and is explicitly enabled by the user on demand using the scl utility.
1.2. Main Features 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 brings the following changes:
- The Red Hat Developer Toolset version of the GNU Compiler Collection (GCC) has been upgraded to version 10.2.1 with many new features and bug fixes.
- The Red Hat Developer Toolset version of the GNU Debugger (GDB) has been upgraded to version 9.2 with many new features and bug fixes.
For a full list of changes and features introduced in this release, see Appendix B, Changes in Version 10.1.
1.3. Compatibility 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is available for Red Hat Enterprise Linux 7 for a number of architectures.
For ABI compatibility information, see Section 2.2.4, “C++ Compatibility”.
| Runs on Red Hat Enterprise Linux 7.6 | Runs on Red Hat Enterprise Linux 7.7 | Runs on Red Hat Enterprise Linux 7.9 | |
|---|---|---|---|
| Built with Red Hat Enterprise Linux 7.6 | Supported | Supported | Supported |
| Built with Red Hat Enterprise Linux 7.7 | Not supported | Supported | Supported |
| Built with Red Hat Enterprise Linux 7.9 | Not Supported | Not Supported | Supported |
Architecture support
Red Hat Developer Toolset is available on the following architectures:
- The 64-bit Intel and AMD architectures
- IBM Power Systems, big endian
- IBM Power Systems, little endian
- 64-bit IBM Z
1.4. Getting Access to Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset is an offering distributed as a part of Red Hat Software Collections.
This content set is available to customers with Red Hat Enterprise Linux 7 subscriptions listed at https://access.redhat.com/solutions/472793.
Enable Red Hat Developer Toolset by using Red Hat Subscription Management. For information on how to register your system with this subscription management service, see the Red Hat Subscription Management collection of guides.
1.4.1. Using Red Hat Software Collections 复制链接链接已复制到粘贴板!
Complete the following steps to attach a subscription that provides access to the repository for Red Hat Software Collections (which includes Red Hat Developer Toolset), and then enable that repository:
Determine the pool ID of a subscription that provides Red Hat Software Collections (and thus also Red Hat Developer Toolset). To do so, display a list of all subscriptions that are available for your system:
subscription-manager list --available
# subscription-manager list --availableCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 with
Pool 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:
subscription-manager attach --pool=pool_id
# subscription-manager attach --pool=pool_idCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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:
subscription-manager list --consumed
# subscription-manager list --consumedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Determine the exact name of the Red Hat Software Collections repository. Retrieve repository metadata and to display a list of available Yum repositories:
subscription-manager repos --list
# subscription-manager repos --listCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
rhel-variant-rhscl-version-rpms rhel-variant-rhscl-version-debug-rpms rhel-variant-rhscl-version-source-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow In addition, certain packages, such as devtoolset-10-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
rhel-version-variant-optional-rpms rhel-version-variant-optional-debug-rpms rhel-version-variant-optional-source-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow For both the regular repositories and optional repositories, replace variant with the Red Hat Enterprise Linux system variant (
serverorworkstation), and version with the Red Hat Enterprise Linux system version (7).Enable the repositories from step no. 3:
subscription-manager repos --enable repository
# subscription-manager repos --enable repositoryCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace repository with the name of the repository to enable.
Once the subscription is attached to the system, you can install Red Hat Developer Toolset as described in Section 1.5, “Installing Red Hat Developer Toolset”. For more information on how to register your system using Red Hat Subscription Management and associate it with subscriptions, see the Red Hat Subscription Management collection of guides.
1.5. Installing Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset is distributed as a collection of RPM packages that can be installed, updated, uninstalled, and inspected by using the standard package management tools that are included in Red Hat Enterprise Linux. Note that a valid subscription that provides access to the Red Hat Software Collections content set is required in order to install Red Hat Developer Toolset on your system. For detailed instructions on how to associate your system with an appropriate subscription and get access to Red Hat Developer Toolset, see Section 1.4, “Getting Access to Red Hat Developer Toolset”.
Before installing Red Hat Developer Toolset, install all available Red Hat Enterprise Linux updates.
1.5.1. Installing All Available Components 复制链接链接已复制到粘贴板!
To install all components that are included in Red Hat Developer Toolset, install the devtoolset-10 package:
yum install devtoolset-10
# yum install devtoolset-10
This installs all development, debugging, and performance monitoring tools, and other dependent packages to the system. Alternatively, you can choose to install only a selected package group as described in Section 1.5.2, “Installing Individual Package Groups”.
Note that since Red Hat Developer Toolset 3.0, the scl-utils package is not a part of Red Hat Developer Toolset, which is a change from preceding versions where the scl utility was installed along with the Red Hat Developer Toolset software collection.
1.5.2. Installing Individual Package Groups 复制链接链接已复制到粘贴板!
To make it easier to install only certain components, such as the integrated development environment or the software development toolchain, Red Hat Developer Toolset is distributed with a number of meta packages that allow you to install selected package groups as described in Table 1.3, “Red Hat Developer Toolset Meta Packages”.
| Package Name | Description | Installed Components |
|---|---|---|
| devtoolset-10-perftools | Performance monitoring tools | SystemTap, Valgrind, OProfile, Dyninst |
| devtoolset-10-toolchain | Development and debugging tools | GCC, make, GDB, binutils, elfutils, dwz, memstomp, strace, ltrace |
To install any of these meta packages:
yum install package_name
# yum install package_name
Replace package_name with a space-separated list of meta packages you want to install. For example, to install only the development and debugging toolchain and packages that depend on it:
yum install devtoolset-10-toolchain
# yum install devtoolset-10-toolchain
Alternatively, you can choose to install all available components as described in Section 1.5.1, “Installing All Available Components”.
1.5.3. Installing Optional Packages 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset is distributed with a number of optional packages that are not installed by default. To list all Red Hat Developer Toolset packages that are available to you but not installed on your system:
yum list available devtoolset-10-\*
$ yum list available devtoolset-10-\*
To install any of these optional packages:
yum install package_name
# yum install package_name
Replace package_name with a space-separated list of packages that you want to install. For example, to install the devtoolset-10-gdb-gdbserver and devtoolset-10-gdb-doc packages:
yum install devtoolset-10-gdb-gdbserver devtoolset-10-gdb-doc
# yum install devtoolset-10-gdb-gdbserver devtoolset-10-gdb-doc
1.5.4. Installing Debugging Information 复制链接链接已复制到粘贴板!
To install debugging information for any of the Red Hat Developer Toolset packages, make sure that the yum-utils package is installed and run:
debuginfo-install package_name
# debuginfo-install package_name
For example, to install debugging information for the devtoolset-10-dwz package:
debuginfo-install devtoolset-10-dwz
# debuginfo-install devtoolset-10-dwz
Note that in order to use this command, you need to have access to the repository with these packages. If your system is registered with Red Hat Subscription Management, enable the rhel-variant-rhscl-version-debug-rpms repository as described in Section 1.4, “Getting Access to Red Hat Developer Toolset”. For more information on how to get access to debuginfo packages, see https://access.redhat.com/site/solutions/9907.
The devtoolset-10-package_name-debuginfo packages can conflict with the corresponding packages from the base Red Hat Enterprise Linux system or from other versions of Red Hat Developer Toolset. This conflict also occurs in a multilib environment, where 64-bit debuginfo packages conflict with 32-bit debuginfo packages.
Manually uninstall the conflicting debuginfo packages prior to installing Red Hat Developer Toolset 10.1 and install only relevant debuginfo packages when necessary.
1.6. Updating Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
1.6.1. Updating to a Minor Version 复制链接链接已复制到粘贴板!
When a new minor version of Red Hat Developer Toolset is available, update your Red Hat Enterprise Linux installation:
yum update
# yum update
This updates all packages on your Red Hat Enterprise Linux system, including the Red Hat Developer Toolset versions of development, debugging, and performance monitoring tools, and other dependent packages.
Use of Red Hat Developer Toolset requires the removal of any earlier pre-release versions of it. Additionally, it is not possible to update to Red Hat Developer Toolset 10.1 from a pre-release version of Red Hat Developer Toolset, including beta releases. If you have previously installed any pre-release version of Red Hat Developer Toolset, uninstall it from your system as described in Section 1.7, “Uninstalling Red Hat Developer Toolset” and install the new version as documented in Section 1.5, “Installing Red Hat Developer Toolset”.
1.6.2. Updating to a Major Version 复制链接链接已复制到粘贴板!
When a new major version of Red Hat Developer Toolset is available, you can install it in parallel with the previous version. For detailed instructions on how to install Red Hat Developer Toolset on your system, see Section 1.5, “Installing Red Hat Developer Toolset”.
1.7. Uninstalling Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
To uninstall Red Hat Developer Toolset packages from your system:
yum remove devtoolset-10\* libasan libatomic libcilkrts libitm liblsan libtsan libubsan
# yum remove devtoolset-10\* libasan libatomic libcilkrts libitm liblsan libtsan libubsan
This removes the GNU Compiler Collection, GNU Debugger, binutils, and other packages that are a part of Red Hat Developer Toolset from the system.
Red Hat Developer Toolset 10.1 for Red Hat Enterprise Linux 7 no longer includes the 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.
Note that the uninstallation of the tools provided by Red Hat Developer Toolset does not affect the Red Hat Enterprise Linux system versions of these tools.
1.8. Using Red Hat Developer Toolset Container Images 复制链接链接已复制到粘贴板!
Docker-formatted container images can be used to run Red Hat Developer Toolset components inside virtual software containers, thus isolating them from the host system and allowing for their rapid deployment. For detailed description of the Red Hat Developer Toolset docker-formatted container images and Red Hat Developer Toolset Dockerfiles, see Using Red Hat Software Collections Container Images.
The docker package, which contains the Docker daemon, command-line tool, and other necessary components for building and using docker-formatted container images, is currently available only for the Server variant of the Red Hat Enterprise Linux 7 product.
Follow the instructions outlined at Getting Docker in RHEL 7 to set up an environment for building and using docker-formatted container images.
1.9. Additional Resources 复制链接链接已复制到粘贴板!
For more information about Red Hat Developer Toolset and Red Hat Enterprise Linux, see the resources listed below.
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 10.1 Release Notes — The Release Notes for Red Hat Developer Toolset 10.1 contain more information.
- Red Hat Enterprise Linux 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides more information on the Eclipse IDE, libraries and runtime support, compiling and building, debugging, and profiling on these systems.
- Red Hat Enterprise Linux 7 Installation Guide — The Installation Guide for Red Hat Enterprise Linux 7 explains how to obtain, install, and update the system.
- 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.
- Getting Started with Containers — The guide contains a comprehensive overview of information about building and using container images on Red Hat Enterprise Linux 7 and Red Hat Enterprise Linux Atomic Host.
See Also
- Appendix B, Changes in Version 10.1 — A list of changes and improvements over the version of the Red Hat Developer Toolset tools in the previous version of Red Hat Developer Toolset.
Part II. Development Tools 复制链接链接已复制到粘贴板!
Chapter 2. GNU Compiler Collection (GCC) 复制链接链接已复制到粘贴板!
The GNU Compiler Collection, commonly abbreviated GCC, is a portable compiler suite with support for a wide selection of programming languages.
Red Hat Developer Toolset is distributed with GCC 10.2.1. This version is more recent than the version included in Red Hat Enterprise Linux and provides a number of bug fixes and enhancements.
2.1. GNU C Compiler 复制链接链接已复制到粘贴板!
2.1.1. Installing the C Compiler 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the GNU C compiler is provided by the devtoolset-10-gcc package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
2.1.2. Using the C Compiler 复制链接链接已复制到粘贴板!
To compile a C program on the command line, run the gcc compiler as follows:
scl enable devtoolset-10 'gcc -o output_file source_file...'
$ scl enable devtoolset-10 'gcc -o output_file source_file...'
This creates a binary file named output_file in the current working directory. If the -o option is omitted, the compiler creates a file named a.out by default.
When you are working on a project that consists of several source files, it is common to compile an object file for each of the source files first and then link these object files together. This way, when you change a single source file, you can recompile only this file without having to compile the entire project. To compile an object file on the command line,:
scl enable devtoolset-10 'gcc -o object_file -c source_file'
$ scl enable devtoolset-10 'gcc -o object_file -c source_file'
This creates an object file named object_file. If the -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:
scl enable devtoolset-10 'gcc -o output_file object_file...'
$ scl enable devtoolset-10 'gcc -o output_file object_file...'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of gcc you are using at any point:
which gcc
$ which gcc
Red Hat Developer Toolset’s 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
$ gcc -v
Example 2.1. Compiling a C Program on the Command Line
Consider a source file named hello.c with the following contents:
Compile this source code on the command line by using the gcc compiler from Red Hat Developer Toolset:
scl enable devtoolset-10 'gcc -o hello hello.c'
$ scl enable devtoolset-10 'gcc -o hello hello.c'
This creates a new binary file called hello in the current working directory.
2.1.3. Running a C Program 复制链接链接已复制到粘贴板!
When 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 run it:
./file_name
$ ./file_name
Example 2.2. Running a C Program on the Command Line
Assuming that you have successfully compiled the 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
Hello, World!
2.2. GNU C++ Compiler 复制链接链接已复制到粘贴板!
2.2.1. Installing the C++ Compiler 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the GNU C++ compiler is provided by the devtoolset-10-gcc-c++ package and is automatically installed with the devtoolset-10-toolchain package as described in Section 1.5, “Installing Red Hat Developer Toolset”.
2.2.2. Using the C++ Compiler 复制链接链接已复制到粘贴板!
To compile a C++ program on the command line, run the g++ compiler as follows:
scl enable devtoolset-10 'g++ -o output_file source_file...'
$ scl enable devtoolset-10 'g++ -o output_file source_file...'
This creates a binary file named output_file in the current working directory. If the -o option is omitted, the g++ compiler creates a file named a.out by default.
When you are working on a project that consists of several source files, it is common to compile an object file for each of the source files first and then link these object files together. This way, when you change a single source file, you can recompile only this file without having to compile the entire project. To compile an object file on the command line:
scl enable devtoolset-10 'g++ -o object_file -c source_file'
$ scl enable devtoolset-10 'g++ -o object_file -c source_file'
This creates an object file named object_file. If the -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:
scl enable devtoolset-10 'g++ -o output_file object_file...'
$ scl enable devtoolset-10 'g++ -o output_file object_file...'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of g++ you are using at any point:
which g++
$ which g++
Red Hat Developer Toolset’s 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
$ g++ -v
Example 2.3. Compiling a C++ Program on the Command Line
Consider a source file named hello.cpp with the following contents:
Compile this source code on the command line by using the g++ compiler from Red Hat Developer Toolset:
scl enable devtoolset-10 'g++ -o hello hello.cpp'
$ scl enable devtoolset-10 'g++ -o hello hello.cpp'
This creates a new binary file called hello in the current working directory.
2.2.3. Running a C++ Program 复制链接链接已复制到粘贴板!
When 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 run it:
./file_name
$ ./file_name
Example 2.4. Running a C++ Program on the Command Line
Assuming that you have successfully compiled the hello binary file as shown in Example 2.3, “Compiling a C++ Program on the Command Line”, you can run it:
./hello
$ ./hello
Hello, World!
2.2.4. C++ Compatibility 复制链接链接已复制到粘贴板!
All compilers from Red Hat Enterprise Linux versions 5, 6, and 7 and from Red Hat Developer Toolset versions 1 to 10 in any -std mode are compatible with any other of those compilers in C++98 mode.
A compiler in C++11, C++14, or C++17 mode is only guaranteed to be compatible with another compiler in those same modes if they are from the same release series.
Supported examples:
- C++11 and C++11 from Red Hat Developer Toolset 6.x
- C++14 and C++14 from Red Hat Developer Toolset 6.x
- C++17 and C++17 from Red Hat Developer Toolset 10.x
- The GCC compiler in Red Hat Developer Toolset 10.x can build code using C++20 but this capability is experimental and not supported by Red Hat.
- All compatibility information mentioned in this section is relevant only for Red Hat-supplied versions of the GCC C++ compiler.
2.2.4.1. C++ ABI 复制链接链接已复制到粘贴板!
Any C++98-compliant binaries or libraries built by the Red Hat Developer Toolset toolchain explicitly with -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 GCC.
The default language standard setting for Red Hat Developer Toolset is C++14 with GNU extensions, equivalent to explicitly using option -std=gnu++14.
Using the C++14 language version is supported in Red Hat Developer Toolset when all C++ objects compiled with the respective flag have been built using Red Hat Developer Toolset 6 or later. Objects compiled by the system GCC in its default mode of C++98 are also compatible, but objects compiled with the system GCC in C++11 or C++14 mode are not compatible.
Starting with Red Hat Developer Toolset 10.x, using the C++17 language version is no longer experimental and is supported by Red Hat. All C++ objects compiled with C++17 must be built using Red Hat Developer Toolset 10.x or later.
Use of C++11, C++14, and C++17 features in your application requires careful consideration of the above ABI compatibility information.
The mixing of objects, binaries and libraries, built by the Red Hat Enterprise Linux 7 system toolchain GCC using the -std=c++0x or -std=gnu++0x flags, with those built with the C++11 or later language versions using the GCC in Red Hat Developer Toolset is explicitly not supported.
Aside from the C++11, C++14, and C++17 ABI, discussed above, the Red Hat Enterprise Linux Application Compatibility Specification is unchanged for Red Hat Developer Toolset. When mixing objects built with Red Hat Developer Toolset with those built with the Red Hat Enterprise Linux 7 toolchain (particularly .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.
A new standard mangling for SIMD vector types has been added to avoid name clashes on systems with vectors of varying lengths. The compiler in Red Hat Developer Toolset uses the new mangling by default. It is possible to use the previous standard mangling by adding the -fabi-version=2 or -fabi-version=3 options to GCC C++ compiler calls. To display a warning about code that uses the old mangling, use the -Wabi option.
On Red Hat Enterprise Linux 7, the GCC C++ compiler still uses the old mangling by default, but emits aliases with the new mangling on targets that support strong aliases. It is possible to use the new standard mangling by adding the -fabi-version=4 option to compiler calls. To display a warning about code that uses the old mangling, use the -Wabi option.
On Red Hat Enterprise Linux 7, the GCC C++ compiler in Red Hat Developer Toolset still uses the old reference-counted implementation of std::string. This is done for compatibility with the Red Hat Enterprise Linux 7 system toolchain GCC. This means that some new C++17 features, such as std::pmr::string, are not available on Red Hat Enterprise Linux 7, even when using the Red Hat Developer Toolset compiler.
2.3. GNU Fortran Compiler 复制链接链接已复制到粘贴板!
2.3.1. Installing the Fortran Compiler 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the GNU Fortran compiler is provided by the devtoolset-10-gcc-gfortran package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
2.3.2. Using the Fortran Compiler 复制链接链接已复制到粘贴板!
To compile a Fortran program on the command line, run the gfortran compiler as follows:
scl enable devtoolset-10 'gfortran -o output_file source_file...'
$ scl enable devtoolset-10 'gfortran -o output_file source_file...'
This creates a binary file named output_file in the current working directory. If the -o option is omitted, the compiler creates a file named a.out by default.
When you are working on a project that consists of several source files, it is common to compile an object file for each of the source files first and then link these object files together. This way, when you change a single source file, you can recompile only this file without having to compile the entire project. To compile an object file on the command line:
scl enable devtoolset-10 'gfortran -o object_file -c source_file'
$ scl enable devtoolset-10 'gfortran -o object_file -c source_file'
This creates an object file named object_file. If the -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:
scl enable devtoolset-10 'gfortran -o output_file object_file...'
$ scl enable devtoolset-10 'gfortran -o output_file object_file...'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of gfortran you are using at any point:
which gfortran
$ which gfortran
Red Hat Developer Toolset’s 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
$ gfortran -v
Example 2.5. Compiling a Fortran Program on the Command Line
Consider a source file named hello.f with the following contents:
program hello print *, "Hello, World!" end program hello
program hello
print *, "Hello, World!"
end program hello
Compile this source code on the command line by using the gfortran compiler from Red Hat Developer Toolset:
scl enable devtoolset-10 'gfortran -o hello hello.f'
$ scl enable devtoolset-10 'gfortran -o hello hello.f'
This creates a new binary file called hello in the current working directory.
2.3.3. Running a Fortran Program 复制链接链接已复制到粘贴板!
When 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 run it:
./file_name
$ ./file_name
Example 2.6. Running a Fortran Program on the Command Line
Assuming that you have successfully compiled the hello binary file as shown in Example 2.5, “Compiling a Fortran Program on the Command Line”, you can run it:
./hello
$ ./hello
Hello, World!
2.4. Specifics of GCC in Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
Static linking of libraries
Certain more recent library features are statically linked into applications built with Red Hat Developer Toolset to support execution on multiple versions of Red Hat Enterprise Linux. This creates an additional minor security risk as standard Red Hat Enterprise Linux errata do not change this code. If the need arises for developers to rebuild their applications due to this risk, Red Hat will communicate this using a security erratum.
Because of this additional security risk, developers are strongly advised not to statically link their entire application for the same reasons.
Specify libraries after object files when linking
In Red Hat Developer Toolset, libraries are linked using linker scripts which might specify some symbols through static archives. This is required to ensure compatibility with multiple versions of Red Hat Enterprise Linux. However, the linker scripts use the names of the respective shared object files. As a consequence, the linker uses different symbol handling rules than expected, and does not recognize symbols required by object files when the option adding the library is specified before options specifying the object files:
scl enable devtoolset-10 'gcc -lsomelib objfile.o'
$ scl enable devtoolset-10 'gcc -lsomelib objfile.o'
Using a library from the Red Hat Developer Toolset in this manner results in the linker error message undefined reference to symbol. To prevent this problem, follow the standard linking practice, and specify the option adding the library after the options specifying the object files:
scl enable devtoolset-10 'gcc objfile.o -lsomelib'
$ scl enable devtoolset-10 'gcc objfile.o -lsomelib'
Note that this recommendation also applies when using the base Red Hat Enterprise Linux version of GCC.
2.5. Additional Resources 复制链接链接已复制到粘贴板!
For more information about the GNU Compiler Collections and its features, see the resources listed below.
Installed Documentation
gcc(1) — The manual page for the
gcccompiler 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:scl enable devtoolset-10 'man gcc'
$ scl enable devtoolset-10 'man gcc'Copy to Clipboard Copied! Toggle word wrap Toggle overflow gfortran(1) — The manual page for the
gfortrancompiler provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man gfortran'
$ scl enable devtoolset-10 'man gfortran'Copy to Clipboard Copied! Toggle word wrap Toggle overflow C++ Standard Library Documentation — Documentation on the C++ standard library can be optionally installed:
yum install devtoolset-10-libstdc++-docs
# yum install devtoolset-10-libstdc++-docsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Once installed, HTML documentation is available at
/opt/rh/devtoolset-10/root/usr/share/doc/devtoolset-10-libstdC++-docs-10.2.1/html/index.html.
Online Documentation
- Red Hat Enterprise Linux 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides in-depth information about GCC.
- Using the GNU Compiler Collection — The upstream 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 — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 4, binutils — Instructions on using binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils — Instructions on using elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 6, dwz — Instructions on using the dwz tool to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
- Chapter 8, GNU Debugger (GDB) — Instructions on debugging programs written in C, C++, and Fortran.
Chapter 3. GNU make 复制链接链接已复制到粘贴板!
The GNU make utility, commonly abbreviated make, is a tool for controlling the generation of executables from source files. make automatically determines which parts of a complex program have changed and need to be recompiled. make uses configuration files called Makefiles to control the way programs are built.
Red Hat Developer Toolset is distributed with make 4.2.1. This version is more recent than the version included in Red Hat Enterprise Linux and provides a number of bug fixes and enhancements.
3.1. Installing make 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, GNU make is provided by the devtoolset-10-make package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
3.2. Using make 复制链接链接已复制到粘贴板!
To build a program without using a Makefile, run the make tool as follows:
scl enable devtoolset-10 'make source_file_without_extension'
$ scl enable devtoolset-10 'make source_file_without_extension'
This command makes use of implicit rules that are defined for a number of programming languages, including C, C++, and Fortran. The result is a binary file named source_file_without_extension in the current working directory.
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of make you are using at any point:
which make
$ which make
Red Hat Developer Toolset’s 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
$ make -v
Example 3.1. Building a C Program Using make
Consider a source file named hello.c with the following contents:
Build this source code using the implicit rules defined by the make utility from Red Hat Developer Toolset:
scl enable devtoolset-10 'make hello'
$ scl enable devtoolset-10 'make hello'
cc hello.c -o hello
This creates a new binary file called hello in the current working directory.
3.3. Using Makefiles 复制链接链接已复制到粘贴板!
To build complex programs that consist of a number of source files, make uses configuration files called Makefiles that control how to compile the components of a program and build the final executable. Makefiles can also contain instructions for cleaning the working directory, installing and uninstalling program files, and other operations.
make automatically uses files named GNUmakefile, makefile, or Makefile in the current directory. To specify another file name, use the -f option:
make -f make_file
$ make -f make_file
Describing the details of Makefile syntax is beyond the scope of this guide. See GNU make, the upstream GNU make manual, which provides an in-depth description of the GNU make utility, Makefile syntax, and their usage.
The full make manual is also available in the Texinfo format as a part of your installation. To view this manual:
scl enable devtoolset-10 'info make'
$ scl enable devtoolset-10 'info make'
Example 3.2. Building a C Program Using a Makefile
Consider the following universal Makefile named 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:
To build the hello.c program using this Makefile, run the make utility:
scl enable devtoolset-10 'make'
$ scl enable devtoolset-10 'make'
gcc -c -Wall hello.c -o hello.o
gcc hello.o -o hello
This creates a new object file hello.o and a new binary file called hello in the current working directory.
To clean the working directory, run:
scl enable devtoolset-10 'make clean'
$ scl enable devtoolset-10 'make clean'
rm -rf hello.o hello
This removes the object and binary files from the working directory.
3.4. Additional Resources 复制链接链接已复制到粘贴板!
For more information about the GNU make tool and its features, see the resources listed below.
Installed Documentation
make(1) — The manual page for the
makeutility provides information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man make'
$ scl enable devtoolset-10 'man make'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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:
scl enable devtoolset-10 'info make'
$ scl enable devtoolset-10 'info make'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Online Documentation
- GNU make — The upstream 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 — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) — Instructions on using the GNU Compiler Collection, a portable compiler suite with support for a wide selection of programming languages.
- Chapter 4, binutils — Instructions on using binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils — Instructions on using elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 6, dwz — Instructions on using the dwz tool to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
- Chapter 8, GNU Debugger (GDB) — Instructions on debugging programs written in C, C++, and Fortran.
Chapter 4. binutils 复制链接链接已复制到粘贴板!
binutils is a collection of various binary tools, such as the GNU linker, GNU assembler, and other utilities that allow you to inspect and manipulate object files and binaries. See Table 4.1, “Tools Included in binutils for Red Hat Developer Toolset” for a complete list of binary tools that are distributed with the Red Hat Developer Toolset version of binutils.
Red Hat Developer Toolset is distributed with binutils 2.35. This version is more recent than the version included in Red Hat Enterprise Linux and the previous release of Red Hat Developer Toolset and provides bug fixes and enhancements.
| Name | Description |
|---|---|
|
| Translates addresses into file names and line numbers. |
|
| Creates, modifies, and extracts files from archives. |
|
| The GNU assembler. |
|
| Decodes mangled C++ symbols. |
|
| Combines DWARF object files into a single DWARF package file. |
|
| Examines and edits ELF files. |
|
| Display profiling information. |
|
| The GNU linker. |
|
| An alternative to the GNU linker. |
|
| Another alternative to the GNU linker. |
|
| Lists symbols from object files. |
|
| Copies and translates object files. |
|
| Displays information from object files. |
|
| Generates an index to the contents of an archive to make access to this archive faster. |
|
| Displays information about ELF files. |
|
| Lists section sizes of object or archive files. |
|
| Displays printable character sequences in files. |
|
| Discards all symbols from object files. |
4.1. Installing binutils 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, binutils are provided by the devtoolset-10-binutils package and are automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
4.2. Using the GNU Assembler 复制链接链接已复制到粘贴板!
To produce an object file from an assembly language program, run the as tool as follows:
scl enable devtoolset-10 'as option ... -o object_file source_file'
$ scl enable devtoolset-10 'as option ... -o object_file source_file'
This creates an object file named object_file in the current working directory.
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of as you are using at any point:
which as
$ which as
Red Hat Developer Toolset’s 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
$ as -v
4.3. Using the GNU Linker 复制链接链接已复制到粘贴板!
To create an executable binary file or a library from object files, run the ld tool as follows:
scl enable devtoolset-10 'ld option ... -o output_file object_file ...'
$ scl enable devtoolset-10 'ld option ... -o output_file object_file ...'
This creates a binary file named output_file in the current working directory. If the -o option is omitted, the compiler creates a file named a.out by default.
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of ld you are using at any point:
which ld
$ which ld
Red Hat Developer Toolset’s 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
$ ld -v
4.4. Using Other Binary Tools 复制链接链接已复制到粘贴板!
The binutils provide many binary tools other than a linker and an assembler. For a complete list of these tools, see Table 4.1, “Tools Included in binutils for Red Hat Developer Toolset”.
To execute any of the tools that are a part of binutils:
scl enable devtoolset-10 'tool option ... file_name'
$ scl enable devtoolset-10 'tool option ... file_name'
See Table 4.1, “Tools Included in binutils for Red Hat Developer Toolset” for a list of tools that are distributed with binutils. For example, to use the objdump tool to inspect an object file:
scl enable devtoolset-10 'objdump option ... object_file'
$ scl enable devtoolset-10 'objdump option ... object_file'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of binutils you are using at any point:
which objdump
$ which objdump
Red Hat Developer Toolset’s 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
$ objdump -v
4.5. Specifics of binutils in Red Hat Developer Toolset 复制链接链接已复制到粘贴板!
Static linking of libraries
Certain more recent library features are statically linked into applications built with Red Hat Developer Toolset to support execution on multiple versions of Red Hat Enterprise Linux. This creates an additional minor security risk as standard Red Hat Enterprise Linux errata do not change this code. If the need arises for developers to rebuild their applications due to this risk, Red Hat will communicate this using a security erratum.
Because of this additional security risk, developers are strongly advised not to statically link their entire application for the same reasons.
Specify libraries after object files when linking
In Red Hat Developer Toolset, libraries are linked using linker scripts which might specify some symbols through static archives. This is required to ensure compatibility with multiple versions of Red Hat Enterprise Linux. However, the linker scripts use the names of the respective shared object files. As a consequence, the linker uses different symbol handling rules than expected, and does not recognize symbols required by object files when the option adding the library is specified before options specifying the object files:
scl enable devtoolset-10 'ld -lsomelib objfile.o'
$ scl enable devtoolset-10 'ld -lsomelib objfile.o'
Using a library from the Red Hat Developer Toolset in this manner results in the linker error message undefined reference to symbol. To prevent this problem, follow the standard linking practice, and specify the option adding the library after the options specifying the object files:
scl enable devtoolset-10 'ld objfile.o -lsomelib'
$ scl enable devtoolset-10 'ld objfile.o -lsomelib'
Note that this recommendation also applies when using the base Red Hat Enterprise Linux version of binutils.
4.6. Additional Resources 复制链接链接已复制到粘贴板!
For more information about binutils, see the resources listed below.
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:
scl enable devtoolset-10 'man tool'
$ scl enable devtoolset-10 'man tool'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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 — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 5, elfutils — Information on how to use elfutils, a collection of binary tools to inspect and manipulate ELF files.
- Chapter 2, GNU Compiler Collection (GCC) — Information on how to compile programs written in C, C++, and Fortran.
Chapter 5. elfutils 复制链接链接已复制到粘贴板!
elfutils is a collection of various binary tools, such as 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.
Red Hat Developer Toolset is distributed with elfutils 0.182. This version is more recent than the version included the previous release of Red Hat Developer Toolset and provides some bug fixes and enhancements.
| Name | Description |
|---|---|
|
| Translates addresses into file names and line numbers. |
|
| Creates, modifies, and extracts files from archives. |
|
| Compares relevant parts of two ELF files for equality. |
|
| Verifies that ELF files are compliant with the generic ABI (gABI) and processor-specific supplement ABI (psABI) specification. |
|
| Locates the source of text relocations in files. |
|
| Creates an offline archive for debugging. |
|
| Lists symbols from object files. |
|
| Displays information from object files. |
|
| Generates an index to the contents of an archive to make access to this archive faster. |
|
| Displays information about ELF files. |
|
| Lists section sizes of object or archive files. |
|
| A new utility for unwinding processes and cores. |
|
| Displays printable character sequences in files. |
|
| Discards all symbols from object files. |
|
| Combines stripped files with separate symbols and debug information. |
5.1. Installing elfutils 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, elfutils is provided by the devtoolset-10-elfutils package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
5.2. Using elfutils 复制链接链接已复制到粘贴板!
To execute any of the tools that are part of elfutils, run the tool as follows:
scl enable devtoolset-10 'tool option ... file_name'
$ scl enable devtoolset-10 'tool option ... file_name'
See Table 5.1, “Tools Included in elfutils for Red Hat Developer Toolset” for a list of tools that are distributed with elfutils. For example, to use the eu-objdump tool to inspect an object file:
scl enable devtoolset-10 'eu-objdump option ... object_file'
$ scl enable devtoolset-10 'eu-objdump option ... object_file'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of elfutils you are using at any point:
which eu-objdump
$ which eu-objdump
Red Hat Developer Toolset’s 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
$ eu-objdump -V
5.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about elfutils, see the resources listed below.
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) — Instructions on compiling programs written in C, C++, and Fortran.
- Chapter 4, binutils — Instructions on using binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 6, dwz — Instructions on using the dwz tool to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size.
Chapter 6. dwz 复制链接链接已复制到粘贴板!
dwz is a command line tool that attempts to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size. To do so, 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.
Red Hat Developer Toolset is distributed with dwz 0.12.
6.1. Installing dwz 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the dwz utility is provided by the devtoolset-10-dwz package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
6.2. Using dwz 复制链接链接已复制到粘贴板!
To optimize DWARF debugging information in a binary file, run the dwz tool as follows:
scl enable devtoolset-10 'dwz option... file_name'
$ scl enable devtoolset-10 'dwz option... file_name'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of dwz you are using at any point:
which dwz
$ which dwz
Red Hat Developer Toolset’s 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
$ dwz -v
6.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about dwz and its features, see the resources listed below.
Installed Documentation
dwz(1) — The manual page for the
dwzutility provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man dwz'
$ scl enable devtoolset-10 'man dwz'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) — Instructions on compiling programs written in C, C++, and Fortran.
- Chapter 4, binutils — Instructions on using binutils, a collection of binary tools to inspect and manipulate object files and binaries.
- Chapter 5, elfutils — Instructions on using elfutils, a collection of binary tools to inspect and manipulate ELF files.
Chapter 7. Annobin 复制链接链接已复制到粘贴板!
The Annobin project consists of the annobin plugin and the annocheck program.
The annobin plugin scans the GNU Compiler Collection (GCC) command line, the compilation state, and the compilation process, and generates the ELF notes. The ELF notes record how the binary was built and provide information for the annocheck program to perform security hardening checks.
The security hardening checker is part of the annocheck program and is enabled by default. It checks the binary files to determine whether the program was built with necessary security hardening options and compiled correctly. annocheck is able to recursively scan directories, archives, and RPM packages for ELF object files.
The files must be in ELF format. annocheck does not handle any other binary file types.
7.1. Installing Annobin 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the annobin plugin and the annocheck program are provided by the devtoolset-10-gcc package and are installed as described in Section 1.5.3, “Installing Optional Packages”.
7.2. Using Annobin Plugin 复制链接链接已复制到粘贴板!
To pass options to the annobin plugin with gcc, use:
scl enable devtoolset-10 'gcc -fplugin=annobin -fplugin-arg-annobin-option file-name'
$ scl enable devtoolset-10 'gcc -fplugin=annobin -fplugin-arg-annobin-option file-name'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of annobin you are using at any point:
which annobin
$ which annobin
Red Hat Developer Toolset’s annobin executable path will begin with /opt.
7.3. Using Annocheck 复制链接链接已复制到粘贴板!
To scan files, directories or RPM packages with the annocheck program:
scl enable devtoolset-10 'annocheck file-name'
$ scl enable devtoolset-10 'annocheck file-name'
annocheck only looks for the ELF files. Other file types are ignored.
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of annocheck you are using at any point:
which annocheck
$ which annocheck
Red Hat Developer Toolset’s annocheck 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 annocheck:
annocheck --version
$ annocheck --version
7.4. Additional Resources 复制链接链接已复制到粘贴板!
For more information about annocheck, annobin and its features, see the resources listed below.
Installed Documentation
annocheck(1) — The manual page for the
annocheckutility provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man annocheck'
$ scl enable devtoolset-10 'man annocheck'Copy to Clipboard Copied! Toggle word wrap Toggle overflow annobin(1) — The manual page for the
annobinutility provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man annobin'
$ scl enable devtoolset-10 'man annobin'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Part III. Debugging Tools 复制链接链接已复制到粘贴板!
Chapter 8. GNU Debugger (GDB) 复制链接链接已复制到粘贴板!
The GNU Debugger, commonly abbreviated as GDB, is a command line tool that can be used to debug programs written in various programming languages. It allows you to inspect memory within the code being debugged, control the execution state of the code, detect the execution of particular sections of code, and much more.
Red Hat Developer Toolset is distributed with GDB 9.2. This version is more recent than the version included in Red Hat Enterprise Linux and the previous release of Red Hat Developer Toolset and provides some enhancements and numerous bug fixes.
8.1. Installing the GNU Debugger 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the GNU Debugger is provided by the devtoolset-10-gdb package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
8.2. Preparing a Program for Debugging 复制链接链接已复制到粘贴板!
Compiling Programs with Debugging Information
To compile a C program with debugging information that can be read by the GNU Debugger, make sure the gcc compiler is run with the -g option:
scl enable devtoolset-10 'gcc -g -o output_file input_file...'
$ scl enable devtoolset-10 'gcc -g -o output_file input_file...'
Similarly, to compile a C++ program with debugging information:
scl enable devtoolset-10 'g++ -g -o output_file input_file...'
$ scl enable devtoolset-10 'g++ -g -o output_file input_file...'
Example 8.1. Compiling a C Program With Debugging Information
Consider a source file named fibonacci.c that has the following contents:
Compile this program on the command line using GCC from Red Hat Developer Toolset with debugging information for the GNU Debugger:
scl enable devtoolset-10 'gcc -g -o fibonacci fibonacci.c'
$ scl enable devtoolset-10 'gcc -g -o fibonacci fibonacci.c'
This creates a new binary file called fibonacci in the current working directory.
Installing Debugging Information for Existing Packages
To install debugging information for a package that is already installed on the system:
debuginfo-install package_name
# debuginfo-install package_name
Note that the yum-utils package must be installed for the debuginfo-install utility to be available on your system.
Example 8.2. Installing Debugging Information for the glibc Package
Install debugging information for the glibc package:
debuginfo-install glibc
# 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
...
8.3. Running the GNU Debugger 复制链接链接已复制到粘贴板!
To run the GNU Debugger on a program you want to debug:
scl enable devtoolset-10 'gdb file_name'
$ scl enable devtoolset-10 'gdb file_name'
This starts the 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:
(gdb) quit
(gdb) quit
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of gdb you are using at any point:
which gdb
$ which gdb
Red Hat Developer Toolset’s 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
$ gdb -v
Example 8.3. Running the gdb Utility on the fibonacci Binary File
This example assumes that you have successfully compiled the fibonacci binary file as shown in Example 8.1, “Compiling a C Program With Debugging Information”.
Start debugging fibonacci with gdb:
8.4. Listing Source Code 复制链接链接已复制到粘贴板!
To view the source code of the program you are debugging:
(gdb) list
(gdb) list
Before you start the execution of the program you are debugging, 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.
You can also display the code that is surrounding a particular line:
(gdb) list file_name:line_number
(gdb) list file_name:line_number
Similarly, to display the code that is surrounding the beginning of a particular function:
(gdb) list file_name:function_name
(gdb) list file_name:function_name
Note that you can change the number of lines the list command displays:
(gdb) set listsize number
(gdb) set listsize number
Example 8.4. Listing the Source Code of the fibonacci Binary File
The fibonacci.c file listed in Example 8.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
(gdb) set listsize 20
You can now display the entire source code of the file you are debugging by running the list command with no additional arguments:
8.5. Setting Breakpoints 复制链接链接已复制到粘贴板!
Setting a New Breakpoint
To set a new breakpoint at a certain line:
(gdb) break file_name:line_number
(gdb) break file_name:line_number
You can also set a breakpoint on a certain function:
(gdb) break file_name:function_name
(gdb) break file_name:function_name
Example 8.5. Setting a New Breakpoint
This example assumes that you have compiled the fibonacci.c file listed in Example 8.1, “Compiling a C Program With Debugging Information” with debugging information.
Set a new breakpoint at line 10:
(gdb) break 10 Breakpoint 1 at 0x4004e5: file fibonacci.c, line 10.
(gdb) break 10
Breakpoint 1 at 0x4004e5: file fibonacci.c, line 10.
Listing Breakpoints
To display a list of currently set breakpoints:
(gdb) info breakpoints
(gdb) info breakpoints
Example 8.6. Listing Breakpoints
This example assumes that you have followed the instructions in Example 8.5, “Setting a New Breakpoint”.
Display the list of currently set breakpoints:
(gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x00000000004004e5 in main at fibonacci.c:10
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004004e5 in main at fibonacci.c:10
Deleting Existing Breakpoints
To delete a breakpoint that is set at a certain line:
(gdb) clear line_number
(gdb) clear line_number
Similarly, to delete a breakpoint that is set on a certain function:
(gdb) clear function_name
(gdb) clear function_name
Example 8.7. Deleting an Existing Breakpoint
This example assumes that you have compiled the fibonacci.c file listed in Example 8.1, “Compiling a C Program With Debugging Information” with debugging information.
Set a new breakpoint at line 7:
(gdb) break 7 Breakpoint 2 at 0x4004e3: file fibonacci.c, line 7.
(gdb) break 7
Breakpoint 2 at 0x4004e3: file fibonacci.c, line 7.
Remove this breakpoint:
(gdb) clear 7 Deleted breakpoint 2
(gdb) clear 7
Deleted breakpoint 2
8.6. Starting Execution 复制链接链接已复制到粘贴板!
To start an execution of the program you are debugging:
(gdb) run
(gdb) run
If the program accepts any command line arguments, you can provide them as arguments to the run command:
(gdb) run argument…
(gdb) run argument…
The execution stops when the first breakpoint (if any) is reached, when an error occurs, or when the program terminates.
Example 8.8. Executing the fibonacci Binary File
This example assumes that you have followed the instructions in Example 8.5, “Setting a New Breakpoint”.
Execute the fibonacci binary file:
(gdb) run
Starting program: /home/john/fibonacci
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
(gdb) run
Starting program: /home/john/fibonacci
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
8.7. Displaying Current Values 复制链接链接已复制到粘贴板!
The 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.
To display the current value of a certain variable:
(gdb) print variable_name
(gdb) print variable_name
Example 8.9. Displaying the Current Values of Variables
This example assumes that you have followed the instructions in Example 8.8, “Executing the fibonacci Binary File” and the execution of the fibonacci binary stopped after reaching the breakpoint at line 10.
Display the current values of variables a and b:
(gdb) print a $1 = 0 (gdb) print b $2 = 1
(gdb) print a
$1 = 0
(gdb) print b
$2 = 1
8.8. Continuing Execution 复制链接链接已复制到粘贴板!
To resume the execution of the program you are debugging after it reached a breakpoint:
(gdb) continue
(gdb) continue
The execution stops again when another breakpoint is reached. To skip a certain number of breakpoints (typically when you are debugging a loop):
(gdb) continue number
(gdb) continue number
The gdb utility also allows you to stop the execution after executing a single line of code:
(gdb) step
(gdb) step
Finally, you can execute a certain number of lines:
(gdb) step number
(gdb) step number
Example 8.10. Continuing the Execution of the fibonacci Binary File
This example assumes that you have followed the instructions in Example 8.8, “Executing the fibonacci Binary File”, and the execution of the fibonacci binary stopped after reaching the breakpoint at line 10.
Resume the execution:
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0x7fffffffe4d8) at fibonacci.c:10
10 printf("%ld ", b);
The execution stops the next time the breakpoint is reached.
Execute the next three lines of code:
(gdb) step 3 13 b = sum;
(gdb) step 3
13 b = sum;
This allows you to verify the current value of the sum variable before it is assigned to b:
(gdb) print sum $3 = 2
(gdb) print sum
$3 = 2
8.9. Additional Resources 复制链接链接已复制到粘贴板!
For more information about the GNU Debugger and all its features, see the resources listed below.
Installed Documentation
Installing the devtoolset-10-gdb-doc package provides the following documentation in HTML and PDF formats in the /opt/rh/devtoolset-10/root/usr/share/doc/devtoolset-10-gdb-doc-9.2 directory:
- The Debugging with GDB book, which is a copy of the upstream material with the same name. The version of this document exactly corresponds to the version of GDB available in Red Hat Developer Toolset.
- The GDB’s Obsolete Annotations document, which lists the obsolete GDB level 2 annotations.
Online Documentation
- Red Hat Enterprise Linux 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides more information on the GNU Debugger and debugging.
- GDB Documentation — The upstream GDB documentation includes the GDB User Manual and other reference material.
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 2, GNU Compiler Collection (GCC) — Further information on how to compile programs written in C, C++, and Fortran.
- Chapter 9, strace — Instructions on using the strace utility to monitor system calls that a program uses and signals it receives.
- Chapter 11, memstomp — Instructions on using the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 9. strace 复制链接链接已复制到粘贴板!
strace is a diagnostic and debugging tool for the command line that can be used to trace system calls that are made and received by a running process. It records the name of each system call, its arguments, and its return value, as well as signals received by the process and other interactions with the kernel, and prints this record to standard error output or a selected file.
Red Hat Developer Toolset is distributed with strace 5.7.
9.1. Installing strace 复制链接链接已复制到粘贴板!
In Red Hat Enterprise Linux, the strace utility is provided by the devtoolset-10-strace package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
9.2. Using strace 复制链接链接已复制到粘贴板!
To run the strace utility on a program you want to analyze:
scl enable devtoolset-10 'strace program argument...'
$ scl enable devtoolset-10 'strace program argument...'
Replace program with the name of the program you want to analyze, and argument with any command line options and arguments you want to supply to this program. Alternatively, you can run the utility on an already running process by using the -p command line option followed by the process ID:
scl enable devtoolset-10 'strace -p process_id'
$ scl enable devtoolset-10 'strace -p process_id'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of strace you are using at any point:
which strace
$ which strace
Red Hat Developer Toolset’s 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
$ strace -V
9.2.1. Redirecting Output to a File 复制链接链接已复制到粘贴板!
By default, 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-10 'strace -o file_name program argument...'
$ scl enable devtoolset-10 'strace -o file_name program argument...'
Replace file_name with the name of the file.
Example 9.1. Redirecting Output to a File
Consider a slightly modified version of the fibonacci file from Example 8.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. Run the strace utility on this file and redirect the trace output to fibonacci.log:
scl enable devtoolset-10 'strace -o fibonacci.log ./fibonacci 20'
$ scl enable devtoolset-10 '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
This creates a new plain-text file called fibonacci.log in the current working directory.
9.2.2. Tracing Selected System Calls 复制链接链接已复制到粘贴板!
To trace only a selected set of system calls, run the strace utility with the -e command line option:
scl enable devtoolset-10 'strace -e expression program argument...'
$ scl enable devtoolset-10 'strace -e expression program argument...'
Replace expression with a comma-separated list of system calls to trace or any of the keywords listed in Table 9.1, “Commonly Used Values of the -e Option”. For a detailed description of all available values, see the strace(1) manual page.
| Value | Description |
|---|---|
|
| System calls that accept a file name as an argument. |
|
| System calls that are related to process management. |
|
| System calls that are related to networking. |
|
| System calls that are related to signal management. |
|
| System calls that are related to inter-process communication (IPC). |
|
| System calls that are related to file descriptors. |
Note that the syntax -e expression is a shorthand for the full form -e trace=expression.
Example 9.2. Tracing Selected System Calls
Consider the employee file from Example 11.1, “Using memstomp”. Run the strace utility on this executable file and trace only the mmap and munmap system calls:
9.2.3. Displaying Time Stamps 复制链接链接已复制到粘贴板!
To prefix each line of the trace with the exact time of the day in hours, minutes, and seconds, run the strace utility with the -t command line option:
scl enable devtoolset-10 'strace -t program argument...'
$ scl enable devtoolset-10 'strace -t program argument...'
To also display milliseconds, supply the -t option twice:
scl enable devtoolset-10 'strace -tt program argument...'
$ scl enable devtoolset-10 'strace -tt program argument...'
To prefix each line of the trace with the time required to execute the respective system call, use the -r command line option:
scl enable devtoolset-10 'strace -r program argument...'
$ scl enable devtoolset-10 'strace -r program argument...'
Example 9.3. Displaying Time Stamps
Consider an executable file named pwd. Run the strace utility on this file and include time stamps in the output:
9.2.4. Displaying a Summary 复制链接链接已复制到粘贴板!
To display a summary of how much time was required to execute each system call, how many times were these system calls executed, and how many errors were encountered during their execution, run the strace utility with the -c command line option:
scl enable devtoolset-10 'strace -c program argument...'
$ scl enable devtoolset-10 'strace -c program argument...'
Example 9.4. Displaying a Summary
Consider an executable file named lsblk. Run the strace utility on this file and display a trace summary:
9.2.5. Tampering with System Call Results 复制链接链接已复制到粘贴板!
Simulating errors returned from system calls can help identify missing error handling in programs.
To make a program receive a generic error as the result of a particular system call, run the strace utility with the -e fault= option and supply the system call:
scl enable devtoolset-10 'strace -e fault=syscall program argument...'
$ scl enable devtoolset-10 'strace -e fault=syscall program argument...'
To specify the error type or return value, use the -e inject= option:
scl enable devtoolset-10 'strace -e inject=syscall:error=error-type program argument' scl enable devtoolset-10 'strace -e inject=syscall:retval=return-value program argument'
$ scl enable devtoolset-10 'strace -e inject=syscall:error=error-type program argument'
$ scl enable devtoolset-10 'strace -e inject=syscall:retval=return-value program argument'
Note that specifying the error type and return value is mutually exclusive.
Example 9.5. Tampering with System Call Results
Consider an executable file named lsblk. Run the strace utility on this file and make the mmap() system call return an error:
9.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about strace and its features, see the resources listed below.
Installed Documentation
strace(1) — The manual page for the
straceutility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man strace'
$ scl enable devtoolset-10 'man strace'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 10, ltrace — Instructions on tracing program library calls using the ltrace tool.
- Chapter 8, GNU Debugger (GDB) — Instructions on debugging programs written in C, C++, and Fortran.
- Chapter 11, memstomp — Instructions on using the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 10. ltrace 复制链接链接已复制到粘贴板!
ltrace is a diagnostic and debugging tool for the command line that can be used to display calls that are made to shared libraries. It uses the dynamic library hooking mechanism, which prevents it from tracing calls to statically linked libraries. ltrace also displays return values of the library calls. The output is printed to standard error output or to a selected file.
Red Hat Developer Toolset is distributed with ltrace 0.7.91. While the base version ltrace remains the same as in the previous release of Red Hat Developer Toolset, various enhancements and bug fixes have ported.
10.1. Installing ltrace 复制链接链接已复制到粘贴板!
In Red Hat Enterprise Linux, the ltrace utility is provided by the devtoolset-10-ltrace package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
10.2. Using ltrace 复制链接链接已复制到粘贴板!
To run the ltrace utility on a program you want to analyze:
scl enable devtoolset-10 'ltrace program argument...'
$ scl enable devtoolset-10 'ltrace program argument...'
Replace program with the name of the program you want to analyze, and argument with any command line options and arguments you want to supply to this program. Alternatively, you can run the utility on an already running process by using the -p command line option followed by the process ID:
scl enable devtoolset-10 'ltrace -p process_id'
$ scl enable devtoolset-10 'ltrace -p process_id'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of ltrace you are using at any point:
which ltrace
$ which ltrace
Red Hat Developer Toolset’s 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
$ ltrace -V
10.2.1. Redirecting Output to a File 复制链接链接已复制到粘贴板!
By default, 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-10 'ltrace -o file_name program argument...'
$ scl enable devtoolset-10 'ltrace -o file_name program argument...'
Replace file_name with the name of the file.
Example 10.1. Redirecting Output to a File
Consider a slightly modified version of the fibonacci file from Example 8.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. Run the ltrace utility on this file and redirect the trace output to fibonacci.log:
scl enable devtoolset-10 'ltrace -o fibonacci.log ./fibonacci 20'
$ scl enable devtoolset-10 '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
This creates a new plain-text file called fibonacci.log in the current working directory.
10.2.2. Tracing Selected Library Calls 复制链接链接已复制到粘贴板!
To trace only a selected set of library calls, run the ltrace utility with the -e command line option:
scl enable devtoolset-10 'ltrace -e expression program argument...'
$ scl enable devtoolset-10 'ltrace -e expression program argument...'
Replace expression with a chain of rules to specify the library calls to trace. The rules can consist of patterns that identify symbol names (such as 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:
scl enable devtoolset-10 'ltrace -e malloc+free-@libc.so* program'
$ scl enable devtoolset-10 'ltrace -e malloc+free-@libc.so* program'
Example 10.2. Tracing Selected Library Calls
Consider the ls command. Run the ltrace utility on this program and trace only the opendir, readdir, and closedir function calls:
For a detailed description of available filter expressions, see the ltrace(1) manual page.
10.2.3. Displaying Time Stamps 复制链接链接已复制到粘贴板!
To prefix each line of the trace with the exact time of the day in hours, minutes, and seconds, run the ltrace utility with the -t command line option:
scl enable devtoolset-10 'ltrace -t program argument...'
$ scl enable devtoolset-10 'ltrace -t program argument...'
To also display milliseconds, supply the -t option twice:
scl enable devtoolset-10 'ltrace -tt program argument...'
$ scl enable devtoolset-10 'ltrace -tt program argument...'
To prefix each line of the trace with the time required to execute the respective system call, use the -r command line option:
scl enable devtoolset-10 'ltrace -r program argument...'
$ scl enable devtoolset-10 'ltrace -r program argument...'
Example 10.3. Displaying Time Stamps
Consider the pwd command. Run the ltrace utility on this program and include time stamps in the output:
10.2.4. Displaying a Summary 复制链接链接已复制到粘贴板!
To display a summary of how much time was required to execute each system call and how many times were these system calls executed, run the ltrace utility with the -c command line option:
scl enable devtoolset-10 'ltrace -c program argument...'
$ scl enable devtoolset-10 'ltrace -c program argument...'
Example 10.4. Displaying a Summary
Consider the lsblk command. Run the ltrace utility on this program and display a trace summary:
10.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about ltrace and its features, see the resources listed below.
Installed Documentation
ltrace(1) — The manual page for the
ltraceutility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man ltrace'
$ scl enable devtoolset-10 'man ltrace'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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 — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 9, strace — Instructions on tracing program system calls using the strace tool.
- Chapter 8, GNU Debugger (GDB) — Instructions on debugging programs written in C, C++, and Fortran.
- Chapter 11, memstomp — Instructions on using the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
Chapter 11. memstomp 复制链接链接已复制到粘贴板!
memstomp is a command line tool that can be used to identify function calls with overlapping memory regions in situations when such an overlap is not permitted by various standards. It intercepts calls to the library functions listed in Table 11.1, “Function Calls Inspected by memstomp” and for each memory overlap, it displays a detailed backtrace to help you debug the problem.
Similarly to Valgrind, the 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.
Red Hat Developer Toolset is distributed with memstomp 0.1.5.
| Function | Description |
|---|---|
|
| Copies n bytes from one memory area to another and returns a pointer to the second memory area. |
|
| 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. |
|
| Copies n bytes from one memory area to another and returns a pointer to the byte following the last written byte. |
|
| Copies a string from one memory area to another and returns a pointer to the second string. |
|
| Copies a string from one memory area to another and returns a pointer to the terminating null byte of the second string. |
|
| Copies a maximum of n characters from one string to another and returns a pointer to the second string. |
|
| 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. |
|
| 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. |
|
| 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. |
|
|
The wide-character equivalent of the |
|
|
The wide-character equivalent of the |
|
|
The wide-character equivalent of the |
|
|
The wide-character equivalent of the |
|
|
The wide-character equivalent of the |
|
|
The wide-character equivalent of the |
11.1. Installing memstomp 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the memstomp utility is provided by the devtoolset-10-memstomp package and is automatically installed with devtoolset-10-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
11.2. Using memstomp 复制链接链接已复制到粘贴板!
To run the memstomp utility on a program you want to analyze:
scl enable devtoolset-10 'memstomp program argument...'
$ scl enable devtoolset-10 'memstomp program argument...'
To immediately terminate the analyzed program when a problem is detected, run the utility with the --kill (or -k for short) command line option:
scl enable devtoolset-10 'memstomp --kill program argument...'
$ scl enable devtoolset-10 'memstomp --kill program argument...'
The use of the --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.
Additionally, if you have compiled the analyzed program with the debugging information or this debugging information is available to you, you can use the --debug-info (or -d) command line option to produce a more detailed backtrace:
scl enable devtoolset-10 'memstomp --debug-info program argument...'
$ scl enable devtoolset-10 'memstomp --debug-info program argument...'
For detailed instructions on how to compile your program with the debugging information built in the binary file, see Section 8.2, “Preparing a Program for Debugging”. For information on how to install debugging information for any of the Red Hat Developer Toolset packages, see Section 1.5.4, “Installing Debugging Information”.
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
Example 11.1. Using memstomp
In the current working directory, create a source file named employee.c with the following contents:
Compile this program into a binary file named employee:
scl enable devtoolset-10 'gcc -rdynamic -g -o employee employee.c'
$ scl enable devtoolset-10 'gcc -rdynamic -g -o employee employee.c'
To identify erroneous function calls with overlapping memory regions:
11.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about memstomp and its features, see the resources listed below.
Installed Documentation
memstomp(1) — The manual page for the
memstomputility provides detailed information about its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man memstomp'
$ scl enable devtoolset-10 'man memstomp'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 8, GNU Debugger (GDB) — Instructions on debugging programs written in C, C++, and Fortran.
- Chapter 9, strace — Instructions on using the strace utility to monitor system calls that a program uses and signals it receives.
- Chapter 13, Valgrind — Instructions on using the Valgrind tool 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 12. SystemTap 复制链接链接已复制到粘贴板!
SystemTap is a tracing and probing tool that allows users to monitor the activities of the entire system without needing to instrument, recompile, install, and reboot. It is programmable with a custom scripting language, which gives it expressiveness (to trace, filter, and analyze) and reach (to look into the running kernel and applications).
SystemTap can monitor various types of events, such as function calls within the kernel or applications, timers, tracepoints, performance counters, and so on. Some included example scripts produce output similar to netstat, ps, top, and iostat, others include pretty-printed function callgraph traces or tools for working around security bugs.
Red Hat Developer Toolset is distributed with SystemTap 4.4. This version is more recent than the version included in the previous release of Red Hat Developer Toolset and provides numerous bug fixes and enhancements.
| Name | Description |
|---|---|
|
| Translates probing instructions into C code, builds a kernel module, and loads it into a running Linux kernel. |
|
| The Dyninst backend for SystemTap. |
|
|
Loads, unloads, attaches to, and detaches from kernel modules built with the |
|
| Serves as a remote shell for SystemTap. |
|
| Determines and—if possible—downloads the kernel information packages that are required to run SystemTap. |
|
|
Merges per-CPU files. This script is automatically executed when the |
|
| Gathers important information about the system for the purpose of reporting a bug in SystemTap. |
|
|
A compile server, which listens for requests from |
12.1. Installing SystemTap 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, SystemTap is provided by the devtoolset-10-systemtap package and is automatically installed with devtoolset-10-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.
In order to place instrumentation into the Linux kernel, SystemTap may also require installation of additional packages with debugging information. To determine which packages to install, run the stap-prep utility as follows:
scl enable devtoolset-10 'stap-prep'
$ scl enable devtoolset-10 'stap-prep'
Note that if you execute this command as the 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 7 SystemTap Beginners Guide.
12.2. Using SystemTap 复制链接链接已复制到粘贴板!
To execute any of the tools that are part of SystemTap:
scl enable devtoolset-10 'tool option...'
$ scl enable devtoolset-10 'tool option...'
See Table 12.1, “Tools Distributed with SystemTap for Red Hat Developer Toolset” for a list of tools that are distributed with SystemTap. For example, to run the stap tool to build an instrumentation module:
scl enable devtoolset-10 'stap option... argument...'
$ scl enable devtoolset-10 'stap option... argument...'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of SystemTap you are using at any point:
which stap
$ which stap
Red Hat Developer Toolset’s 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
$ stap -V
12.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about SystemTap and its features, see the resources listed below.
Installed Documentation
stap(1) — The manual page for the
stapcommand 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:scl enable devtoolset-10 'man stap'
$ scl enable devtoolset-10 'man stap'Copy to Clipboard Copied! Toggle word wrap Toggle overflow staprun(8) — The manual page for the
stapruncommand provides detailed information on its usage. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man staprun'
$ scl enable devtoolset-10 'man staprun'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Online Documentation
- 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 7 SystemTap Tapset Reference — The SystemTap Tapset Reference for Red Hat Enterprise Linux 7 provides further details about SystemTap.
- The SystemTap Documentation — The SystemTap documentation provides further documentation about SystemTap, and numerous examples of the SystemTap scripts.
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 13, Valgrind — Instructions on using the Valgrind tool 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, OProfile — Instructions on using the OProfile tool to determine which sections of code consume the greatest amount of CPU time and why.
- Chapter 15, Dyninst — Instructions on using the Dyninst library to instrument a user-space executable.
Chapter 13. Valgrind 复制链接链接已复制到粘贴板!
Valgrind is an instrumentation framework that ships with a number of tools for profiling applications. It can be used to detect various memory errors and memory-management problems, such as the use of uninitialized memory or an improper allocation and freeing of memory, or to identify the use of improper arguments in system calls. For a complete list of profiling tools that are distributed with the Red Hat Developer Toolset version of Valgrind, see Table 13.1, “Tools Distributed with Valgrind for Red Hat Developer Toolset”.
Valgrind profiles an application by rewriting it and instrumenting the rewritten binary. This allows you to profile your application without the need to recompile it, but it also makes Valgrind significantly slower than other profilers, especially when performing extremely detailed runs. It is therefore not suited to debugging time-specific issues, or kernel-space debugging.
Red Hat Developer Toolset is distributed with Valgrind 3.16.1. This version is more recent than the version included in the previous release of Red Hat Developer Toolset and provides numerous bug fixes and enhancements.
| Name | Description |
|---|---|
| Memcheck | Detects memory management problems by intercepting system calls and checking all read and write operations. |
| Cachegrind | Identifies the sources of cache misses by simulating the level 1 instruction cache (I1), level 1 data cache (D1), and unified level 2 cache (L2). |
| Callgrind | Generates a call graph representing the function call history. |
| Helgrind | Detects synchronization errors in multithreaded C, C++, and Fortran programs that use POSIX threading primitives. |
| DRD | Detects errors in multithreaded C and C++ programs that use POSIX threading primitives or any other threading concepts that are built on top of these POSIX threading primitives. |
| Massif | Monitors heap and stack usage. |
13.1. Installing Valgrind 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, Valgrind is provided by the devtoolset-10-valgrind package and is automatically installed with devtoolset-10-perftools.
For detailed instructions on how to install Red Hat Developer Toolset and related packages to your system, see Section 1.5, “Installing Red Hat Developer Toolset”.
Note that if you use Valgrind in combination with the GNU Debugger, it is recommended that you use the version of GDB that is included in Red Hat Developer Toolset to ensure that all features are fully supported.
13.2. Using Valgrind 复制链接链接已复制到粘贴板!
To run any of the Valgrind tools on a program you want to profile:
scl enable devtoolset-10 'valgrind --tool=tool program argument...'
$ scl enable devtoolset-10 'valgrind --tool=tool program argument...'
See Table 13.1, “Tools Distributed with Valgrind for Red Hat Developer Toolset” for a list of tools that are distributed with Valgrind. The argument of the --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:
scl enable devtoolset-10 'valgrind --tool=cachegrind program argument...'
$ scl enable devtoolset-10 'valgrind --tool=cachegrind program argument...'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of Valgrind you are using at any point:
which valgrind
$ which valgrind
Red Hat Developer Toolset’s 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
$ valgrind --version
13.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about Valgrind and its features, see the resources listed below.
Installed Documentation
valgrind(1) — The manual page for the
valgrindutility provides detailed information on how to use Valgrind. To display the manual page for the version included in Red Hat Developer Toolset:scl enable devtoolset-10 'man valgrind'
$ scl enable devtoolset-10 'man valgrind'Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Valgrind Documentation — HTML documentation for Valgrind is located at
/opt/rh/devtoolset-10/root/usr/share/doc/devtoolset-10-valgrind-3.16.1/html/index.html.
Online Documentation
- Red Hat Enterprise Linux 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides more information about Valgrind and its Eclipse plug-in.
- Red Hat Enterprise Linux 7 Performance Tuning Guide — The Performance Tuning Guide for Red Hat Enterprise Linux 7 provide more detailed information about using Valgrind to profile applications.
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 11, memstomp — Instructions on using the memstomp utility to identify calls to library functions with overlapping memory regions that are not allowed by various standards.
- Chapter 12, SystemTap — An introduction to the SystemTap tool and instructions on how to use it to monitor the activities of a running system.
- Chapter 14, OProfile — Instructions on using the OProfile tool to determine which sections of code consume the greatest amount of CPU time and why.
- Chapter 15, Dyninst — Instructions on using the Dyninst library to instrument a user-space executable.
Chapter 14. OProfile 复制链接链接已复制到粘贴板!
OProfile is a low overhead, system-wide profiler that uses the performance-monitoring hardware on the processor to retrieve information about the kernel and executables on the system, such as when memory is referenced, the number of level 2 cache (L2) requests, and the number of hardware interrupts received. It consists of a configuration utility, a daemon for collecting data, and a number of tools that can be used to transform the data into a human-readable form. For a complete list of tools that are distributed with the Red Hat Developer Toolset version of OProfile, see Table 14.1, “Tools Distributed with OProfile for Red Hat Developer Toolset”.
OProfile profiles an application without adding any instrumentation by recording the details of every nth event. This allows it to consume fewer resources than Valgrind, but it also causes its samples to be less precise. Unlike Valgrind, which only collects data for a single process and its children in user-space, OProfile is well suited to collect system-wide data on both user-space and kernel-space processes, and requires root privileges to run.
Red Hat Developer Toolset is distributed with OProfile 1.4.0.
| Name | Description |
|---|---|
|
| Records samples either for a single process or system-wide using the Linux Performance Events subsystem. |
|
| Generates an annotated source file or assembly listing from the profiling data. |
|
| Generates a directory containing executable, debug, and sample files. |
|
|
Generates a summary of a profiling session in a format compatible with |
|
| Displays a list of available events. |
|
| Converts a sample database file from a foreign binary format to the native format. |
|
| Converts a just-in-time (JIT) dump file to the Executable and Linkable Format (ELF). |
|
| Generates image and symbol summaries of a profiling session. |
|
| A new tool for counting the number of times particular events occur during the duration of a monitored command. |
14.1. Installing OProfile 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, OProfile is provided by the devtoolset-10-oprofile package and is automatically installed with devtoolset-10-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.
14.2. Using OProfile 复制链接链接已复制到粘贴板!
To run any of the tools that are distributed with OProfile:
scl enable devtoolset-10 'tool option...'
# scl enable devtoolset-10 'tool option...'
See Table 14.1, “Tools Distributed with OProfile for Red Hat Developer Toolset” for a list of tools that are distributed with OProfile. For example, to use the ophelp command to list available events in the XML format:
scl enable devtoolset-10 'ophelp -X'
$ scl enable devtoolset-10 'ophelp -X'
Note that you can execute any command using the 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-10 'bash'
$ scl enable devtoolset-10 'bash'
To verify the version of OProfile you are using at any point:
which operf
$ which operf
Red Hat Developer Toolset’s 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
# operf --version
14.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about OProfile and its features, see the resources listed below.
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:
scl enable devtoolset-10 'man oprofile'
$ scl enable devtoolset-10 'man oprofile'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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:
scl enable devtoolset-10 'man tool'
scl enable devtoolset-10 'man tool'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Online Documentation
- Red Hat Enterprise Linux 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides more information on OProfile.
-
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
operftool.
See Also
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 12, SystemTap — An introduction to SystemTap and instructions on how to use it to monitor the activities of a running system.
- Chapter 13, Valgrind — Instructions on using the Valgrind tool 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 15, Dyninst — Instructions on using the Dyninst library to instrument a user-space executable.
Chapter 15. Dyninst 复制链接链接已复制到粘贴板!
The Dyninst library provides an application programming interface (API) for instrumenting and working with user-space executables during their execution. It can be used to insert code into a running program, change certain subroutine calls, or even remove them from the program. It serves as a valuable debugging and performance-monitoring tool. The Dyninst API is also commonly used along with SystemTap to allow non-root users to instrument user-space executables.
Red Hat Developer Toolset is distributed with Dyninst 10.2.1.
15.1. Installing Dyninst 复制链接链接已复制到粘贴板!
In Red Hat Developer Toolset, the Dyninst library is provided by the devtoolset-10-dyninst package and is automatically installed with devtoolset-10-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”. In addition, it is recommended that you also install the GNU Compiler Collection provided by the devtoolset-10-toolchain package.
If you intend to write a custom instrumentation for binaries, install the relevant header files:
yum install devtoolset-10-dyninst-devel
# yum install devtoolset-10-dyninst-devel
You can also install API documentation for this library:
yum install devtoolset-10-dyninst-doc
# yum install devtoolset-10-dyninst-doc
For a complete list of documents that are included in the devtoolset-10-dyninst-doc package, see Section 15.3, “Additional Resources”. For detailed instructions on how to install optional packages to your system, see Section 1.5, “Installing Red Hat Developer Toolset”.
15.2. Using Dyninst 复制链接链接已复制到粘贴板!
15.2.1. Using Dyninst with SystemTap 复制链接链接已复制到粘贴板!
To use Dyninst along with SystemTap to allow non-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.
To use the Dyninst runtime to instrument an executable file:
scl enable devtoolset-10 "stap --dyninst -c 'command' option... argument..."
$ scl enable devtoolset-10 "stap --dyninst -c 'command' option... argument..."
Similarly, to use the Dyninst runtime to instrument a user’s process:
scl enable devtoolset-10 "stap --dyninst -x process_id option... argument..."
$ scl enable devtoolset-10 "stap --dyninst -x process_id option... argument..."
See Chapter 12, SystemTap for more information about the Red Hat Developer Toolset version of SystemTap. For a general introduction to SystemTap and its usage, see the SystemTap Beginners Guide for Red Hat Enterprise Linux 7.
Example 15.1. Using Dyninst with SystemTap
Consider a source file named exercise.C that has the following contents:
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 the standard output. Compile this program on the command line using the g++ compiler from Red Hat Developer Toolset:
scl enable devtoolset-10 'g++ -g -o exercise exercise.C'
$ scl enable devtoolset-10 'g++ -g -o exercise exercise.C'
Now consider another source file named count.stp with the following contents:
This SystemTap script prints the total number of times the print_iteration() function was called during the execution of a process. Run this script on the exercise binary file:
15.2.2. Using Dyninst as a Stand-alone Library 复制链接链接已复制到粘贴板!
Before using the Dyninst library as a part of your application, set the value of the DYNINSTAPI_RT_LIB environment variable to the path to the runtime library file:
export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-10/root/usr/lib64/dyninst/libdyninstAPI_RT.so
$ export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-10/root/usr/lib64/dyninst/libdyninstAPI_RT.so
This sets the DYNINSTAPI_RT_LIB environment variable in the current shell session.
Example 15.2, “Using Dyninst as a Stand-alone Application” illustrates how to write and build a program to monitor the execution of a user-space process. For a detailed explanation of how to use Dyninst, see the resources listed in Section 15.3, “Additional Resources”.
Example 15.2. Using Dyninst as a Stand-alone Application
Consider the exercise.C source file from Example 15.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.
Now consider another source file named count.C with the following contents:
Note that a client application is expected to destroy all 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.
This program accepts a process ID and a function name as command line arguments and then prints the total number of times the function was called during the execution of the process. You can use the following Makefile to build these two files:
To compile the two programs on the command line using the g++ compiler from Red Hat Developer Toolset, run the make utility:
scl enable devtoolset-10 make
$ scl enable devtoolset-10 make
g++ -g -I/opt/rh/devtoolset-10/root/usr/include/dyninst count.C -c
g++ -g -I/opt/rh/devtoolset-10/root/usr/include/dyninst count.o -L /opt/rh/devtoolset-10/root/usr/lib64/dyninst -ldyninstAPI -o count
g++ -g -I/opt/rh/devtoolset-10/root/usr/include/dyninst exercise.C -o exercise
This creates new binary files called exercise and count in the current working directory.
In one shell session, execute the exercise binary file as follows and wait for it to prompt you to enter the starting number:
./exercise
$ ./exercise
Enter the starting number:
Do not enter this number. Instead, start another shell session and type the following at its prompt to set the DYNINSTAPI_RT_LIB environment variable and execute the count binary file:
export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-10/root/usr/lib64/dyninst/libdyninstAPI_RT.so ./count `pidof exercise` print_iteration
$ export DYNINSTAPI_RT_LIB=/opt/rh/devtoolset-10/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...
Now switch back to the first shell session and enter the starting number as requested by the exercise program. For example:
When the exercise program terminates, the count program displays the number of times the print_iteration() function was executed:
Function executed 5 times.
Function executed 5 times.
15.3. Additional Resources 复制链接链接已复制到粘贴板!
For more information about Dyninst and its features, see the resources listed below.
Installed Documentation
The devtoolset-10-dyninst-doc package installs the following documents in the /opt/rh/devtoolset-10/root/usr/share/doc/devtoolset-10-dyninst-doc-10.2.1/ directory:
-
Dyninst Programmer’s Guide — A detailed description of the Dyninst API is stored in the
DyninstAPI.pdffile. -
DynC API Programmer’s Guide — An introduction to DynC API is stored in the
dynC_API.pdffile. -
ParseAPI Programmer’s Guide — An introduction to the ParseAPI is stored in the
ParseAPI.pdffile. -
PatchAPI Programmer’s Guide — An introduction to PatchAPI is stored in the
PatchAPI.pdffile. -
ProcControlAPI Programmer’s Guide — A detailed description of ProcControlAPI is stored in the
ProcControlAPI.pdffile. -
StackwalkerAPI Programmer’s Guide — A detailed description of StackwalkerAPI is stored in the
stackwalker.pdffile. -
SymtabAPI Programmer’s Guide — An introduction to SymtabAPI is stored in the
SymtabAPI.pdffile. -
InstructionAPI Reference Manual — A detailed description of the InstructionAPI is stored in the
InstructionAPI.pdffile.
For information on how to install this package on your system, see Section 15.1, “Installing Dyninst”.
Online Documentation
- Dyninst Home Page — The project home page provides links to additional documentation and related publications.
- 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 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 — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 12, SystemTap — An introduction to SystemTap and instructions on how to use it to monitor the activities of a running system.
- Chapter 13, Valgrind — Instructions on using the Valgrind tool 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, OProfile — Instructions on using the OProfile tool to determine which sections of code consume the greatest amount of CPU time and why.
Part V. Compiler Toolsets 复制链接链接已复制到粘贴板!
Chapter 16. Compiler Toolsets documentation 复制链接链接已复制到粘贴板!
The descriptions of the three compiler toolsets:
- LLVM Toolset
- Go Toolset
- Rust Toolset
have been moved to a separate documentation set under Red Hat Developer Tools.
Part VI. Getting Help 复制链接链接已复制到粘贴板!
Chapter 17. Accessing Red Hat Product Documentation 复制链接链接已复制到粘贴板!
Red Hat Product Documentation located at https://access.redhat.com/site/documentation/ serves as a central source of information. It is currently translated in 23 languages, and for each product, it provides different kinds of books from release and technical notes to installation, user, and reference guides in HTML, PDF, and EPUB formats.
Below is a brief list of documents that are directly or indirectly relevant to this book.
Red Hat Developer Toolset
- Red Hat Developer Toolset 10.1 Release Notes — The Release Notes for Red Hat Developer Toolset 10.1 contain more information.
- Using Red Hat Software Collections Container Images — The Using Red Hat Software Collections Container Images provides instructions for obtaining, configuring, and using container images that are shipped with Red Hat Software Collections, including the Red Hat Developer Toolset container images.
- 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 7 Developer Guide — The Developer Guide for Red Hat Enterprise Linux 7 provides more information about libraries and runtime support, compiling and building, debugging, and profiling.
- Red Hat Enterprise Linux 7 Installation Guide — The Installation Guide for Red Hat Enterprise Linux 7 explains how to obtain, install, and update the system.
- 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 18. Contacting Global Support Services 复制链接链接已复制到粘贴板!
Unless you have a Self-Support subscription, when both the Red Hat Documentation website and Customer Portal fail to provide the answers to your questions, you can contact Global Support Services (GSS).
18.1. Gathering Required Information 复制链接链接已复制到粘贴板!
Several items of information should be gathered before contacting GSS.
Background Information
Ensure you have the following background information at hand before calling GSS:
- 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
If you ever forget your Red Hat login information, it can be recovered at https://access.redhat.com/site/help/LoginAssistance.html.
Diagnostics
The diagnostics report for Red Hat Enterprise Linux is required as well. This report is also known as a sosreport and the program to create the report is provided by the sos package. To install the sos package and all its dependencies on your system:
yum install sos
# yum install sos
To generate the report:
sosreport
# sosreport
For more information, access the Knowledgebase article at https://access.redhat.com/kb/docs/DOC-3593.
Account and Contact Information
In order to help you, GSS requires your account information to customize their support, as well contact information to get back to you. When you contact GSS ensure you have your:
- 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
Determining an issue’s severity is important to allow the GSS team to prioritize their work. There are four levels of 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.
For more information on determining the severity level of an issue, see https://access.redhat.com/support/policy/severity.
Once the issue severity has been determined, submit a service request through the Customer Portal under the Connect option, or at https://access.redhat.com/support/contact/technicalSupport.html. Note that you need your Red Hat login details in order to submit service requests.
If the severity is level 1 or 2, then follow up your service request with a phone call. Contact information and business hours are found at https://access.redhat.com/support/contact/technicalSupport.html.
If you have a premium subscription, then after hours support is available for Severity 1 and 2 cases.
Turn-around rates for both premium subscriptions and standard subscription can be found at https://access.redhat.com/support/offerings/production/sla.html.
18.2. Escalating an Issue 复制链接链接已复制到粘贴板!
If you feel an issue is not being handled correctly or adequately, you can escalate it. There are two types of escalations:
- 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.
More information on escalation, including contacts, is available at https://access.redhat.com/support/policy/mgt_escalation.html.
18.3. Re-opening a Service Request 复制链接链接已复制到粘贴板!
If there is more relevant information regarding a closed service request (such as the problem reoccurring), you can re-open the request via the Red Hat Customer Portal at https://access.redhat.com/support/policy/mgt_escalation.html or by calling your local support center, the details of which can be found at https://access.redhat.com/support/contact/technicalSupport.html.
In order to re-open a service request, you need the original service-request number.
18.4. Additional Resources 复制链接链接已复制到粘贴板!
For more information, see the resources listed below.
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 10.0 复制链接链接已复制到粘贴板!
The sections below document features and compatibility changes introduced Red Hat Developer Toolset 10.0.
A.1. Changes in GCC 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with GCC 10.2.1.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
General improvements
New built-in functions:
-
The
__has_builtinbuilt-in preprocessor operator can now be used to query support for built-in GCC functions. -
The
__builtin_roundevenfunction has been added for the corresponding function from ISO/IEC TS 18661.
-
The
New command-line options:
-
-fallocation-dceremoves unnecessary pairs of thenewanddeleteoperators. -
-fprofile-partial-traininginforms the compiler that it should optimize only the size of code paths that are covered by the training run. -
-fprofile-reproduciblecontrols the level of reproducibility of profiles gathered by-fprofile-generate. Using this option you can rebuild a program with the same outcome. It is useful for distribution packages, for example. -
Experimental: the new
-fanalyzeroption enables a new static analysis pass and associated warnings. This pass examines paths in the code to detect various common errors, for example, double-free bugs. Note that this option is available only for code written in C.
-
Interprocedural optimization improvements:
- The interprocedural scalar replacement of aggregates (IPA-SRA) pass was re-implemented to work at link time. It can now also remove computing and returning unused return values.
-
The
-finline-functionsoption is now enabled at the optimization level-O2. This option now reduces code size better. Inliner heuristics now work faster to avoid negative impact on-flto-O2compile times. - Inliner heuristics and function cloning can now use value-range information to predict the effectiveness of individual transformations.
- During link-time optimization the C++ One Definition Rule is now used to increase precision of type-based alias analysis.
Link-time optimization improvements:
-
The parallel phase of the Link Time Optimization (LTO) can now automatically detect a running
jobserverof themaketool.
-
The parallel phase of the Link Time Optimization (LTO) can now automatically detect a running
Profile-driven optimization improvements:
- Profile maintenance during compilation and hot or cold code partitioning have been improved.
-
When GCC prints a warning, the option that controls the warning is now displayed as a hyperlink which you can click and see the documentation for the particular warning. To control this behavior, use the
-fdiagnostics-urlsoption.
Language-specific improvements
-
Several newly implemented OpenMP 5.0 features have been added. For example, the
conditional lastprivateclause,scanandloopdirectives,order(concurrent)anduse_device_addrclauses support,ifclauses onsimdconstructs or partial support for thedeclare variantdirective.
Notable changes related to languages include:
C family
New attributes:
-
The
accessfunction and type attribute has been added. It describes how a function accesses objects passed to it by a pointer or reference and associates such arguments with integer arguments that denote the objects' sizes. You can also use this attribute to enable the detection of invalid accesses by user-defined functions, such as those diagnosed by the-Wstringop-overflowoption.
-
The
New warnings:
-
-Wstring-compare, enabled by the-Wextraoption, warns about equality and inequality expressions between zero and the result of a call tostrcmporstrncmpwhen such expressions evaluate to a constant because the length of one argument is greater than the size of the array pointed to by the other argument. -
-Wzero-length-bounds, enabled by the-Warray-boundsoption, warns about accesses to elements of zero-length arrays that might overlap with other members of the same object.
-
Enhancements to existing warnings:
-
-Warray-boundsnow detects more out-of-bounds accesses to member arrays and elements of zero-length arrays. -
-Wformat-overflownow fully uses string length information calculated by thestrlenoptimization pass. -
-Wrestrictdetects overlapping accesses to dynamically allocated objects. -
-Wreturn-local-addrdiagnoses more instances of return statements returning addresses of automatic variables. -
-Wstringop-overflowdetects more out-of-bounds stores to member arrays including zero-length arrays, dynamically allocated objects, and variable length arrays. It now also detects more instances of reads of unterminated character arrays by the built-in string functions. In addition, the warning now detects out-of-bounds accesses by calls to user-defined functions declared with the new attribute access. -
-Warith-conversionre-enables warnings from-Wconversion,-Wfloat-conversion, and-Wsign-conversion. These warnings are now disabled by default for expressions where the result of an arithmetic operation will not fit into the target type because of promotion, but where the operands of the expressions fit into the target type.
-
C
Several new features from the upcoming C2X revision of the ISO C standard are now supported. To enable them, use
-std=c2xand-std=gnu2x. Some of these features are also supported as extensions when you compile with earlier C versions. Some features were previously supported as extensions and now have been added to the C standard. They are enabled by default in C2X mode and not diagnosed with-std=c2x-Wpedantic.-
The
[[]]attribute syntax is now supported. - In C2X mode, empty parentheses in a function definition give that function a type with a prototype for subsequent calls. Other old-style function definitions are diagnosed by default in C2X mode.
-
The
-
GCC now defaults to
-fno-common. As a result, global variable accesses are more efficient on various targets. However, in the C language, global variables with multiple tentative definitions now cause linker errors. With the-fcommonoption such definitions are silently merged during linking.
C++
The following C++20 features have been implemented:
- Concepts, including the P0734R0, P0857R0, P1084R2, P1141R2, P0848R3, P1616R1, and P1452R2 proposals
-
P1668R1: Permitting unevaluated inline-assembly in
constexprfunctions -
P1161R3: Deprecate
a[b,c] - P0848R3: Conditionally trivial special member functions
- P1091R3: Structured binding extensions
-
P1143R2: Adding the
constinitkeyword -
P1152R4: Deprecating
volatile - P0388R4: Permit conversions to arrays of unknown bound
-
P0784R7: More
constexprcontainers (constexpr new) -
P1301R4:
[[nodiscard("with reason")]] - P1814R0: Class template argument deduction for alias templates
- P1816R0: Class template argument deduction for aggregates
- P0960R3: Parenthesized initialization of aggregates
-
P1331R2: Permitting trivial default initialization in
constexprcontexts -
P1327R1: Allowing
dynamic_castand polymorphictypeidin constant expressions P0912R5: Coroutines. The
-fcoroutinesoption enables the support for coroutinesTo learn more about the above-mentioned proposals, see C++ Standards Support in GCC.
- Several C++ defect reports have been resolved. You can find the overall defect report status on the C++ Defect Report Support in GCC page.
New warnings:
-
G++ can now detect modifying constant objects in the
constexprevaluation, which is undefined behavior. -
Memory consumption of the compiler, when performing the
constexprevaluation, has been reduced. -
The
noexceptspecifier is now properly treated as a complete-class context. -
You can now use the
deprecatedattribute on namespaces.
-
G++ can now detect modifying constant objects in the
Runtime library libstdc++
The following experimental C++2a support features have been improved:
-
Library concepts in
<concepts>and<iterator> -
Constrained algorithms in
<ranges>,<algorithm>, and<memory> -
New algorithms
shift_leftandshift_right -
The
std::spanclass template -
Three-way comparisons in
<compare>and throughout the library -
Constexprsupport in<algorithm>and other places -
<stop_token>andstd::jthread -
std::atomic_refandstd::atomic<floating point> -
Integer comparison functions (for example,
cmp_equal,cmp_less, and other functions) -
std::ssizeandstd::to_array -
std::construct_at,std::destroy, andconstexprstd::allocator -
Mathematical constants in
<numbers>
-
Library concepts in
-
The random number generator
std::random_devicenow supports RDSEED.
Fortran
-
The compiler now rejects mismatches between actual and dummy argument lists in a single file and prints an error. To turn these errors into warnings, use the new
-fallow-argument-mismatchoption. This option is implied withstd=legacy. The-Wargument-mismatchoption has been removed. -
The binary, octal, and hexadecimal (BOZ) literal constants have been improved and now conform better to the Fortran 2008 and 2018 standards. In these Fortran standards, BOZ literal constants do not have types or kinds. With this enhancement, documented and undocumented extensions to the Fortran standards now emit errors during compilation. You can enable some of these extensions with the
-fallow-invalid-bozoption, which turns errors into warnings and the code is compiled as with the earlier GFortran.
Target-specific improvements
Changes to architecture and processor support include:
AMD64 and Intel 64
-
GCC now supports the Cooper Lake Intel CPU. To enable it, use the
-march=cooperlakeoption, which enables the AVX512BF16 ISA extensions. -
GCC now supports the Tiger Lake Intel CPU. To enable it, use the
-march=tigerlakeoption, which enables the MOVDIRI MOVDIR64B AVX512VP2INTERSECT ISA extensions.
A.2. Changes in binutils 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with binutils 2.35.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
The assembler
-
The
.symverdirective has been extended to update the visibility of the original symbol and assign one original symbol to different versioned symbols. - The Intel SERIALIZE and TSXLDTRK instructions are now supported.
-
The
-mlfence-after-load=,-mlfence-before-indirect-branch=, and-mlfence-before-ret=options have been added to the x86 assembler to help mitigate CVE-2020-0551. -
The
--gdwarf-5option has been added to the assembler to generate DWARF 5 debug output if such output is generated. Also, it is now possible to generate version 5.debug_linesections. -
The
-malign-branch-boundary=NUM,-malign-branch=TYPE[+TYPE…],-malign-branch-prefix-size=NUM, and-mbranches-within-32B-boundariesoptions have been added to the x86 assembler to align branches within a fixed boundary with segment prefixes or the NOP instructions. -
The
--gdwarf-cie-versioncommand-line flag has been added. This flag controls which version of DWARF CIE (Common Information Entries) the assembler creates.
The linker
-
The command-line options
--export-dynamic-symboland--export-dynamic-symbol-listhave been added to make symbols dynamic. -
The
-Map=filenamecommand-line option has been extended. Iffilenameis a directory, the linker will create thefilename/output-filename.mapfile. -
The
--warn-textrelcommand-line option has been added to warn aboutDT_TEXTRELbeing set in a position-independent executable or shared object. -
The command-line options
--enable-non-contiguous-regionsand--enable-non-contiguous-regions-warningshave been added. -
Relative path names in
INPUT()andGROUP()directives in linker scripts are now searched in relation to the directory of the linker script before other search paths. -
The
-z start-stop-visibility=…command-line option has been added to control the visibility of synthetic__start_SECNAMEand__stop_SECNAMEsymbols. -
The
--dependency-filecommand-line option has been added to write a Make-style dependency file listing the input files consulted by the linker, like the files written by the compiler-Mand-MPoptions. -
The
ldcheck for thePHDR segment not covered by LOAD segmenterror is more effective now. The check now catches cases that earlier versions ofldincorrectly allowed. If you see this error, it is likely you are linking with a bad linker script or the binary you are building is not intended to be loaded by a dynamic loader. In the latter case, the--no-dynamic-linkeroption is appropriate. -
The
--no-print-map-discardedcommand-line option has been added.
Other binary utilities
-
The readelf tool now displays symbol names differently when wide mode is not enabled. If the name is too long, it will be shortened and the last five characters replaced with "[…]". You can restore the old behaviour with the
-Tor--silent-truncationoption. -
The readelf tool now has the
-Lor--lintor--enable-checksoption, which enables warning messages about possible problems with the file(s) being examined. For example, with this option enabled, readelf will check for zero-sized sections, which are allowed by the ELF standard but might be potentially dangerous if the user was expecting them to actually contain something. -
Binutils now supports
debuginfod, an HTTP server for distributing ELF/DWARF debugging information as well as source code. When built withdebuginfod, readelf and objdump can automatically querydebuginfodservers for separate debugging files when such files otherwise cannot be found. To build binutils withdebuginfod, pass the--with-debuginfodconfigure option. This requireslibdebuginfod, thedebuginfodclient library.debuginfodis distributed with elfutils, starting with version 0.178. For more information, see https://sourceware.org/elfutils. -
The
--outputoption has been added to the ar program. This option can be used to specify the output directory when extracting members from an archive. -
The
--keep-sectionoption has been added to objcopy and strip. This option keeps the specified section from being removed. -
The
--source-comment[=<txt>]option has been added to objdump. It provides a prefix to source code lines displayed in a disassembly. -
The
--set-section-alignment <section-name>=<align>option has been added to objcopy to allow the changing of section alignments. -
The
--verilog-data-widthoption has been added to objcopy for Verilog targets to control the width of data elements in the Verilog hexadecimal format. The separate debug information file options of readelf (
--debug-dump=linksand--debug-dump=follow) and objdump (--dwarf=linksand--dwarf=follow-links) will now display or follow (or both) multiple links if a file has more than one such link. This usually happens when the GCC-gsplit-dwarfoption is used.In addition, the
--dwarf=follow-linksoption for objdump now also affects its other display options. For example, when combined with the--symsoption, it will cause the symbol tables in any linked debug information files to also be displayed. When combined with the--disassembleoption, the--dwarf= follow-linksoption will ensure that any symbol tables in the linked files are read and used when disassembling code in the main file.- Dumping types encoded in the Compact Type Format are now supported in objdump and readelf.
A.3. Changes in elfutils 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with elfutils 0.180.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
-
The new
eu-elfclassifytool has been added to analyze ELF objects. -
The new
debuginfodserver with a client tool and library has been added.debuginfodindexes and automatically fetches ELF, DWARF, and source from files and RPM archives through HTTP. -
libeblis now directly compiled intolibdw.so. -
eu-readelfnow has multiple new flags for notes, section numbering, and symbol tables. -
libdwhas improved multithreading support. -
libdwnow supports additional GNU DWARF extensions. -
Better support for debug info for code built with GCC LTO (link time optimization). The
eu-readelfandlibdwutilities can now read and handle.gnu.debuglto_sections, and correctly resolve file names for functions that are defined across compile units (CUs). -
The
eu-nmutility now explicitly identifies weak objects asVand common symbols asC.
A.4. Changes in GDB 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with GDB 9.2.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
New features
-
The
debuginfodserver is now supported. This is an HTTP server for distributing ELF and DWARF debugging information and source code.
New convenience variables and functions
$_gdb_major$_gdb_minorWith these new convenience variables for testing the running version of GDB, you can run newer commands and syntaxes without breaking legacy scripts.
$_gdb_setting$_gdb_setting_str$_gdb_maint_setting$_gdb_maint_setting_strWith these new convenience functions for accessing GDB settings, you can change the logic of user-defined commands depending on current GDB settings.
$_cimag$_crealWith these new convenience functions, you can get the imaginary and real parts of an imaginary number.
$_shell_exitcode$_shell_exitsignalWith these new convenience variables, you can access the exit code or exit status of shell commands executed by the GDB
shell,pipe, andmakecommands.
New and improved commands
-
New command options infrastructure has been provided to better support completion, for example,
CMD -[TAB]will now show a completion of available command options for CMD. -
Command names can now use the
.character.
New commands
define-prefixWith this command, you can define your own prefix commands, for example,
abc defandabc def ghican now be entirely separate commands.| [command] | shell_command(another name of this command ispipe)This command executes a given GDB command, sending its output to the given shell_command.
with setting [value] [-- command]This command temporarily sets the given setting to value (if specified) and runs the optional command, resetting setting when complete.
Changed commands
helpaproposThe commands now use new title styling.
printfevalThe commands can now print C-style and Ada-style string convenience variables without the need for a running process, for example, when debugging core dumps.
info sources [-dirname | -basename] [--] [regexp]New filtering options have been added. Using them, users can limit results to file, directory, or base names matching a given regular expressions.
focuswinheight+,-,>, and<These TUI commands are now case-sensitive.
backtraceThe command now supports new options which can override global display preferences (
set backtraceandset printsettings). New options include:-entry-values,frame-arguments,-raw-frame-arguments,-frame-info,-past-main,-past-entry,-full,-no-filters, and-hide.frame applytfaasfaasThe commands now support the new
-past-mainand-past-entrycommand options.info typesThe command now support the new
-qoption to disable printing of some header information similar toinfo variablesandinfo functions.info variablesinfo functionswhereisThe commands now support the new
-noption to exclude non-debugging symbols from the output.
Settings
set may-call-functionsshow may-call-functionsThe default value is
on. These new commands control whether GDB will attempt to call functions in the program during command execution, for example, theprint expressioncommand.set print finishshow print finishIf these commands are set to
on, GDB will print the value returned by the current function when thefinishcommand is used.set print max-depthshow print max-depthThese new commands limit the display of deeply nested structures to the set number of levels. The default limit of nesting levels is 20.
set print raw-valuesshow print raw-valuesThese new commands globally override the use of pretty-printers when printing a value. The default value is
off.set style title foregroundset style title backgroundset style title intensityset style highlight foregroundset style highlight backgroundset style highlight intensityWith these new commands, you can customize the display styling of the title and highlight styles.
maint set worker-threadsmaint show worker-threadsExperimental: if these commands are set to
unlimited, GDB will use multi-threaded symbol loading for better performance.set style tui-border foregroundset style tui-border backgroundset style tui-border intensityset style tui-active-border foregroundset style tui-active-border backgroundset style tui-active-border intensityThese new commands set the display styling of various TUI borders.
set print frame-infoshow print frame-infoThese new commands control what frame information is printed by commands that print a frame, for example,
backtrace,frame, andstepi.set tui compact-sourceshow tui compact-sourceThese new commands enable a new
compactdisplay style for the TUI source window.set debug remote-packet-max-charsshow debug remote-packet-max-charsThese new commands control the number of characters to output in a remote packet when using
set debug remote. The default value is 512 bytes.show styleThis new command now styles the output of all subcommands using their own styling.
set print frame-argumentsA new value
presencehas been added. It will display only the presence of arguments with…instead of printing the actual argument names and values.set print-raw-frame-argumentsshow print-raw-frame-argumentsThese two commands replace deprecated
set/show print raw frame-argumentscommands.
Language-specific improvements
Fortran
-
GDB can now set breakpoints on a nested function or subroutine using the
::operator. info modules [-q] [regexp]This new command returns a list of modules that match regexp. If regexp is not provided, the command returns a list of all modules.
info module functions [-q] [-m module_regexp] [-t type_regexp] [regexp]info module variables [-q] [-m module_regexp] [-t type_regexp] [regexp]These new commands return a list of functions or variables within all modules, grouped by module. Results may be limited by module regular expressions, function or variable type signature regular expressions, or name regular expressions.
Python API
gdb.Value.format_stringThis new method returns a string representation of the Value object.
gdb.TypeobjfileThis new property returns the
objfilein which the type was defined.gdb.lookup_static_symbolgdb.lookup_static_symbolsThese new functions support the lookup of symbols with static linkage. The first function returns the first matching symbol. The second one returns all matching symbols.
gdb.Objfile.lookup_global_symbolgdb.Objfile.lookup_static_symbolThese new functions support lookup of symbols in an
Objfile: global symbols and symbols with static linkage respectively.gdb.BlockThis function now supports Python dictionary syntax, for example:
symbol = some_block[variable], where symbol is of typegdb.Symbol.
Machine Interface (MI) improvements
A new default MI version 3 has been introduced (
-i=mi3).- The output of multi-location breakpoint locations has been corrected.
-
The new
-fix-multi-location-breakpoint-outputcommand has been added to correct syntax errors in older MI versions.
All new commands are MI implementations of CLI equivalents:
-
-complete LINE -
-catch-throw -
-catch-rethrow -
-catch-catch -
-symbol-info-functions -
-symbol-info-types -
-symbol-info-variables -
-symbol-info-modules -
-symbol-info-module-functions -
-symbol-info-module-variables
-
A.5. Changes in strace 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with strace 5.7.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
Changes in behavior
The
%processclass now contains system calls associated with the process life cycle (creation, execution, termination):-
kill,tkill,tgkill,pidfd_send_signal, andrt_sigqueueinfohave been added. -
arch_prctlandunsharehave been removed.
-
-
Messages about unknown tracees are now subject to the strace quietness setting
-q(--quiet). -
A new warning has been added. It occurs when the
-A(--output-append-mode) option is used without-o(--output) or the-S(--summary-sort-by) option without-c/-C(--summary-only/--summary).
Improvements
Every short option now has a long option alias. This change brings the following improvements:
-
The ability to use human-readable settings for the
-I(--interruptible) option. -
The ability to silence specific messages using the
-e quiet(--quiet) qualifier (which is an alias for the-qoption), including messages that could not be silenced previously, for example path resolution messages and messages about process being superseded byexecve. -
The ability to specify selected flexible data (FD) decoding features using the
-e decode-fds(--decode-fds) qualifier, which is an alias for the-yoption. -
The ability to set precision for the absolute timestamp, relative timestamp, and system call time output. Use the
--absolute-timestamps,--relative-timestamps, and--syscall-timesoptions, respectively.
-
The ability to use human-readable settings for the
System call return status filtering has been implemented with the
-e status=setoption and its aliases:-
The
-z(--successful-only) option limits system call printing to successful system calls only. -
The
-Z(--failed-only) option limits system call printing to failed system calls only.
-
The
-
The
--pidns-translationoption for PID (process ID) namespace translation has been added. This improvement addresses the Fedora bug BZ#1035433. -
Seccomp-BPF can now be used to stop tracees only for filtered system calls. Use the
--seccomp-bpfoption to enable this feature. -
Two new extensions to the
-D(--daemonize) option have been implemented. They move strace into a separate process group (-DDor--daemonize=pgroup) and session (-DDDor--daemonize=session). -
Interval specification in the
when=subexpression of the system call tampering expressions has been implemented. -
It is now possible to select the set of displayed columns in the call summary output using the
-U(--summary-columns) option. - It is now possible to sort on any summary column.
- System call count statistics have been enhanced: overhead is now applied per call.
- It is now possible to show information about minimum and maximum call duration in the call summary output.
- The system call delay injection and overhead values can now be supplied with a time measure unit suffix and provided in the IEEE 754 floating-point format. Please refer to the “Time specification format description” section of the strace manual page (available via the “scl enable devtoolset-10 — man strace” command) for details.
-
Printing of PIDs associated with process file descriptors (pidfds) in
-yy(--decode-fds=pidfd) mode has been implemented. -
Performance of the
libdw-basedstack traces printing has been improved by implementing a symbol-to-address cache. -
The
-e trace=%clockoption has been added for tracing system calls reading of modifying system clocks. -
The
-e trace=%credsoption has been added for tracing system calls related to process credentials. -
Decoding of the following system calls has been implemented:
clone3,fsconfig,fsmount,fsopen,fspick,open_tree,openat2,move_mount,pidfd_getfd, andpidfd_open. -
Decoding of the following system calls has been enhanced:
arch_prctl,bpf,clone,inotify_init,io_cancel,io_submit,io_uring_register,io_uring_setup,keyctl,mbind,perf_event_open,prctl,s390_sthyi,sched_getattr,sched_setattr,set_mempolicy,syscall, andsyslog. -
Decoding of the following
ioctlcommands has been implemented:PTP_CLOCK_GETCAPS2,PTP_EXTTS_REQUEST2,PTP_PEROUT_REQUEST2,PTP_ENABLE_PPS2,PTP_SYS_OFFSET2,RTC_VL_READ, andWDIOC_*. -
The
HIDIOCGRAWUNIQ()ioctlcommand number printing has been implemented. -
Decoding of the
NETLINK_ROUTEnetlink protocol has been enhanced. -
Decoding of the following netlink attributes has been implemented:
IFLA_*,TCA_ACT_FLAGS,TCA_STATS_PKT64, andUNIX_DIAG_UID. -
Lists of the following constants have been updated:
AT_*,AUDIT_*,BPF_*,BTRFS_*,CAN_*,CLONE_*,ETH_*,FAN_*,GRND_*,IFLA_*,IORING_*,IPPROTO_*,KEXEC_*,KEY_*,KEYCTL_*,KVM_*,LWTUNNEL_*,MADV_*,*_MAGIC,MAP_*,MPOL_*,MREMAP_*,MSG_*,P_*,PERF_*,PPC_PTRACE_*,PR_*,PTP_*,RTM_F_*,SCHED_*,SCTP_*,SECCOMP_*,SO_*,STATX_*,TCP_*,TIPC_*,UFFDIO_*,V4L2_*, andXDP_*. -
The strace manual page and the strace
--helpcommand output have been enhanced.
Bug fixes
-
The
statxsystem call has been added to the%fstattrace class. -
Decoding of
getdentsandgetdents64system calls has been fixed in cases when they return many directory entries. -
The pathtrace matching of the
openat2system call has been fixed. -
Various minor fixes in
VIDIOC_*ioctloutput formatting have been made. -
Stack trace printing has been fixed for early system calls when strace is configured to use
libdwback end for stack tracing. This improvement addresses the Fedora bug BZ#1788636 -
Decoding of the
NDA_LLADDRnetlink neighbor table attribute has been fixed. -
Decoding of the
BPF_PROG_LOADBPF system call command has been fixed. -
The
evdevioctlbitset decoding has been fixed.
A.6. Changes in SystemTap 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with SystemTap 4.3.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
-
Userspace probes can be targeted by the hexadecimal
buildidfromreadelf -n. This alternative to a path name enables matching binaries to be probed under any name, and thus allows a single script to target a range of different versions. This feature works well in conjunction with the elfutilsdebuginfodserver. -
Script functions can use probe
$contextvariables to access variables in the probed location, which allows the SystemTap scripts to use common logic to work with a variety of probes.
For further information about notable changes, see the upstream SystemTap 4.3 release notes before updating SystemTap.
A.7. Changes in Valgrind 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.0 is distributed with Valgrind 3.16.1.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
-
It is now possible to dynamically change the value of many command-line options while your program is running under Valgrind: through
vgdb, throughgdbconnected to the Valgrindgdbserver, or through program client requests. To get a list of dynamically changeable options, run thevalgrind --help-dyn-optionscommand. -
For the Cachegrind (
cg_annotate) and Callgrind (callgrind_annotate) tools the--autoand--show-percsoptions now default toyes. -
The Memcheck tool produces fewer false positive errors on optimized code. In particular, Memcheck now better handles the case when the compiler transformed an
A && Bcheck intoB && A, whereBcould be undefined andAwas false. Memcheck also better handles integer equality checks and non-equality checks on partially defined values. -
The experimental Stack and Global Array Checking tool (
exp-sgcheck) has been removed. An alternative for detecting stack and global array overruns is using the AddressSanitizer (ASAN) facility of GCC, which requires you to rebuild your code with the-fsanitize=addressoption.
Appendix B. Changes in Version 10.1 复制链接链接已复制到粘贴板!
The sections below document features and bug fixes introduced in Red Hat Developer Toolset 10.1.
B.1. Changes in GCC 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is distributed with GCC 10.2.1, which provides numerous bug fixes.
One of the most notable bug fixes is:
Previously, the
gcc-gfortransubpackage did not include thelibgfortran_nonshared.astatic library. As a consequence, linking a program was not always successful because several symbols were missing. With this update, thedevtoolset-10-gcc-gfortranpackage now contains thelibgfortran_nonshared.alibrary and the program can be linked successfully.
B.2. Changes in elfutils 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is distributed with elfutils 0.182.
Numerous bug fixes and new features have been added since the previous release of Red Hat Developer Toolset:
New features added to the
debuginfodserver:-
More efficient package traversal,
debuginfodnow tolerates various errors during scanning. The grooming process is more visible and interruptible, and provides more Prometheus metrics. - A new thread-busy metric and more detailed error metrics.
-
The new
--fdcache-mintmpoption and file system free space tracking. - Increased web API concurrency while grooming.
-
More efficient package traversal,
New features added to
debuginfod-client:- Compressed kernel ELF images are now supported.
-
The
DEBUGINFOD_SONAMEmacro has been added todebuginfod.h. This macro can be used with thedlopen()function to load thelibdebuginfod.solibrary. -
The new
debuginfod_set_verbose_fdfunction andDEBUGINFOD_VERBOSEenvironment variable have been added.
B.3. Changes in strace 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is distributed with strace 5.7.
The following feature has been added since the previous release of Red Hat Developer Toolset:
The
--pidns-translationoption has been added for PID namespace translation. For more information about PID namespace translation, see the pid_namespaces manual page.This enhancement addresses RHEL Bug#1790836 and Fedora Bug#1035433.
B.4. Changes in Dyninst 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is distributed with Dyninst 10.2.1.
The following features have been added since the previous release of Red Hat Developer Toolset 10.1:
-
support for the
debuginfodprotocol for automated DWARFdebuginfodownloading - several memory leak fixes
B.5. Changes in SystemTap 复制链接链接已复制到粘贴板!
Red Hat Developer Toolset 10.1 is distributed with SystemTap 4.4.
The following features have been added or modified since the previous release of Red Hat Developer Toolset:
- Performance and stability improvements to user-space probing.
- Users can now access implicit thread local storage variables on these architectures: AMD64, Intel 64, IBM Z, the little-endian variant of IBM Power Systems.
- Initial support for processing of floating point values.
- Improved concurrency for scripts using global variables. The locks required to protect concurrent access to global variables have been optimized so that they span the smallest possible critical region.
- New syntax for defining aliases with both a prologue and an epilogue.
-
New
@probewritepredicate. -
syscallarguments are writable again.
For further information about notable changes, see the upstream SystemTap 4.4 release notes before updating SystemTap.