public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "simark@simark.ca" <simark@simark.ca>,
	Aditya Kamath1 <Aditya.Kamath1@ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] 0001-Fix-multi-thread-debug-bug-in-AIX.patch
Date: Fri, 17 Feb 2023 14:18:42 +0000	[thread overview]
Message-ID: <8728e4f68ab1d57df73a0d7acc2aa1e9a8b065b7.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB3544B015A880690CA1F6284AD6A19@CH2PR15MB3544.namprd15.prod.outlook.com>

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>Yes, it resolves the issue.

Excellent.  A few final comment on the patch, including one
change I hadn't noticed before:

>@@ -508,14 +552,17 @@ pdc_read_data (pthdb_user_t user_current_pid, void *buf,
>   /* This is needed to eliminate the dependency of current thread
>      which is null so that thread reads the correct target memory.  */
>   {
>-    scoped_restore_current_thread restore_current_thread;
>+    scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
>     /* Before the first inferior is added, we pass inferior_ptid.pid ()
>        from pd_enable () which is 0.  There is no need to switch threads
>        during first initialisation.  In the rest of the callbacks the
>        current thread needs to be correct.  */
This comment is no longer relevant as the code relating to it was
deleted.  The comment should be deleted as well.
>-    if (user_current_pid != 0)
>-      switch_to_thread (current_inferior ()->process_target (),
>-			ptid_t (user_current_pid));
>+    inferior_ptid = ptid_t (user_current_pid);
>+    scoped_restore_current_inferior restore_inferior;
>+    set_current_inferior (inf);
>+
>+    scoped_restore_current_program_space restore_current_progspace;
>+    set_current_program_space (inf->pspace);
>     status = target_read_memory (addr, (gdb_byte *) buf, len);
>   }
>   ret = status == 0 ? PDC_SUCCESS : PDC_FAILURE;

 
>+  tp = find_thread_ptid (proc_target, ptid_t (pid));
>+
>+  /* If the pthreadlibrary is not ready to debug 
>+     then this is just a main process which needs 
>+     a priv to be set.  The if condition below does 
>+     the same.  Otherwise we go to the for loop to 
>+     sync the pthread and GDB thread lists.  */
>+
>   /* Apply differences between the two arrays to GDB's thread list.  */
>+
>   for (pi = gi = 0; pi < pcount || gi < gcount;)

These changes all seem to be leftovers from previous attempts,
I guess they should be removed again.

>+  inferior *inf = current_inferior (); 
>+  /* When attaching / handling fork child, don't try loading libthread_db
>+     until we know about all shared libraries.  */
>+  if (inf->in_initial_library_scan)
>+    return;

"libthread_db" is Linux specific.  Please update the comment so
it makes sense in the AIX context.
 
>@@ -1362,12 +1439,16 @@ aix_thread_target::fetch_registers (struct regcache *regcache, int regno)
> {
>   struct thread_info *thread;
>   pthdb_tid_t tid;
>+  thread = find_thread_ptid (current_inferior ()->process_target (), ptid_t (regcache->ptid ().pid (), 0, regcache->ptid ().tid ()));
> 
>-  if (!PD_TID (regcache->ptid ()))
>+  /* If a new inferior is born, then its pthread debug library is yet to
>+     initialised and hence has no private data. So the below if condition
>+     exists.  */
>+
>+  if (regcache->ptid ().tid () == 0)
>     beneath ()->fetch_registers (regcache, regno);
>   else
>     {
>-      thread = find_thread_ptid (current_inferior (), regcache->ptid ());
>       aix_thread_info *priv = get_aix_thread_info (thread);
>       tid = priv->tid;

I hadn't seen this change below, it doesn't really make sense to me.
You really need to use regcache->ptid here, this should be correct.
When did you see a case where this was not correct?   Does this still
happen now that we have the in_initial_library_scan check?

Bye,
Ulrich


  parent reply	other threads:[~2023-02-17 14:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CH2PR15MB35449137854F561F1EA7DE04D6D69@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-02 17:43 ` Ulrich Weigand
     [not found]   ` <DM6PR15MB3545C1FD15BEC2D160B3AB81D6D79@DM6PR15MB3545.namprd15.prod.outlook.com>
2023-02-06 19:07     ` Ulrich Weigand
     [not found]       ` <CH2PR15MB35449148A6541A1581B1749ED6DB9@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-08 18:44         ` Ulrich Weigand
     [not found]           ` <DM6PR15MB3545F7F15C72DF6970E4D0AED6DE9@DM6PR15MB3545.namprd15.prod.outlook.com>
2023-02-13 19:01             ` Ulrich Weigand
     [not found]               ` <CH2PR15MB35444D2E4EC3340265427F47D6A29@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-16 19:46                 ` Ulrich Weigand
     [not found]                   ` <CH2PR15MB354455A756AF729AE5F796E2D6A19@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-17 12:04                     ` Ulrich Weigand
     [not found]                       ` <CH2PR15MB3544B015A880690CA1F6284AD6A19@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-17 14:18                         ` Ulrich Weigand [this message]
     [not found]                           ` <CH2PR15MB3544E905156ECE35D5ADCD43D6A19@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-02-17 19:14                             ` Ulrich Weigand
     [not found] <CH2PR15MB35447ECA01D9D2F75AEACC1DD6319@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-10-28  9:49 ` Ulrich Weigand
     [not found]   ` <CH2PR15MB3544280C0A0B3D7F2F35BD0FD63F9@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-11-08 12:17     ` Ulrich Weigand
     [not found]       ` <CH2PR15MB3544E198B0622C3AD22597A2D6029@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-11-15 18:16         ` Ulrich Weigand
     [not found]           ` <CH2PR15MB35442C5A578DC4042072FC83D60A9@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-11-23 14:15             ` Ulrich Weigand
     [not found]               ` <CH2PR15MB35441FE8F8E1FECD83202EF6D60C9@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-11-23 17:09                 ` Ulrich Weigand
     [not found]                   ` <CH2PR15MB3544AB7CA50F834387522DB0D60C9@CH2PR15MB3544.namprd15.prod.outlook.com>
     [not found]                     ` <CH2PR15MB354465C64C4B32DA395C110AD6129@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-11-30 14:57                       ` Ulrich Weigand
     [not found]                         ` <CH2PR15MB354486F155F5CC97501D056DD6179@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-12-05 18:33                           ` Ulrich Weigand
     [not found]                             ` <CH2PR15MB35447EE88C64F7F36A0C61F5D61D9@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-12-08 16:29                               ` Ulrich Weigand
     [not found]                                 ` <CH2PR15MB3544B1D8ED7EA9E56FEC79E5D6E19@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-12-15 15:53                                   ` Ulrich Weigand
     [not found]                                     ` <CH2PR15MB35449A5A2BA7153A02CE913BD6E59@CH2PR15MB3544.namprd15.prod.outlook.com>
2022-12-22 12:50                                       ` Ulrich Weigand
     [not found]                                         ` <CH2PR15MB3544BD03B93F39BA8E9E5452D6EC9@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-01-09 14:04                                           ` Ulrich Weigand
     [not found]                                             ` <CH2PR15MB354417A03BCE77E3BA1C3A20D6FF9@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-01-11 13:31                                               ` Ulrich Weigand
     [not found]                                                 ` <BY5PR15MB3540261B391EA10F29AF5120D6C29@BY5PR15MB3540.namprd15.prod.outlook.com>
2023-01-20 14:44                                                   ` Ulrich Weigand
     [not found]                                                     ` <CH2PR15MB3544A44737D2C7BF3CDC9BAAD6CC9@CH2PR15MB3544.namprd15.prod.outlook.com>
2023-01-30 19:54                                                       ` Tom Tromey

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=8728e4f68ab1d57df73a0d7acc2aa1e9a8b065b7.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simark@simark.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).