From patchwork Thu May 25 12:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 70076 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 E4A653858418 for ; Thu, 25 May 2023 12:58:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4A653858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685019487; bh=Y4tkU1PqsMrZFwMSXssdSmkRkl2mbLOd5o0vPTvpgME=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xP2jcCVUjDK16OdkuLLSnbRe+19THDFYhruaA/OVlELENDVtulqzU9iJUmAIGTYk/ nVP6N2KCCR8xoDVkUKfNyNHXrGF/PMuODWBoixsSKW47YF9d0egqlXG2g+bTOuYVva J0z6iZ01U3lXMN5QHRVRH9h9f7NEKEo1VJgeGqlg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 8394C3858D32 for ; Thu, 25 May 2023 12:57:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8394C3858D32 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-33818ccd411so15365465ab.1 for ; Thu, 25 May 2023 05:57:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685019465; x=1687611465; 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=Y4tkU1PqsMrZFwMSXssdSmkRkl2mbLOd5o0vPTvpgME=; b=eG7dUq5WSGgsf+5q3sOjaB8ERuGrXzwHxN97E6itJO3JrbJQywyUd4aiO93Z3oDNbZ 6q0PJWVMij2Va0Lxs3Q9Me8qEUAnafys4jUSn3lfZdDhSZlr7BCDT+RMpfWoj5OC1BjI 9S3XRen3MKfCyo4UQZsm9sU4AAsirKRTHxdVg0uvOi4v3a2/+HneV5wGqGIItwLRMi2p W5s+tm19eg5F9RP61tASh7F1vJ9VFITBONtOlRHw+IwxZ8PnP1U/PgOcqNW/BNEqu3XJ f7gztHpn4xo87jB5N7MOMVwCtrcBzf/DHi1CArVOobgezluzQJtSYVSEWjTcY/kpmbuy kE7A== X-Gm-Message-State: AC+VfDw4P+Piv6J3hyHZHHbhNunNMMr4PjE2YleOYco8YKWTb1ejmRrY LaTkbf523qv40AdGxbpwMJGIvP9RKg+6rYauomL0hw== X-Google-Smtp-Source: ACHHUZ4l3HlWjdjhEvkquDmMQ+MOooX3NNhxl9QCppK6AfSMN8GXOfc4LLm6JsvW22eUaOFV/7J9Wg== X-Received: by 2002:a92:dc47:0:b0:338:d170:6e32 with SMTP id x7-20020a92dc47000000b00338d1706e32mr12180763ilq.7.1685019464780; Thu, 25 May 2023 05:57:44 -0700 (PDT) Received: from localhost.localdomain (71-211-130-244.hlrn.qwest.net. [71.211.130.244]) by smtp.gmail.com with ESMTPSA id t16-20020a056638349000b0041aafdf3d29sm426682jal.45.2023.05.25.05.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 05:57:44 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use scoped_value_mark in two more places Date: Thu, 25 May 2023 06:57:37 -0600 Message-Id: <20230525125737.1849340-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 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: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I found a couple of spots that could use scoped_value_mark. One of them is a spot that didn't consider the possibility that value_mark can return NULL. I tend to doubt this can be seen in this context, but nevertheless this is safer. Regression tested on x86-64 Fedora 36. --- gdb/f-lang.c | 15 +++++++-------- gdb/value.c | 8 +++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 365e0c0489b..9f579c5c990 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -261,8 +261,8 @@ class fortran_array_repacker_base_impl { if (inner_p) { - gdb_assert (m_mark == nullptr); - m_mark = value_mark (); + gdb_assert (!m_mark.has_value ()); + m_mark.emplace (); } } @@ -272,9 +272,8 @@ class fortran_array_repacker_base_impl { if (inner_p) { - gdb_assert (m_mark != nullptr); - value_free_to_mark (m_mark); - m_mark = nullptr; + gdb_assert (m_mark.has_value ()); + m_mark.reset (); } } @@ -295,9 +294,9 @@ class fortran_array_repacker_base_impl written. */ LONGEST m_dest_offset; - /* Set with a call to VALUE_MARK, and then reset after calling - VALUE_FREE_TO_MARK. */ - struct value *m_mark = nullptr; + /* Set and reset to handle removing intermediate values from the + value chain. */ + gdb::optional m_mark; }; /* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array diff --git a/gdb/value.c b/gdb/value.c index 980722a6dd7..fb9466493b5 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3878,7 +3878,9 @@ value::fetch_lazy_register () frame_info_ptr next_frame; int regnum; struct type *type = check_typedef (this->type ()); - struct value *new_val = this, *mark = value_mark (); + struct value *new_val = this; + + scoped_value_mark mark; /* Offsets are not supported here; lazy register values must refer to the entire register. */ @@ -3982,10 +3984,6 @@ value::fetch_lazy_register () frame_debug_printf ("%s", debug_file.c_str ()); } - - /* Dispose of the intermediate values. This prevents - watchpoints from trying to watch the saved frame pointer. */ - value_free_to_mark (mark); } /* See value.h. */