From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id 728CE3858408 for ; Fri, 1 Sep 2023 14:47:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 728CE3858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7924a3eb5afso75066939f.0 for ; Fri, 01 Sep 2023 07:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1693579635; x=1694184435; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TNCBtZbitavorWtTJEPbKy3YTGAJKxpt1BTEnTTvF88=; b=REcgYjNDvUjQtVy98JtGKMFXMBNrF9P5BJo8jU4Em+sdDgMYFMLMwPDfrkolD7IkRo UhxDoyCaMvhuXPWfaFyNKFfJJ3Ww57m7+uiEpmEZ6A6zisol+8WN1PoZpnB68Z2EfCJe VZoEcywMWVVFDGR3/Y9RbkNLX9ngnEBDjFOjKu72BTw+wJtT+Qc13zbvM/sqFppRt/lR zUHd6gnHWqFDXiR8FpCDztuwGUpfOfUOUazT9+20Zy52SSfnnAzOas02WxP+Xhdh2sck rG97hXTCuM6WTHC+e2DhA2pz0GpNdC3RGb7A3IWm2wZ7NQK9hy0St60I4mFqwm3BlJyD bHkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693579635; x=1694184435; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TNCBtZbitavorWtTJEPbKy3YTGAJKxpt1BTEnTTvF88=; b=Y3lvrj1K9MllrlEJ6YnFBwOvxev5Q3RIvpKVFt80/YGizOEvb9N4uo2EyE1vWTcyw9 H/ip3qY6N01YIJHti6JkrH2z6ZXy7L6XY/zxp3ntOo+rcRt+6rWuEzY2es/TYl1S6ptJ dwUYUx2h0raWRH9LiTqh+Rw/4PNowG7Pl9Zhf+kMoI5T+VUKiAhJZXzJH90B1NqxdPM1 2pu0iqcktN/YxWHsK7MQg5vhlf/ihntwYbdg3aAvhl1XJztVJa61NGk4cAw1/ZZ5t+1H 5hWOtJUql5nkhlZFfAwRlXxYUwDIEO6gQjYoc94fGcNUu/8wlWjZLBVDFQXIdfg1bxNX 3lfw== X-Gm-Message-State: AOJu0YzKRfUS7vqNejkvldJdhLh6b694qUDoRQs/fSvKgnybPjau3wlF 6HlqiXhkj+uzrjMGXs07HfjpsiaKIXtRLL05LoBfPA== X-Google-Smtp-Source: AGHT+IG618nfcMaZ0CB7FIsGjmE6xMvCZRN38wKB5L6crOERUEZNYyHtNR8ZsBIpsDaw4lEA+Ar2Jw== X-Received: by 2002:a6b:5103:0:b0:792:9333:2cbf with SMTP id f3-20020a6b5103000000b0079293332cbfmr2658980iob.6.1693579635507; Fri, 01 Sep 2023 07:47:15 -0700 (PDT) Received: from localhost.localdomain (75-166-150-212.hlrn.qwest.net. [75.166.150.212]) by smtp.gmail.com with ESMTPSA id q1-20020a0566380ec100b0042b1a9f8480sm1036710jas.35.2023.09.01.07.47.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 07:47:15 -0700 (PDT) From: Tom Tromey Date: Fri, 01 Sep 2023 08:47:14 -0600 Subject: [PATCH 4/4] Fix bug in -var-evaluate-expression MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230901-varobj-fixes-v1-4-b9a1f8139ca7@adacore.com> References: <20230901-varobj-fixes-v1-0-b9a1f8139ca7@adacore.com> In-Reply-To: <20230901-varobj-fixes-v1-0-b9a1f8139ca7@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,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 List-Id: This bug points out that if one uses -var-set-visualizer with "None" -- to disable a pretty-printer for a varobj -- then -var-evaluate-expression will still use pretty-printing. This is a combination of bugs. First, setting the visualizer does not update the display text; and second, computing the display text should use "raw" when Python is available but no visualizer is desired. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11738 --- gdb/testsuite/gdb.python/py-varobj.c | 2 ++ gdb/testsuite/gdb.python/py-varobj.exp | 12 ++++++++++++ gdb/testsuite/gdb.python/py-varobj.py | 4 +++- gdb/varobj.c | 9 +++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-varobj.c b/gdb/testsuite/gdb.python/py-varobj.c index 894ce8fca06..88d0e74b7e0 100644 --- a/gdb/testsuite/gdb.python/py-varobj.c +++ b/gdb/testsuite/gdb.python/py-varobj.c @@ -21,6 +21,8 @@ struct test { struct test tval = {23}; +struct test *test_ptr = &tval; + int main () { return 0; } diff --git a/gdb/testsuite/gdb.python/py-varobj.exp b/gdb/testsuite/gdb.python/py-varobj.exp index 0e0978352a5..f1eb35265b0 100644 --- a/gdb/testsuite/gdb.python/py-varobj.exp +++ b/gdb/testsuite/gdb.python/py-varobj.exp @@ -47,3 +47,15 @@ mi_gdb_test "-var-create tval * tval" \ mi_gdb_test "-var-list-children --all-values tval" \ ".*value=.*flicker.*" + +mi_gdb_test "-var-create test_ptr * test_ptr" \ + "\\^done.*" + +mi_gdb_test "-var-evaluate-expression test_ptr" \ + "\\^done,value=\"map\"" +mi_gdb_test "-var-set-visualizer test_ptr None" \ + "\\^done.*" +# mi_gdb_test "-var-update test_ptr" ".*" +mi_gdb_test "-var-evaluate-expression test_ptr" \ + "\\^done,value=\"$hex.*\"" \ + "evaluate without visualizer" diff --git a/gdb/testsuite/gdb.python/py-varobj.py b/gdb/testsuite/gdb.python/py-varobj.py index bc31a198297..578ad14d4df 100644 --- a/gdb/testsuite/gdb.python/py-varobj.py +++ b/gdb/testsuite/gdb.python/py-varobj.py @@ -12,6 +12,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import gdb import gdb.printing @@ -30,6 +31,7 @@ def str_lookup_function(val): lookup_tag = val.type.tag if lookup_tag == "test": return TestPrinter(val) - + if val.type.code == gdb.TYPE_CODE_PTR and val.type.target().tag == "test": + return TestPrinter(val.dereference()) gdb.printing.register_pretty_printer(None, str_lookup_function) diff --git a/gdb/varobj.c b/gdb/varobj.c index 3ae8d728e82..a4fcbffc311 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1393,6 +1393,9 @@ varobj_set_visualizer (struct varobj *var, const char *visualizer) /* If there are any children now, wipe them. */ varobj_delete (var, 1 /* children only */); var->num_children = -1; + + /* Also be sure to reset the print value. */ + varobj_set_display_format (var, var->format); #else error (_("Python support required")); #endif @@ -2212,6 +2215,12 @@ varobj_value_get_print_value (struct value *value, return "{...}"; } } + else + { + /* If we've made it here, we don't want a pretty-printer -- + if we had one, it would already have been used. */ + opts.raw = true; + } } #endif -- 2.40.1