Red Hat Training

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

B.4. Changes in GDB

Red Hat Developer Toolset 4.1 is distributed with GDB 7.11, 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.

B.4.1. Changes Since Red Hat Developer Toolset 4.0

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

New Features

  • Thread numbers are now per-inferior instead of global. When debugging multiple inferiors, GDB now displays thread IDs using a qualified INF_NUM.THR_NUM form. For example:
    (gdb) info threads
      Id   Target Id         Frame
      1.1  Thread 0x7ffff7fc2740 (LWP 8155) (running)
      1.2  Thread 0x7ffff7fc1700 (LWP 8168) (running)
    * 2.1  Thread 0x7ffff7fc2740 (LWP 8157) (running)
      2.2  Thread 0x7ffff7fc1700 (LWP 8190) (running)
    As consequence, thread numbers visible in the $_thread convenience variable and in Python's InferiorThread.num attribute are no longer unique between inferiors.
    GDB now maintains a second thread ID per thread, referred to as the global thread ID, which is the new equivalent of thread numbers in previous releases. See below for $_gthread.
    For backwards compatibility, thread IDs of the Machine Interpreter (MI) always refer to global IDs.
  • Commands that accept thread IDs now accept the qualified INF_NUM.THR_NUM form as well. For example:
    (gdb) thread 2.1
    [Switching to thread 2.1 (Thread 0x7ffff7fc2740 (LWP 8157))] (running)
  • In commands that accept a list of thread IDs, it is now possible to refer to all threads of an inferior using a star wildcard. GDB accepts INF_NUM.*, to refer to all threads of inferior INF_NUM, and * to refer to all threads of the current inferior. For example, info threads 2.*.
  • You can use the info threads -gid command to display the global thread ID of all threads.
  • The new $_gthread convenience variable holds the global number of the current thread.
  • The new $_inferior convenience variable holds the number of the current inferior.
  • For multi-threaded programs, GDB now displays the ID and the name of the thread that hit a breakpoint or received a signal. For example:
    Thread 3 "bar" hit Breakpoint 1 at 0x40087a: file program.c, line 20.
    Thread 1 "main" received signal SIGINT, Interrupt.
  • GDB now allows users to specify explicit locations, bypassing the linespec parser. This feature is also available to GDB/MI clients.
  • The following commands now list corresponding items in ascending ID order to maintain consistency with all other info commands: info threads, info inferiors, info display, info checkpoints, and maint info program-spaces.
  • In the Ada programming language, the overloads selection menu has been enhanced to display the parameter types and the return types for the matching overloaded subprograms.
  • Support has been added for thread names in the remote protocol. The reply to qXfer:threads:read may now include a name attribute for each thread.
  • GDB now has support for fork and exec events on remote-mode Linux targets. This enables follow-fork-mode, detach-on-fork, and follow-exec-mode modes and fork and exec catchpoints.

New Commands

The following new commands have been added:
maint set target-non-stop [on|off|auto], maint show target-non-stop
Controls whether GDB targets always operate in non-stop mode even if set non-stop is set to off. The default is auto, which means non-stop mode is enabled if it is supported by the target.
maint set bfd-sharing, maint show bfd-sharing
Controls whether bfd objects can be used more than once.
set debug bfd-cache, show debug bfd-cache
Controls whether debugging information regarding bfd caching is displayed.
set remote multiprocess-extensions-packet, show remote multiprocess-extensions-packet
Controls the use of remote protocol multiprocess extensions.
set remote thread-events, show remote thread-events
Controls the use of thread create and exit events.
set ada print-signatures on|off, show ada print-signatures
Controls the display of parameter types and return types in overloads selection menus. By default, this option is active (on).
set max-value-size, show max-value-size
Controls the maximum number of bytes of memory that GDB is allowed to allocate for value contents. The option prevents GDB from allocating overly large buffers by accessing inconsistent data of a debugged program. The default amount is 64 kB.
set remote exec-event-feature-packet, show remote exec-event-feature-packet
GDB now has support for exec events on extended-remote Linux targets. This enables follow-exec-mode mode and exec catchpoints. The commands control the use of the remote exec event feature.
set remote catch-syscall-packet, show remote catch-syscall-packet
GDB now has support for catching system calls on remote Linux targets. The commands control the use of the feature.
The following commands have been enhanced:
  • The disassemble command now accepts a new modifier: /s. When the modifier is used, the command prints mixed source code and disassembly similarly to the /m modifier. There are two differences: disassembled instructions are now printed in program order, and source for all relevant files is now printed. The /m option is now considered deprecated because its "source-centric" output has not proven useful in practice.
  • The record instruction-history command now accepts a new modifier: /s. The option behaves exactly like the /m modifier and prints mixed source code and disassembly.
  • The set scheduler-locking command now supports a new option, replay. When set scheduler-locking replay is used, it behaves like off in record mode and like on in replay mode.

New Remote Packets

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

Table B.1. New Remote Packets

Remote PacketDescription
exec stop reason Serves as an indicator that an exec system call was executed.
exec-events feature in qSupported Using the qSupported packet, support for exec events can be requested by GDB using the new gdbfeature exec event. The qSupported response can contain the corresponding stubfeature. Use appropriate set and show commands to enable these features and display the current setting.
vCtrlC An equivalent to interrupting with the ^C character, but it works in non-stop mode.
thread created stop reason Indicates that the thread has just been created and is stopped at entry.
thread exit stop reply Indicates that the thread has terminated.
QThreadEvents Enables or disables thread create and exit event reporting. For example, this is used in non-stop mode when GDB stops a set of threads and synchronously waits for the their corresponding stop replies. Without exit events, if one of the threads exits, GDB would wait forever not knowing that it should no longer expect a stop for that same thread.
N stop reply Indicates that there are no resumed threads left in the target (all threads are stopped). The remote stub reports support for this stop reply to the qSupported query by GDB.
QCatchSyscalls Enables or disables catching system calls from the inferior process. The remote stub reports support for this packet to the qSupported query of GDB.
syscall_entry stop reason Indicates that a system call was just called.
syscall_return stop reason Indicates that a system call just returned.

Python Scripting Support

Python scripting support has been improved:
  • gdb.InferiorThread objects now have a new attribute, global_num, which refers to the global thread ID. The existing num attribute now refers to the per-inferior number of the thread. See per-inferior thread numbers: the section called “New Features”.
  • gdb.InferiorThread objects now have a new attribute, inferior, which is the Inferior object the thread belongs to.

Change in the Machine Interface Interpreter (GDB/MI)

The following change has been made the GDB/MI.
  • The -var-set-format command has been enhanced to support input in zero-hexadecimal format. The output of the command is in the hexadecimal format with zero-padding on the left.