From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20714 invoked by alias); 18 Oct 2017 13:17:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 19714 invoked by uid 89); 18 Oct 2017 13:17:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Google-Smtp-Source:AOwi7QA X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 13:17:34 +0000 Received: by mail-wm0-f67.google.com with SMTP id u138so10264562wmu.4 for ; Wed, 18 Oct 2017 06:17:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EnpXiItiy1hnsJ/5pCFxZ5Eh543G6VMlffuOxLqxRng=; b=O4PkD2rkb1W9AxS9uxYU3BETIAr3y4gNrV6aqLmmiGSlLrEgG9h/Z8M2LG1YYZDE1K 4cUxPen10xxj81cOQCH6nR1O4nHh5ykd3siL8L/G42/lF4lpEr7X8ZB2QFXc0FWVmqTl E6J+Ykc4h3TqGSaJPRflrcH8hG+RNg4AFkg/wWjyfWGQUZVxtKp+w8nGn2Lt96o2YlDQ j2HyHPkxbrwJGlxUwDJh4sfKU5XDYJt3aDHuvvIgHjIjaonV7Ks7q6r3WmfyRpQuXeME HtwolrHprknABBIxWyTC6r9F/Q7169CFA9pLlX2+E+w0nqi70uwNupbLoLTkwVc4uB+1 dh7w== X-Gm-Message-State: AMCzsaXpBlX0UPPgzmoiosLHL4R9NDqM8X0h/B/us1/fB5YSkBfWylSk fwaD1hU1EtjIAU0cpbhc4PZAU+50a8Y= X-Google-Smtp-Source: AOwi7QA+pa/b8vc1Tf0ROVXP8v5BPhiTmNGtUcDsAjLwuo5K4V64S8TiNeVS4Yu7/aOfbrKr1u/M7Q== X-Received: by 10.80.176.225 with SMTP id j88mr21054424edd.25.1508332651993; Wed, 18 Oct 2017 06:17:31 -0700 (PDT) Received: from centos7dev.localdomain ([213.207.96.130]) by smtp.gmail.com with ESMTPSA id t20sm10293137edd.75.2017.10.18.06.17.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 06:17:31 -0700 (PDT) From: Patrick Frants To: gdb-patches@sourceware.org Cc: Patrick Frants Subject: [PATCH 1/2] In cp_print_value_fields() obey dont_print_statmem=1 explicitly passed from cp_print_static_field() Date: Wed, 18 Oct 2017 13:17:00 -0000 Message-Id: <20171018131729.23137-1-osscontribute@gmail.com> X-SW-Source: 2017-10/txt/msg00562.txt.bz2 This fixes Bug gdb/13669 (https://sourceware.org/bugzilla/show_bug.cgi?id=13669) cp_print_value_fields() in cp-valprint.c optionally skips static members based on options->static_field_print. Additionally cp_print_value_fields() has a parameter dont_print_statmem, which instructs the current invocation to skip static members. The "if () continue" statement (line 236) fails to take into account this parameter and therefore gdb gets into an infinite recursion involving cp_print_value_fields() and cp_print_static_field(). Sample backtrace (note dont_print_statmem=1): (gdb) bt 30 #0 0x00007ffff754737d in __libc_sigaction () from target:/lib64/libc.so.6 #1 0x0000000000527c65 in gdb_demangle (name=0xd97683 "m_blendColour", options=3) at cp-support.c:1524 #2 0x0000000000646a6f in fprintf_symbol_filtered (stream=0x7fffffffd580, name=0xd97683 "m_blendColour", lang=, arg_mode=3) at utils.c:2433 #3 0x000000000052866f in cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16284, val=0x221f040, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:267 #4 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16284, stream=0x7fffffffd580, val=0x221f040, type=) at cp-valprint.c:672 #5 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16283, val=0x221eb90, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #6 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16283, stream=0x7fffffffd580, val=0x221eb90, type=) at cp-valprint.c:672 #7 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16282, val=0x221e710, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #8 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16282, stream=0x7fffffffd580, val=0x221e710, type=) at cp-valprint.c:672 #9 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16281, val=0x221f7b0, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #10 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16281, stream=0x7fffffffd580, val=0x221f7b0, type=) at cp-valprint.c:672 #11 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16280, val=0x221e100, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #12 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16280, stream=0x7fffffffd580, val=0x221e100, type=) at cp-valprint.c:672 #13 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16279, val=0x2213190, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #14 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16279, stream=0x7fffffffd580, val=0x2213190, type=) at cp-valprint.c:672 #15 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16278, val=0x2212d20, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #16 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16278, stream=0x7fffffffd580, val=0x2212d20, type=) at cp-valprint.c:672 #17 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16277, val=0x2212860, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #18 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16277, stream=0x7fffffffd580, val=0x2212860, type=) at cp-valprint.c:672 #19 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16276, val=0x2213660, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #20 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16276, stream=0x7fffffffd580, val=0x2213660, type=) at cp-valprint.c:672 #21 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16275, val=0x22121d0, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #22 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16275, stream=0x7fffffffd580, val=0x22121d0, type=) at cp-valprint.c:672 #23 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16274, val=0x2211e10, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #24 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16274, stream=0x7fffffffd580, val=0x2211e10, type=) at cp-valprint.c:672 #25 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16273, val=0x2214210, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #26 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16273, stream=0x7fffffffd580, val=0x2214210, type=) at cp-valprint.c:672 #27 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16272, val=0x2213d60, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 #28 0x0000000000529301 in cp_print_static_field (options=0x7fffffffcda0, recurse=16272, stream=0x7fffffffd580, val=0x2213d60, type=) at cp-valprint.c:672 #29 cp_print_value_fields (type=, type@entry=0xdc90c0, real_type=, offset=offset@entry=0, address=address@entry=6295612, stream=stream@entry=0x7fffffffd580, recurse=recurse@entry=16271, val=0x22137d0, options=0x7fffffffcda0, dont_print_vb=0x0, dont_print_statmem=1) at cp-valprint.c:333 (More stack frames follow...) ------------------------------------------------ REPRODUCTION: A unittest has been added as two files: binutils-gdb/gdb/testsuite/gdb.cp/printstaticrecursion.exp binutils-gdb/gdb/testsuite/gdb.cp/printstaticrecursion.cc --- gdb/cp-valprint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index fb9bfd904f..9dda6e2e5c 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -230,7 +230,7 @@ cp_print_value_fields (struct type *type, struct type *real_type, const gdb_byte *valaddr = value_contents_for_printing (val); /* If requested, skip printing of static fields. */ - if (!options->static_field_print + if ( (!options->static_field_print || dont_print_statmem) && field_is_static (&TYPE_FIELD (type, i))) continue; -- 2.14.0