From patchwork Thu Apr 17 13:39:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Wingo X-Patchwork-Id: 608 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id DCE99360060 for ; Thu, 17 Apr 2014 06:39:22 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 758C962B04C3F; Thu, 17 Apr 2014 06:39:22 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id EA59662B0880B for ; Thu, 17 Apr 2014 06:39:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type; q=dns; s=default; b=sq8xXjz2ryJyViGq NWJx9mOVaBT2E1bdNeerY0h7Lf/JqJjgNcTn6b3DaEkA9KzXwzLTb/mJixCaGSSy 4+tQcypIYLAImwrg6JNahT5o9ga4OzQTgxHRsQltIpSq1U/Fx/ie4zaPjnh5D/q6 dJoaH9POQ5e2zOsljZxQVuifzuM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type; s=default; bh=uBLJ4qWmh2UXYzdvc88ZtI q6K6Y=; b=LYlQgCvc5O7BU5Av1c1AW8+U5huEizTSbea1wqOVyWF8U7U5c/V6RA /wTT5GXg/5WjATxPIBaLSZO8cUP/StHHGSAuhs+GoQ4uCWbXlexaRZ4dbEBIZlem 1H905JXwXhYwZDow4LyniB9KbNRpQdkoAoQQ+PzydFFzGZ/AmyX+Y= Received: (qmail 6441 invoked by alias); 17 Apr 2014 13:39:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 6421 invoked by uid 89); 17 Apr 2014 13:39:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: sasl.smtp.pobox.com Received: from a-pb-sasl-quonix.pobox.com (HELO sasl.smtp.pobox.com) (208.72.237.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Apr 2014 13:39:18 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 0872EF7D7; Thu, 17 Apr 2014 09:39:16 -0400 (EDT) Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id F2A26F7D6; Thu, 17 Apr 2014 09:39:15 -0400 (EDT) Received: from rusty (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id F089BF7D5; Thu, 17 Apr 2014 09:39:13 -0400 (EDT) From: Andy Wingo To: gdb-patches@sourceware.org Cc: wingo@igalia.com Subject: [PATCH] [guile] Run finalizers from GDB thread Date: Thu, 17 Apr 2014 15:39:11 +0200 Message-ID: <87sipcqdmo.fsf@igalia.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: AA219F36-C635-11E3-B5DA-873F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-DH-Original-To: gdb@patchwork.siddhesh.in gdb/ChangeLog: * guile/guile.c (_initialize_guile): Disable automatic finalization, if Guile offers us that possibility. * guile/guile.c (call_initialize_gdb_module): * guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run finalizers in appropriate places. * configure.ac: Add a check for scm_set_automatic_finalization_enabled. --- gdb/ChangeLog | 12 ++++++++++++ gdb/configure.ac | 5 +++++ gdb/guile/guile.c | 11 +++++++++++ gdb/guile/scm-safe-call.c | 4 ++++ 4 files changed, 32 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e408e2e..73c147f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2014-04-17 Andy Wingo + * guile/guile.c (_initialize_guile): Disable automatic + finalization, if Guile offers us that possibility. + + * guile/guile.c (call_initialize_gdb_module): + * guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run + finalizers in appropriate places. + + * configure.ac: Add a check for + scm_set_automatic_finalization_enabled. + +2014-04-17 Andy Wingo + * guile/scm-symtab.c (stscm_free_sal_smob): Remove useless free function. (This was the only useless free function.) diff --git a/gdb/configure.ac b/gdb/configure.ac index ff84a2e..06f2bf1 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1112,6 +1112,11 @@ AC_DEFUN([AC_TRY_LIBGUILE], GUILE_CPPFLAGS=$new_CPPFLAGS GUILE_LIBS=$new_LIBS], [found_usable_guile=no]) + dnl scm_set_automatic_finalization_enabled added in Guile 2.2. + AC_CHECK_FUNC(scm_set_automatic_finalization_enabled, + AC_DEFINE(HAVE_GUILE_MANUAL_FINALIZATION, 1, + [Define if Guile supports manual finalization.]) + ) CPPFLAGS=$save_CPPFLAGS LIBS=$save_LIBS if test "${found_usable_guile}" = no; then diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index f2fd8d8..f488e12 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -572,6 +572,10 @@ call_initialize_gdb_module (void *data) performed within the desired module. */ scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL); +#if HAVE_GUILE_MANUAL_FINALIZATION + scm_run_finalizers (); +#endif + return NULL; } @@ -715,6 +719,13 @@ _initialize_guile (void) side to define module "gdb" which imports "_gdb". There is evidently no similar convention in Guile so we skip this. */ +#if HAVE_GUILE_MANUAL_FINALIZATION + /* Our SMOB free functions are not thread-safe, as GDB itself is not intended + to be thread-safe. Disable automatic finalization so that finalizers + aren't run in other threads. */ + scm_set_automatic_finalization_enabled (0); +#endif + /* scm_with_guile is the most portable way to initialize Guile. Plus we need to initialize the Guile support while in Guile mode (e.g., called from within a call to scm_with_guile). */ diff --git a/gdb/guile/scm-safe-call.c b/gdb/guile/scm-safe-call.c index 147d7f5..6b6de93 100644 --- a/gdb/guile/scm-safe-call.c +++ b/gdb/guile/scm-safe-call.c @@ -156,6 +156,10 @@ gdbscm_with_catch (void *data) d->unwind_handler, d, d->pre_unwind_handler, d); +#if HAVE_GUILE_MANUAL_FINALIZATION + scm_run_finalizers (); +#endif + return NULL; }