From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 531D43858D1E for ; Wed, 14 Jun 2023 13:35:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 531D43858D1E 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-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b1a7e31dcaso9731891fa.2 for ; Wed, 14 Jun 2023 06:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686749731; x=1689341731; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=42Tp6zXgyq0gacD7cPbJDhxh+9yG5thHblEBHvm3kHI=; b=VOSEdUk5dUgXLkFEeGqCG62vnUEJiBihLwCd4TBTzymRA+ZSc8/VIEJ13/Lw/sbEoW d0nBZxOEXCbu/SBG5umaRIhuAhXispqtBO59lzbq5O32UNoUAcZcofaYIcAoMPcJwzed zGs9ycBrau1sO4dW9TfRh21sMJcmyV48DW2dMSwSjNkRhX30zvrVd16GaNkmK/MvxIz8 XpRYLCXP16bAHdGtz4s97cFe+avuwPP0n94U/1LthHbOMwJLYxTFITuIm3mHA61kHwas ORaZUZqYV1spfeGKiLTOHda0bRacExV9+Ao5LvVwvIbZQVOMs1PQh7bJWU/VMkAnCc+J YRhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686749731; x=1689341731; 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=42Tp6zXgyq0gacD7cPbJDhxh+9yG5thHblEBHvm3kHI=; b=beef8dscvKq7gTthT4asC3p9oXSY2tbTxiUt1TUr66lBl9CknPa4SG7r+2ih97vGn9 6LCUX6Hn8nVakGAEOXUR2NYa+aZc/IMDVvsQ+SWY1K62HgP7jZUKpB83NS3kHM3RZExg jvQsSDjA+76/uY81gmOWzV5HcjyJH8mBbykCyM0m09lTyEfpLW0ZMRWiyuGa66t+gHas xxndruFUW4MPwAK8PHV1Nlw8YXhzkO4has7NMCW8KL1dGCAHWOeO7uzrD7mbOcgkaX5R lguPeTxRlHzP6kaXtEoYFn7FRyD05OG0H3ORdRikWO5FAvYQcNRxq2nXL0UGM49h22hR fSEg== X-Gm-Message-State: AC+VfDw71CoVeuKZYsmxtUVQbzgBIPbO2mC8fvhFdhC0x8eW98w+dqcC oh0QVezx4DZdtOEFbfdbtAnGXbuSBVHsf0RB X-Google-Smtp-Source: ACHHUZ6WP2hrOKHLsAdUJf8kh/Qt9eHsWu8sEJSC6VXCvbnjnBSFWZ+Sfy7amqbbry8PsGO2k2e4Vw== X-Received: by 2002:a2e:a0d5:0:b0:2b1:c613:4b9d with SMTP id f21-20020a2ea0d5000000b002b1c6134b9dmr6821699ljm.4.1686749730931; Wed, 14 Jun 2023 06:35:30 -0700 (PDT) Received: from fedora.. (78-73-77-63-no2450.tbcn.telia.com. [78.73.77.63]) by smtp.gmail.com with ESMTPSA id e3-20020a2e8183000000b002adaacdb900sm2584838ljg.42.2023.06.14.06.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 06:35:30 -0700 (PDT) From: Simon Farre To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v2] gdb/dap - Getting thread names Date: Wed, 14 Jun 2023 15:35:18 +0200 Message-Id: <20230614133518.46605-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.5 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: Renamed thread_name according to convention (_ first) 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..253756022df 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