From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id F03953858D20; Tue, 27 Feb 2024 17:38:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F03953858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709055513; bh=rs0JOnRtjxZl4jxS7wci4LcVttBgPNouXtkxVhCx+ys=; h=From:To:Subject:Date:From; b=ySs28m95LmYb2pb43akAy9tBzj+gyAv4LBjzaEPpVlNboWT1yd0TWvd7Fhrp72muo GcaqPUG+3DCIcTtxllIqBK4zKnNnPdTQ2xmLABl9TwsuMVIJLJuLikseTSp9KPJ5VX UWPwlPaBqMgl0xOUAEMJ0YmN9DCHohVv0iTC07xc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Change finalize_values into a final cleanup X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: beadf912845c9c37c5afeadd77635950cf697d9f X-Git-Newrev: ec471b627aa76fa8ac1f103ecabd73e304e952c8 Message-Id: <20240227173833.F03953858D20@sourceware.org> Date: Tue, 27 Feb 2024 17:38:33 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dec471b627aa7= 6fa8ac1f103ecabd73e304e952c8 commit ec471b627aa76fa8ac1f103ecabd73e304e952c8 Author: Tom Tromey Date: Fri Feb 23 13:24:03 2024 -0700 Change finalize_values into a final cleanup =20 This removes finalize_values in favor of adding a new final cleanup. This is safe now that extension languages are explicitly shut down. Diff: --- gdb/top.c | 6 ------ gdb/value.c | 15 ++++++++------- gdb/value.h | 4 ---- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/gdb/top.c b/gdb/top.c index 67d6670cd9c..cf7d3a913ba 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1803,12 +1803,6 @@ quit_force (int *exit_arg, int from_tty) exception_print (gdb_stderr, ex); } =20 - /* Destroy any values currently allocated now instead of leaving it - to global destructors, because that may be too late. For - example, the destructors of xmethod values call into the Python - runtime, which is finalized via a final cleanup. */ - finalize_values (); - /* Do any final cleanups before exiting. */ try { diff --git a/gdb/value.c b/gdb/value.c index c7e940badb9..a2b2721d183 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -4499,12 +4499,13 @@ and exceeds this limit will cause an error."), selftests::test_insert_into_bit_range_vector); selftests::register_test ("value_copy", selftests::test_value_copy); #endif -} - -/* See value.h. */ =20 -void -finalize_values () -{ - all_values.clear (); + /* Destroy any values currently allocated in a final cleanup instead + of leaving it to global destructors, because that may be too + late. For example, the destructors of xmethod values call into + the Python runtime. */ + add_final_cleanup ([] () + { + all_values.clear (); + }); } diff --git a/gdb/value.h b/gdb/value.h index e8d3c9fd907..9d7e88d9433 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1630,10 +1630,6 @@ struct value *call_internal_function (struct gdbarch= *gdbarch, =20 const char *value_internal_function_name (struct value *); =20 -/* Destroy the values currently allocated. This is called when GDB is - exiting (e.g., on quit_force). */ -extern void finalize_values (); - /* Convert VALUE to a gdb_mpq. The caller must ensure that VALUE is of floating-point, fixed-point, or integer type. */ extern gdb_mpq value_to_gdb_mpq (struct value *value);