Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Pedro Alves <palves@redhat.com>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>,
	gdb-patches@sourceware.org,  Nathan Sidwell <nathan@acm.org>,
	Ian Lance Taylor <iant@google.com>,
	Nick Clifton <nickc@redhat.com>
Subject: Re: [PATCH] libiberty: Initialize d_printing in all cplus_demangle_* functions.
Date: Mon, 13 Mar 2017 20:35:00 -0000	[thread overview]
Message-ID: <1489437334.21350.72.camel@klomp.org> (raw)
In-Reply-To: <a3993cdc-dbb0-e377-3e46-a84d8cf971a0@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]

Hi,

Switching mailinglist from gcc to gdb.

On Mon, 2017-03-13 at 18:54 +0000, Pedro Alves wrote:
> On 03/13/2017 06:29 PM, Mark Wielaard wrote:
> 
> > O, sorry. I should have let Nick known about the gdb regressions I found.
> > Besides this patch gdb needs the following one-liner fix:
> > 
> > diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
> > index fd1e949..5278c05 100644
> > --- a/gdb/cp-name-parser.y
> > +++ b/gdb/cp-name-parser.y
> > @@ -201,6 +201,7 @@ make_empty (enum demangle_component_type d_type)
> >  {
> >    struct demangle_component *ret = d_grab ();
> >    ret->type = d_type;
> > +  ret->d_printing = 0;
> >    return ret;
> >  }
> 
> Should gdb be memsetting instead to avoid having to know about
> libiberty's "internals"?

Maybe. But I went with the version I tested.

Basically none of this would be needed if gdb only used the
cplus_demangle_fill_* functions to initialize the data structures
(although that is where there was a bug, but that is now fixed).

cp-name-parser.y however sometimes uses the cplus_demangle_fill
functions, but other times fills in the data structures by hand (using
its own partial fill function make_empty). I know too little of this
code to know why. Maybe the set of cplus_demangle_fill functions isn't
complete enough or maybe the way the parser works not all information
needed is there yet to call cplus_demangle_fill or maybe doing it by
hand just felt more efficient?

>  Either version is pre-approved for GDB.

Thanks. I checked in the attached to merge libiberty again and fix
cp-name-parser.y make_empty.

Cheers,

Mark

[-- Attachment #2: 0001-Merge-libiberty-Initialize-d_printing-in-all-cplus_d.patch --]
[-- Type: text/x-patch, Size: 3713 bytes --]

From b9da89d161e3903faa335f444af2bf05e40f926e Mon Sep 17 00:00:00 2001
From: mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 Mar 2017 18:26:47 +0000
Subject: [PATCH] Merge libiberty: Initialize d_printing in all
 cplus_demangle_fill_* functions.

While integrating the d_printing recursion guard change into gdb I
noticed we forgot to initialize the demangle_component d_printing
field in cplus_demangle_fill_{name,extended_operator,ctor,dtor}.
As is done in cplus_demangle_fill_{component,builtin_type,operator}.
It happened to work because in gcc all demangle_components were
allocated through d_make_empty. But gdb has its own allocation
mechanism (as might other users).

libiberty/ChangeLog:

       * cp-demangle.c (cplus_demangle_fill_name): Initialize
       demangle_component d_printing.
       (cplus_demangle_fill_extended_operator): Likewise.
       (cplus_demangle_fill_ctor): Likewise.
       (cplus_demangle_fill_dtor): Likewise.

gdb/ChangeLog:

       * cp-name-parser.y (make_empty): Initialize d_printing to zero.
---
 gdb/ChangeLog           | 4 ++++
 gdb/cp-name-parser.y    | 1 +
 libiberty/ChangeLog     | 8 ++++++++
 libiberty/cp-demangle.c | 4 ++++
 4 files changed, 17 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e4c4432..7de2498 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-03-13  Mark Wielaard  <mark@klomp.org>
+
+	* cp-name-parser.y (make_empty): Initialize d_printing to zero.
+
 2017-03-10  Keith Seitz  <keiths@redhat.com>
 
 	PR c++/8218
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index fd1e949..5278c05 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -201,6 +201,7 @@ make_empty (enum demangle_component_type d_type)
 {
   struct demangle_component *ret = d_grab ();
   ret->type = d_type;
+  ret->d_printing = 0;
   return ret;
 }
 
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index e93e327..b513fce 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-12  Mark Wielaard  <mark@klomp.org>
+
+	* cp-demangle.c (cplus_demangle_fill_name): Initialize
+	demangle_component d_printing.
+	(cplus_demangle_fill_extended_operator): Likewise.
+	(cplus_demangle_fill_ctor): Likewise.
+	(cplus_demangle_fill_dtor): Likewise.
+
 2017-03-08  Mark Wielaard  <mark@klomp.org>
 
 	PR demangler/70909
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 341a418..04832ff 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -854,6 +854,7 @@ cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
 {
   if (p == NULL || s == NULL || len == 0)
     return 0;
+  p->d_printing = 0;
   p->type = DEMANGLE_COMPONENT_NAME;
   p->u.s_name.s = s;
   p->u.s_name.len = len;
@@ -869,6 +870,7 @@ cplus_demangle_fill_extended_operator (struct demangle_component *p, int args,
 {
   if (p == NULL || args < 0 || name == NULL)
     return 0;
+  p->d_printing = 0;
   p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR;
   p->u.s_extended_operator.args = args;
   p->u.s_extended_operator.name = name;
@@ -888,6 +890,7 @@ cplus_demangle_fill_ctor (struct demangle_component *p,
       || (int) kind < gnu_v3_complete_object_ctor
       || (int) kind > gnu_v3_object_ctor_group)
     return 0;
+  p->d_printing = 0;
   p->type = DEMANGLE_COMPONENT_CTOR;
   p->u.s_ctor.kind = kind;
   p->u.s_ctor.name = name;
@@ -907,6 +910,7 @@ cplus_demangle_fill_dtor (struct demangle_component *p,
       || (int) kind < gnu_v3_deleting_dtor
       || (int) kind > gnu_v3_object_dtor_group)
     return 0;
+  p->d_printing = 0;
   p->type = DEMANGLE_COMPONENT_DTOR;
   p->u.s_dtor.kind = kind;
   p->u.s_dtor.name = name;
-- 
1.8.3.1


       reply	other threads:[~2017-03-13 20:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1489356354-27648-1-git-send-email-mark@klomp.org>
     [not found] ` <20170313181150.GA287@x4>
     [not found]   ` <20170313182959.GC2167@stream>
     [not found]     ` <a3993cdc-dbb0-e377-3e46-a84d8cf971a0@redhat.com>
2017-03-13 20:35       ` Mark Wielaard [this message]
2017-03-14  1:26         ` Pedro Alves
2017-03-14  9:05           ` Mark Wielaard
2017-03-14 10:50             ` Pedro Alves
2017-03-27 14:28               ` [pushed/ob] cplus_demangle_fill_component: Handle DEMANGLE_COMPONENT_RVALUE_REFERENCE (Re: [PATCH] libiberty: Initialize d_printing in all cplus_demangle_* functions.) Pedro Alves
2017-03-27 14:36           ` [pushed] gdb/cp-name-parser.y: Eliminate make_empty, use cplus_demangle_fill_component " Pedro Alves

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=1489437334.21350.72.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=gdb-patches@sourceware.org \
    --cc=iant@google.com \
    --cc=markus@trippelsdorf.de \
    --cc=nathan@acm.org \
    --cc=nickc@redhat.com \
    --cc=palves@redhat.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