From patchwork Sun Oct 29 23:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78719 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 406C838323E6 for ; Sun, 29 Oct 2023 23:25:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id C5FD5386193C for ; Sun, 29 Oct 2023 23:23:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5FD5386193C 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 C5FD5386193C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621797; cv=none; b=puw6GQF0i68T8POwPzwaBbRZVB2rN/dH6sdYzuwLZ4gKAosfPBfddSsr/F1jiHzEr7LyRShoEK+3y96qOqBYIerQEo/qkStRqYxLeqD2aufRI0oklNEuGhIEZfMMXonIT76tvDMs90MYrvmDVd3riQC5Tm+Fw1bk006RVVaeE1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621797; c=relaxed/simple; bh=oK5wjt6011Fry+maRtnGYLCCF70nlmXngDeW8br1QZc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=gvqabkLP2MCYMvOMHYYaN0/iJds1E8JMpPLFL4V8x7BLfjdndvu16oj/WaBcq0YqNe1xKApe+9RhHTOTLWtKL9eA/c+4IXPwS/e5gUl9p3j4YuRZkq8l6TIJbKaw8JbPniwQfwh4vGFd8gKqKvGgjVuNwDe3bxySNtyN3vk8cZg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id wxu9qPoOVKOkLxF7dqQEPk; Sun, 29 Oct 2023 23:23:10 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xF7dq9c50ULW5xF7dqS5hC; Sun, 29 Oct 2023 23:23:09 +0000 X-Authority-Analysis: v=2.4 cv=Yusc+qUX c=1 sm=1 tr=0 ts=653ee95d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA: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=jhezerGsRqZyMnVp+LejC0pHnU 23HtMogdj3ww91aKzReAfC2/qUAtd0cOB0wl0HyacF1YMjAs21Z1H1WMxHCue698k149e0Oy1xYdn RP2ohWZdiZmI06XIKEhbQUIJm; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:56344 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 1qxF7c-0042zY-2v for gdb-patches@sourceware.org; Sun, 29 Oct 2023 17:23:08 -0600 From: Tom Tromey Date: Sun, 29 Oct 2023 17:23:43 -0600 Subject: [PATCH 22/30] Use read_var_value overload in py-framefilter.c MIME-Version: 1.0 Message-Id: <20231029-split-objfile-2023-bound-sym-october-v1-22-612531df2734@tromey.com> References: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@tromey.com> In-Reply-To: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@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: 1qxF7c-0042zY-2v 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]:56344 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJyoyZ9vJXvcJWkuQ3Gj09kgxHigO0dtKJcFrbCIe/TZab4uj9+d1Bki2b62IYUk/WmVF+M9ccv2YGI+nZR/B8i2MiduOvaIXV2fS8rtm1hl/LD2wmPv WOiImzlgUAtULBShrsm5/gkeVto4XZ9m5vSMP0MVG/YMpk5pof2uK1kEjSxTrwYaBqFDKThuR39pCNvUTpIhT76fsOFJn3vhD7I= X-Spam-Status: No, score=-3023.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org 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