public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "hi-angel at yandex dot ru" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/27141] New: [RFE] Getting a python-call result is overly complicated
Date: Sat, 02 Jan 2021 19:12:42 +0000	[thread overview]
Message-ID: <bug-27141-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=27141

            Bug ID: 27141
           Summary: [RFE] Getting a python-call result is overly
                    complicated
           Product: gdb
           Version: 10.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: hi-angel at yandex dot ru
  Target Milestone: ---

Unless I'm missing something, the only way to get a return value from python is
to write a whole separate class with two methods.¹ This is unwieldy and hinders
quick scripting.

For example, right now I want to set `commands` to a breakpoint so the debugee
gets only paused when there's a certain string somewhere in the `bt` command.
Well, the check is really easy to script up:

    py 'my_string' in gdb.execute('bt', to_string=True)

But then if I execute it as part of gdb "if" statement, I'll get

    No symbol "py" in current context.

Having to write a whole "convenience" function means not only a redundant text,
but also a need to debug it. Also, if one has to debug it in the current
session, my experience says that unless they already know how it works, they
might screw up the current session (that's what happened to me back when I was
trying to make pretty-printers work with no experience on them)

So, it would be really helpful to either teach `py` and/or `pi` calls to return
values, so they can be executed as part of any other GDB command chain, or to
introduce a new (a `p1`?) call for that purpose.

1: https://sourceware.org/gdb/current/onlinedocs/gdb/Functions-In-Python.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2021-01-02 19:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 19:12 hi-angel at yandex dot ru [this message]
2021-01-02 20:45 ` [Bug python/27141] " hi-angel at yandex dot ru
2021-01-06 18:15 ` ssbssa at sourceware dot org
2021-01-06 18:47 ` hi-angel at yandex dot ru

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=bug-27141-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).