Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] gdb/python: add Corefile.mapped_files method
Date: Tue, 23 Sep 2025 14:52:47 +0100	[thread overview]
Message-ID: <87segdff80.fsf@redhat.com> (raw)
In-Reply-To: <875xdil1vp.fsf@tromey.com>

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> Add a new Corefile.mapped_files method which returns a list of
> Andrew> gdb.CorefileMappedFile objects.
>
> Andrew> Each gdb.CorefileMappedFile object represents a file that was mapped
> Andrew> into the process when the core file was created.
>
> Thanks.
>
> Andrew> +  /* A List of gdb.CorefileMappedFile objects.  This list is only created
> Andrew> +     the first time the user calls gdb.Corefile.mapped_files(), the result
> Andrew> +     is cached here.  If this pointer is not NULL then this is an owning
> Andrew> +     pointer (i.e. this owns a reference to the List).  */
> Andrew> +  PyObject *mapped_files;
>
> A Python list is a mutable object, so I think user code could mess
> around with this data.
>
> IMO it would be better to make this a tuple instead.
>
> Andrew> +  /* A List of gdb.CorefileMappedFileRegion objects.  */
> Andrew> +  PyObject *regions;
>
> Same here.  Though I wonder if that's overly paranoid of me.

No, I think this is the right amount of paranoid.  I've updated both
these to Tuples, and extended the tests to check these are not
modifiable.

>
> Andrew> +      object->mapped_files = nullptr;
>
> Perhaps this has to be hoisted if the initialization of object->inferior
> does (see earlier review).

Done.

>
> Andrew> +	  gdbpy_ref<corefile_mapped_file_region_object> region_obj
> Andrew> +	    ((corefile_mapped_file_region_object *) PyObject_New
>
> I think the cast of the return value of PyObject_New shouldn't be
> needed.  PyObject_New is a macro that supplies the cast.
>
> There were a few cases of this.

Fixed the two added in this commit.  I also fixed one from patch #1 too.

>
> Andrew> +  gdbpy_ref<> start (gdb_py_object_from_ulongest (obj->start));
> Andrew> +  if (start == nullptr)
> Andrew> +    return nullptr;
> Andrew> +
> Andrew> +  return start.release ();
>
> The null check isn't really needed since the release does the same.
> I think it's normal to just write
>
>     return gdb_py_object_from_ulongest (obj->start).release ();

Switched to this style.  I was already using this for some of the string
creation stuff, so I'm not sure why I did it differently here.

I posted a V2 series with all these fixes.

Thanks,
Andrew


  reply	other threads:[~2025-09-23 13:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 16:03 [PATCH 0/3] Core file Python API Andrew Burgess
2025-09-02 16:03 ` [PATCH 1/3] gdb/python: introduce gdb.Corefile API Andrew Burgess
2025-09-02 16:26   ` Eli Zaretskii
2025-09-16 17:25   ` Tom Tromey
2025-09-23 13:50     ` Andrew Burgess
2025-09-02 16:03 ` [PATCH 2/3] gdb: make structured core file mappings processing global Andrew Burgess
2025-09-16 17:28   ` Tom Tromey
2025-09-02 16:03 ` [PATCH 3/3] gdb/python: add Corefile.mapped_files method Andrew Burgess
2025-09-16 17:54   ` Tom Tromey
2025-09-23 13:52     ` Andrew Burgess [this message]
2025-09-23 13:44 ` [PATCHv2 0/3] Core file Python API Andrew Burgess
2025-09-23 13:44   ` [PATCHv2 1/3] gdb/python: introduce gdb.Corefile API Andrew Burgess
2025-10-03 18:56     ` Tom Tromey
2025-10-06  8:54       ` Andrew Burgess
2025-10-06 15:39         ` Tom Tromey
2025-10-06 16:13           ` Andrew Burgess
2025-09-23 13:44   ` [PATCHv2 2/3] gdb: make structured core file mappings processing global Andrew Burgess
2025-10-13 13:57     ` Lancelot SIX
2025-10-13 14:37       ` Andrew Burgess
2025-10-13 15:16         ` Six, Lancelot
2025-10-14  9:12         ` Lancelot SIX
2025-09-23 13:44   ` [PATCHv2 3/3] gdb/python: add Corefile.mapped_files method Andrew Burgess
2025-10-03 19:15     ` Tom Tromey
2025-10-07  6:24       ` Tom de Vries
2025-10-07 12:21         ` Andrew Burgess
2025-10-07 13:08           ` Tom de Vries
2025-10-07 13:26             ` Andrew Burgess
2025-10-07 14:38               ` Andrew Burgess
2025-10-07 15:43                 ` Tom de Vries
2025-10-07 16:28                   ` Andrew Burgess
2025-10-08  9:29                     ` Andrew Burgess
2025-10-08 10:36                       ` Tom de Vries
2025-10-08 14:14                         ` Andrew Burgess
2025-10-08 15:43                           ` Tom de Vries
2025-10-08 16:03                             ` Andrew Burgess
2025-10-16 20:00           ` Tom Tromey
2025-10-17 10:02             ` Andrew Burgess
2025-10-17 13:32               ` Andrew Burgess

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=87segdff80.fsf@redhat.com \
    --to=aburgess@redhat.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