From patchwork Sun Apr 14 03:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 88463 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 8A3B33846410 for ; Sun, 14 Apr 2024 03:28:25 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 241533849AF9 for ; Sun, 14 Apr 2024 03:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 241533849AF9 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 241533849AF9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713065279; cv=none; b=KUnzW1QoSUCueUI9ZxRKBqRrNdd5hGM4ualt+PALhi4SK4FZPDLNNd2SEplzVVkk9OA+rdzW2FkJQdBXQa8Vb6pTyWOhCO7tMfr0c97Paw/DeJZSHePCwTGA5RBz52s4Nw6UQtlm0+lrZaj6pbQZGZ/K4qXLGsbchtEeGL26+5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713065279; c=relaxed/simple; bh=dIZy7fC77OvDPjsS6hIfmZz8Ui27nby7wfmSBzSc1eg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Yzkzc9Wb2MizJ54DntYmx1LfG0vZcaDg4crsQEb9xu+CBfkJkpLUHdotKgquXs41NI8A4n+xZzSUqgpiMxATLmAtbLw1KaK9uNMB+JHiLDZfajjfr0VRZ5pLS5KmsaeDy/mCRxjNc/EcP1cz5yU10k6CRn9AjwX8P+X2YZsJTp8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713065276; 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=cd6bx5KQgPRJCogqST6kR9hquj04dSWo8TdHdOW9PNs=; b=cwJxclNIbZzlzLJ9Dji+KbVOinici/kRu5YRnocMLE8wU2hrnHe9tzU2Df3S5Jc8pMJO/i zM+h/69pJJa0MvlHjQ/xY6VBpI67ov4X0nxkNXQf4xBLVJkzH0HoRrOL8GNpmvAslfj60P iJyMKlIIBdGmXyXQSflFdFAx7SOkNik= 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-615-2xnZs8WYNb6XCeYB_iv0dg-1; Sat, 13 Apr 2024 23:27:55 -0400 X-MC-Unique: 2xnZs8WYNb6XCeYB_iv0dg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 DF9EF80A1B9; Sun, 14 Apr 2024 03:27:54 +0000 (UTC) Received: from f39-1.lan (unknown [10.22.16.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FA0FC13FA1; Sun, 14 Apr 2024 03:27:54 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Pedro Alves , Kevin Buettner Subject: [PATCH v2 2/2] Make thread_db_target::pid_to_str checkpoint-aware Date: Sat, 13 Apr 2024 20:24:27 -0700 Message-ID: <20240414032731.130266-3-kevinb@redhat.com> In-Reply-To: <20240414032731.130266-1-kevinb@redhat.com> References: <20240414032731.130266-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 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 a880d31d326..755c8e9e0e1 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"