Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: Guinevere Larsen <guinevere@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/4] gdb/progspace: add solib_ops pointer in program_space
Date: Mon, 16 Jun 2025 14:41:46 -0400	[thread overview]
Message-ID: <222942a6-2d9c-43d1-b68d-0826863989f2@efficios.com> (raw)
In-Reply-To: <c7ec9fc4-bba0-40d6-ad55-48e7c93a251d@efficios.com>

On 6/11/25 2:43 PM, Simon Marchi wrote:
> On 6/11/25 2:14 PM, Guinevere Larsen wrote:
>>> @@ -1273,9 +1277,9 @@ solib_name_from_address (struct program_space *pspace, CORE_ADDR address)
>>>   bool
>>>   solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
>>>   {
>>> -  const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
>>> +  const solib_ops *ops = current_program_space->solib_ops ();
>>>   -  if (ops->keep_data_in_core)
>>> +  if (ops != nullptr && ops->keep_data_in_core != nullptr)
>>
>> Can this function be called before the program space is fully setup?
>>
>> Otherwise I think we should either assume that it was set correctly,
>> or assert it. Better to be loud and easy to find the bug than
>> accidentally adding a regression in a hard-to-spot place.
>>
>> This goes to all other similar places where you check for ops !=
>> nullptr.
> 
> I don't really know for sure for all the methods.
> program_space::m_solib_ops is nullptr before you run the program, and I
> don't know off-hand which methods are reachable with an inferior that's
> not running yet.  I'll try to see if I can figure it out.

I think it would be safer to leave it like this.  There are some
functions in solib.c that are called with m_solib_ops == nullptr (when
the inferior isn't running), and returning early just makes sense there.

Speaking of that, I found out that I am missing an early return in the
newly added print_.  So with this patch, if you do "info shared" without
running the inferior first, GDB crashes.  I'll add it.

It's probable that some of the functions in solib.c are always called in
paths where the inferior is running, so there we could assert that ops
!= nullptr.  But figuring those out seems difficult, and I wouldn't be
that confident to get it right.

If for some reason the program space's solib_ops wasn't properly set up,
I think it would quickly show up in the test results.

Simon

  reply	other threads:[~2025-06-16 18:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 19:40 [PATCH v2 1/4] gdb/solib: add solib -> solib_ops backlink Simon Marchi
2025-06-09 19:40 ` [PATCH v2 2/4] gdb/solib: use solib::ops for operations that concern a single solib Simon Marchi
2025-06-09 19:40 ` [PATCH v2 3/4] gdb/progspace: add solib_ops pointer in program_space Simon Marchi
2025-06-11 18:14   ` Guinevere Larsen
2025-06-11 18:43     ` Simon Marchi
2025-06-16 18:41       ` Simon Marchi [this message]
2025-06-16 18:53         ` Simon Marchi
2025-06-16 19:38         ` Guinevere Larsen
2025-06-16 19:41           ` Simon Marchi
2025-06-09 19:40 ` [PATCH v2 4/4] gdb/solib: C++ify solib_ops Simon Marchi
2025-06-12 12:56   ` Guinevere Larsen
2025-06-12 15:02     ` Simon Marchi

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=222942a6-2d9c-43d1-b68d-0826863989f2@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.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