Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb/dwarf: fix failed assertion in dwarf2_find_containing_comp_unit selftest
Date: Thu, 27 Feb 2025 14:12:55 +0100	[thread overview]
Message-ID: <47dd9357-b15d-4568-8701-97b15f941475@suse.de> (raw)
In-Reply-To: <20250226165255.25737-2-simon.marchi@efficios.com>

On 2/26/25 17:52, Simon Marchi wrote:
> Commit 2f0521c0d6f6 ("gdb/dwarf: fix signature_type created with nullptr
> section") added some asserts in the dwarf2_per_cu_data constructor to
> verify that the passed dwarf2_per_bfd and dwarf2_section_info are not
> nullptr.  However, the dummy dwarf2_per_cu_data objects create the in
> dwarf2_find_containing_comp_unit selftests are passed nullptr for those
> parameters.
> 
> I prefer to keep the asserts in place, as protection for the non-test
> code and as self documentation, so fix this by passing some dummy
> pointers in the test.
> 

Hi Simon,

I"ve applied the series, and confirmed that gdb.gdb/unittest.exp passes 
again.

LGTM.

Reviewed-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> Change-Id: Ic7cdc1b976f7506041b651222234eefc998e473a
> ---
>   gdb/dwarf2/read.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 2b060959c36f..59d79af004ca 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -20946,9 +20946,16 @@ namespace find_containing_comp_unit {
>   static void
>   run_test ()
>   {
> -  const auto create_dummy_per_cu = [] (sect_offset sect_off, unsigned int length)
> +  char dummy_per_bfd;
> +  char dummy_section;
> +
> +  const auto create_dummy_per_cu = [&] (sect_offset sect_off,
> +					unsigned int length)
>       {
> -      return dwarf2_per_cu_data_up (new dwarf2_per_cu_data (nullptr, nullptr,
> +      auto per_bfd = reinterpret_cast<dwarf2_per_bfd *> (&dummy_per_bfd);
> +      auto section = reinterpret_cast<dwarf2_section_info *> (&dummy_section);
> +
> +      return dwarf2_per_cu_data_up (new dwarf2_per_cu_data (per_bfd, section,
>   							    sect_off, length));
>       };
>   


  reply	other threads:[~2025-02-27 13:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 16:52 [PATCH 1/2] gdb/dwarf: pass unit length to dwarf2_per_cu_data constructor Simon Marchi
2025-02-26 16:52 ` [PATCH 2/2] gdb/dwarf: fix failed assertion in dwarf2_find_containing_comp_unit selftest Simon Marchi
2025-02-27 13:12   ` Tom de Vries [this message]
2025-02-27 13:15   ` Tom de Vries
2025-02-27 15:18     ` Simon Marchi
2025-02-27 13:09 ` [PATCH 1/2] gdb/dwarf: pass unit length to dwarf2_per_cu_data constructor Tom de Vries

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=47dd9357-b15d-4568-8701-97b15f941475@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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