Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Can Acar <canacar@imcan.dev>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix: Sign extensions for DW_FORM_addrx were never considered
Date: Fri, 24 Oct 2025 07:43:12 -0600	[thread overview]
Message-ID: <878qh0jtzj.fsf@tromey.com> (raw)
In-Reply-To: <20251023214230.13646-1-canacar@imcan.dev> (Can Acar's message of "Thu, 23 Oct 2025 14:42:26 -0700")

>>>>> "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

  parent reply	other threads:[~2025-10-24 13:43 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 [this message]
2025-10-28  1:02   ` Can Acar
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=878qh0jtzj.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=canacar@imcan.dev \
    --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