public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/27141] New: [RFE] Getting a python-call result is overly complicated
@ 2021-01-02 19:12 hi-angel at yandex dot ru
  2021-01-02 20:45 ` [Bug python/27141] " hi-angel at yandex dot ru
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hi-angel at yandex dot ru @ 2021-01-02 19:12 UTC (permalink / raw)
  To: gdb-prs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-06 18:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02 19:12 [Bug python/27141] New: [RFE] Getting a python-call result is overly complicated hi-angel at yandex dot ru
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

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).