Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Can Acar <canacar@imcan.dev>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix: Sign extensions for DW_FORM_addrx were never considered
Date: Mon, 27 Oct 2025 18:02:52 -0700	[thread overview]
Message-ID: <CAKB9nm+y0_iRYFNuna4hN5YrW35JjjGchs76+mTwz=VXb38AMQ@mail.gmail.com> (raw)
In-Reply-To: <878qh0jtzj.fsf@tromey.com>

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

CC'ing gdb-patches@sourceware.org as well this time. Sorry for the multiple
emails.

On Fri, Oct 24, 2025 at 6:43 AM Tom Tromey <tom@tromey.com> wrote:

> >>>>> "Can" == Can Acar <canacar@imcan.dev> writes:
>
> Can> DW_FORM_addr is converted (sign-extended) to a signed value when
> Can> the dwarf size is less than the size of unrelocated_addr, if the
> Can> target architecture "naturally" sign extends an address (bfd.c).
>
> Thanks for the patch.
>
> Can>  static unrelocated_addr
> Can>  read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int
> addr_index,
> Can> -             std::optional<ULONGEST> addr_base, int addr_size)
> Can> +             std::optional<ULONGEST> addr_base, unit_head *cu_header)
>
> I think it'd be better to merge read_addr_index_1 and read_addr_index,
> i.e. have it be:
>
> static unrelocated_addr
> read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index)
> ...
>
> Can> +  return cu_header->read_address(abfd, info_ptr, &ignore_bytes_read);
>
> gdb puts a space before "("
>
> Can>    else
> Can>      {
> Can>        cutu_reader reader (*per_cu, *per_objfile, nullptr, nullptr,
> false,
> Can>                      language_minimal);
> Can>        addr_base = reader.cu ()->addr_base;
> Can> -      addr_size = reader.cu ()->header.addr_size;
> Can> +      cu_header = &reader.cu ()->header;
>
> I'm not sure it is safe to refer to hold this pointer after cutu_reader
> is destroyed.
>
> Instead this could be refactored slightly to:
>
> std::optional<cutu_reader> reader;
> if ()
> ...
> else
>   {
>     reader.emplace (...)
>     cu = reader->cu ();
>   }
>
> thanks,
> Tom
>

I've implemented your suggestions, and will be sending in a new patch
version in a moment.

Best regards,
Can

[-- Attachment #2: Type: text/html, Size: 4187 bytes --]

  reply	other threads:[~2025-10-28  1:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 21:42 Can Acar
2025-10-23 21:44 ` Can Acar
2025-10-24 13:43 ` Tom Tromey
2025-10-28  1:02   ` Can Acar [this message]
2025-10-28  1:03     ` [PATCH v2] " Can Acar

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='CAKB9nm+y0_iRYFNuna4hN5YrW35JjjGchs76+mTwz=VXb38AMQ@mail.gmail.com' \
    --to=canacar@imcan.dev \
    --cc=gdb-patches@sourceware.org \
    --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