From patchwork Mon Jun 5 23:28:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 70616 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 0F99D3858C2B for ; Mon, 5 Jun 2023 23:29:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F99D3858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686007755; bh=OrPQDoS8u5tLj1js+JHgBd4jzrQDTpEaTtHDJr33h4g=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nAZn2D2/XTf55vq7mRxHWava3jDnrhpCyuMVGs7pJ8ydZeCrvM89+jMkAqCl8JPts cVuujXijclCHA3DElWFnufO40meWdd4A7sa+2amz1F5gyovLkEkpzJabd7MIZDw1fy snfr1B3z4OA4CAUJFYSqlBB5UBI/bKtOvfsiU3Tw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 13B1D3858D20 for ; Mon, 5 Jun 2023 23:28:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13B1D3858D20 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-977e83d536fso174051866b.3 for ; Mon, 05 Jun 2023 16:28:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686007730; x=1688599730; 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=OrPQDoS8u5tLj1js+JHgBd4jzrQDTpEaTtHDJr33h4g=; b=WLORbpSDpB26f0h6sbmjBrr0ZYPqL+O2mGfHH3TAYUAFQgJaxVrd0oD+YZRpVv2YDx RsGVQ7cDZ/BS9vt5kK6LhkOXD9Vo9KRXagAnh1W8+jGybDFhsL0PjwLIH71TkoNSOofH PqE9GvEVvqPwvYU0aLmUBPECk9Ygyr6o4jXKTjB5xkfmqxCiO267xbeKK1eegaefoRoy DEqe1PPzJspACKcYv85m2wWgnwyWtxzKBqrNtuG1iHSYmuwa0kwzTNvixvvYE7da4r3j HRz5/ErATfzbyhxPdDv6onhWaxL+0xQ18KhDR8u06C3d37gzJ/6WPQ5tFzAPq8EXMqX3 697g== X-Gm-Message-State: AC+VfDx9cAeBWB43mXf+SbxQnDduNWDFhoAUQK7k1EfsyU6CZFoXaNhh bUSYSTb7nMJFqMR6NwkH7dV0DaIbTrLuSQ4PwcE= X-Google-Smtp-Source: ACHHUZ4NDa5U61MTFYhJthhG00J9ALVTMjzFXh8+GAlxXS6yLledJsgk+Lppi/57uKZlTx34gSS7bQ== X-Received: by 2002:a17:907:2cc7:b0:976:8fdd:9046 with SMTP id hg7-20020a1709072cc700b009768fdd9046mr328413ejc.12.1686007729762; Mon, 05 Jun 2023 16:28:49 -0700 (PDT) Received: from localhost (p200300eaff33e077eb60eb1a97c40520.dip0.t-ipconnect.de. [2003:ea:ff33:e077:eb60:eb1a:97c4:520]) by smtp.gmail.com with ESMTPSA id hb13-20020a170906b88d00b009786c8249d6sm62344ejb.175.2023.06.05.16.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 16:28:49 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Bruno Larsen , Andrew Burgess , Tom de Vries , Thiago Jung Bauermann Subject: [PATCH v3] gdb/testsuite: Avoid infinite loop in gdb.reverse/step-reverse.exp Date: Tue, 6 Jun 2023 01:28:44 +0200 Message-Id: <20230605232844.80533-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 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 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: Thiago Jung Bauermann via Gdb-patches From: Thiago Jung Bauermann Reply-To: Thiago Jung Bauermann Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This testcase sometimes gets stuck in a loop for hours when running in our CI. The problem is that due to an issue unrelated to reverse debugging the inferior exits early, and because of the overly generic ".*" pattern the testcase keeps sending the "next" command without noticing that the inferior is gone. gdb_test_multiple has a pattern to detect that "The program is not being run.", but since it is placed after the patterns from the caller it won't be triggered. It also has a timeout pattern but because it is triggered between successful matches, each time the test matches the '-re -wrap ".*"' this counts as a successful match and the timeout is reset. Since the test binary is compiled with debug information, fix by changing one of the generic patterns to match entering the main function and the other one to match the source code line number that is shown by GDB right after the "step" command. Also, as a precaution add a maximum number of times the "next" command will be sent. Co-Authored-By: Tom de Vries --- Changes since v2: - Put "^main" in the correct re in "$step_out == 1" case (pointed out by Bruno). Changes since v1: - Added maximum number of iterations (code provided by Tom). - Changed one of the patterns to match the main function (suggested by Bruno). - Clarified why the timeout pattern isn't effective (explanation from Andrew). Tom, Most of the patch now is the iteration-counting code. Since I copied it from your email, I thought it made sense to record you as co-author. I hope it's ok. gdb/testsuite/gdb.reverse/step-reverse.exp | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) base-commit: 3c5e824b9cee93a987a77906240c509add260a0d diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp index 729218d4cb8c..4b78a8f8fb75 100644 --- a/gdb/testsuite/gdb.reverse/step-reverse.exp +++ b/gdb/testsuite/gdb.reverse/step-reverse.exp @@ -247,6 +247,7 @@ gdb_test_multiple "step" "$test_message" { gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call" set step_out 0 +set max_iterations 1000 gdb_test_multiple "next" "reverse next over recursion" { -re -wrap ".*NEXT OVER THIS RECURSION.*" { pass "$gdb_test_name" @@ -257,11 +258,19 @@ gdb_test_multiple "next" "reverse next over recursion" { } } if { "$step_out" == 1 } { + set iterations 0 gdb_test_multiple "next" "stepping out of recursion" { - -re -wrap "NEXT OVER THIS RECURSION.*" { + -re -wrap "^main.*NEXT OVER THIS RECURSION.*" { set step_out 0 + pass "$gdb_test_name" } - -re -wrap ".*" { + -re -wrap "^\[0-9\].*" { + incr iterations + if { $iterations == $max_iterations } { + fail "$gdb_test_name (reached $max_iterations iterations)" + return + } + send_gdb "next\n" exp_continue } @@ -276,9 +285,16 @@ gdb_test_no_output "set exec-dir reverse" "reverse again to test recursion" gdb_test "step" ".*EXIT RECURSIVE FUNCTION.*" "enter recursive function" set seen_recursive_call 0 +set iterations 0 gdb_test_multiple "next" "step over recursion inside the recursion" { -re -wrap ".*RECURSIVE CALL.*" { incr seen_recursive_call + incr iterations + if { $iterations == $max_iterations } { + fail "$gdb_test_name (reached $max_iterations iterations)" + return + } + send_gdb "next\n" exp_continue } @@ -286,7 +302,13 @@ gdb_test_multiple "next" "step over recursion inside the recursion" { gdb_assert {"$seen_recursive_call" == 1} \ "step over recursion inside the recursion" } - -re -wrap ".*" { + -re -wrap "^\[0-9\].*" { + incr iterations + if { $iterations == $max_iterations } { + fail "$gdb_test_name (reached $max_iterations iterations)" + return + } + send_gdb "next\n" exp_continue }