Brussels / 1 & 2 February 2020


GDB pipelines -- convenience iteration over inferior data structures

Bringing MDB's "walkers" to GDB

We introduce a GDB plugin for working with large data structures in the inferior.

This plugin brings some of the flexibility of Unix pipelines to the GDB command prompt, providing the ability to conveniently run some action on every element in a data structure that matches certain criteria.

One big aim of this plugin is to make it easy and convenient for a user to write their own sub-commands to iterate over the data structures used in their own program.

This is intended for anyone who has found difficulty inspecting large data structures from inside GDB.

MDB -- the debugger on Solaris -- has a feature called "walkers" that is used to great effect when inspecting the contents of large data structures in the Solaris Kernel.

We introduce a GDB plugin to provide the same type of functionality.

Similar to Unix pipelines, one can now flexibly write a surprisingly powerful command by combining several "walkers".

Some examples are: - Search an inferior data structure for nodes that are malformed.

 gdb-pipe <mywalker> <startnode> | if ! <some verification test>
  • Put breakpoints on member functions of those nodes in a data structure matching some criteria. gdb-pipe <mywalker> <startnode> | if <interesting-check> | show break {}->function-member

  • Put breakpoints on a given function when passed a node that matches some criteria. gdb-pipe <mywalker> <startnode> | if <interesting-check> | show break somefunc if <arg> == {}

This plugin has a strong aim to make it easy for users to write "walkers" over their own data structures, and already has "walkers" for the open source projects "neovim" and "GCC".

We would like to discuss possible future directions for this plugin with regards to speed improvements to work on extremely large data structures, and how there could be a tie-in with pretty-printers.


Matthew Malcomson