From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 5E2C53858288 for ; Thu, 1 Jun 2023 21:43:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E2C53858288 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5147f4bbfdaso1975971a12.0 for ; Thu, 01 Jun 2023 14:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685655780; x=1688247780; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=alMYR/55StAdtqsYjJQ+z/ZygS4VrWXlev9HUxDnRBo=; b=Y+5UhMUU4llmjXrj4B74j4yqftNtmeKjvIV+vg/hkuD7l2/Q2Ko7Tdqxjg+BNXbnNA CiC8sZeNIoXf+JCjvgGk4sxRM2fIn+EIuH1KJkeh27qfS11aQ15+7S8oVZ8Wd6o4zW0q dPFyzyc2lzXQTioqH4RVDky26VXHngjh7Q1MzQndYV5oZJq1dXfX2hGPQ7l3E03laDqM zmJpef0+aK6alRKiCE8b5/O7OCnOjGD8t14EHsd9w1W4C74XOxretDHz01ktB5kGe++s HmdlipdJ9yW+W2j8O9Wbd/kueZE09Rzjc5vQWA0/xEdAZblRNTKjt5DkDm+Uzt9UjVtb gRvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655780; x=1688247780; 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=alMYR/55StAdtqsYjJQ+z/ZygS4VrWXlev9HUxDnRBo=; b=Aqg5P4stBA0XwlGAjN2/JGOcVM8lG0HU6UrHx9CO2TbdU9bkIGUznK/UFisnk1aivH oYs8Gg32Z9aNX4dE1cKGuDWC3kPbcgp4+MyCQxmRtVFdfx8QaPsZd7GvdRznuJd1uYzW pjb/XIZIG2mXeEaBSf5BczKYPd68mPthOGA4QNWDDGLTdMO+9DJGdke9q9lPo+mMx1SL yy53lt7UKdwJO7XudE/EExsqPiLgPnmFgMsJCE3XIwAisziAVQJsXrCbbCybplcP9r6s L/mHZi3jPIdiLusWmCJlD4o4j6uTDw/GhXlbmjvw5HO+if7+UsDj5059+3AM+hMnXEIN Q7lw== X-Gm-Message-State: AC+VfDxzJUTUFdj1Ldpgshhr1AgvWWnP/SXdf+Qn+KtXXv1ZVv15asyh xlLMirT8U/PEKeq+FwdNzjfP8FJhRc9esNJ7K60= X-Google-Smtp-Source: ACHHUZ64dV4Myk497d84UVSxbOlNYQPj6iorcspJvFztPmoZd6wEWShqdpX0guKQWt5z4mJ4qeORSA== X-Received: by 2002:a17:907:268c:b0:94e:cf72:8147 with SMTP id bn12-20020a170907268c00b0094ecf728147mr9207502ejc.48.1685655779965; Thu, 01 Jun 2023 14:42:59 -0700 (PDT) Received: from localhost (p200300eaff33e08878ebf65188eb3c13.dip0.t-ipconnect.de. [2003:ea:ff33:e088:78eb:f651:88eb:3c13]) by smtp.gmail.com with ESMTPSA id q9-20020a170906940900b009545230e682sm11129475ejx.91.2023.06.01.14.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:42:59 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Bruno Larsen , Andrew Burgess , Tom de Vries , Thiago Jung Bauermann Subject: [PATCH v2] gdb/testsuite: Avoid infinite loop in gdb.reverse/step-reverse.exp Date: Thu, 1 Jun 2023 23:42:39 +0200 Message-Id: <20230601214239.209822-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 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: 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 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 | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp index 729218d4cb8c..c70d2fcb5166 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,18 @@ 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.*" { set step_out 0 } - -re -wrap ".*" { + -re -wrap "^main .*" { + incr iterations + if { $iterations == $max_iterations } { + fail "$gdb_test_name (reached $max_iterations iterations)" + return + } + send_gdb "next\n" exp_continue } @@ -276,9 +284,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 +301,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 } base-commit: d987df5c95340a8b41b23d68ad6a8f9f33485835