public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Tom Tromey <tom@tromey.com>
Cc: "Jose E. Marchesi via Gdb-patches" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 0/1] Integrate GNU poke in GDB
Date: Wed, 12 May 2021 10:06:21 +0200	[thread overview]
Message-ID: <87bl9gnzpe.fsf@oracle.com> (raw)
In-Reply-To: <87k0o56qvz.fsf@tromey.com> (Tom Tromey's message of "Tue, 11 May 2021 12:56:32 -0600")


> Jose> It allows the GDB user to execute Poke code from within the
> Jose> debugger with access to the target memory, types and values.
>
> Jose> - Eventually we will probably want to ship some prewritten Poke
> Jose>   code in a pickle gdb.pk.  Would $pkddatadir/poke/ be a good
> Jose>   location for Poke code distributed with GDB?
>
> Like what kind of thing are you thinking?

Any Poke code that is specific to GDB in any way.  For example, this
code is part of the initialization and opens the IO space for the
current target provided by GDB:

  open ("<gdb>");

In fact in an initial version I had put that in a gdb.pk file that was
loaded in start_poke.  But since I didn't need to add anything else
there, I decided to just do it from C instead:

  if (pk_compile_statement (poke_compiler, "open (\"<gdb>\");", NULL, &val)
      != PK_OK)
    error (_("Could not open <gdb>"));

> Jose> - There are three commands:
>
> Jose>   poke STR
> Jose>   poke-add-type EXPR
> Jose>   poke-add-types REGEXP
> Jose>   poke-dump-types
>
> Jose>   All three commands make sure to start the poke incremental
> Jose>   compiler if it isn't running already.
>
> It's maybe more gdb-ish to make one command and use subcommands.

What would be the gdb-ish way:

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

or

b) poke STR
   poke add type EXPR
   poke add types REGEXP
   poke dump types

Because a) will be problematic: `add-types' can be a valid Poke
expression if both `add' and `types' are defined as variables.

Doing b) would be ok I think.

> I wonder if you considered implementing this by writing some Python to
> glue Poke into gdb.  This would have some advantages:
>
> * It wouldn't be a configure-time decision by whoever built gdb -- if
>   you have Poke, it could "just work".  (Of course this assumes gdb is
>   built with Python, but that's the norm for distros.)
>
> * How Poke is glued in and how the commands work would be controlled by
>   ordinary Poke patches, rather than having to go through GDB.  This
>   would let you evolve the GDB integration along with the library.

That is a very clever idea that no, I had not considered.

But I am not really looking forward to write Python bindings for libpoke
(or Python for anything for that matter) and even if I could recruit
someone to do that work, the stuff would need to be maintained ... poke
depending on Python, supporting future Python versions and what not,
argh no no no no :)

Also somehow I would not feel comfortable getting into such troubles and
going C++->Python->C->Poke for something that can be simply achieved as
C++->Poke in about 700 lines of C++.

So unless there is a strong feeling about this on the GDB side, I would
much prefer to integrate via libpoke directly.

PS: If GDB supported writing plugins in C or C++ like bash does, I
    wouldn't blink twice before adopting your suggestion!

  reply	other threads:[~2021-05-12  8:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 15:10 Jose E. Marchesi
2021-05-10 15:10 ` [PATCH 1/1] " Jose E. Marchesi
2021-05-10 16:56   ` Eli Zaretskii
2021-05-10 18:49     ` Jose E. Marchesi
2021-05-10 18:52       ` Eli Zaretskii
2021-05-11  7:33   ` Andrew Burgess
2021-05-11 13:07     ` Jose E. Marchesi
2021-05-12  8:52       ` Andrew Burgess
2021-05-12 10:14         ` Jose E. Marchesi
2021-05-13 16:59   ` Tom Tromey
2021-05-10 18:39 ` [PATCH 0/1] " Simon Marchi
2021-05-10 20:07   ` Jose E. Marchesi
2021-05-11  6:25     ` Andrew Burgess
2021-05-13 17:04   ` Tom Tromey
2021-05-11 18:56 ` Tom Tromey
2021-05-12  8:06   ` Jose E. Marchesi [this message]
2021-05-13 15:52     ` Tom Tromey
2021-05-14 20:52       ` Jose E. Marchesi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bl9gnzpe.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).