[PATCH 0/1] Integrate GNU poke in GDB

Jose E. Marchesi jose.marchesi@oracle.com
Mon May 10 15:10:43 GMT 2021


Hi GDB people!

The patch below integrates GNU poke (http://jemarch.net/poke) in
GDB by mean of libpoke.

It allows the GDB user to execute Poke code from within the
debugger with access to the target memory, types and values.

A few notes:

- The poke support is optional, and built if specified with
  --enable-poke at configure time.

- The poke support requires libpoke from git master (which will
  become poke 2.x in a few months) since it uses some interfaces
  that are not available in the released poke 1.x series.

- Sorry for what is probably an atrocious mixture of C and C++
  idioms.  I avoid C++ like the pest, but I am all willing to try
  and write proper C++ for this integration.

- Eventually we will probably want to ship some prewritten Poke
  code in a pickle gdb.pk.  Would $pkddatadir/poke/ be a good
  location for Poke code distributed with GDB?

And a few questions:

- Where am I supposed to cleanup and shut down the incremental
  compiler when GDB exits?  I looked but I cannot find a
  counterpart to _initialize_FOO, like _finalize_FOO.

- There are many global parameters that can be configured in the
  poke incremental compiler: the numeration base used when
  printing values, the global endianness, a cut-off value for how
  many array elements are printed, and the like.  Reasonable
  defaults for them are set in `start_poke', but I would like the
  GDB user to be able to change these settings.  I could add a
  `poke-set SETTING [VALUE]' command, but I was wondering whether
  there is a better way, like a global register of settings
  already in GDB?

- I am using target_{read,write}_raw_memory to access the
  target's memory.  What is the difference between the raw and
  non-raw accessors?

- How can I demangle C++ identifiers?  And how can I detect when
  a given type is a C++ one that needs demangling?

How this stuff works:

- GDB links with libpoke.so and uses the interface in libpoke.h.
  This is also how the GNU poke application (the command-line
  editor) is implemented.

- There are three commands:

  poke STR
  poke-add-type EXPR
  poke-add-types REGEXP
  poke-dump-types

  All three commands make sure to start the poke incremental
  compiler if it isn't running already.

- Access to the target's memory is provided by GDB by installing
  a Foreign IO device in the incremental compiler.  This is
  `iod_if' in poke.c.

- Access to the terminal is provided by GDB by providing a
  pk_term_if implementation to the incremental compiler.  This is
  `poke_term_if' in poke.c.

- Access to GDB values is provided by GDB by installing an alien
  token handler in the incremental compiler.  This is
  `poke_alien_token_handler' in poke.c.

Jose E. Marchesi (1):
  Integrate GNU poke in GDB

 gdb/ChangeLog       |   8 +
 gdb/Makefile.in     |   6 +-
 gdb/configure       |  89 +++++-
 gdb/configure.ac    |  15 +
 gdb/doc/ChangeLog   |   6 +
 gdb/doc/Makefile.in |   1 +
 gdb/doc/gdb.texinfo |   4 +
 gdb/doc/poke.texi   | 373 ++++++++++++++++++++++
 gdb/poke.c          | 762 ++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 1257 insertions(+), 7 deletions(-)
 create mode 100644 gdb/doc/poke.texi
 create mode 100644 gdb/poke.c

-- 
2.25.0.2.g232378479e



More information about the Gdb-patches mailing list