Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: manjian2006@gmail.com
To: gdb-patches@sourceware.org,	tromey@redhat.com,
	brobecker@adacore.com,	xdje42@gmail.com
Cc: linzj <linzj@ucweb.com>
Subject: [PATCH v4] fixed inherit_abstract_dies infinite recursive call
Date: Wed, 22 Jan 2014 07:07:00 -0000	[thread overview]
Message-ID: <1390374431-17981-1-git-send-email-manjian2006@gmail.com> (raw)

From: linzj <linzj@ucweb.com>

      * ChangeLog
      Modified ChangeLog as Doug Evans suggested.
      * dwarf2read.c
      Modified ChangeLog as Doug Evans suggested.

     > btw, do you have a copyright assignment on file?
     > This change feels small enough to me to not need one,
     > but it's not clear. 

     I am a Chinese guy,and Chinese have not clue about the copyright.
     (A joke.I don't need copyright.)
      
>    Reset the die's in_process bit using cleanup facility.
>>    ChangeLog added.
>>    Please Joel Brobecker <brobecker@adacore.com> 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        |  4 ++++
 gdb/dwarf2read.c | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9b1cbfa..0098a72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-20  lin zuojian  <manjian2006@gmail.com>
+	* dwarf2read.c (struct die_info): New member in_process.
+	(reset_die_in_process): New function.
+	(process_die): Set it at the start, reset when returning.
 2013-12-19  Keven Boell  <keven.boell@intel.com>
 
 	* cp-namespace.c (cp_lookup_nested_symbol): Enable
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7ca527d..ffedde5 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1225,6 +1225,9 @@ struct die_info
        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 +8011,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)
 {
+  struct cleanup *in_process;
+
+  /* Only process those not already 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 +8119,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
       new_symbol (die, NULL, cu);
       break;
     }
+    do_cleanups (in_process);
 }
 \f
 /* DWARF name computation.  */
-- 
1.8.3.2


             reply	other threads:[~2014-01-22  7:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22  7:07 manjian2006 [this message]
2014-01-28 12:06 ` Joel Brobecker
2014-02-10 14:28   ` PING: " Joel Brobecker
2014-02-10 17:37     ` Doug Evans
2014-02-11  2:19       ` Joel Brobecker
2014-02-12  6:58         ` Doug Evans
2014-02-13  7:31           ` Joel Brobecker
2014-02-13  8:01             ` lin zuojian
2014-02-14  3:34               ` Joel Brobecker
2014-02-19  6:48                 ` Doug Evans
2014-02-19  7:00                   ` lin zuojian
2014-02-19  7:59                   ` Joel Brobecker
2014-02-20 17:18                     ` Doug Evans
2014-02-20 17:48                       ` Joel Brobecker
2014-02-12  1:29     ` manjian2006

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390374431-17981-1-git-send-email-manjian2006@gmail.com \
    --to=manjian2006@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=linzj@ucweb.com \
    --cc=tromey@redhat.com \
    --cc=xdje42@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox