From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id NwhPD2zj+2rJ8hUAWB0awg (envelope-from ) for ; Tue, 17 Nov 2026 00:17:32 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jPAJPC8P; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 223EE1E091; Tue, 17 Nov 2026 00:17:32 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3DC251E043 for ; Tue, 17 Nov 2026 00:17:30 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16A344B19738 for ; Tue, 17 Nov 2026 05:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16A344B19738 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=jPAJPC8P 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 AC9C34BA23E9 for ; Tue, 17 Nov 2026 05:17:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC9C34BA23E9 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 AC9C34BA23E9 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794892621; cv=none; b=gQHcNcNiTHu1/IbjC4qK11dZks9y87U3LkWgmKkadFUuxLJmMXJ0UM2YHiWQTY5loPE0P1Q51QrzmqPDp3lAmwuXkJeNVPVgMWZZnUSyd/YWDWGqRfrY0+fUmTG59fhdH/yzhivsJ+Orz0WhXjt2gg0o1aqKEL7I4xUDcbGRs0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794892621; c=relaxed/simple; bh=BthMRysLCfENi1P2qHbd11qDp0P+rLMQRGdonp3os9E=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=DYZs4pbpylFgZ4zKlAIHCyqT3rA1IBzEEExi+avAMfRPJPfnZxJs7c6HhA0RTrsjtcCmW525JYCs83ni6wbzuH24cOuGdlbzbFsYpD+eacSxwXLpxnXSthD6jJ275y6uWLb3AuTYeT9K8vLavJ1bhYAHkkKV2jmWqCj4O9goWoc= ARC-Authentication-Results: i=1; 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=jPAJPC8P DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC9C34BA23E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794892621; 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=BtbhWhq1nQXNBXymCZZQ9c3Eew27FDhrkNkgAh4M3UY=; b=jPAJPC8PiC5XeOOiwSRF0VyyOxh3Tjqja8S4OWjWGwO1pUQXE6SoUagKx11ofQZKrQDcmO FhVYmct70JT2C2t37x/g8TvGqreMk6IymplURv1s9xC5mOKtyE93pvxwpNFcjP1bnTSMPd UGc0dT3GGlXW2QHnQkaELPJNoyABRIE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-8DoMx_HjPrS_Wi5COCXM0A-1; Tue, 17 Nov 2026 00:16:59 -0500 X-MC-Unique: 8DoMx_HjPrS_Wi5COCXM0A-1 X-Mimecast-MFC-AGG-ID: 8DoMx_HjPrS_Wi5COCXM0A_1794892618 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E2FA7180054B; Tue, 17 Nov 2026 05:16:57 +0000 (UTC) Received: from [100.90.172.125] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E75D3180055C; Tue, 17 Nov 2026 05:16:56 +0000 (UTC) Message-ID: Date: Mon, 16 Nov 2026 22:16:54 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Kevin Buettner Subject: Re: [PATCH 1/1] gdb, infcall, breakpoint: Handle cycles in conditional expr evaluation To: Mohamed Bouhaouel , gdb-patches@sourceware.org Cc: abdul.b.ijaz@intel.com References: <20261002143505.38658-1-mohamed.bouhaouel@intel.com> In-Reply-To: <20261002143505.38658-1-mohamed.bouhaouel@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uS2g7Au3Iy0CA02UWWtjPWY3lDoN5Qiejw37AUiftyc_1794892618 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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~public-inbox=simark.ca@sourceware.org On 10/2/26 7:35 AM, Mohamed Bouhaouel wrote: > Take the following scenario: > > (gdb) break foo if foo (1) == 2 > (gdb) run > > The program stops at 'foo', then GDB tries to evaluate the condition. > The condition triggers an inferior call of 'foo', which causes a stop at > 'foo' again, and GDB is stuck in this infinite cycle. > > The same issue exists also for indirect cycles, e.g., > > (gdb) break foo if bar (1) > (gdb) break bar if foo (1) > (gdb) run > > To avoid this, check for cycles just before evaluating a breakpoint > condition. If a breakpoint is hit again while its own condition is > being evaluated, the evaluation of that condition is aborted with an > error message. > > With the patch, the behavior becomes: > > (gdb) break foo if foo (1) == 2 > Breakpoint 2 at 0x55555555514c: file infcall-from-bp-cond-cycle.c, line 27. > (gdb) continue > Continuing. > Error in testing condition for breakpoint 2: > Aborting expression evaluation for the conditional bp: > A cycle was detected during the evaluation. > > Breakpoint 2, foo (a=1) at infcall-from-bp-cond-cycle.c:27 > 27 return a + add_one (a); > Error in testing condition for breakpoint 2: > The program being debugged stopped while in a function called from GDB. > Evaluation of the expression containing the function > (foo) will be abandoned. > When the function is done executing, GDB will silently stop. > (gdb) backtrace > #0 foo (a=1) at infcall-from-bp-cond-cycle.c:27 > #1 > #2 foo (a=11) at infcall-from-bp-cond-cycle.c:27 > #3 0x00005555555551af in main () at infcall-from-bp-cond-cycle.c:47 My AI reviewer found a case which probably ought to be allowed. Perhaps a depth setting could be added? Alternately, a setting which disables cycle detection? The example uses factorial from gdb.base/break.c. Using the baseline build (without your patch): $ /home/kevinb-claude/installs/cycles-baseline/bin/gdb \ -q -nx -batch -iex 'set debuginfod enabled off' \ -ex 'break factorial if value > 1 && factorial (value - 1) > 100' \ -ex run -ex bt ./break Breakpoint 1 at 0x40055b: file break.c, line 63. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 1, factorial (value=6) at break.c:63 63 if (value > 1) { /* set breakpoint 7 here */ #0 factorial (value=6) at break.c:63 #1 0x00000000004004f8 in main (argc=1, argv=0x7fffffffd238, envp=0x7fffffffd248) at break.c:47 Note that this worked perfectly well, but... With your patch: $ /home/kevinb-claude/installs/cycles-patched/bin/gdb \ -q -nx -batch -iex 'set debuginfod enabled off' \ -ex 'break factorial if value > 1 && factorial (value - 1) > 100' \ -ex run -ex bt ./break Breakpoint 1 at 0x40055b: file break.c, line 63. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Error in testing condition for breakpoint 1: Aborting expression evaluation for the conditional bp: A cycle was detected during the evaluation. Breakpoint 1, factorial (value=5) at break.c:63 63 if (value > 1) { /* set breakpoint 7 here */ Error in testing condition for breakpoint 1: The program being debugged stopped while in a function called from GDB. Evaluation of the expression containing the function (factorial) will be abandoned. When the function is done executing, GDB will silently stop. #0 factorial (value=5) at break.c:63 #1 #2 factorial (value=6) at break.c:63 #3 0x00000000004004f8 in main (argc=1, argv=0x7fffffffd238, envp=0x7fffffffd248) at break.c:47 In any case, it'd be nice to have a way to run cases like this which terminate naturally. Also, I think that it'd be better if the new error message would use the word "breakpoint" instead of "bp". The AI mentioned that some wording involving "reentry" would be preferable to "cycle", but I find that your wording (with cycle) better conveys the problem to me. Kevin