Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] Add -P command line switch for executing Python scripts
Date: Tue, 23 Jul 2019 20:25:00 -0000	[thread overview]
Message-ID: <87sgqwv6ql.fsf@tromey.com> (raw)
In-Reply-To: <20190721235427.21893-3-kevinb@redhat.com> (Kevin Buettner's	message of "Sun, 21 Jul 2019 16:54:26 -0700")

>>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:

Kevin> This commit introduces a new command line switch to GDB, a -P /
Kevin> --python switch which is used for executing a python script.
Kevin> Encountering -P curtails normal argument processing by GDB; any
Kevin> remaining arguments (after the script name) are passed to the
Kevin> script.

Kevin> 1) After script execution, exit() was called which (obviously)
Kevin>    caused GDB to exit.
Kevin> 2) The printing of GDB's banner (copyright info, bug reporting
Kevin>    instructions, and help instructions) was suppressed.
Kevin> 3) Due to the exit() noted above, GDB's CLI was not (automatically)
Kevin>    invoked.  If the CLI was desired, it could be run from the Python
Kevin>    script via use of the gdb.cli method, which was added as part of
Kevin>    that work.

Kevin> I've changed things so that exit() is no longer called.  GDB's CLI
Kevin> will be invoked after script execution.  Also, GDB's banner will be
Kevin> printed (or not) as normal.  I.e, the banner will be printed unless
Kevin> the -q switch is specified.

Kevin> If the script doesn't want the CLI for some reason, it can explicitly
Kevin> call exit().  It may be the case that the script would be better off
Kevin> calling a (yet to be written) gdb.exit() method for doing this
Kevin> instead.  Such a method could make sure that GDB shuts down properly.

The intent of -P was to provide a way to run gdb in a "Python script"
mode.  I think this changes defeat this goal.

For (2), printing the banner is just not great for an interpreter.  The
default for interpreters should be silence, with the script being
interpreted choosing what to emit.  "-q" isn't sufficient because it is
common for #! handling to only allow a single argument.

I think if -P is going to just mean "start gdb, but interpret some
Python script at startup", then it might as well not exist -- an
invocation like '-ex "source blah.py"' is just as good, and can be used
on older gdbs as well.

(1) and (3) seem linked.  Here the idea was to have a way to script gdb
where the command line was completely optional and under control of the
script.

Maybe -P isn't the right vehicle for this.  Later on, I was looking at
having a "Python" gdb interpreter -- not to actually interpret gdb
input, but to at least control gdb output.  And, I looked into compiling
gdb PIE so that one could just "import gdb" from an ordinary Python
interpreter.

thanks,
Tom


  parent reply	other threads:[~2019-07-23 20:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-21 23:54 [PATCH 0/3] " Kevin Buettner
2019-07-21 23:54 ` [PATCH 2/3] " Kevin Buettner
2019-07-23  2:47   ` Simon Marchi
2019-07-23 20:25   ` Tom Tromey [this message]
2019-07-27 20:47     ` Kevin Buettner
2019-08-21 16:39     ` Pedro Alves
2019-07-21 23:54 ` [PATCH 3/3] Tests for Python -P commandline support Kevin Buettner
2019-07-21 23:54 ` [PATCH 1/3] Documentation " Kevin Buettner
2019-07-22 14:42   ` Eli Zaretskii
2019-07-22 16:04   ` Simon Marchi

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=87sgqwv6ql.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.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