From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gWIuIQGn0miySQ8AWB0awg (envelope-from ) for ; Tue, 23 Sep 2025 09:56:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GPTEF49I; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8206D1E0BA; Tue, 23 Sep 2025 09:56:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D0DFB1E047 for ; Tue, 23 Sep 2025 09:56:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 096773858424 for ; Tue, 23 Sep 2025 13:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 096773858424 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GPTEF49I Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 77B043858C5E for ; Tue, 23 Sep 2025 13:52:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77B043858C5E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 77B043858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758635572; cv=none; b=PAhVK+DdJAYSwjziikWKlk9jcjj0JRfbS2uRYyELr64acIu2Zaklzqx2Qa9c/YWrhgMHjTtRA4rNXQFl7OHBMD8PeaNGKgwkRJq89SBcpgcMXGmxmFAbQbbjr1aRINVZzgn42cCA/uDLWm/0fwFrrWKhTM7TyxXGMbjVkFnY0dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758635572; c=relaxed/simple; bh=mKBT9Q2R5GEuL3dHbYbo2Q3srHuC27l6mG6/J2zRGy4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MnlWZBFmelLI8UiUEBCTbJYjyeGA86u3+KsA+812ZD8Qg+S22GpEk9kUn0dX58mrdGaE5bD4+Ew02q/cco/qUMinEmkOv9+eWSm/wla6rATW/7iwa9SMMl1augKHJQHRR+X4gA3wKcKyKApZWYfC9I8aLp6GXGYsMPC0HNgeBq8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77B043858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758635572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jd46B/46xV6/KxnAyHzhArjX4XgIaKby4kF/OYckra0=; b=GPTEF49IU8pM/YQf6ggguIS8xMrV77BW6pZHnQ/Jwo3XK7WS+Nn/33B7+ZPYZmb9D57Nax UKcffz1rKJdKxjeQ7HLYyDmxvUBKc4lsKBm50z1/F28xGPKs+dBwmaK7STYaxdIu1Y5WXp 9MYdAhsaKSHa+uTrOkDayrizXx2G1Ts= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-k2LUiPMsOfa7tLfPb-jFpA-1; Tue, 23 Sep 2025 09:52:51 -0400 X-MC-Unique: k2LUiPMsOfa7tLfPb-jFpA-1 X-Mimecast-MFC-AGG-ID: k2LUiPMsOfa7tLfPb-jFpA_1758635569 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3efa77de998so2557465f8f.0 for ; Tue, 23 Sep 2025 06:52:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758635569; x=1759240369; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jd46B/46xV6/KxnAyHzhArjX4XgIaKby4kF/OYckra0=; b=GtWt0qCkVdhoD6GuZ858eskepCcNRKWP6Ggm+cCaH1bein4kXjmxp+VHYxrXU+z4Dz B37af0S+k0Mu0vms4IqFYD8Yyv6CsvEN47Jyfm5nNOtru/vTUPfaGTqqENpjGfz08Z9/ PfrOe+72F4m41KC0Ky0tCRGgznK8fqtgJsgUitJRzVh0hXoIbq+6j8ya6gt2HQPrwC1y NURCfRDRgIbg3834QKRF9QYaXZa8Ccj8EbNgetk072GrLa9fQb8sLa1cgQf9DimwaLce xca9jjFg9sFMzq9HdE60l7pxBrVvJ9viPJ3gGSGh4e/n4/SlSDjuhvpWQU7fCLi2XgP7 NYbQ== X-Gm-Message-State: AOJu0Yy0RwaLbKmH4A6yB5MKLJxf641/JqcZQpjhMLKVRhmWlfB4d7nj QXe5D1Hrcq+/MvSk3EBo6HAYtZpX1jzAVXAYTiI3ddqBRE6KoxkE22gGel7mp0oNjinnWxMw75z h2TxMUJXfvIYnJsRVnDl+WZgGKopRrcyPkIMApX6KbvbCsENkjfhWhKUtDdmCOpz99qNmEts= X-Gm-Gg: ASbGncuhRXccZ8EeQznrHRGyNaZMSp9vf8EHu9OGYCpNUyjXVbQec1QX9v6V3PvmJXr mBTt5iIqMXJaa/HD2th/xdUBWsMsvUz8h3Uig+UDSqamw2cCEDnB9u+mk09D/LgI7a9rypxiE02 ei1hsyjvQ9waxyYF8Y8Gd39JYvf77BxmJx0fGd4gVFAKV9zPEfqM8C0YTEK9o0XppDF/qD34wp4 byZTsIIKq+ousOsAW+0oRjONtWVqXC1VuqFOLCYiLJM78p/VdMB+GdQWYcRflFwf0MO7HCAxxqH XeToQuwMOZRCGgZCGUXvl8JKQRaDDW+ScS8= X-Received: by 2002:a5d:5f55:0:b0:3ec:dc7e:70fa with SMTP id ffacd0b85a97d-405ba7d6567mr2806525f8f.0.1758635568700; Tue, 23 Sep 2025 06:52:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyQ9zZanME+xIaK8KZ9OIzVq8MsQmC8t7TdMLGZqNqEVb0/pynjCqSzXjfaMtXmvHiyqH0EA== X-Received: by 2002:a5d:5f55:0:b0:3ec:dc7e:70fa with SMTP id ffacd0b85a97d-405ba7d6567mr2806506f8f.0.1758635568265; Tue, 23 Sep 2025 06:52:48 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee1095489asm23231596f8f.24.2025.09.23.06.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 06:52:47 -0700 (PDT) From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/3] gdb/python: add Corefile.mapped_files method In-Reply-To: <875xdil1vp.fsf@tromey.com> References: <5b014e8b969d0661adf41c803fdaf8e83a55a880.1756828929.git.aburgess@redhat.com> <875xdil1vp.fsf@tromey.com> Date: Tue, 23 Sep 2025 14:52:47 +0100 Message-ID: <87segdff80.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zE66q4Yix8098-AQp3SEsvue7C3p71vuaq_BPvtUH4E_1758635569 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom Tromey writes: >>>>>> "Andrew" == Andrew Burgess 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 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