Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matthieu Longo <matthieu.longo@arm.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v1 2/4] gdb/python: eval_python_command returns both exit code and result
Date: Thu, 23 Apr 2026 20:11:55 +0100	[thread overview]
Message-ID: <c7b351af-446b-426f-a1a7-fa946047d598@arm.com> (raw)
In-Reply-To: <87ik9psdqk.fsf@tromey.com>

On 17/04/2026 18:22, Tom Tromey wrote:
>>>>>> Matthieu Longo <matthieu.longo@arm.com> writes:
> 
>> A previous commit [1] centralized the Python code evaluation in the
>> helper function eval_python_command(). However, a missed case in
>> varobj_set_visualizer() requires both the exit code and the result
>> of the evaluation.
> 
>> This patch updates eval_python_command() to return both values and
>> adjusts existing callers accordingly. It also replaces the use of
>> PyRun_String() in varobj_set_visualizer() with a call to
>> eval_python_command().
> 
> Could we have it just return null on failure?
> And always return a gdbpy_ref<>?
> 

Yes, we can do that. I hadn't noticed that NULL was returned in case of an error occurred during the 
evaluation. To be honest, the Python doc is not super-clear about what is supposed to be returned.

>> --- a/gdb/python/python.c
>> +++ b/gdb/python/python.c
>> @@ -299,42 +299,40 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
>>      NULL means that this is evaluating a string, not the contents of a
>>      file.  */
>   
>> -int
>> +std::pair<int, gdbpy_ref<>>
>>   eval_python_command (const char *command, int start_symbol,
>>   		     const char *filename)
> 
> Either way I think the comment needs an update to describe the return
> result.
> 

Fixed in the next revision.

>> +  if (mainmod == nullptr)
>> +    return std::make_pair(-1, nullptr);
>   
> Space before parens throughout, though of course this is moot if
> returning gdbpy_ref<>.

Moot now.

> 
> Tom

Matthieu

  reply	other threads:[~2026-04-23 19:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 10:51 [PATCH v1 0/4] gdb/python: more fixes again for Python limited C API support Matthieu Longo
2026-04-09 10:51 ` [PATCH v1 1/4] gdb/python: add gdbpy_borrowed_ref Matthieu Longo
2026-04-17 15:40   ` Tom Tromey
2026-04-23 17:31     ` Matthieu Longo
2026-04-09 10:51 ` [PATCH v1 2/4] gdb/python: eval_python_command returns both exit code and result Matthieu Longo
2026-04-17 17:22   ` Tom Tromey
2026-04-23 19:11     ` Matthieu Longo [this message]
2026-04-09 10:51 ` [PATCH v1 3/4] gdb/python: migrate Python initialization to use the new config API (PEP 741) Matthieu Longo
2026-04-17 15:53   ` Tom Tromey
2026-04-24  9:41     ` Matthieu Longo
2026-04-24 14:56       ` Tom Tromey
2026-04-27 15:12         ` Matthieu Longo
2026-04-28 14:44           ` Tom Tromey
2026-04-09 10:51 ` [PATCH v1 4/4] gdb/python: work around missing symbols not yet part of Python limited API Matthieu Longo
2026-04-17 17:26   ` Tom Tromey
2026-04-24 10:14     ` Matthieu Longo
2026-04-15  9:18 ` [PATCH v1 0/4] gdb/python: more fixes again for Python limited C API support Matthieu Longo

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=c7b351af-446b-426f-a1a7-fa946047d598@arm.com \
    --to=matthieu.longo@arm.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