From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 43B253858423 for ; Sat, 29 Oct 2022 18:48:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43B253858423 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-pj1-x102d.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso12721246pjc.0 for ; Sat, 29 Oct 2022 11:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+87wX/csykUoe8A319Iqww51gN7QcYsXEmT16g9HNEo=; b=PbhYs37hBZZQDWhzUfSSBbh3Y3LG32+BDEEYqCK1cdUt3e7mvEUJZthTgOtLuTG5ke XV8fL3q2fLYvDH5yJ3yPd9V+xIa37ObTzy0Mi4y9YKevoezo55Pl9kDCkFD3Jyp1J3Md +58ppwx8FnwsBNVH2JdgrMpOMY1zSnnIpP/DVLkj5OjP14vKOFjFqDeRuAOVXA00RHBK EAVCp9Ge1sQAYB1Jmsxht3cAQLEFI4CVVZ0eWI323LeoY7AZog94cJ8P+o33DmG8L08S BnP1u7nE2AZNmotrhOzPf8GoOn8SdYrrmZ015jdTGColBOrlgi/v2cyL03k1u5DHIBg3 lj+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+87wX/csykUoe8A319Iqww51gN7QcYsXEmT16g9HNEo=; b=DduL242biWsPNm0bXQdf3IGKSK8PZwiB5tdXx92Z77E96ke2xIrOroGGsdbF5/P9pL WssYin51d60dw1oK7O5uLEHxtc84Tl+ZeLkgGGgGIx911eT9rtYBtWFWrgkSdWFDYWWm 48FWpsNolW7PcSMImLA8F6TONFa0HH45s1pOwfKVXtf0PP7J9W+mlJ6ivXYNbs/JhGZD oo4J0RYSVfeJSUzVLHMQYwcK2XXUDUxiG0+axmLlAS6R6+namoIxKIIag/5uarC4R9kN Ky4k+vq9sBUcsjG/rer7ieBdipHI6jhyvsi4/1oWals6v3RJqPPLndexE+G/EkAWF9Z9 BxTg== X-Gm-Message-State: ACrzQf0zQDYmnqpzIV3zQwIEAXjbi0kS6AP2J0GxM9v3hWUD8qnd0Kn1 TTzSv3Fyc73dexCFoFa2X560 X-Google-Smtp-Source: AMsMyM6ThD7+enWcyxZksYRgAgxKZ6BLCrh4eJZjoHGckSndcNbzyb/5kk+TtL9WQRAix4vKePI6MA== X-Received: by 2002:a17:902:b94c:b0:178:336f:13d6 with SMTP id h12-20020a170902b94c00b00178336f13d6mr5822926pls.64.1667069336085; Sat, 29 Oct 2022 11:48:56 -0700 (PDT) Received: from takamaka.gnat.com ([184.69.131.86]) by smtp.gmail.com with ESMTPSA id y4-20020aa79ae4000000b0056bdc3f5b29sm1478679pfp.186.2022.10.29.11.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 11:48:55 -0700 (PDT) Received: by takamaka.gnat.com (Postfix, from userid 1000) id 4A48784046; Sat, 29 Oct 2022 11:48:54 -0700 (PDT) Date: Sat, 29 Oct 2022 11:48:54 -0700 From: Joel Brobecker To: Tom Tromey via Gdb-patches Cc: Tom Tromey , Joel Brobecker Subject: Re: [PATCH] Fix regression in pointer-to-member printing Message-ID: References: <20221018175304.3158312-1-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018175304.3158312-1-tromey@adacore.com> X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Hi Tom, On Tue, Oct 18, 2022 at 11:53:04AM -0600, Tom Tromey via Gdb-patches wrote: > PR c++/29243 points out that "info func" on a certain C++ executable > will cause an infinite loop in gdb. > > I tracked this down to a bug introduced by commit 6b5a7bc76 ("Handle > member pointers directly in generic_value_print"). Before this > commit, the C++ code to print a member pointer would wind up calling > value_print_scalar_formatted; but afterward it simply calls > generic_value_print and gets into a loop. Thanks for the fix :-). The patch looks good to me. Thanks also for including a regression test! > This patch restores the previous behavior and adds a regression test. > --- > gdb/testsuite/gdb.cp/member-ptr.cc | 8 ++++++++ > gdb/testsuite/gdb.cp/member-ptr.exp | 4 ++++ > gdb/valprint.c | 2 +- > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc > index 22ffcc58d39..a563d2e6af3 100644 > --- a/gdb/testsuite/gdb.cp/member-ptr.cc > +++ b/gdb/testsuite/gdb.cp/member-ptr.cc > @@ -142,6 +142,11 @@ int Diamond::vget_base () > return this->Left::x + 2000; > } > > +struct Container > +{ > + PMI member; > +}; > + > int > func (int x) > { > @@ -205,6 +210,9 @@ int main () > null_pmi = NULL; > null_pmf = NULL; > > + Container contain; > + contain.member = &A::j; > + > pmi = NULL; /* Breakpoint 1 here. */ > > (diamond.*diamond_pfunc_ptr) (20); > diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp > index 110497b893b..5b91bcb493a 100644 > --- a/gdb/testsuite/gdb.cp/member-ptr.exp > +++ b/gdb/testsuite/gdb.cp/member-ptr.exp > @@ -628,3 +628,7 @@ gdb_test "print null_pmi = 0" "$vhn = NULL" > gdb_test "print null_pmf" "$vhn = NULL" > gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*( const)?, int\\)\\) $hex " > gdb_test "print null_pmf = 0" "$vhn = NULL" > + > +# Print with a format, bypassing the direct call to the scalar > +# printer. See PR c++/29243. > +gdb_test "print/x contain" " = {member = $hex}" > diff --git a/gdb/valprint.c b/gdb/valprint.c > index f079f31fa7b..585af69cb27 100644 > --- a/gdb/valprint.c > +++ b/gdb/valprint.c > @@ -879,7 +879,7 @@ generic_value_print_memberptr > cp_print_class_member (valaddr, type, stream, "&"); > } > else > - generic_value_print (val, stream, recurse, options, decorations); > + value_print_scalar_formatted (val, options, 0, stream); > } > > /* See valprint.h. */ > -- > 2.34.3 > -- Joel