Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Kempke, Nils-Christian via Gdb-patches" <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>,
	Nils-Christian Kempke via Gdb-patches
	<gdb-patches@sourceware.org>
Subject: RE: [PATCH v3 2/2] gdb, dwarf: create symbols for template tags without names
Date: Wed, 24 Aug 2022 08:47:27 +0000	[thread overview]
Message-ID: <CY4PR1101MB207101D96FA559D5849697B4B8739@CY4PR1101MB2071.namprd11.prod.outlook.com> (raw)
In-Reply-To: <878rnedbkx.fsf@tromey.com>

Hi Tom,

Thanks for the review!

> > +  die_info* child = die->parent->child;
> 
> The "*" is in the wrong spot.

Fixed in v4.
 
> > +  while (child != die && child != nullptr)
> 
> Here the loop condition checks for nullptr, but below the assert does
> not:
> 
> > +  }
> > +  gdb_assert (child == die);
> 
> It seems to me that one or the other must be incorrect.

Mh, here I am not sure.  Theoretically, I'd assume that the die we are
looking at will definitely be a child of its parent.  The setup would be severely
broken if not.  However, if it is broken, then the children we are iterating over
would, at some point, not have siblings anymore and child->sibling would be
NULL.  I added the child != nullptr check to the loop condition to catch this case
and not run into a Segfault.

The  gdb_assert (child == die) also implies that child != nullptr as we assume that
die != nullptr (even though we don't check this explicitly, but dwarf2_name, the
only caller of unnamed_template_tag_name also just assumes die != nullptr).
I just added the assert to make sure we did not exit the loop because of broken
child-parent relations.  I don't think either of them is really wrong.

Then, looking at this again I think the better solution is to have 
  while (child != die)
as the loop condition and
  gdb_assert (child != nullptr)
inside the while and remove the gdb_assert (child == die).  I'll change it to that
for v4 now.

> 
> > +  const std::string name_str = "<unnamed" + std::to_string
> (nth_unnamed) + ">";
> > +  return obstack_strndup (&cu->per_objfile->objfile->per_bfd-
> >storage_obstack,
> > +			  name_str.c_str (), name_str.size ());
> 
> Better IMO to use objfile::intern.

Yes, changed in v4.
 
Thanks,
Nils
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


      reply	other threads:[~2022-08-24  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 15:36 [PATCH v3 0/2] Handle unnamed template tags in GDB Nils-Christian Kempke via Gdb-patches
2022-08-23 15:36 ` [PATCH v3 1/2] gdb, testsuite: adapt function_range expected name Nils-Christian Kempke via Gdb-patches
2022-08-23 15:36 ` [PATCH v3 2/2] gdb, dwarf: create symbols for template tags without names Nils-Christian Kempke via Gdb-patches
2022-08-23 19:06   ` Tom Tromey
2022-08-24  8:47     ` Kempke, Nils-Christian via Gdb-patches [this message]

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=CY4PR1101MB207101D96FA559D5849697B4B8739@CY4PR1101MB2071.namprd11.prod.outlook.com \
    --to=gdb-patches@sourceware.org \
    --cc=nils-christian.kempke@intel.com \
    --cc=tom@tromey.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