From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KAGlHY19WWgt1hoAWB0awg (envelope-from ) for ; Mon, 23 Jun 2025 12:15:09 -0400 Received: by simark.ca (Postfix, from userid 112) id 74B841E102; Mon, 23 Jun 2025 12:15:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE 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 5EC101E11E for ; Mon, 23 Jun 2025 12:15:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA22C38697FF for ; Mon, 23 Jun 2025 16:15:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA22C38697FF Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.129.114]) by sourceware.org (Postfix) with ESMTP id CB6C838697FF for ; Mon, 23 Jun 2025 16:11:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB6C838697FF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CB6C838697FF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750695103; cv=none; b=wPJhWGNJkAIiWCkxRrUEKgq09trSMXhLdv1VpfSyyu1tXvkE4hT/wUs2jjSey6jz7vVCxpaKcZ18XVrSwRipBN5yWkwV5A5QtIn4Lr1INz0BnRG2Lfv2GNrfRM+qiePDVHoltuucsq82P1Aj0+w0MRtDC/7ihJPcKyIwwTT7oPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750695103; c=relaxed/simple; bh=Tii4ItR47sAKH4x2uRv1i4DWFjsYOV9TaiafoM3/R1U=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=P7CZNp+91aT2vT4yEj1DWOmKr3DW/NVkvzdIg2kCByVNHmw8g+IHK4bbQ51DWR1JhNCUJVqL2AmfvqL9CAKixM/SsHjqAOlQYB1Ovq3r9HaAqQ53funkETRcnEkZOzmuuwOLBntHkDOaD33fsbFUFMo30iAlepHz/L1GgyyGG6E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB6C838697FF Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2094.outbound.protection.outlook.com [40.107.244.94]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-SER4gvmOMfGkRNbv-lavTQ-2; Mon, 23 Jun 2025 12:11:42 -0400 X-MC-Unique: SER4gvmOMfGkRNbv-lavTQ-2 X-Mimecast-MFC-AGG-ID: SER4gvmOMfGkRNbv-lavTQ_1750695101 Received: from SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) by CH3PR17MB6292.namprd17.prod.outlook.com (2603:10b6:610:14b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.27; Mon, 23 Jun 2025 16:11:38 +0000 Received: from SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::6398:7dc0:7d88:5a4d]) by SA1PR17MB5365.namprd17.prod.outlook.com ([fe80::6398:7dc0:7d88:5a4d%5]) with mapi id 15.20.8857.026; Mon, 23 Jun 2025 16:11:37 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany , Eli Zaretskii Subject: [RFC v5 17/18] gdb/python: allow instantiation of gdb.LineTable objects Date: Mon, 23 Jun 2025 17:10:12 +0100 Message-ID: <20250623161013.650814-18-jan.vrany@labware.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250623161013.650814-1-jan.vrany@labware.com> References: <20250623161013.650814-1-jan.vrany@labware.com> X-ClientProxiedBy: LO4P123CA0082.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:190::15) To SA1PR17MB5365.namprd17.prod.outlook.com (2603:10b6:806:1d8::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR17MB5365:EE_|CH3PR17MB6292:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e8e7f38-9db5-49ea-b590-08ddb270a1d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?15EdGutU6D9OZHjkhYUCIiabapPejQSUKR2mvXUwEZxUhpb7wwZ+Vjl8Ua7j?= =?us-ascii?Q?mL4bA5kvob17rLuB4aWcfoCV0W/3AxxKhIi3GxLpskoV6fPymvEkxbMbQ5sv?= =?us-ascii?Q?yklMLH6goczWnMONL0rUTs48cwhgjYCKj8sNJ2bBcCGrM6l5AGGkRLub9A2Z?= =?us-ascii?Q?i7uktEhDbKrn+BQxXZPVqqW5VGpB+ZAZNX3DJJXM+MK7OtUM1DeXZmcPXMAp?= =?us-ascii?Q?6JkhSK1dOk9QtOaeiP8KumnJl6EE+S/jIUrk4tBAST//XXKeSNSm1CJjSF37?= =?us-ascii?Q?cK6n8LJ/DH5yqJg1nSCqOgaRZLxCm4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FaP+eXjzUMShHCBjoIvaFV832uG5ZcDL5g8eppVd6FvUTI9fNrGR2?= =?us-ascii?Q?epRa5rgflj2PT2nyMejZwSZHOPrckbbJMMQEd2cmtLLX1PJ/lleDgesRdp7e?= =?us-ascii?Q?24wYEWjWE2LvHdY+aS4q+g0frBc7tcMgN1rZdq3M/ERBZ58ZODoKIsGKCk2Z?= =?us-ascii?Q?hDPdRs6DWzXaDpkl0PH3jQMxy+EVFqTybFcGBk6NQ9jFkr/tVArN5Fozv7CP?= =?us-ascii?Q?1hcWKeaxxsw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR17MB5365.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?F26pwLQYx7pw1eJjOjcPOJKuWf0hK2QhfSoVXimxD21t3/Dkw2pdkqVVCPex?= =?us-ascii?Q?UR3B6EtCY1DTYCIGOJgpmaFU7kPiV+iBdC5hQV8Snma2AfcGA5RJrLLHEKYU?= =?us-ascii?Q?22Yt926Nqi4pxnhAoLqCCIOyfLU9IQN1Q3zewaUqcd7jLJnZUq/CtxPtNJ2R?= =?us-ascii?Q?j0a3+cu6XeIzL8/pUbdxrVEdbEF1lzPuYsoaPvmFt9uc9bupG2iCojG9ypdw?= =?us-ascii?Q?4FzyRUVQ1LQHGY1OW/jiOa+rW8PD2S6FvGS5UguVz/iiZwSeu+tUZq5rfFHJ?= =?us-ascii?Q?Yweb1lxLyyF3FS9MdgQziVfT+w1QdigjL4gh7GtDqNSfPC81026aRj0sXvvD?= =?us-ascii?Q?VaLou5/TrAy0UBRdhgiN/ysl3cZuERVEWKCNwpW3ipTj/nNpqw8ta+hP4v6G?= =?us-ascii?Q?yKTkfGnxvtH2ZVU7++N4u7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?= =?us-ascii?Q?BGPovKgLoofv1kyIvS4h236QGwVTeI6btlzRzNR3lLCvqIO9n/t+Na1FwaJ/?= =?us-ascii?Q?Gop9BaM8++yqgGz4Xgvf1eMI80FaBuwqk/3QbEs6/kmmwYLzxhPYQfW+TQLN?= =?us-ascii?Q?q/DUHEh5XGK3bU2NctMNoN4+ROS6P5ntSD1YJplLQ4Xp5n44rcieVvI/O6Xv?= =?us-ascii?Q?0kC5tRAjPRGC5N5dFV4YrOjU33cDrvN/TaGAQ4m0r0LaMsjicAghkNztQAcC?= =?us-ascii?Q?rWX/EWRchszClGz3M8tp3k4Qc9xtztO16tKIRNkl?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e8e7f38-9db5-49ea-b590-08ddb270a1d2 X-MS-Exchange-CrossTenant-AuthSource: SA1PR17MB5365.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2025 16:11:37.8734 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yVoI10deekGlPDx1EgIoXau9xQMSFYKbZs5aP0aCzwmtUupl/Iul9XTxOHE0P72GqZhj1HR1q9PWAdGOXo/tKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR17MB6292 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: G8B04UQRb2V_biMjeMztkxFE5qYWHXZMd24COAdTPAY_1750695101 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 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 This commit allows users to instantiate gdb.LineTable objects. This is a step towards a Python support for dynamically generated code (JIT) in GDB. Reviewed-By: Eli Zaretskii --- gdb/doc/python.texi | 8 ++ gdb/python/py-linetable.c | 104 +++++++++++++++++++++- gdb/testsuite/gdb.python/py-linetable.exp | 32 ++++++- 3 files changed, 140 insertions(+), 4 deletions(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 2b33cd32201..768ca8ba750 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -6876,6 +6876,14 @@ Line: 45 Address: 0x400615L In addition to being able to iterate over a @code{LineTable}, it also has the following direct access methods: =20 +@defun LineTable.__init__ (symtab, entries) +Creates a new @code{LineTable} object and associate it with given +@var{symtab}. Old linetable that might already be associated with @var{sy= mtab} +is discarded. The @var{entries} argument is a list of @code{LineTableEntr= y} +objects that constitute the newly created line table. Line table entries +do not need to be sorted. +@end defun + @defun LineTable.line (line) Return a Python @code{Tuple} of @code{LineTableEntry} objects for any entries in the line table for the given @var{line}, which specifies diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index 57d1a74bf78..d4b1f86614a 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -17,7 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . = */ =20 +#include #include "python-internal.h" +#include "objfiles.h" =20 struct linetable_entry_object { PyObject_HEAD @@ -294,6 +296,102 @@ ltpy_is_valid (PyObject *self, PyObject *args) Py_RETURN_TRUE; } =20 +/* Object initializer; creates new linetable. + + Use: __init__(SYMTAB, ENTRIES). */ + +static int +ltpy_init (PyObject *zelf, PyObject *args, PyObject *kw) +{ + struct linetable_object *self =3D (struct linetable_object*) zelf; + + static const char *keywords[] =3D { "symtab", "entries", nullptr }; + PyObject *symtab_obj; + PyObject *entries; + + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords, +=09=09=09=09=09&symtab_obj, &entries)) + return -1; + + struct symtab *symtab =3D symtab_object_to_symtab (symtab_obj); + if (symtab =3D=3D nullptr) + { + PyErr_Format (PyExc_TypeError, +=09=09 _("The symtab argument is not valid gdb.Symtab.")); + return -1; + } + + if (!PyList_Check (entries)) + { + PyErr_Format (PyExc_TypeError, +=09=09 _("The entries parameter is not a list.")); + return -1; + } + + struct objfile *objfile =3D symtab->compunit ()->objfile (); + + /* Commit 1acc9dca "Change linetables to be objfile-independent" + changed linetables so that entries contain relative of objfile's + text section offset. Since the objfile has been created dynamically + and may not have "text" section offset initialized, we do it here. + + Note that here no section is added to objfile (since that requires + having bfd_section first), only text offset. */ + if (objfile->sect_index_text =3D=3D -1) + { + objfile->section_offsets.push_back (0); + objfile->sect_index_text =3D objfile->section_offsets.size () - 1; + } + CORE_ADDR text_section_offset =3D objfile->text_section_offset (); + + long nentries =3D PyList_Size (entries); + long linetable_size + =3D sizeof (struct linetable) + + std::max(nentries - 1, 0L) * sizeof (struct linetable_entry); + struct linetable *linetable + =3D (struct linetable *)obstack_alloc (&(objfile->objfile_obstack), +=09=09=09=09=09 linetable_size); + linetable->nitems =3D nentries; + for (int i =3D 0; i < nentries; i++) + { + linetable_entry_object *entry_obj +=09=3D (linetable_entry_object *)PyList_GetItem (entries, i); +=09=09=09; + if (! PyObject_TypeCheck (entry_obj , &linetable_entry_object_type)) +=09{ +=09 PyErr_Format (PyExc_TypeError, +=09=09 _("Element at %d of entries argument is not a " +=09=09=09 "gdb.LineTableEntry object"), i); +=09 return -1; +=09} + + /* Since PC of entries passed to this function are "unrelocated", +=09 we compensate here. */ + CORE_ADDR pc ((CORE_ADDR)entry_obj->pc - text_section_offset); + + linetable->item[i].line =3D entry_obj->line; + linetable->item[i].set_unrelocated_pc (unrelocated_addr (pc)); + linetable->item[i].is_stmt =3D entry_obj->is_stmt; + linetable->item[i].prologue_end =3D entry_obj->prologue_end; + linetable->item[i].epilogue_begin =3D entry_obj->epilogue_begin; + } + /* Now sort the entries in increasing PC order. */ + if (nentries > 0) + { + auto linetable_entry_ordering =3D [] (const struct linetable_entry &= e1, +=09=09=09=09=09 const struct linetable_entry &e2) +=09{ +=09 return e1.unrelocated_pc () < e2.unrelocated_pc (); +=09}; + std::sort (&(linetable->item[0]), &(linetable->item[nentries]), +=09=09 linetable_entry_ordering); + } + symtab->set_linetable (linetable); + self->symtab =3D symtab_obj; + Py_INCREF (symtab_obj); + + return 0; +} /* Deconstructor for the line table object. Decrement the reference to the symbol table object before calling the default free. */ =20 @@ -302,7 +400,8 @@ ltpy_dealloc (PyObject *self) { linetable_object *obj =3D (linetable_object *) self; =20 - Py_DECREF (obj->symtab); + if (obj->symtab) + Py_DECREF (obj->symtab); Py_TYPE (self)->tp_free (self); } =20 @@ -591,8 +690,9 @@ PyTypeObject linetable_object_type =3D { 0,=09=09=09=09 /* tp_descr_get */ 0,=09=09=09=09 /* tp_descr_set */ 0,=09=09=09=09 /* tp_dictoffset */ - 0, =09=09=09 /* tp_init */ + ltpy_init, =09=09=09 /* tp_init */ 0,=09=09=09=09 /* tp_alloc */ + PyType_GenericNew=09=09 /* tp_new */ }; =20 static PyMethodDef ltpy_iterator_methods[] =3D { diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.= python/py-linetable.exp index cf01a694070..057a58aa200 100644 --- a/gdb/testsuite/gdb.python/py-linetable.exp +++ b/gdb/testsuite/gdb.python/py-linetable.exp @@ -39,12 +39,12 @@ gdb_py_test_silent_cmd "python lt =3D gdb.selected_fram= e().find_sal().symtab.linet =20 gdb_test_multiline "input simple command" \ "python" "" \ - "def list_lines():" "" \ + "def list_lines(lt):" "" \ " for l in lt:" "" \ " print ('L' + str(l.line) + ' A ' + hex(l.pc))" "" \ "end" "" =20 -gdb_test "python list_lines()" \ +gdb_test "python list_lines(lt)" \ "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $he= x.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \ "test linetable iterator addr" gdb_test "python print(len(lt.line(42)))" "2" \ @@ -106,3 +106,31 @@ gdb_test "python print( gdb.LineTableEntry('xx', 12345= 6).pc)" \ gdb_test "python print( gdb.LineTableEntry(10, 123456, prologue_end =3D Tr= ue).prologue_end)" \ "True" \ "test prologue_end keyword argument" + +# Test gdb.LineTable.__init__(). To do so, we create new compunit and new +# symtab. +gdb_py_test_silent_cmd "python cu =3D gdb.Compunit(\"dynamic_cu\", gdb.Obj= file(\"dynamic_objf\"), 0x100, 0x200)" \ + "create new compunit" 1 +gdb_py_test_silent_cmd "python st =3D gdb.Symtab(\"dynamic_st\", cu)" \ + "create new symtab" 1 +gdb_test "python lt2 =3D gdb.LineTable(st, \[gdb.LineTableEntry(10, 0x123)= \]); print(lt)" \ + "