From patchwork Sun Apr 14 19:44:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 88469 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B63F3846420 for ; Sun, 14 Apr 2024 19:59:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A29783846405 for ; Sun, 14 Apr 2024 19:58:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A29783846405 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A29783846405 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713124712; cv=none; b=jJLN7rhHzw3XoEIrq4EWinsxvigCsCZ2Y7b5OGM9kHl1yiAKcI8jI52VudLLE7MmHqCIxXA6BjzKoAhWxCOcmQQE+v4Ru35v0Nr9GymrGWxhWa7FVG8x9D4frhoKNz/hc7udBa5FLbIZa2AiOwp8/mlG8FeWdqUm7I3xyBuahYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713124712; c=relaxed/simple; bh=aixwe8YAUcvNWKyQJSwum3LuqxqLPaB9A67lmWychsQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QfRHEFQiG2HIOHBK+4aNCYW0JyGwICoLlHgH18rZ83tnlWO8tdKFu7IhqSN3EZ16s1uIdaz53rMrKRQXdNw/XiQh2lZpt8scDraqtnej11QObLJ58OSMorCkJRr2TcsiTqMnRal8O87pJv/2YXXFve8DouTT9wjwLLrCcAjUQqU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713124708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uWnMFFF2PSLewsi0c13aj2W/Ys/UgsEbbmBP4iZjtaw=; b=A/cgFpBvUkpSGS21tPX1oUezh0ksPbRBSH/+8eD/uIHMm86syuhjt/okiLDDm/Izi5n8OY zDfw8F6Bc7KBsKs1ViZpGbZcgWqShF9CjPerxWi19eIMh9FaZGjBuSCc9bwP5M1piJwpEX NHD+pGPTWCtF1zO95xRzHgHI+nInRVo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-u6Dwm_emMamWQQWf1hH9Tg-1; Sun, 14 Apr 2024 15:58:25 -0400 X-MC-Unique: u6Dwm_emMamWQQWf1hH9Tg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C59D7801FAF; Sun, 14 Apr 2024 19:58:24 +0000 (UTC) Received: from f39-1.lan (unknown [10.22.16.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59B1A1BDAA; Sun, 14 Apr 2024 19:58:24 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Pedro Alves , Kevin Buettner Subject: [PATCH v3 3/3] Make thread_db_target::pid_to_str checkpoint-aware Date: Sun, 14 Apr 2024 12:44:44 -0700 Message-ID: <20240414195812.151224-4-kevinb@redhat.com> In-Reply-To: <20240414195812.151224-1-kevinb@redhat.com> References: <20240414195812.151224-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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+patchwork=sourceware.org@sourceware.org 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. 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); diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp index 929b09b6876..491d070d902 100644 --- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp +++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp @@ -170,7 +170,7 @@ with_test_prefix "check continue to exit on non-checkpointed inferior" { gdb_test "continue" "Inferior 1.*? exited normally.*" } -set proc_re "(?:process $::decimal|Thread $::hex \\(LWP $::decimal\\))" +set proc_re "(?:process $::decimal)" set main_proc "\\(main process\\)" set hello_c "hello\\.c" set goodbye_c "goodbye\\.c"