From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3420738319D5 for ; Fri, 21 Jun 2024 18:22:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3420738319D5 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 3420738319D5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718994130; cv=none; b=CUw1uyFwhdL9lNjLZfdtiZXYclL2/bdShcBhApobPcT020aF0nww3hoPhw/vUVZLCKfeZ2WVoWnASK3/dho6BMfWtT7kyDlW7cpYKHw7JxgHNc1f1FmxR/2dML+ZAWdodi/bBd2RvrHzTy1fCc+0QgMZLAH70BK8uOfVxRoQ4Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718994130; c=relaxed/simple; bh=etix8fM9bwCezDPKOM7bZeo7pzR8KqEmVHVVTKMYhXc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VhRf/jW96b7DWay8/CAwaRvqJf4FmpZ1jKnV8cVYWBwcN6laL3YLu2pLOEcQFG5RBp8W9CCaGTwLRcqO+2j4IASvDgQVAE69qdnz9IsWNJpZUiqOTQ5Sjc/jnPuaS7wXaRJGsYCQ85kDGqo9asAggW8t1NSm0xj9N3VWK0WjtCE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718994128; 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=CvVHNwT9ft0eQWtFiXh/SD8GmhZJGmulqwevcbMwJsE=; b=V/4X4s3JtNac8UJolVZJ4ZKrOnSDcvby8t0Vm0Uo4domyeAqdQmJ6SxwIlRcWTfj+KAp8j MYosAzcRfhSAPB9i9opuUjlWjVJnzqoBVs6R4mOqi0YmlbtvTpw4R/lVZ/SdkownAOpap6 VMEybgg5RWr8hZz0rTFHcBTCmE6lRfY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-dyZQ-gvzPQiwt8nTA3pQfg-1; Fri, 21 Jun 2024 14:22:05 -0400 X-MC-Unique: dyZQ-gvzPQiwt8nTA3pQfg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B773D1956088 for ; Fri, 21 Jun 2024 18:22:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.13]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 590DF19560B6; Fri, 21 Jun 2024 18:22:03 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH 1/4] gdb, record: Introduce record_full_following_entry function Date: Fri, 21 Jun 2024 15:09:16 -0300 Message-ID: <20240621180918.860097-3-blarsen@redhat.com> In-Reply-To: <20240621180918.860097-2-blarsen@redhat.com> References: <20240621180918.860097-2-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.3 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_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,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 List-Id: While replaying the inferior, there are a couple repetitions of a code pattern: 1. Check the direction of execution of the inferior 2. Check if there is another entry that direction 3. Advance the current location to the next entry The following commit would add one more use of this pattern, and it felt like a good idea to separate this into it's own small function, so this commit does that. I also changed the checks into asserts, since not having a following entry would lead to an infinite loop in waiting for the inferior, so this failure should be easier to spot. This patch shouldn't have any user-visible changes. --- gdb/record-full.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/gdb/record-full.c b/gdb/record-full.c index eb62d186fa5..1de3ae0a1c8 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -462,6 +462,21 @@ record_full_end_release (struct record_full_entry *rec) xfree (rec); } +/* Convenience function to find the next entry in the history, based on + the current execution direction. This should be called only when we + are sure there is a following entry. */ +static struct record_full_entry * +record_full_following_entry (struct record_full_entry *curr) +{ + if (execution_direction == EXEC_REVERSE) + { + gdb_assert (curr->prev); + return curr->prev; + } + gdb_assert (curr->next); + return curr->next; +} + /* Free one record entry, any type. Return entry->type, in case caller wants to know. */ @@ -1418,18 +1433,7 @@ record_full_wait_1 (struct target_ops *ops, } if (continue_flag) - { - if (execution_direction == EXEC_REVERSE) - { - if (record_full_list->prev) - record_full_list = record_full_list->prev; - } - else - { - if (record_full_list->next) - record_full_list = record_full_list->next; - } - } + record_full_list = record_full_following_entry (record_full_list); } while (continue_flag); @@ -1447,13 +1451,7 @@ record_full_wait_1 (struct target_ops *ops, } catch (const gdb_exception &ex) { - if (execution_direction == EXEC_REVERSE) - { - if (record_full_list->next) - record_full_list = record_full_list->next; - } - else - record_full_list = record_full_list->prev; + record_full_list = record_full_following_entry (record_full_list); throw; } -- 2.45.2