public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] gdb: check for empty offsets vector in inherit_abstract_dies
Date: Fri, 21 Oct 2022 09:35:53 -0600	[thread overview]
Message-ID: <87czalchpi.fsf@tromey.com> (raw)
In-Reply-To: <20221021132104.1772565-1-simon.marchi@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Fri, 21 Oct 2022 09:21:03 -0400")

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> +  if (!offsets.empty ())
Simon> +    {
Simon> +      std::sort (offsets.begin (), offsets.end ());
Simon> +      sect_offset *offsets_end = offsets.data () + offsets.size ();
Simon> +      for (sect_offset *offsetp = offsets.data () + 1;
Simon> +	   offsetp < offsets_end;
Simon> +	   offsetp++)
Simon> +	if (offsetp[-1] == *offsetp)
Simon> +	  complaint (_("Multiple children of DIE %s refer "
Simon> +		       "to DIE %s as their abstract origin"),
Simon> +		     sect_offset_str (die->sect_off),
Simon> +		     sect_offset_str (*offsetp));
Simon> +    }
 
Simon>    sect_offset *offsetp = offsets.data ();
Simon> +  sect_offset *offsets_end = offsets.data () + offsets.size ();
Simon>    die_info *origin_child_die = origin_die->child;
Simon>    while (origin_child_die != nullptr && origin_child_die->tag != 0)
Simon>      {

This subsequent loop does stuff like:

      while (offsetp < offsets_end
	     && *offsetp < origin_child_die->sect_off)
	offsetp++;

which in this scenario would be comparing null pointers using "<"?

I'm guessing this whole loop should be hoisted into the 'if'.

Tom

WARNING: multiple messages have this Message-ID
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH 1/2] gdb: check for empty offsets vector in inherit_abstract_dies
Date: Fri, 21 Oct 2022 09:35:53 -0600	[thread overview]
Message-ID: <87czalchpi.fsf@tromey.com> (raw)
Message-ID: <20221021153553.LRleca8LaHz5VzzcSnui4VzMQpncN_C5oxm0Mqj002A@z> (raw)
In-Reply-To: <20221021132104.1772565-1-simon.marchi@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Fri, 21 Oct 2022 09:21:03 -0400")

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> +  if (!offsets.empty ())
Simon> +    {
Simon> +      std::sort (offsets.begin (), offsets.end ());
Simon> +      sect_offset *offsets_end = offsets.data () + offsets.size ();
Simon> +      for (sect_offset *offsetp = offsets.data () + 1;
Simon> +	   offsetp < offsets_end;
Simon> +	   offsetp++)
Simon> +	if (offsetp[-1] == *offsetp)
Simon> +	  complaint (_("Multiple children of DIE %s refer "
Simon> +		       "to DIE %s as their abstract origin"),
Simon> +		     sect_offset_str (die->sect_off),
Simon> +		     sect_offset_str (*offsetp));
Simon> +    }
 
Simon>    sect_offset *offsetp = offsets.data ();
Simon> +  sect_offset *offsets_end = offsets.data () + offsets.size ();
Simon>    die_info *origin_child_die = origin_die->child;
Simon>    while (origin_child_die != nullptr && origin_child_die->tag != 0)
Simon>      {

This subsequent loop does stuff like:

      while (offsetp < offsets_end
	     && *offsetp < origin_child_die->sect_off)
	offsetp++;

which in this scenario would be comparing null pointers using "<"?

I'm guessing this whole loop should be hoisted into the 'if'.

Tom

  parent reply	other threads:[~2022-10-21 15:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 13:21 Simon Marchi
2022-10-21 13:21 ` [PATCH 2/2] gdb: make inherit_abstract_dies use vector iterators Simon Marchi
2022-10-21 18:04   ` Tom Tromey
2022-10-21 18:04     ` Tom Tromey
2022-10-21 18:26     ` Simon Marchi
2022-10-21 15:35 ` Tom Tromey [this message]
2022-10-21 15:35   ` [PATCH 1/2] gdb: check for empty offsets vector in inherit_abstract_dies Tom Tromey
2022-10-21 15:46   ` Simon Marchi
2022-10-21 18:02     ` Tom Tromey

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=87czalchpi.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).