Red Hat Training

A Red Hat training course is available for Red Hat Developer Toolset

A.6. Changes in GDB

Red Hat Developer Toolset 4.0 is distributed with GDB 7.10, which provides a number of bug fixes and improvements over the Red Hat Enterprise Linux system version and the version included in the previous release of Red Hat Developer Toolset. Below is a comprehensive list of new features in this release.

A.6.1. Changes Since Red Hat Developer Toolset 3.1

The following features have been added since the release of GDB in Red Hat Developer Toolset 3.1:

New Features

  • GDB now honors the content of the /proc/PID/coredump_filter file (PID is the process ID). This file can be used to specify the types of memory mappings that will be included in a corefile. For more information, please see the core(5) manual page.
    GDB also has a new command: set use-coredump-filter on|off. It allows to set whether GDB reads the content of the /proc/PID/coredump_filter file when generating a corefile.
  • The info os command can now be used to display information about CPUs. Run info os cpus to list all CPUs and cores on the system.
  • The info source command can now be used to display the producer string (if it was included in the debugging information). The string usually contains the compiler version and command-line arguments.
  • Directory names supplied to the set sysroot commands may be prefixed with target: to instruct GDB to access shared libraries from the target system, regardless of whether it is local or remote. This replaces the remote: prefix. The default system root has been changed from "" (empty) to target:. For backward compatibility, remote: is automatically converted to target:.
  • The system root specified by the set sysroot command is prepended to the filename of the main executable (if reported to GDB as absolute by the operating system) when starting processes remotely and when attaching to already-running local or remote processes.
  • GDB now supports automatic location and retrieval of executable files from remote targets. Remote debugging can now be initiated using only the target remote or target extended-remote commands (no set sysroot or file commands are required). See also the section called “New Remote Packets” below.
  • Support for the Verilog hexadecimal format has been added to the dump command.
  • GDB and gdbserver are now able to access executable and shared library files without the set sysroot command when attaching to processes running in different mount namespaces from the debugger. This makes it possible to attach to processes in containers as simply as gdb -p PID or gdbserver --attach PID. See also the section called “New Remote Packets” below.
  • Support for completion for all of the available register groups, including target-specific groups, has been added to the tui reg command.
  • The size of GDB's command history is no longer determined by reading the HISTSIZE environment variable. Instead, the dedicated GDBHISTSIZE environment variable is now used. To disable truncation of command history, set GDBHISTSIZE to -1 or leave it empty. Non-numeric values are ignored.
  • Support for fork events on extended-remote Linux targets has been added. This makes it possible to use the follow-fork-mode and detach-on-fork options on targets with Linux kernels 2.5.60 and higher for both the fork and vfork calls, as well as fork and vfork catchpoints.
  • Using new gdbfeatures (fork-events and vfork-events), the qSupported packet allows GDB to request support for fork and vfork events, and the qSupported response can contain the corresponding stubfeatures. Standard set and show commands can be used to set and display whether these features are enabled.
  • The info record command now displays the format of the recording and when the btrace record target is used, it also shows the branch-tracing configuration for the current thread. In case of the BTS format, the command displays the ring buffer size.
  • Support for DTrace USDT (Userland Static Defined Tracing) probes has been added.
  • GDB now supports the compilation and injection of source code into the inferior. GDB will use GCC 5.0 or higher built with libcc1.so to compile the source code to object code, and if successful, inject and execute that code within the current context of the inferior. Currently, the C language is supported. The commands used for interfacing with this new feature are:
    compile code [-raw|-r] [--] [source code]
    compile file [-raw|-r] filename
  • The dll-symbols command and its two aliases (add-shared-symbol-files and assf) have been removed. Use the sharedlibrary command or its alias share instead.
  • On resume, GDB now always passes the signal the program had stopped for to the thread the signal was sent to, even if the user changed threads before resuming. Previously, GDB would often (but not always) deliver the signal to the thread that happened to be current at resume time.
  • Conversely, the signal command now consistently delivers the requested signal to the current thread. GDB now asks for confirmation if the program had stopped for a signal, and the user switched threads meanwhile.
  • The off and auto states of the breakpoint always-inserted mode have been merged into one. Now, when the breakpoint always-inserted mode is set to off, GDB does not remove breakpoints from the target until all threads stop, even in non-stop mode. The auto mode has been removed, and off is now the default mode.
  • The --xdb command-line option (HP-UX XDB compatibility mode) has been removed.

New Remote Packets

A number of new remote packets have been added. See Table A.1, “New Remote Packets” for a complete list.

Table A.1. New Remote Packets

Remote PacketDescription
qXfer:btrace-conf:read Return the branch-trace configuration for the current thread.
Qbtrace-conf:bts:size Set the requested ring-buffer size for branch tracing in the BTS format.
swbreak stop reason Indicates a memory breakpoint instruction was executed, irrespective of whether it was GDB that planted the breakpoint or the breakpoint was hardcoded in the program. This is required for correct non-stop mode operation.
hwbreak stop reason Indicates the target stopped for a hardware breakpoint. This is required for correct non-stop mode operation.
vFile:fstat: Return information about files on the remote system.
qXfer:exec-file:read Return the full absolute name of the file that was executed to create a process running on the remote system.
vFile:setfs: Select the file system on which vFile: operations with file name arguments will operate. This is required for GDB to be able to access files on remote targets where the remote stub does not share a common file system with the inferior(s).
fork stop reason Indicates that a fork system call was executed.
vfork stop reason Indicates that a vfork system call was executed.
vforkdone stop reason Indicates that a vfork child of the specified process has executed an exec or exit function, allowing the vfork parent to resume execution.

