From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 54D9F3858D32 for ; Tue, 13 Jun 2023 07:10:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54D9F3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f629ccb8ebso6219013e87.1 for ; Tue, 13 Jun 2023 00:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686640244; x=1689232244; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hxRbGCJU3YV06n8dl6dGVdaGlk2Iz3qu+U1gbqppUGQ=; b=TsWnkwkHOK3KLDJVB21S6lOsVqBF+rK1D3BU1i3HA41YPy4UOOscXuVKoP81m0zOU4 o5SQlF7E0Hw8+h0JYtpJMJXQY/BTXcmNUYGcEgSoUGk2vybfdlL929wGdU05JTdwu15D Xqb0fVikpNB/YxJKO8U2Mbp+Ct5UAcmTdLmKU0wI5DWoVYMQowa6bQHfwNJOjrxfXDoR /wx/2Nf/odb+tNOFGoiq0ypDRK9RUVhypG8cn8D0OgBaMK8QqEA+n3aPt37fappBEnZl Vvq9MudLXS86Tkv62uswE50D++tVgAs05dMynqemyH1xHlsfSlz8jLaV822d0W6KG+Km TrUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686640244; x=1689232244; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hxRbGCJU3YV06n8dl6dGVdaGlk2Iz3qu+U1gbqppUGQ=; b=EfyXwQdxWTi6HVQCrT+hPs4tMKSzZNM5MeWWOssg2N6DlghxlkryQF/buNpwIT8Rjn 3Bltn8Tj/R/Eh/qcHzl7/wypAeTBWMtTnu29kf+saiMI+qUkagVlkQrTAMXy7EcXK6Kk ChjKWsO2LFcDueXBvuHVk39MEyNDGu5OtsvunWlqiqLlqFP3jZvHlEoUtxyWauvmqjVV hS2ZYZ2mIaLArxjU7iaQD79rJQHTpwKXDncvjWfvtTO1NMFinzJ09OwL/rwcvEKVtE6b GGz8fQIKeBArsgs3Kq7sPRsJxeWpRyGOr50tU63AsgUcWBr7aYs6AMMJxu5USG7pCR2N MxZg== X-Gm-Message-State: AC+VfDzi6s+Ga9RvC9kkWgccfR62q9wyrzKos15/ydoutXVpF9Ebx042 ZQT6CKL6rCXgGigJt1wpEh3TJLWpnVXE8Q== X-Google-Smtp-Source: ACHHUZ4/KIqc+De+2psYhme3hKuWuehmiM6JVj2PNaubdD4QBvcPdl5Vo1teclqqHXX2meotmMiMxw== X-Received: by 2002:a05:6512:457:b0:4dd:9fd8:3a36 with SMTP id y23-20020a056512045700b004dd9fd83a36mr4837618lfk.1.1686640244083; Tue, 13 Jun 2023 00:10:44 -0700 (PDT) Received: from fedora.. (78-73-77-63-no2450.tbcn.telia.com. [78.73.77.63]) by smtp.gmail.com with ESMTPSA id 7-20020ac24847000000b004f60be0c685sm1674029lfy.123.2023.06.13.00.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:10:43 -0700 (PDT) From: Simon Farre To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v1] gdb/dap - Getting thread names Date: Tue, 13 Jun 2023 09:10:23 +0200 Message-Id: <20230613071023.7258-1-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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