Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Lancelot SIX <Lancelot.Six@amd.com>
To: Simon Marchi <simark@simark.ca>,
	Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/11] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops
Date: Fri, 8 May 2026 11:36:12 +0100	[thread overview]
Message-ID: <e28f14bf-eff5-481a-8bb1-c81b785c0b66@amd.com> (raw)
In-Reply-To: <223ae525-3642-46e3-8490-f8d17de90968@simark.ca>



On 08/05/2026 02:37, Simon Marchi wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> On 5/7/26 1:56 PM, Lancelot SIX wrote:
>>> diff --git a/gdb/observable.h b/gdb/observable.h
>>> index 5f064cf1fc8c..c8cbdbad97d1 100644
>>> --- a/gdb/observable.h
>>> +++ b/gdb/observable.h
>>> @@ -92,9 +92,13 @@ extern observable<inferior */* exec_inf */, inferior */* follow_inf */>
>>>      the child (because we follow only the child or we follow both), CHILD_INF
>>>      is the child inferior.  Otherwise, CHILD_INF is nullptr.
>>>
>>> -   FORK_KIND is TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED.  */
>>> +   FORK_KIND is TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED.
>>> +
>>> +   detach_on_fork and follow_child represent the "detach-on-fork" and
>>> +   "follow-fork-mode" settings.  */
>>
>> Just a nitpick here.
>>
>> Should DETACH_ON_FORK and FOLLOW_CHILD be upper case?
> 
> Yes (it's not a nitpick, you're objectively right).
> 
>>> @@ -839,6 +849,24 @@ rocm_solib_target_inferior_execd (inferior *exec_inf, inferior *follow_inf)
>>>     get_solib_info (exec_inf)->solib_list.clear ();
>>>   }
>>>
>>> +static void
>>> +rocm_solib_target_inferior_forked (inferior *parent_inf, inferior *child_inf,
>>> +                               target_waitkind fork_kind,
>>> +                               bool detach_on_fork, bool follow_child)
>>> +{
>>> +  if (detach_on_fork && follow_child && fork_kind == TARGET_WAITKIND_FORKED)
>>> +    {
>>> +      /* In this particular configuration, infrun's follow_fork_inferior
>>> +     function moves the parent pspace to the child directly.  Remove the
>>> +     existing rocm_solib_ops from the child and restore the host solib_ops,
>>> +     to make it look like a brand new pspace.  */
>>> +      auto rocm_ops_holder = child_inf->pspace->release_solib_ops ();
>>> +      auto rocm_ops
>>> +    = gdb::checked_static_cast<rocm_solib_ops *> (rocm_ops_holder.get ());
>>> +      child_inf->pspace->set_solib_ops (rocm_ops->release_host_ops ());
>>
>> I think I am overall OK with the approach, even if I would prefer not
>> have the target explicitly rely on assumption about what the core does.
>>
>> If the core in infrun was to change at some point, I expect this would
>> fail: the pspace's solib would not be a rocm_solib_ops, so
>> checked_static_cast would fail.  Should this use dynimac_cast and test
>> for nullptr instead?
>>
>> Would it work to do it unconditionnaly (not check for detach_on_fork and
>> follow_inf), check if the pspace's solib is the rocm one, and if so use
>> the host one instead?
> 
> I also hesitated between the two options:
> 
>   1) do a very targeted check + checked_static_cast
>   2) just do a dynamic cast and see
> 
> We can afford to do 1), because we control both sides (core and target).
> It's not like it's an external lib that could change out of our contorl.
> If the core ever changes in this regard, yes the checked_static_cast
> will fail (in debug mode), then we simply update the target accordingly.
> I like doing it this way, so that our expectations are written in code
> and verified.  It also has the potential to catch some unwanted changes
> in the core, which the dynamic_cast would hide.
> 

My main concern would be that most people contributing to GDB do not 
build the amdgpu target (requires the rocm-dbgapi library to be 
available), so it would be easy for many to build with 
--enable-targets-all and not enable this code path.

That being said, we (at AMD) would pull such change from master and hit 
a CI failure quite promptly, so I do not expect this would be un-noticed 
for very long.

> So I'm still team 1) for the moment.  I guess in general I'm team "use
> asserts generously".
> 

I am happy to follow you there and keep this approach.

>> And last question, shouldn't this be in solib-rocm.c rather than
>> amd-dbgapi-target.c?
> 
> I'm confused, it is in solib-rocm.c currently, isn't it?

You are absolutely right, somehow I thought I was in amd-dbgapi-target.c…

Best,
Lancelot.

> 
> Simon


  reply	other threads:[~2026-05-08 10:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 19:32 [PATCH 00/11] Multiple solib_ops in a program_space Simon Marchi
2025-12-09 19:32 ` [PATCH 01/11] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops Simon Marchi
2026-05-07 17:56   ` [PATCH 1/11] " Lancelot SIX
2026-05-08  1:37     ` Simon Marchi
2026-05-08 10:36       ` Lancelot SIX [this message]
2026-06-08 18:36         ` Simon Marchi
2025-12-09 19:32 ` [PATCH 02/11] gdb/solib: use early return in solib_read_symbols Simon Marchi
2026-04-28 16:16   ` Tom Tromey
2026-05-08  1:44     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 03/11] gdb/solib-rocm: pass reference to cache to rocm_code_object_stream_file Simon Marchi
2026-05-07 18:20   ` [PATCH 3/11] " Lancelot SIX
2026-05-08  1:48     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 04/11] gdb/solib-rocm: add cached_fd to manage cached fd lifetime Simon Marchi
2026-05-07 20:17   ` [PATCH 4/11] " Lancelot SIX
2026-05-08  1:52     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 05/11] gdb: de-constify some methods of solib_ops Simon Marchi
2025-12-09 19:32 ` [PATCH 06/11] gdb/solib-rocm: move per-inferior data to rocm_solib_ops Simon Marchi
2026-04-28 16:19   ` Tom Tromey
2026-05-08  2:02     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 07/11] gdb/solib-rocm: save inferior in rocm_solib_ops Simon Marchi
     [not found]   ` <87a4unm59w.fsf@tromey.com>
2026-05-08  2:10     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 08/11] gdb/solib: add remove_solib function Simon Marchi
2026-04-28 16:23   ` Tom Tromey
2025-12-09 19:32 ` [PATCH 09/11] gdb: add objfile -> solib backlink Simon Marchi
2026-04-28 16:28   ` Tom Tromey
2026-05-08  2:25     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 10/11] gdb: change default objfile iteration order to start with current objfile Simon Marchi
2026-04-28 16:42   ` Tom Tromey
2026-05-08  2:40     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 11/11] gdb: multiple solib_ops per program space Simon Marchi
2026-04-28 17:27   ` Tom Tromey
2026-05-08  2:52     ` Simon Marchi
2026-04-28 16:00 ` [PATCH 00/11] Multiple solib_ops in a program_space Simon Marchi
2026-04-28 17:28   ` Tom Tromey
2026-05-08  2:40     ` 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=e28f14bf-eff5-481a-8bb1-c81b785c0b66@amd.com \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --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