public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Farre <simon.farre.cx@gmail.com>
To: gdb-patches@sourceware.org
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: [PATCH v1] gdb/dap - Getting thread names
Date: Tue, 13 Jun 2023 09:10:23 +0200	[thread overview]
Message-ID: <20230613071023.7258-1-simon.farre.cx@gmail.com> (raw)

When testing firefox tests, it is apparent that
_get_threads returns threads with name field = None.

I had initially thought that this was due to Firefox setting the names
using /proc/pid/task/tid/comm, by writing directly to the proc fs the
names, but apparently GDB seems to catch this, because I re-wrote
the basic-dap.exp/c to do this specifically and it saw the changes.

So I couldn't determine right now, what operation of name change that
GDB does not pick up, but with this patch, GDB will pick up the thread
names for an applications that set the name of a thread in ways that
aren't obvious.
---
 gdb/python/lib/gdb/dap/threads.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/python/lib/gdb/dap/threads.py b/gdb/python/lib/gdb/dap/threads.py
index c3b42ee4991..b61fb94dce8 100644
--- a/gdb/python/lib/gdb/dap/threads.py
+++ b/gdb/python/lib/gdb/dap/threads.py
@@ -18,6 +18,12 @@ import gdb
 from .server import request
 from .startup import send_gdb_with_response, in_gdb_thread
 
+def thread_name(thr):
+    if thr.name is not None:
+        return thr.name
+    if thr.details is not None:
+        return thr.details
+    return None
 
 # A helper function to construct the list of threads.
 @in_gdb_thread
@@ -27,7 +33,7 @@ def _get_threads():
         one_result = {
             "id": thr.global_num,
         }
-        name = thr.name
+        name = thread_name(thr)
         if name is not None:
             one_result["name"] = name
         result.append(one_result)
-- 
2.40.1


             reply	other threads:[~2023-06-13  7:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  7:10 Simon Farre [this message]
2023-06-13 12:56 ` 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=20230613071023.7258-1-simon.farre.cx@gmail.com \
    --to=simon.farre.cx@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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).