public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org,
	Joel Brobecker <brobecker@adacore.com>,
	Pedro Alves <palves@redhat.com>
Subject: Re: GDB 10.2 Release -- 2021-04-11 update
Date: Mon, 12 Apr 2021 21:18:55 -0700	[thread overview]
Message-ID: <20210412211855.771ff58a@f33-m1.lan> (raw)
In-Reply-To: <ff31653f-bf6a-2ea9-330e-2fe5f6f0b8e7@polymtl.ca>

On Mon, 12 Apr 2021 10:04:44 -0400
Simon Marchi <simon.marchi@polymtl.ca> wrote:

> >>     This looks like a difficult issue to solve, with both GDB *and*
> >>     GDBserver needing a fix, and no clear indication that I could see
> >>     that they would be getting a similar fix. With that in mind,
> >>     I'm wondering if we shouldn't give ourselves a deadline after which
> >>     we simply accept this as a known limitation of the 10.2 release,
> >>     and work on fixing it for the GDB 11 release instead.  
> > 
> > So... I have the beginnings of a patch for gdbserver.  I'm tracking
> > down some regressions though, so don't have anything I can share
> > quite yet.  
> 
> I didn't have time to look at GDBserver yet.  Could you share your patch
> (it could be just a link to an external git repo) even if it's not ready
> yet?

My current patch is below.  It's small, so I decided to post it in
this reply.

It no longer works for the case which originally got me interested in
this problem (which is gdb.threads/fork-plus-threads.exp w/
--target_board=native-extended-gdbserver), but it also no longer
causes regressions in gdb.threads/tls.exp.  Things are getting further
though - i.e. _rtld_global is now being found.

Things are going astray further along, but I'm not quite sure where
yet.  I'm still working on it...

diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index 055a0fa970f..9403b419710 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -44,10 +44,14 @@ struct thread_db
   /* Connection to the libthread_db library.  */
   td_thragent_t *thread_agent;
 
-  /* If this flag has been set, we've already asked GDB for all
-     symbols we might need; assume symbol cache misses are
-     failures.  */
-  int all_symbols_looked_up;
+  /* This flag is set after asking GDB for symbols that we need.  It
+     does not, however, indicate that all necessary symbols have found
+     as these may be split among several shared objects.  */
+  bool initialized;
+
+  /* Flag which indicates that it's okay to ask GDB for symbols via
+     a qSymbol reply.  */
+  bool qsymbol_reply_okay;
 
 #ifndef USE_LIBTHREAD_DB_DIRECTLY
   /* Handle of the libthread_db from dlopen.  */
@@ -359,19 +363,20 @@ thread_db_look_up_symbols (void)
   const char **sym_list;
   CORE_ADDR unused;
 
+  thread_db->qsymbol_reply_okay = true;
+
   for (sym_list = thread_db->td_symbol_list_p (); *sym_list; sym_list++)
     look_up_one_symbol (*sym_list, &unused, 1);
 
-  /* We're not interested in any other libraries loaded after this
-     point, only in symbols in libpthread.so.  */
-  thread_db->all_symbols_looked_up = 1;
+  thread_db->qsymbol_reply_okay = false;
+  thread_db->initialized = true;
 }
 
 int
 thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp)
 {
   struct thread_db *thread_db = current_process ()->priv->thread_db;
-  int may_ask_gdb = !thread_db->all_symbols_looked_up;
+  int may_ask_gdb = thread_db->qsymbol_reply_okay || !thread_db->initialized;
 
   /* If we've passed the call to thread_db_look_up_symbols, then
      anything not in the cache must not exist; we're not interested
@@ -396,7 +401,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
   thread_db = proc->priv->thread_db;
 
   /* If the thread layer is not (yet) initialized, fail.  */
-  if (thread_db == NULL || !thread_db->all_symbols_looked_up)
+  if (thread_db == NULL || !thread_db->initialized)
     return TD_ERR;
 
   /* If td_thr_tls_get_addr is missing rather do not expect td_thr_tlsbase
@@ -888,7 +893,7 @@ thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid)
 
   /* If the thread layer isn't initialized, return.  It may just
      be that the program uses clone, but does not use libthread_db.  */
-  if (thread_db == NULL || !thread_db->all_symbols_looked_up)
+  if (thread_db == NULL || !thread_db->initialized)
     return;
 
   /* find_one_thread calls into libthread_db which accesses memory via


  reply	other threads:[~2021-04-13  4:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11  5:39 Joel Brobecker
2021-04-12  6:00 ` Kevin Buettner
2021-04-12 14:04   ` Simon Marchi
2021-04-13  4:18     ` Kevin Buettner [this message]
2021-04-14  1:45       ` Simon Marchi
2021-04-15  3:46         ` Kevin Buettner

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=20210412211855.771ff58a@f33-m1.lan \
    --to=kevinb@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=simon.marchi@polymtl.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).