From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id BEBF63856DE8 for ; Sun, 5 Nov 2023 18:11:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEBF63856DE8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BEBF63856DE8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207897; cv=none; b=IywkaOR7L0FE2T7snuvuclU+w74H9PJ2lIJDTc9AI5ew1OStEiGMbrz0qz/SfBddijxknPvrIkIEIiPVJJbGR958VMmpIwwFVHogvhFvxIDirBO4CyHhYxQePUlKVgbZveV/sDNcWWILbsDcuMVyz1ntdVoeexDKyhGzP7437YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207897; c=relaxed/simple; bh=oK5wjt6011Fry+maRtnGYLCCF70nlmXngDeW8br1QZc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=PrwRXgQq0FgnWWmxkoDRpiCdqKEWgMrS7UTUGEfAOfWt/ciINd4K0vQCciJOFyTlurFpMccnB/KFlx/97aqN/LTUJiL0B3abojYB51t6fMg89gnV4gXDpvNdcqi+XbFjyr+Aw8URQvxGkLaLHgd44hqcbDtAagwAZj37aF5GCHQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id zh0RqeQxF6nOZzhawqqvu5; Sun, 05 Nov 2023 18:11:34 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id zhawqjdPHpPpmzhawq74jj; Sun, 05 Nov 2023 18:11:34 +0000 X-Authority-Analysis: v=2.4 cv=MJVzJeVl c=1 sm=1 tr=0 ts=6547dad6 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=fAIwGuswDSaqnPqpljcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/QDZjME9B2Q69knRWj3WbT403HmAZc3pAtTWeJ80r1Q=; b=Gnkhxy0rOPfxD8PWgJj2duuy8y whtVU8ZOwY+PDydR+zcSt3/ED0AM7LBYILwHitye5ClTYiyjn4JxRsGtJWil9yzy8VCfGpcNYkNFK o5vVNvYFt6wr7atJmdsyHTTID; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:51014 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qzhav-003Y66-2a for gdb-patches@sourceware.org; Sun, 05 Nov 2023 11:11:33 -0700 From: Tom Tromey Date: Sun, 05 Nov 2023 11:12:01 -0700 Subject: [PATCH v2 23/31] Use read_var_value overload in py-framefilter.c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231105-split-objfile-2023-bound-sym-october-v2-23-dbd2d158bbc3@tromey.com> References: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.77.73 X-Source-L: No X-Exim-ID: 1qzhav-003Y66-2a X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:51014 X-Source-Auth: tom+tromey.com X-Email-Count: 24 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAlVMFKpUOsCIyZKNY1aYhzQr1lWlvnElrGqHoKaAld8+hOBo30DVoFFZCFbFQYFs7z7J6VdDTbluSQQyCMKV6hmolcPNrjh57SYitOp2Y2aN7DR1qlM 9+75KRKZ76gmwiwQk6iGJ+EbrQN3qTn8UQGutpHaSz+b0CBN4p0YGUSOlMCEXEe2cRZ+P5Bbmh2pMSE35r8gnIUhdjUAm2iuXU0= X-Spam-Status: No, score=-3023.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This changes py-framefilter.c to use the new read_var_value overload. --- gdb/python/py-framefilter.c | 54 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e555dc3d879..07b30a587b1 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -41,24 +41,22 @@ enum mi_print_types MI_PRINT_LOCALS }; -/* Helper function to extract a symbol, a name and a language +/* Helper function to extract a symbol, a name and a language definition from a Python object that conforms to the "Symbol Value" - interface. OBJ is the Python object to extract the values from. - NAME is a pass-through argument where the name of the symbol will - be written. NAME is allocated in this function, but the caller is + interface. OBJ is the Python object to extract the values from. + NAME is a pass-through argument where the name of the symbol will + be written. NAME is allocated in this function, but the caller is responsible for clean up. SYM is a pass-through argument where the - symbol will be written and SYM_BLOCK is a pass-through argument to - write the block where the symbol lies in. In the case of the API - returning a string, this will be set to NULL. LANGUAGE is also a - pass-through argument denoting the language attributed to the - Symbol. In the case of SYM being NULL, this will be set to the - current language. Returns EXT_LANG_BT_ERROR on error with the - appropriate Python exception set, and EXT_LANG_BT_OK on success. */ + symbol will be written. In the case of the API returning a string, + this will be set to NULL. LANGUAGE is also a pass-through argument + denoting the language attributed to the Symbol. In the case of SYM + being NULL, this will be set to the current language. Returns + EXT_LANG_BT_ERROR on error with the appropriate Python exception + set, and EXT_LANG_BT_OK on success. */ static enum ext_lang_bt_status extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr *name, - struct symbol **sym, const struct block **sym_block, - const struct language_defn **language) + block_symbol *sym, const struct language_defn **language) { gdbpy_ref<> result (PyObject_CallMethod (obj, "symbol", NULL)); @@ -79,21 +77,19 @@ extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr *name, entirely synthetic symbol/value pairing. In that case, use the current language. */ *language = current_language; - *sym = NULL; - *sym_block = NULL; + *sym = {}; } else { /* This type checks 'result' during the conversion so we just call it unconditionally and check the return. */ - *sym = symbol_object_to_symbol (result.get ()); /* TODO: currently, we have no way to recover the block in which SYMBOL was found, so we have no block to return. Trying to evaluate SYMBOL will yield an incorrect value when it's located in a FRAME and evaluated from another frame (as permitted in nested functions). */ - *sym_block = NULL; + *sym = { symbol_object_to_symbol (result.get ()), nullptr }; - if (*sym == NULL) + if (sym->symbol == NULL) { PyErr_SetString (PyExc_RuntimeError, _("Unexpected value. Expecting a " @@ -103,13 +99,13 @@ extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr *name, /* Duplicate the symbol name, so the caller has consistency in garbage collection. */ - name->reset (xstrdup ((*sym)->print_name ())); + name->reset (xstrdup (sym->symbol->print_name ())); /* If a symbol is specified attempt to determine the language from the symbol. If mode is not "auto", then the language has been explicitly set, use that. */ if (language_mode == language_mode_auto) - *language = language_def ((*sym)->language ()); + *language = language_def (sym->symbol->language ()); else *language = current_language; } @@ -443,21 +439,20 @@ enumerate_args (PyObject *iter, { const struct language_defn *language; gdb::unique_xmalloc_ptr sym_name; - struct symbol *sym; - const struct block *sym_block; + block_symbol bsym; struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; - success = extract_sym (item.get (), &sym_name, &sym, &sym_block, - &language); + success = extract_sym (item.get (), &sym_name, &bsym, &language); if (success == EXT_LANG_BT_ERROR) return EXT_LANG_BT_ERROR; + symbol *sym = bsym.symbol; success = extract_value (item.get (), &val); if (success == EXT_LANG_BT_ERROR) return EXT_LANG_BT_ERROR; - if (sym && out->is_mi_like_p () + if (sym != nullptr && out->is_mi_like_p () && ! mi_should_print (sym, MI_PRINT_ARGS)) continue; @@ -559,8 +554,6 @@ enumerate_locals (PyObject *iter, gdb::unique_xmalloc_ptr sym_name; struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; - struct symbol *sym; - const struct block *sym_block; int local_indent = 8 + (8 * indent); gdb::optional tuple; @@ -568,10 +561,11 @@ enumerate_locals (PyObject *iter, if (item == NULL) break; - success = extract_sym (item.get (), &sym_name, &sym, &sym_block, - &language); + block_symbol bsym; + success = extract_sym (item.get (), &sym_name, &bsym, &language); if (success == EXT_LANG_BT_ERROR) return EXT_LANG_BT_ERROR; + symbol *sym = bsym.symbol; success = extract_value (item.get (), &val); if (success == EXT_LANG_BT_ERROR) @@ -583,7 +577,7 @@ enumerate_locals (PyObject *iter, /* If the object did not provide a value, read it. */ if (val == NULL) - val = read_var_value (sym, sym_block, frame); + val = read_var_value (bsym, frame); /* With PRINT_NO_VALUES, MI does not emit a tuple normally as each output contains only one field. The exception is -- 2.41.0