From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uAapHyMJNWYblwQAWB0awg (envelope-from ) for ; Fri, 03 May 2024 11:56:19 -0400 Received: by simark.ca (Postfix, from userid 112) id 7CDFB1E0C1; Fri, 3 May 2024 11:56:19 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6753B1E092 for ; Fri, 3 May 2024 11:56:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1545E3845148 for ; Fri, 3 May 2024 15:56:17 +0000 (GMT) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by sourceware.org (Postfix) with ESMTPS id 648A838449C2 for ; Fri, 3 May 2024 15:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 648A838449C2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 648A838449C2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714751759; cv=none; b=vgrQCuFn/jDWRsLEb8wGN5clwBPMyx67mAdjz+vHe/vgnQ+isd5LO5U7M5vtJAhS2umAki2yeoFyeMVJ7aOdRcVUTSOc1SqwE/6k6oCa8MS+J6j/qIKX0/9nJxGsUJvcYbEZ0U97mZt2YaqbA4OQAuyLvleQPAONYdRznfT1IX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714751759; c=relaxed/simple; bh=A8/yLP+borH6QP1wJ+7acICVYaozH9IV4bn69N1EEH0=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=KV3hhGtpAZq2w1UbIyP6yh1V+U771hhygVddjkyO8cRPvbOZaIzwb1QdWseSNOG7r1wpFNSrf8w6uApFFeanbUb8uDwCleZ6rahwRws03GI9pKW6GmrW/yMIN8Ed8MBPgSpqUTQzbtqMhUBoesTsOMuqw93uubQt6OsXel2d9V0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-34da04e44a2so2593870f8f.1 for ; Fri, 03 May 2024 08:55:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714751756; x=1715356556; h=content-transfer-encoding:in-reply-to:content-language:from :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K2LD5z3xsF08uGCi6b0wcKAR8GjbkUMiJZn+zBvB8Mo=; b=Crpdz8GnxkSGPPIU368cMtGB0Su0H+SHDTayieZZO6UImxFdSd8atJvN1N+epAUGO0 rkYhunm8r1qQSM4a+jA5xsF9yVBF8ZZi+kD+XGzstjl835ACM1y6un4oOf3mgrU1O2R0 D5vVV+oDpLXI90QjrBsECmNPhJyN4hi6QvgBYOwXi1byYVUaPf0/qnuDT8kqEM4sPNUh JUzqBrFruS4+XrLMTQjwtYURgTpG8Rz9icbfeYHoPj2fSKZd8E0DvtAxEsaGRZfKaLRI j+UmOnPKpc3EBsur1XC6lTGkj6vzhMwWjscswdTaERsSFILVmBaM1BZowIB6snh/DiMZ Ou6Q== X-Forwarded-Encrypted: i=1; AJvYcCXFkXvFjLG7YgggO+9OIycKxOfmFWduL/H6UONGNXYzRjfNHFesCVjpqeneEXqriVKPuQkKh27hyOXDFaUxUdsSD3RxxfJ01VnSVA== X-Gm-Message-State: AOJu0YyqJmnMet2ieduBPZNkpYJrP1dUyO5wBx/hlMajmwf75Hfkd9hm Z+sVtCaWknIH/V/Ubvq9KHRMELcexkZuOTlaUce1geRPFuTZgay8E8PZSg== X-Google-Smtp-Source: AGHT+IGlGRM2BqMnUZbvxV2lI3ZfNa0lpVh36UkyIkNdkEG0Ha0Oy39L31fTVmCHuyEOoDfE2/oG6w== X-Received: by 2002:adf:f04d:0:b0:33d:fb3:9021 with SMTP id t13-20020adff04d000000b0033d0fb39021mr2217839wro.54.1714751755870; Fri, 03 May 2024 08:55:55 -0700 (PDT) Received: from ?IPV6:2001:8a0:f93d:b900:7cde:c2ed:ba96:7cc7? ([2001:8a0:f93d:b900:7cde:c2ed:ba96:7cc7]) by smtp.gmail.com with ESMTPSA id s16-20020adfea90000000b0034de587ffebsm4083438wrm.4.2024.05.03.08.55.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 May 2024 08:55:55 -0700 (PDT) Message-ID: Date: Fri, 3 May 2024 16:55:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] Make thread_db_target::pid_to_str checkpoint-aware To: Kevin Buettner , gdb-patches@sourceware.org References: <20240414195812.151224-1-kevinb@redhat.com> <20240414195812.151224-4-kevinb@redhat.com> From: Pedro Alves Content-Language: en-US In-Reply-To: <20240414195812.151224-4-kevinb@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 2024-04-14 20:44, Kevin Buettner wrote: > This commit prevents thread_db_target::pid_to_str from considering > a checkpoint as a thread. The reason for doing this is that pids > associated with checkpoints can never be a thread due to the fact > that checkpoints (which are implemented by forking a process) can > only work with single-threaded processes. Well, that isn't strictly true, as a checkpoint can spawn a new thread/clone. Or even exec... But let's not go there... > > Without this commit, many of the "info checkpoints" commands > in gdb.multi/checkpoint-multi.exp will incorrectly show some > of the checkpoints as threads. E.g... > > * 1.0 A Thread 0x7ffff7cd3740 (LWP 128534) at 0x401199, file hello.c, line 51 > 1.2 process 128546 at 0x401199, file hello.c, line 51 > 1.3 process 128547 at 0x401199, file hello.c, line 51 > 2.1 process 128538 at 0x401258, file goodbye.c, line 62 > 2.2 A Thread 0x7ffff7cd3740 (LWP 128542) at 0x401258, file goodbye.c, line 62 > 3.0 A Thread 0x7ffff7cd3740 (LWP 128543) at 0x40115c, file hangout.c, line 31 > 3.2 process 128545 at 0x40115c, file hangout.c, line 31 > > With this commit in place, the output looks like this instead: > > * 1.0 A process 129961 at 0x401199, file hello.c, line 51 > 1.2 process 129974 at 0x401199, file hello.c, line 51 > 1.3 process 129975 at 0x401199, file hello.c, line 51 > 2.1 process 129965 at 0x401258, file goodbye.c, line 62 > 2.2 A process 129969 at 0x401258, file goodbye.c, line 62 > 3.0 A process 129970 at 0x40115c, file hangout.c, line 31 > 3.2 process 129972 at 0x40115c, file hangout.c, line 31 > > (For brevity, I've removed the directory elements in each of the paths > above.) > > The testcase, gdb.multi/checkpoint-multi.exp, has been updated to > reflect the fact that only "process" should now appear in output > from "info checkpoints". > --- > gdb/linux-thread-db.c | 4 +++- > gdb/testsuite/gdb.multi/checkpoint-multi.exp | 2 +- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c > index 65bf4a79fdf..488a7086acf 100644 > --- a/gdb/linux-thread-db.c > +++ b/gdb/linux-thread-db.c > @@ -48,6 +48,7 @@ > #include "gdbsupport/pathstuff.h" > #include "valprint.h" > #include "cli/cli-style.h" > +#include "linux-fork.h" > > /* GNU/Linux libthread_db support. > > @@ -1657,7 +1658,8 @@ thread_db_target::pid_to_str (ptid_t ptid) > { > thread_info *thread_info = current_inferior ()->find_thread (ptid); > > - if (thread_info != NULL && thread_info->priv != NULL) > + if (thread_info != NULL && thread_info->priv != NULL > + && !forks_exist_p (current_inferior ())) > { > thread_db_thread_info *priv = get_thread_db_thread_info (thread_info); > I think that it's better to change linux-fork.c, avoid special casing checkpoints if we can. If linux-fork.c wants to print a process, then it should pass down a process ptid. Like: diff --git c/gdb/linux-fork.c w/gdb/linux-fork.c index e35e438cabc..9003b43dc82 100644 --- c/gdb/linux-fork.c +++ w/gdb/linux-fork.c @@ -807,7 +807,8 @@ info_checkpoints_command (const char *arg, int from_tty) else gdb_printf (" "); - gdb_printf ("%s", target_pid_to_str (fi.ptid).c_str ()); + ptid_t pid_ptid (fi.ptid.pid ()); + gdb_printf ("%s", target_pid_to_str (pid_ptid).c_str ()); gdb_printf (_(" at ")); ULONGEST pc