From patchwork Wed Feb 8 15:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 64487 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 AE816385B52E for ; Wed, 8 Feb 2023 15:24:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE816385B52E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675869842; bh=QVGPM7c7kDUIEBxvjBRYm5lR90tv6mFdHD10HmQyOJ4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=IrrMHFDuxXqTyvn8xImAZcgdyUxvzPpfmsJ8Z+I+dKQc0JaFN6xU6pHj+k1ELKkyb DcvEcNm8HbCbCw653RxXg/3dswPSZSqPKbbS1Z+xDV6I4nQTIpz07z1rpPwdv5ta0O nVCxz8jYc5fEyBMrPgmFesQBOIv7X0N/HykIiGig= 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 42FEF3858D39 for ; Wed, 8 Feb 2023 15:23:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42FEF3858D39 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-587-WZiLMzgIPUOv2mJEDEF_vA-1; Wed, 08 Feb 2023 10:23:36 -0500 X-MC-Unique: WZiLMzgIPUOv2mJEDEF_vA-1 Received: by mail-qk1-f198.google.com with SMTP id g6-20020ae9e106000000b00720f9e6e3e2so12449820qkm.13 for ; Wed, 08 Feb 2023 07:23:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QVGPM7c7kDUIEBxvjBRYm5lR90tv6mFdHD10HmQyOJ4=; b=p6uOgOIeO119NGypgMtvmGhQQCj+PORK8PnYCJozwDMXHwme61w7xeXkNN1gGkh5mr Plfrxtt5HyxHCQ7Q5w+GkbpqKu56KIJOIcXzGMsvR10ciHrLz9p8+tsW9df68ZEDI3Zi 9RljysnwMhlhz9NtI8iM1BHkqu5OkS0Iw+eKZVN1nm2trZaq8vUxrHXKCxwHbgLGGzax U7DaTGsW2/r/fealfshGhiJYgc0DivboFvc/VTvAPmlGRh0c16JoxNGbwLHx88bqRiWy jR0HKxcqRhKM9DLDM9vejaoSC2LFwrMxItdKa5JGWeAONdlzdie0g6IuscrCV9kAHT8Z lh1g== X-Gm-Message-State: AO0yUKVsYmm0RrRtWvqZsv+Io8HQ8lUYyWRYvm/SvZOce6yE+RPPFlKG auGQsYTGCKHKawiVdDtc8nVwvejkrMgpK+voHpvTaPwAmei8gPKYk67x2W/r5VyHKr51W2jnNAE /oT84UN90Ric/iyKzu1GhakzcsP9/dTR7xVc/v7LFI+2rrFJsCkjpt3d5lPGpZ4AgYBluyXRNsO d5Vfc= X-Received: by 2002:a05:6214:1c09:b0:56b:377e:88a7 with SMTP id u9-20020a0562141c0900b0056b377e88a7mr14985152qvc.21.1675869815982; Wed, 08 Feb 2023 07:23:35 -0800 (PST) X-Google-Smtp-Source: AK7set9oeYUS02O1xrWU0ubEQWIzLkoAsCYn3GWj24cG2SJFyAlyVCofMuQvNzqU671FU1Lw9JE+sQ== X-Received: by 2002:a05:6214:1c09:b0:56b:377e:88a7 with SMTP id u9-20020a0562141c0900b0056b377e88a7mr14985110qvc.21.1675869815647; Wed, 08 Feb 2023 07:23:35 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id u20-20020ae9c014000000b00720750365b9sm11627921qkk.129.2023.02.08.07.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 07:23:35 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/3] gdb: don't print global thread-id to CLI in describe_other_breakpoints Date: Wed, 8 Feb 2023 15:23:28 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 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, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that describe_other_breakpoints was printing the global thread-id to the CLI. For CLI output we should be printing the inferior local thread-id (e.g. "2.1"). This can be seen in the following GDB session: (gdb) info threads Id Target Id Frame 1.1 Thread 4065742.4065742 "bp-thread-speci" main () at /tmp/bp-thread-specific.c:27 * 2.1 Thread 4065743.4065743 "bp-thread-speci" main () at /tmp/bp-thread-specific.c:27 (gdb) break foo thread 2.1 Breakpoint 3 at 0x40110a: foo. (2 locations) (gdb) break foo thread 1.1 Note: breakpoint 3 (thread 2) also set at pc 0x40110a. Note: breakpoint 3 (thread 2) also set at pc 0x40110a. Breakpoint 4 at 0x40110a: foo. (2 locations) Notice that GDB says: Note: breakpoint 3 (thread 2) also set at pc 0x40110a. The 'thread 2' in here is using the global thread-id, we should instead say 'thread 2.1' which corresponds to how the user specified the breakpoint. This commit fixes this issue and adds a test. --- gdb/breakpoint.c | 5 +- gdb/testsuite/gdb.multi/bp-thread-specific.c | 28 +++++++++ .../gdb.multi/bp-thread-specific.exp | 61 +++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.multi/bp-thread-specific.c create mode 100644 gdb/testsuite/gdb.multi/bp-thread-specific.exp diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index adf38e7d722..701555a060e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7045,7 +7045,10 @@ describe_other_breakpoints (struct gdbarch *gdbarch, if (b->thread == -1 && thread != -1) gdb_printf (" (all threads)"); else if (b->thread != -1) - gdb_printf (" (thread %d)", b->thread); + { + struct thread_info *thr = find_thread_global_id (b->thread); + gdb_printf (" (thread %s)", print_thread_id (thr)); + } gdb_printf ("%s%s ", ((b->enable_state == bp_disabled || b->enable_state == bp_call_disabled) diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.c b/gdb/testsuite/gdb.multi/bp-thread-specific.c new file mode 100644 index 00000000000..51b6492085f --- /dev/null +++ b/gdb/testsuite/gdb.multi/bp-thread-specific.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +foo () +{ + return 0; +} + +int +main () +{ + return foo (); +} diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.exp b/gdb/testsuite/gdb.multi/bp-thread-specific.exp new file mode 100644 index 00000000000..777fcf85ab0 --- /dev/null +++ b/gdb/testsuite/gdb.multi/bp-thread-specific.exp @@ -0,0 +1,61 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that GDB uses the correct thread-id when describing multiple +# thread specific breakpoints at the same location. + +# The plain remote target can't do multiple inferiors. +require !use_gdb_stub + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +gdb_test "add-inferior -exec ${binfile}" "Added inferior 2.*" "add inferior 2" +gdb_test "inferior 2" + +if {![runto_main]} { + return -1 +} + +gdb_test "info threads" \ + [multi_line \ + " Id\\s+Target Id\\s+Frame\\s*" \ + " 1\\.1\\s+\[^\r\n\]+" \ + "\\* 2\\.1\\s+\[^\r\n\]+"] \ + "check we have the expected threads" + +# Set the first breakpoint. Currently this is going to insert at two +# locations ('foo' in both inferiors) even though only one of those +# locations will ever trigger ('foo' in inferior 2). +gdb_test "break foo thread 2.1" \ + "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)" + +set bpnum [get_integer_valueof "\$bpnum" "INVALID"] + +# Now set another breakpoint that will be at the same location as the +# earlier breakpoint. Check that the thread-id used when describing +# the earlier breakpoints is correct. +gdb_test "break foo thread 1.1" \ + [multi_line \ + "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \ + "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \ + "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"] From patchwork Wed Feb 8 15:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 64488 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 A3F943857B93 for ; Wed, 8 Feb 2023 15:24:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3F943857B93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675869843; bh=EtlS7X/0eePjlHQJfe1etJkzGJo0sdsy3mLQNsp8/N4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=T3eiZTeKfJsPyJHTMBi2qwxqAXIopZwrWQZ4vVlUbZ90M5pFGbwYEkntyKCRhLG9W FwpmaGoNbc5KD4BdUl9Bj6sTFZGhh6aurWRNzFbDun7KkNC8mA8QLSJZT6ayymCfLn wZ+KNqvDCm2FuhURclD5Z7eLRYmjF2+5RcoVQcP0= 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 277913858C50 for ; Wed, 8 Feb 2023 15:23:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 277913858C50 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-354-P20oLH_vOhSYtR3UymFvrQ-1; Wed, 08 Feb 2023 10:23:38 -0500 X-MC-Unique: P20oLH_vOhSYtR3UymFvrQ-1 Received: by mail-qv1-f72.google.com with SMTP id k15-20020a0cd68f000000b00535261af1b1so9988240qvi.13 for ; Wed, 08 Feb 2023 07:23:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EtlS7X/0eePjlHQJfe1etJkzGJo0sdsy3mLQNsp8/N4=; b=X1gDk5mDB9Ev0xP3T9WdJZgSLY6Vk+K/4Jf2PWCzGVllAmxqvdKkmQKZ9LuZRalDph yePPPGJXPyL0IsRjrB0QZYLxvybyJiz6any/j6vPsRL5w3/KZe4lRwshsL+85db6sqSn V+vHozSxjzwdqpGqIq/7Lzb5a0kU8ZdBI/WWk8oZ6YBdSvNuluRGozglXT6N3Pko8myB mD4SyEH4a8zAjDfBGjfJXdeNK4pFPLr5sixTTCEus4HNNAzKZG/DmloG3rc6Tk0XBecH 5sP8g/2c7zV8hogUTKFa9tNrKpmzDZ2S3WAux2HiIN+ETi04NwEgJomEfAUVip6mwTCf uzZg== X-Gm-Message-State: AO0yUKVD9nQ1GxoTbPRXrfSOj6N9E8l3USt5MHc23BnotRhlO/qb8wrY 5bX3mCaS3dQ61MMeSxb9kqW4qBF9rtGY8HjHINRiww36S4tdnPcg/dcDU6ae0PQUMRddYNkJ9Ea o/PtmTDGjpIU7bZryqrbFieXWimHxSmRC1wzciIE1tp75cyWdDvvrrXfc5MXHFCVZdoVYvSXF7t eGfOQ= X-Received: by 2002:a05:622a:110c:b0:3ba:1acd:4da with SMTP id e12-20020a05622a110c00b003ba1acd04damr12537799qty.60.1675869817924; Wed, 08 Feb 2023 07:23:37 -0800 (PST) X-Google-Smtp-Source: AK7set+yHn05tAYX5NcE/WHZJjVurRQt/qksXL3xWO1DNkfvzlKiOUFcdEEmFH7ToU5Xch+JQv2zIA== X-Received: by 2002:a05:622a:110c:b0:3ba:1acd:4da with SMTP id e12-20020a05622a110c00b003ba1acd04damr12537766qty.60.1675869817597; Wed, 08 Feb 2023 07:23:37 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id g7-20020a05620a40c700b007208a81e11esm11337436qko.41.2023.02.08.07.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 07:23:37 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb: show task number in describe_other_breakpoints Date: Wed, 8 Feb 2023 15:23:29 +0000 Message-Id: <8716dc72011765a13c3eee0b60a262fbcbd48d41.1675869497.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 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_H2, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that describe_other_breakpoints doesn't show the task number, but does show the thread-id. I can't see any reason why we'd want to not show the task number in this situation, so this commit adds this missing information, and extends gdb.ada/tasks.exp to check this case. --- gdb/breakpoint.c | 2 ++ gdb/testsuite/gdb.ada/tasks.exp | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 701555a060e..6b576859592 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7049,6 +7049,8 @@ describe_other_breakpoints (struct gdbarch *gdbarch, struct thread_info *thr = find_thread_global_id (b->thread); gdb_printf (" (thread %s)", print_thread_id (thr)); } + else if (b->task != 0) + gdb_printf (" (task %d)", b->task); gdb_printf ("%s%s ", ((b->enable_state == bp_disabled || b->enable_state == bp_call_disabled) diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp index 88ef123865b..83692054e4f 100644 --- a/gdb/testsuite/gdb.ada/tasks.exp +++ b/gdb/testsuite/gdb.ada/tasks.exp @@ -50,16 +50,21 @@ gdb_test "watch j task 1 task 3" "You can specify only one task\\." # breakpoint in the list that matched the triggered-breakpoint's # address, no matter which task it was specific to. gdb_test "break break_me task 1" "Breakpoint .* at .*" +set bp_number [get_integer_valueof "\$bpnum" "INVALID" \ + "get number of breakpoint for task 1"] gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 1" \ "check info breakpoints for task 1 breakpoint" # Now, insert a breakpoint that should stop only if task 3 stops, and -# extract its number. -gdb_breakpoint "break_me task 3" message -set bp_number [get_integer_valueof "\$bpnum" -1] -if {$bp_number < 0} { - return -} +# extract its number. Use gdb_test here so that we can validate that +# the 'Breakpoint ... also set at' line correctly includes the task +# number of the prevoius breakpoint. +gdb_test "break break_me task 3" \ + [multi_line \ + "Note: breakpoint $bp_number \\(task 1\\) also set at pc $hex\\." \ + "Breakpoint $decimal at $hex: \[^\r\n\]+"] +set bp_number [get_integer_valueof "\$bpnum" "INVALID" \ + "get number of breakpoint for task 3"] gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 3" \ "check info breakpoints for task 3 breakpoint" From patchwork Wed Feb 8 15:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 64489 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 209B5385800A for ; Wed, 8 Feb 2023 15:24:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 209B5385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675869849; bh=9sovpJpV8zayyv1/beWmmmWwJZvGY3ZJt2MJDVVZ0Kw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=cy0Fm0kfBGw1CfTudYKNVQ+0nAeW3FkmBqSEEBif/vFNJniEwgZstTkoTxM760JHR uFHcNikCVbAiPEG0pLOEtZeWsNFQD/WfzohJz3EyEFYlWC+r3w+hGKf4bcpwW47mBz S8xLSBZh4tjrEjY/bbHI+5QSRABcULyEFPQls6F8= 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 1E12B385840D for ; Wed, 8 Feb 2023 15:23:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E12B385840D Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-639-p37Fh17YPMyhBOq_MXJvuA-1; Wed, 08 Feb 2023 10:23:40 -0500 X-MC-Unique: p37Fh17YPMyhBOq_MXJvuA-1 Received: by mail-qt1-f198.google.com with SMTP id i5-20020ac813c5000000b003b86b748aadso10934097qtj.14 for ; Wed, 08 Feb 2023 07:23:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9sovpJpV8zayyv1/beWmmmWwJZvGY3ZJt2MJDVVZ0Kw=; b=eodJ78sqFaqwFFDTzQQCSmRgz/V7ANmrYGTouWyVl4e6fk4FVNkO0KHrTAiPlv1jdL 8bCltGlPH5R8MrcJAoq6RDV7enWd6vnkWju7sRmPY0MC5mOMyGno6jzaFmAUBq0oPgub 7IlCa45O9JuqG1kN9t+FqCUSHT7FYBKpjCjZoA2gJQ5A6v0WznlghqTPNkGcaxutFjKV kYpE2/2Us9JRgHiB6WIWVvSxAtY8+PKbcpFWnKQJVHwfhtEX0fncpjgZKiXtpNc0oAhg YZ5QGoUSAy3t8mQz76klMx1qTHJnwCz5QNG3+E8Mde57bCDRpcTgB54JbwTiq5Jw68X1 3IoA== X-Gm-Message-State: AO0yUKWsbp5yxccK54BAxH/BvP8FOUaPYs4hQVnjaUg3NaR2d4ObEA5p ZatZEo4xTjApwUWm6Lzs5LV2HsfjX/8JRmxgwVN/lcsgQhyUT5VHA4drpRJBM16QQx9TJ8pU8rS 1trKbVil6tbGXjmGMLkMshjHt0txOZaFClLItTAIsl1Qvs3OMZjhvnvmFD/l/w/Yyv4g7Crf78Z SDejk= X-Received: by 2002:ac8:7f01:0:b0:3b8:5057:377b with SMTP id f1-20020ac87f01000000b003b85057377bmr13238849qtk.65.1675869819979; Wed, 08 Feb 2023 07:23:39 -0800 (PST) X-Google-Smtp-Source: AK7set8qwCuqgDiZIdi3NU27Y1H85+gIfGdjRfAf9dvqUsiQu57/xlX9wVPEuuW6zTKkyWoEgityfA== X-Received: by 2002:ac8:7f01:0:b0:3b8:5057:377b with SMTP id f1-20020ac87f01000000b003b85057377bmr13238808qtk.65.1675869819663; Wed, 08 Feb 2023 07:23:39 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id f3-20020ac84703000000b003b2d890752dsm11543384qtp.88.2023.02.08.07.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 07:23:39 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/3] gdb: don't use the global thread-id in the saved breakpoints file Date: Wed, 8 Feb 2023 15:23:30 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 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_H2, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that breakpoint::print_recreate_thread was printing the global thread-id. This function is used to implement the 'save breakpoints' command, and should be writing out suitable CLI commands for recreating the current breakpoints. The CLI does not use global thread-ids, but instead uses the inferior specific thread-ids, e.g. "2.1". This commit updates breakpoint::print_recreate_thread to use the print_thread_id function, and adds a test for this change. --- gdb/breakpoint.c | 5 +- .../gdb.multi/bp-thread-specific.exp | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 6b576859592..6e3c76305e7 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -14120,7 +14120,10 @@ void breakpoint::print_recreate_thread (struct ui_file *fp) const { if (thread != -1) - gdb_printf (fp, " thread %d", thread); + { + struct thread_info *thr = find_thread_global_id (thread); + gdb_printf (fp, " thread %s", print_thread_id (thr)); + } if (task != 0) gdb_printf (fp, " task %d", task); diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.exp b/gdb/testsuite/gdb.multi/bp-thread-specific.exp index 777fcf85ab0..6a7cd044af4 100644 --- a/gdb/testsuite/gdb.multi/bp-thread-specific.exp +++ b/gdb/testsuite/gdb.multi/bp-thread-specific.exp @@ -15,6 +15,9 @@ # Check that GDB uses the correct thread-id when describing multiple # thread specific breakpoints at the same location. +# +# Also check that the correct thread-ids are used in the saved +# breakpoints file. # The plain remote target can't do multiple inferiors. require !use_gdb_stub @@ -59,3 +62,46 @@ gdb_test "break foo thread 1.1" \ "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \ "Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \ "Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"] + +# Save the breakpoints into a file. +if {[is_remote host]} { + set bps bps +} else { + set bps [standard_output_file bps] +} + +remote_file host delete "$bps" +gdb_test "save breakpoint $bps" "" "save breakpoint to bps" + +if {[is_remote host]} { + set bps [remote_upload host bps [standard_output_file bps]] +} + +# Now dig through the saved breakpoints file and check that the +# thread-ids were written out correctly. First open the saved +# breakpoints and read them into a list. +set fh [open $bps] +set lines [split [read $fh] "\n"] +close $fh + +# Except the list created from the saved breakpoints file will have a +# blank line entry at the end, so remove it now. +gdb_assert {[string equal [lindex $lines end] ""]} \ + "check last item was an empty line" +set lines [lrange $lines 0 end-1] + +# These are the lines we expect in the saved breakpoints file, in the +# order that we expect them. These are strings, not regexps. +set expected_results \ + [list \ + "break -qualified main" \ + "break foo thread 2.1" \ + "break foo thread 1.1"] + +# Now check that the files contents (in LINES) matches the +# EXPECTED_RESULTS. +gdb_assert {[llength $lines] == [llength $expected_results]} \ + "correct number of lines in saved breakpoints file" +foreach a $lines b $expected_results { + gdb_assert {[string equal $a $b]} "line '$b'" +}