From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29619 invoked by alias); 22 Jan 2014 03:44:34 -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 29572 invoked by uid 89); 22 Jan 2014 03:44:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f41.google.com Received: from mail-pb0-f41.google.com (HELO mail-pb0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 22 Jan 2014 03:44:30 +0000 Received: by mail-pb0-f41.google.com with SMTP id up15so8798181pbc.28 for ; Tue, 21 Jan 2014 19:44:28 -0800 (PST) X-Received: by 10.68.192.131 with SMTP id hg3mr13455729pbc.136.1390362268820; Tue, 21 Jan 2014 19:44:28 -0800 (PST) Received: from ubuntu.dhcp.ucweb.local ([70.39.187.196]) by mx.google.com with ESMTPSA id jn12sm17392559pbd.37.2014.01.21.19.44.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Jan 2014 19:44:28 -0800 (PST) From: manjian2006@gmail.com To: gdb-patches@sourceware.org, tromey@redhat.com, brobecker@adacore.com, xdje42@gmail.com Cc: linzj Subject: [PATCH V3] fixed inherit_abstract_dies infinite recursive call Date: Wed, 22 Jan 2014 03:44:00 -0000 Message-Id: <1390362244-3146-1-git-send-email-manjian2006@gmail.com> X-SW-Source: 2014-01/txt/msg00830.txt.bz2 From: linzj Reset the die's in_process bit using cleanup facility. >> ChangeLog added. >> Please Joel Brobecker helps with the testcases. >> >> The c++ code causing the problem is: >> >> >> >> // Integer variants of certain metrics, used for HTML rendering. >> >> int ascent(FontBaseline baselineType = AlphabeticBaseline) const >> >> { >> >> if (baselineType == AlphabeticBaseline) >> >> return lroundf(m_ascent); >> >> return height() - height() / 2; >> >> } >> >> >> >> int height(FontBaseline baselineType = AlphabeticBaseline) const >> >> { >> >> return ascent(baselineType) + descent(baselineType); >> >> } >> >> >> >> As you can see,ascent(0x5816d55) calls height(0x5812c1b),and height calls >> >> ascent(0x5816d55) recursivly.And the compiler generates these dwarf code >> >> representing this relationship preciously. >> >> >> >> A dwarf die may have the following relationship: >> >> 564860c<----------------------------- >> >> | | >> >> |(abstract origin) | >> >> | | >> >> V | >> >> 5816d55 | (abstract origin) >> >> | | >> >> |(child) | >> >> | | >> >> V | >> >> ... | >> >> 5812c34------------------------------ >> >> So inherit_abstract_dies may results in infinite recursive call. >> >> A bit field call in_process has been add to struct die_info to fix this problem. >> >> process_die would first check if a die is in processing state, if so,just return. >> >> Then in_process bit is set.Before process_die returns,this bit field is unset. --- ChangeLog | 8 ++++++++ gdb/dwarf2read.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9b1cbfa..c17af8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-01-20 lin Zuojian + * gdb/dwarf2read.c(struct die_info): Add a + bit to form a bitmap to avoid visit twice + when process_die. + * gdb/dwarf2read.c(process_die): Test in_process + bit to avoid visit twice.Set in_process bit + before doing actual jobs.Unset in_process bit + before process_die returns. 2013-12-19 Keven Boell * cp-namespace.c (cp_lookup_nested_symbol): Enable diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 7ca527d..cf27283 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1224,6 +1224,8 @@ struct die_info /* True if we're presently building the full type name for the type derived from this DIE. */ unsigned char building_fullname : 1; + /* True if this die is in process. */ + unsigned char in_process : 1; /* Abbrev number */ unsigned int abbrev; @@ -8008,11 +8010,27 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) } } +/* Reset the in_process bit of a die. */ +static void +reset_die_in_process(void *arg) +{ + struct die_info *die = arg; + die->in_process = 0; +} + /* Process a die and its children. */ static void process_die (struct die_info *die, struct dwarf2_cu *cu) { + /* The in process bit of a die's cleanup. */ + struct cleanup * in_process; + + /* Only process those who are not in process. */ + if (die->in_process) + return; + die->in_process = 1; + in_process = make_cleanup(reset_die_in_process,die); switch (die->tag) { case DW_TAG_padding: @@ -8100,6 +8118,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, NULL, cu); break; } + do_cleanups(in_process); } /* DWARF name computation. */ -- 1.8.3.2