From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 789tHGu692drUC4AWB0awg (envelope-from ) for ; Thu, 10 Apr 2025 08:32:43 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=GimEtYr+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 65DD51E0C3; Thu, 10 Apr 2025 08:32:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 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 F145D1E05C for ; Thu, 10 Apr 2025 08:32:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13A4B3839068 for ; Thu, 10 Apr 2025 12:32:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13A4B3839068 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=GimEtYr+ Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id E06223839052 for ; Thu, 10 Apr 2025 12:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E06223839052 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E06223839052 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744288321; cv=none; b=I7N12EpHETmYmVQvuWt9AJ7ylbhgxc1dwlrEQhnZYS7RzKcUU/ZVejAeXkB5lnlfAWFeP53tHxpDaDoGYfUjylmT3mYCOdmJxkc+ORjtXYvz8YbyxEExrVOjaESvYZSs5st5cnIoB7QTWxtut2MttXNDPwGKffYyEJf+Bf9f2sU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744288321; c=relaxed/simple; bh=N1ARMvi7SZd50b2Zh2iLZoD0jXMXWinEek9euxleDow=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=bzJ2+TFk2rvHKoj1vIK6fsL0vhbM0tuPKA4H7U6+sr67QxvAv7Aapwmcz5wyBstx2nfy2o9opF+TX355kwVIXJhftKK8Hnlwx0BTbv+j9eYkPpxeyq3G+fJM3aNpxHojmTMwRzCfJDwzbUJ/mZPQ81ZK1ecxSvcxs277Qjf6HVc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E06223839052 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2r4a-0001Ww-CP; Thu, 10 Apr 2025 08:32:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=PS0p7dYTqHYmkuE5in3AjRYh5dWh7XxZdDpMhEgkLpA=; b=GimEtYr+Thir jKcek32JoPm4lbRdMNeUvdgTHJOVCQpjyrnWkKsRlj5M6prIsIg2hSJqovt+mn8IFu7Faz/t22WsZ 0ahtEzyhS3BtX3jCGYhRR8eLD+epatMzbyBtKQKqxpf+++ooRLVHRZfeo3F+aKtY9eIIIKePgfZBg K+htpYJ562kPbD7akfjLN8yojaU4RGzD8iYPNysVtFDwYCkcIjii5CHay97voCn+zrZeFVdYE5UI3 W5dxpwpmSHlQjduOBLvDVhRFSbGibFp226boidi1lMeZacpErCJxv+otuWCsEUWvnDrQuuO6Vh3vm oTp8coKT/OjYZsvGGQMNDA==; Date: Thu, 10 Apr 2025 15:31:53 +0300 Message-Id: <865xjcqjt2.fsf@gnu.org> From: Eli Zaretskii To: Craig Blackmore Cc: gdb-patches@sourceware.org In-Reply-To: <20250410110426.3488955-1-craig.blackmore@embecosm.com> (message from Craig Blackmore on Thu, 10 Apr 2025 12:04:26 +0100) Subject: Re: [RFC PATCH] gdb: Add python support for demangling register unwind values References: <20250410110426.3488955-1-craig.blackmore@embecosm.com> 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 > From: Craig Blackmore > Cc: Craig Blackmore > Date: Thu, 10 Apr 2025 12:04:26 +0100 > > This patch addresses the scenario where a register value is saved in > some mangled form on the target and gdb does not have sufficient > information to demangle it. > > After getting a register value from an unwinder, call out to extension > languages to allow the value to be demangled. This avoids having to > write a new unwinder and allows the standard unwinders to be used. > > This approach is purely for demangling values that have been read, there > is no similar support provided for mangling values being written back to > the target as this was not something that I needed to be able to do. > > Only one demangler can be registered at any one time. In future, the > implementation could be extended to support multiple demanglers executed > in order of priority. > > The demangler is registered globally. In future, the implementation > could be extended to register per program space and object file too. > > gdbpy_get_register_descriptor is now externally visible as it is used > to create a gdb.RegisterDescriptor object to pass to the demangler. > > This patch adds gdb.Value.is_lval_{register,memory} variables so that > the demangler can choose to skip modifying values that did not come > directly from the target and may not need demangling, for example, > values taken directly from DWARF. > --- > gdb/NEWS | 11 +++ > gdb/doc/python.texi | 48 +++++++++++ > gdb/extension-priv.h | 8 ++ > gdb/extension.c | 35 ++++++++ > gdb/extension.h | 6 ++ > gdb/frame.c | 3 + > gdb/guile/guile.c | 2 + > gdb/python/lib/gdb/__init__.py | 17 ++++ > gdb/python/lib/gdb/unwinder.py | 34 ++++++++ > gdb/python/py-registers.c | 2 +- > gdb/python/py-unwind.c | 80 +++++++++++++++++ > gdb/python/py-value.c | 25 ++++++ > gdb/python/python-internal.h | 4 + > gdb/python/python.c | 4 +- > .../gdb.python/py-unwind-demangler.c | 80 +++++++++++++++++ > .../gdb.python/py-unwind-demangler.exp | 86 +++++++++++++++++++ > .../gdb.python/py-unwind-demangler.py | 44 ++++++++++ > gdb/testsuite/gdb.python/py-value.exp | 8 ++ > 18 files changed, 495 insertions(+), 2 deletions(-) > create mode 100644 gdb/testsuite/gdb.python/py-unwind-demangler.c > create mode 100644 gdb/testsuite/gdb.python/py-unwind-demangler.exp > create mode 100644 gdb/testsuite/gdb.python/py-unwind-demangler.py Thanks. The documentation parts are okay, with one comment: > +@subheading Unwinder Register Value Demangler Skeleton Code Making a construct state out of more than 2-3 nouns produces very confusing phrases in English. I suggest to use this instead: @subheading Skeleton Code for a Register Value Demangler Reviewed-By: Eli Zaretskii