Python Scripting Support

Python scripting support has been improved:
  • Objects of the gdb.Objfile class have a new attribute, username, which is the user-specified name of the objfile.
  • Support for writing frame unwinders in Python has been added.
  • A new method, optimized_out, has been added to gdb.Type objects. It is used for returning the optimized out gdb.Value instance of this type.
  • New methods, reference_value and const_value, have been added to gdb.Value objects. They are used to return a reference to the value and the const version of the value, respectively.
  • Auto-loading of Python scripts contained in the .debug_gdb_scripts special section is now supported.
  • Xmethods can now specify the type of the result.
  • You can now access frame registers from Python scripts.
  • The producer attribute for gdb.Symtab objects has been added.
  • The progspace attribute for gdb.Objfile objects has been added. It is the gdb.Progspace object of the containing program space.
  • The owner attribute for gdb.Objfile objects has been added.
  • The build_id attribute for gdb.Objfile objects has been added. It is the build ID generated when the file was built.
  • The add_separate_debug_file method has been added to gdb.Objfile objects.
  • A new event, gdb.clear_objfiles, has been added. It is triggered when a new file for debugging is selected.
  • You can now add attributes to gdb.Objfile and gdb.Progspace objects.
  • A new function, gdb.lookup_objfile, has been added.
The following new events are triggered when the state of the inferior is modified by GDB.
gdb.events.inferior_call_pre
Function call is about to be made.
gdb.events.inferior_call_post
Function call has just been made.
gdb.events.memory_changed
A memory location has been altered.
gdb.events.register_changed
A register has been altered.
The following new Python-based convenience functions have been added.
  • $_caller_is(name [, number_of_frames])
  • $_caller_matches(regexp [, number_of_frames])
  • $_any_caller_is(name [, number_of_frames])
  • $_any_caller_matches(regexp [, number_of_frames])

New Commands

The following new commands have been added:
set serial parity odd|even|none, show serial parity
Set or show parity for remote serial I/O.
maint print symbol-cache
Print the contents of the symbol cache.
maint print symbol-cache-statistics
Print statistics of symbol cache usage.
maint flush-symbol-cache
Flush the contents of the symbol cache.
record btrace bts, record bts
Begin branch-trace recording using the Branch Trace Store (BTS) format.
tui enable, tui disable
Enable or and disable the TUI (Text User Interface) mode.
set mpx bound, show mpx bound
Investigate bound tables in Intel(R) MPX-enabled applications.
maint info btrace
Display information about branch-tracing internals.
maint btrace packet-history
Display raw branch-tracing data.
maint btrace clear-packet-history
Discard stored raw branch-tracing data.
maint btrace clear
Discard all branch-tracing data. The next invocation of the record command will fetch and process it again.
demangle [-l language] [--] name
Demangle name in the specified language or the current language if the parameter is omitted. This command replaces the renamed maint demangle command. The old command name is kept as a no-op command to avoid maint demangle being interpreted as maint demangler-warning.
queue-signal signal-name-or-number
Queue a signal to be delivered to the thread when it is resumed.
maint print user-registers
Display all currently available user registers.
compile code [-r|-raw] [--] [source code]
Compile, inject, and execute in the inferior the executable object code produced by compiling the provided source code.
compile [file -r|-raw] filename
Compile and inject into the inferior the executable object code produced by compiling the source code stored in the filename provided.
compile print
Evaluate an expression using the compiler and display the result.

New Options

The following new options have been added:
set debug dwarf-die, show debug dwarf-die
Renamed from set debug dwarf2-die and show debug dwarf2-die respectively.
set debug dwarf-read, show debug dwarf-read
Renamed from set debug dwarf2-read and show debug dwarf2-read respectively.
maint set dwarf always-disassemble, maint show dwarf always-disassemble
Renamed from maint set dwarf2 always-disassemble and maint show dwarf2 always-disassemble respectively.
maint set dwarf max-cache-age, maint show dwarf max-cache-age
Renamed from maint set dwarf2 max-cache-age and maint show dwarf2 max-cache-age respectively.
set debug dwarf-line, show debug dwarf-line
Control display of debugging info regarding DWARF line processing.
set max-completions, show max-completions
Set the maximum number of candidates to be considered during completion. The default value is 200. This limit allows GDB to avoid generating large completion lists, the computation of which can cause the debugger to become temporarily unresponsive.
set history remove-duplicates, show history remove-duplicates
Control the removal of duplicate history entries.
maint set symbol-cache-size, maint show symbol-cache-size
Control the size of the symbol cache.
set record btrace bts buffer-size, show record btrace bts buffer-size
Set and show the size of the ring buffer used for branch tracing in the BTS format. The obtained size may differ from the requested size. To see the obtained buffer size, use the info record command.
set debug linux-namespaces, show debug linux-namespaces
Control display of debugging info regarding Linux namespaces.
set debug symbol-lookup, show debug symbol-lookup
Control display of debugging info regarding symbol lookup.
The thread apply all command now supports a new option, -ascending, for calling its specified command for all threads in an ascending order.

Change in the Machine Interface Interpreter (GDB/MI)

The following change has been made the GDB/MI.
  • The -list-thread-groups command outputs an exit-code field for inferiors that have exited.