From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id EE5A83858CD1 for ; Mon, 31 Jul 2023 17:33:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE5A83858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3490a0bb5cdso16015815ab.2 for ; Mon, 31 Jul 2023 10:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1690824782; x=1691429582; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D2sd+vfpC9w0ETKeVwfOJtAZEHyLMWJIKAFs5cE54u4=; b=Y8y38W9dsHSG0NkjDVMgbHZqR4Qt1Q/U4BUsZDdJkPriDhwgOmp60mshLcuRUi2Dkm cjZK2kBSCdHN/K6qttDJKj/xK0SBgU9enfzx0f1UpSakPWly7OkMQp5R77AP4mq6sXd1 7zJ5Q54SVz21Z5TlHDlwvsnU1TssRHQ4wBE+kLm97fhIFq++iVXDSu11zhbpREOE2irO fgvxL6dRbz7Ehr897iEaKiGyXi01REMEtf4L58CsxXBgHXtNIEByyeHWqJBwQYK7GhSh d9udFf7z/stLavZyhpTjCrQkMLJoLnwQ8tgtzNNvFmXAshQzpkWOlqG5xnK0YoUMmp4D pjvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690824782; x=1691429582; 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=D2sd+vfpC9w0ETKeVwfOJtAZEHyLMWJIKAFs5cE54u4=; b=jvnvp8aH0TTQkx+/UXyHp4NY1GC0axtsF5XAWV+lnup9xImUEZkBgdLmVt/LIfdfIh 8tuwRUoXe6GkjDVZNtPZbrHoay7Y0f/gNucBXsGfZ09AOftnVTumnzxvVOKA61m3WWuv 4x9qG3UvqFIv0aFpYfpZK/EK95s7/I+cJ2IZb7O/A2UZMsYjy2KIgf13XJoU2ndR2NKU xxVDna0/1mdaatrz2XrMo8UX2wJPWf9XpMteaX9FrxOLAY+Ef2EIrR5lDDUodIc/EETN ilC7nP5FEPJmxnIBk/WFsw6YSxMGT3KxfAgY7yVrax5+Z+9HMJ6NCMJ8hhJHiFJwN3h8 twVA== X-Gm-Message-State: ABy/qLZurwaS3gC3CMfzpJuQe44rVuk5laNnUexHZCoUTWoAMtlCXO9L 7vgkHjOl88UP/ZgLF1We0SZyhFbHR+UdWsdaqZif3w== X-Google-Smtp-Source: APBJJlElmIONBL1eNShpsH/VLfWwJbQ35aFIZnUzqPi2deOHTJ/pBiFixpHEyLVBfdn4dXPGkHHmZg== X-Received: by 2002:a92:cda2:0:b0:349:2f69:3045 with SMTP id g2-20020a92cda2000000b003492f693045mr121208ild.26.1690824782185; Mon, 31 Jul 2023 10:33:02 -0700 (PDT) Received: from localhost.localdomain (75-166-135-140.hlrn.qwest.net. [75.166.135.140]) by smtp.gmail.com with ESMTPSA id u7-20020a92d1c7000000b00348c7617795sm3293060ilg.49.2023.07.31.10.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:33:01 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Change py-thread-exited.exp to work with gdbserver Date: Mon, 31 Jul 2023 11:32:54 -0600 Message-Id: <20230731173254.2725820-1-tromey@adacore.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,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: gdbserver does not notify gdb of new threads when they are created. I'm not sure if this is documented anywhere, but it is mentioned on this page: https://sourceware.org/gdb/wiki/LocalRemoteFeatureParity Search for "Finding new threads in the inferior". This behavior is a bit unfortunate -- I would think that it would be better to arrange for such notification if something on the gdb side is interested. Meanwhile, this patch fixes py-thread-exited.exp to work around this problem. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30677 --- gdb/testsuite/gdb.python/py-thread-exited.c | 6 +++--- gdb/testsuite/gdb.python/py-thread-exited.exp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-thread-exited.c b/gdb/testsuite/gdb.python/py-thread-exited.c index fd0342bc765..d62133ba59e 100644 --- a/gdb/testsuite/gdb.python/py-thread-exited.c +++ b/gdb/testsuite/gdb.python/py-thread-exited.c @@ -24,14 +24,14 @@ pthread_t thread3_id; void* do_thread (void* d) { - return NULL; + return NULL; /* In thread */ } int main (void) { pthread_create (&thread2_id, NULL, do_thread, NULL); - pthread_join (thread2_id, NULL); pthread_create (&thread3_id, NULL, do_thread, NULL); + pthread_join (thread2_id, NULL); pthread_join (thread3_id, NULL); - return 12; + return 12; /* Done */ } diff --git a/gdb/testsuite/gdb.python/py-thread-exited.exp b/gdb/testsuite/gdb.python/py-thread-exited.exp index 957585958a2..937816106e2 100644 --- a/gdb/testsuite/gdb.python/py-thread-exited.exp +++ b/gdb/testsuite/gdb.python/py-thread-exited.exp @@ -36,9 +36,17 @@ if ![runto_main] { return -1 } -gdb_breakpoint 37 "last of main" -gdb_continue_to_breakpoint "continue to breakpoint" +gdb_breakpoint [gdb_get_line_number "In thread" ${testfile}.c] +gdb_breakpoint [gdb_get_line_number "Done" ${testfile}.c] + +# gdbserver does not notify new threads on creation. In order for +# this test to even see that the threads are created, we have to +# arrange to stop when they are running. +gdb_continue_to_breakpoint "continue to first in-thread breakpoint" +gdb_continue_to_breakpoint "continue to second in-thread breakpoint" + +gdb_continue_to_breakpoint "continue to end breakpoint" gdb_test "python print(threadOneExit)" \ ".*event type: thread-exited. global num: 2.*" -- 2.40.1