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: Thu, 2 Feb 2023 17:43:25 +0000	[thread overview]
Message-ID: <09f2433177505899c9bd31347af9b43118e4f890.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB35449137854F561F1EA7DE04D6D69@CH2PR15MB3544.namprd15.prod.outlook.com>

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

>>Is there an existing gdb test case that exercises this code?
>>If not then it seems like a new test is warranted. 
>
>This I am not aware of at least when I tried finding. 

I think the question here is simply whether, if you run the
test suite both without and with your patch, are any of the
FAILs fixed with the patch?   If not, it would be good to
create a new test that fails without the patch and succeeds
with it, and add that to the test suite.


I think we're getting pretty close now, but I do still have
some additional comments on the latest patch:

> /* Return whether to treat PID as a debuggable thread id.  */
> 
>-#define PD_TID(ptid)	(pd_active && ptid.tid () != 0)
>+#define PD_TID(ptid, data)	(data->pd_active && ptid.tid () != 0)

I'm not sure why the pd_active test is needed here
at all - if ptid.tid () != 0, thread debugging *must*
be active, otherwise you'd never have installed a ptid
with the tid field set, right?

If that check can indeed be omitted, that would simplify
the patch a bit since you wouldn't need to provide the
"data" struct in quite as many places.

>/* Address of the function that libpthread will call when libpthdebug
>   is ready to be initialized.  */
>
> static CORE_ADDR pd_brk_addr;

I believe this needs to go into the aix_thread_variables struct;
the address might be different if the pthread library is loaded
at different addresses into different inferiors.

> /* Whether the current architecture is 64-bit.  
>    Only valid when pd_able is true.  */
>
>static int arch64;

Likewise - some inferiors may be 64-bit and others 32-bit.

In general, *any* static variable in this file is suspect.


>+/* Callback for counting GDB threads for process pid.  */
> 
> static int
>-giter_count (struct thread_info *thread, void *countp)
>+giter_count (pid_t pid)

This only was a callback because it was called via
iterate_over_threads.  Now that you're using the
all_threads C++ iterator, I think both of those
routines should just be inlined into its caller.


>@@ -565,6 +565,7 @@ solib_aix_bfd_open (const char *pathname)
>   const char *sep;
>   int filename_len;
>   int found_file;
>+  std::string string_path = pathname;
> 
>   if (pathname[path_len - 1] != ')')
>     return solib_bfd_open (pathname);
>@@ -618,6 +619,15 @@ solib_aix_bfd_open (const char *pathname)
>       if (member_name == bfd_get_filename (object_bfd.get ()))
> 	break;
> 
>+      std::string s = bfd_get_filename (object_bfd.get ());
>+
>+      /* For every inferior after first int bfd system we 
>+	 will have the pathname instead of the member name
>+	 registered. Hence the below condition exists.  */
>+
>+      if (string_path.compare (s) == 0)
>+	return object_bfd;

That's still not quite right, as the pathname component
might have been changed here:
  /* Calling solib_find makes certain that sysroot path is set properly
     if program has a dependency on .a archive and sysroot is set via
     set sysroot command.  */
  gdb::unique_xmalloc_ptr<char> found_pathname
    = solib_find (filename.c_str (), &found_file);

I think a simple but correct way to check whether the BFD filename
already contains a member name is to check for the presence of an
opening parenthesis e.g. via:
    strrchr (bfd_get_filename (...), '(');


Bye,
Ulrich


  reply	other threads:[~2023-02-02 17:43 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  6:47 Aditya Kamath1
2022-10-28  9:49 ` Ulrich Weigand
2022-11-08 12:00   ` Aditya Kamath1
2022-11-08 12:17     ` Ulrich Weigand
2022-11-13 18:15       ` Aditya Kamath1
2022-11-15 18:16         ` Ulrich Weigand
2022-11-21  8:27           ` Aditya Kamath1
2022-11-23 14:15             ` Ulrich Weigand
2022-11-23 16:03               ` Aditya Kamath1
2022-11-23 17:09                 ` Ulrich Weigand
2022-11-23 18:45                   ` Aditya Kamath1
2022-11-29  8:18                     ` Aditya Kamath1
2022-11-30 14:57                       ` Ulrich Weigand
2022-12-02  7:50                         ` Aditya Kamath1
2022-12-05 18:33                           ` Ulrich Weigand
2022-12-08 10:28                             ` Aditya Kamath1
2022-12-08 10:46                               ` Aditya Kamath1
2022-12-08 16:29                               ` Ulrich Weigand
2022-12-15 12:58                                 ` Aditya Kamath1
2022-12-15 15:53                                   ` Ulrich Weigand
2022-12-19  6:30                                     ` Aditya Kamath1
2022-12-22 12:50                                       ` Ulrich Weigand
2022-12-26 13:18                                         ` Aditya Kamath1
2023-01-09 14:04                                           ` Ulrich Weigand
2023-01-10 12:23                                             ` Aditya Kamath1
2023-01-11 13:31                                               ` Ulrich Weigand
2023-01-13 14:06                                                 ` Aditya Kamath1
2023-01-20 14:44                                                   ` Ulrich Weigand
2023-01-27 14:40                                                     ` Aditya Kamath1
2023-01-30 19:54                                                       ` Tom Tromey
2023-02-02  6:24                                                       ` Aditya Kamath1
2023-02-02  6:35                                                         ` Aditya Kamath1
2023-02-02 17:43                                                           ` Ulrich Weigand [this message]
2023-02-03 11:10                                                             ` Aditya Kamath1
2023-02-06 19:07                                                               ` Ulrich Weigand
2023-02-07 11:57                                                                 ` Aditya Kamath1
2023-02-08 18:44                                                                   ` Ulrich Weigand
2023-02-10 16:33                                                                     ` Aditya Kamath1
2023-02-10 16:46                                                                       ` Aditya Kamath1
2023-02-13 19:01                                                                       ` Ulrich Weigand
2023-02-14 14:13                                                                         ` Aditya Kamath1
2023-02-16 19:46                                                                           ` Ulrich Weigand
2023-02-17 11:26                                                                             ` Aditya Kamath1
2023-02-17 12:04                                                                               ` Ulrich Weigand
2023-02-17 13:22                                                                                 ` Aditya Kamath1
2023-02-17 14:18                                                                                   ` Ulrich Weigand
2023-02-17 15:15                                                                                     ` Aditya Kamath1
2023-02-17 19:14                                                                                       ` Ulrich Weigand
2022-11-08 12:00 Aditya Kamath1

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=09f2433177505899c9bd31347af9b43118e4f890.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).