From patchwork Tue Dec 24 12:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 103668 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 1319D3858433 for ; Tue, 24 Dec 2024 12:07:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1319D3858433 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dAMKEFUS 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 ESMTP id 563563858D28 for ; Tue, 24 Dec 2024 12:05:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 563563858D28 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 563563858D28 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=1735041947; cv=none; b=g5dU3qczJ+z0fnKPZy90bdRdLLJr8l98qcFFI25wYj7s8sRWdNTkNYwgHacRwNDI2nxrP7oDs96KpuF5k0yrS6wOkx5zHYDbcJ9Sw0eGS/TUg0j5dJBZssLLvRUJhHxykgR38TxqEbBAUB1ENqLNYkeWniW+DAtlNOpRdmHy1no= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735041947; c=relaxed/simple; bh=37ndWlfnoN5ScIPQTolTB3NLythLnXrTqSmyOPp8nw0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=xxPlBfnm9RqivANznvLz7jg8ZsGNevnWY7cmtxlhwFdgETIrbiqDQi+iQR62V3JtTvmlhZxXYWQ5x+Jacn2gEA0ylSrzYvf88HLp+zvFFZRWKTSxBIWhq+ZY6QBRsGSGEMPY2Qyt5dcCvIVxbWz3xZniSkhIcw1qDgIVcTbPpI0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 563563858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735041947; 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=aiYXQYbNyilYqHTIjwiPDJ2kDv7LGfwQX2yz67ChqCs=; b=dAMKEFUSB/6XxVEsKpEO9eqw0L/ZZbrwZIeeCw8cTaqvbNQ5WwSrmYNHKIBn8zr3LTbq+2 PlWp0taFFU60pbPQGA0i8x8mwnqndVdu8pZCxgu923drNUcallfTseVlwUw+TwZ69DrURz 0d2HhFvmV4BCPm4uxclXPDhjIbWKh2E= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-CLBWzAlNOsG85CUCaZj_Yg-1; Tue, 24 Dec 2024 07:05:45 -0500 X-MC-Unique: CLBWzAlNOsG85CUCaZj_Yg-1 X-Mimecast-MFC-AGG-ID: CLBWzAlNOsG85CUCaZj_Yg Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-436723db6c4so21105375e9.3 for ; Tue, 24 Dec 2024 04:05:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735041943; x=1735646743; 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=aiYXQYbNyilYqHTIjwiPDJ2kDv7LGfwQX2yz67ChqCs=; b=lrQcIenpv95xc0GxNa9Doi93ozaSMdpB0neiDhorwu1VFTEuN7yUl93riHS5BfABDg R5RK815DWR+H7zK2ZkSakK51bcV6l2lNlgzY3PYN+x6sacmBhlDBLz5++UA+GUwl4kg6 Y08lvBaquFZD3Q5o5a0pg7R4ozbKSsAstgkB50f9hlEjuWiqlWvHC03hD0NXU418w1Uw z6pew+4/CtHi8KeWA0TD1xdtfu9t3fGVwgJwNr5ZxfwMQTKq/N7ow/McR6Z79xmFetfw jGhi2XU5WoGIWGmqAyzOAXW+ZDmxhvgRSihHrKGh58yqpm6o994coXFJpyrmHfMU7/Dy /UVw== X-Gm-Message-State: AOJu0YxxkrKJX6R6wwvkRC8x7BkbjKBstETdTBLM5/c1Dua4XyInFJep +O76GWh0oZnKsevLsKNCYby83735DSOSko+qlHLrfPoFQ4fuDWA9q2qjj1zApoefYGcvMBk6yZ3 El+/CTFbySVQVdozD0Ca0mmrKo9xeCIXTQVogt2Xm5ruEF9ienrK56BRQG6I4d08aLQN20h02sH OcTnCwm82OaBE/lqV3sUxYEp5tPZk+S/U4HgF1FnZTI3U= X-Gm-Gg: ASbGnctRhonzaXE8tzEjmVZsOe7e6lIrHo118bNFmFp5XbZe1sBm2hxJTvzydXuiLNT rNnNL0Awg2ERoWMkNrT0MJgGtNN7HoSUR750SdfdsGIyCmUfGxovy5eA3Hb582UKGmk4NLzfEy4 EhBin2o5hvZjBvN6uhp4P72P+i3V37Uqmi4iihz/Q/5/3Nwg6hcdOQEuARk0uEmFfrnrrhEF9Fu IZCl8G8n3jPUjZgC5x5TEDx92wgkfth7v30G2AUniwkv9h3YZV2wicxSw4GLg+R/5N7yh3RACK0 X-Received: by 2002:a5d:59ab:0:b0:385:fd31:ca31 with SMTP id ffacd0b85a97d-38a223fd39fmr18164519f8f.53.1735041943547; Tue, 24 Dec 2024 04:05:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQFxplqK8SmtzsX/SLOVZUd3mZK7KUtfg5gO8q1DvrKNUOjGjx6PX3DsCJJva7GnNncQvmEA== X-Received: by 2002:a5d:59ab:0:b0:385:fd31:ca31 with SMTP id ffacd0b85a97d-38a223fd39fmr18164485f8f.53.1735041943067; Tue, 24 Dec 2024 04:05:43 -0800 (PST) Received: from localhost (60.81.93.209.dyn.plus.net. [209.93.81.60]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c828989sm14038638f8f.18.2024.12.24.04.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 04:05:41 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/3] gdb/testsuite: restructure gdb.base/dlmopen.exp Date: Tue, 24 Dec 2024 12:05:35 +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-MFC-PROC-ID: 5Jnz1ZvcfPkwMbYnFwaLofNyg693R9sj-xlyR_UDJi0_1735041944 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 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.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 In the next commit I want to add more tests to the dlmopen.exp script. Doing this will be easier if the dlmopen.exp script was structured so that the current tests were contained inside separatate procs. So this commit moves all of the current tests within dlmopen into two procs, and then calls these. There should be no changes to what is actually being tested in this commit. --- gdb/testsuite/gdb.base/dlmopen.exp | 81 ++++++++++++++++++------------ 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp index dee046a8b33..f1da76a13f6 100644 --- a/gdb/testsuite/gdb.base/dlmopen.exp +++ b/gdb/testsuite/gdb.base/dlmopen.exp @@ -77,16 +77,16 @@ if { [build_executable "build shlib" $binfile_lib2 $srcfile_lib \ return } -if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ +if { [build_executable "failed to build" $testfile $srcfile \ [list additional_flags=-DDSO1_NAME=\"$binfile_lib1\" \ additional_flags=-DDSO2_NAME=\"$binfile_lib2\" \ shlib_load debug]] } { - return -1 + return } -if { ![runto_main] } { - return -1 -} +# Some locations needed by the tests. +set bp_inc [gdb_get_line_number "bp.inc" $srcfile_lib] +set bp_main [gdb_get_line_number "bp.main" $srcfile] # Check that 'info shared' show NUM occurrences of DSO. proc check_dso_count { dso num } { @@ -158,41 +158,58 @@ proc test_dlmopen {} { } } -# Remove the pause. We only need it for the attach test. -gdb_test "print wait_for_gdb = 0" "\\\$1 = 0" +# Setup for calling 'test_dlmopen', this is the version of the test +# that doesn't use 'attach'. +proc test_dlmopen_no_attach {} { + clean_restart $::binfile -# Break in the to-be-loaded library and at the end of main. -set bp_inc [gdb_get_line_number "bp.inc" $srcfile_lib] -set bp_main [gdb_get_line_number "bp.main" $srcfile] + if { ![runto_main] } { + return + } -delete_breakpoints -gdb_breakpoint $srcfile_lib:$bp_inc allow-pending -gdb_breakpoint $srcfile:$bp_main + # Remove the pause. We only need it for the attach test. + gdb_test "print wait_for_gdb = 0" "\\\$1 = 0" -test_dlmopen + # Break in the to-be-loaded library and at the end of main. + delete_breakpoints + gdb_breakpoint $::srcfile_lib:$::bp_inc allow-pending + gdb_breakpoint $::srcfile:$::bp_main -# Try the same again when attaching after dlmopen(). -require can_spawn_for_attach + test_dlmopen +} -clean_restart $binfile +# Setup for calling 'test_dlmopen', this is the version of the test +# that does use 'attach'. +proc test_dlmopen_with_attach {} { + if { ![can_spawn_for_attach] } { + unsupported "cannot run attach tests" + return + } -# Start the test program. -set test_spawn_id [spawn_wait_for_attach $binfile] -set testpid [spawn_id_get_pid $test_spawn_id] + clean_restart $::binfile -# Attach. -if { ![gdb_attach $testpid] } { - return -} + # Start the test program. + set test_spawn_id [spawn_wait_for_attach $::binfile] + set testpid [spawn_id_get_pid $test_spawn_id] -with_test_prefix "attach" { - # Remove the pause. We no longer need it. - gdb_test "print wait_for_gdb = 0" "\\\$1 = 0" + # Attach. + if { ![gdb_attach $testpid] } { + return + } - # Set the same breakpoints again. This time, however, we do not allow the - # breakpoint to be pending since the library has already been loaded. - gdb_breakpoint $srcfile_lib:$bp_inc - gdb_breakpoint $srcfile:$bp_main + with_test_prefix "attach" { + # Remove the pause. We no longer need it. + gdb_test "print wait_for_gdb = 0" "\\\$1 = 0" - test_dlmopen + # Set the same breakpoints again. This time, however, we do not allow the + # breakpoint to be pending since the library has already been loaded. + gdb_breakpoint $::srcfile_lib:$::bp_inc + gdb_breakpoint $::srcfile:$::bp_main + + test_dlmopen + } } + +# Run the actual tests. +test_dlmopen_no_attach +test_dlmopen_with_attach