From patchwork Tue May 17 14:45:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5bu65piOIOS5lA==?= X-Patchwork-Id: 12308 Received: (qmail 27685 invoked by alias); 17 May 2016 14:45:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27659 invoked by uid 89); 17 May 2016 14:45:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.4 required=5.0 tests=AWL, BAYES_50, CHARSET_FARAWAY_HEADER, FREEMAIL_FROM, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Database, H*r:65.55.111, Hx-spam-relays-external:sk:blu004-, H*RU:sk:blu004- X-HELO: BLU004-OMC2S19.hotmail.com Received: from blu004-omc2s19.hotmail.com (HELO BLU004-OMC2S19.hotmail.com) (65.55.111.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Tue, 17 May 2016 14:45:33 +0000 Received: from BLU181-W69 ([65.55.111.72]) by BLU004-OMC2S19.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 17 May 2016 07:45:31 -0700 X-TMN: [zBClPEvKRJIFfsrYNXyPF/fsggq5l3Uv] Message-ID: From: =?gb2312?B?vajD9yDHxw==?= To: "gdb-patches@sourceware.org" Subject: [PATCH] The parameter in value_entirely_optimized_out is NULL Date: Tue, 17 May 2016 22:45:31 +0800 MIME-Version: 1.0 Hi: The GDB(v7.7 onwards) will crash at value_entirely_optimized_out (value=0x0) in some cases. These cases are reported in GDB Database as Bug 20020,17076,17685 in X86 platform and other reports that use cross-compiled GDB host(ARM & MIPS) from our side. This bug is introduced when the patch https://sourceware.org/ml/gdb-patches/2013-10/msg00353.html is added. The code from this patch that caused the regression is listed below: Thanks Jmqiao diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 1d7147c..4b625d1 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -333,12 +333,9 @@ cp_print_value_fields (struct type *type, struct type *real_type, fprintf_filtered (stream, _(""), ex.message); - else if (v == NULL) - val_print_optimized_out (NULL, stream); - else - cp_print_static_field (TYPE_FIELD_TYPE (type, i), - v, stream, recurse + 1, - options); + cp_print_static_field (TYPE_FIELD_TYPE (type, i), + v, stream, recurse + 1, + options); } Therefore, I propose to partly revert the previous patch and apply the change below. Is it acceptable ? diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index effce30..aaf36d1 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -328,9 +328,12 @@ cp_print_value_fields (struct type *type, struct type *real_type, } END_CATCH - cp_print_static_field (TYPE_FIELD_TYPE (type, i), - v, stream, recurse + 1, - options); + if (v == NULL) + val_print_optimized_out(NULL, stream); + else + cp_print_static_field (TYPE_FIELD_TYPE (type, i), + v, stream, recurse + 1, + options); } else if (i == vptr_fieldno && type == vptr_basetype) {