From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 42034385800A for ; Thu, 3 Jun 2021 09:22:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 42034385800A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x332.google.com with SMTP id t16-20020a05600c1990b02901a0d45ff03aso1898416wmq.2 for ; Thu, 03 Jun 2021 02:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TTdUCGWeBsCB0DVN6GzgvJYMp9NbjVXo/5AaKILh8tc=; b=Om8gVL7iX7OkJVjK48c8aeAE2liw327iMLUMK69mzdrIK8vYMFLMDtSn4W7xE4UQCF mdh0czYB1RDO8dr60JPZ+/QjCm+D3UWXShU3MirlsI2gWS8D+JQ+mzxolJm1E3Q9nBmL 8X2dRkXSbP9biJARr1Sc3bOVeflfqgq4Ti9bDxwS00t/ASn5XSwsMzQjgbnppwJ1q02s gUwAs++G15/mvjMbL3HOPoK5lT6nEykl1+rue2JtFqtMwl+kaYz0G040KeoX2qPe6lp/ AQglLPpPMnZdl/YmGzEyy7vshEmsyP1m98BzkpwH7d5IMijZfjhYHIYjcptrqtWV6Zwn hxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TTdUCGWeBsCB0DVN6GzgvJYMp9NbjVXo/5AaKILh8tc=; b=SeA7Hdng7TgSM1YSCINX2Jrtq9944xe4ilsSNfBODIE1tXFUBK/GYFjzx9ZpZQ+gkr EnniIlcmQU3wDptxDM/ndTKC46exHjyAX8cSYDwoBhRcLhYZ1ava++lIhesOzQtQW+5W 6SOfQoVdfqYd61uTCNv/XGbnsoFSSLGZHrgUGlarY6fxzF6xeZSvrcMk8LiVncEiDw6e d26LnKfyM6ECfB9dItWqLRQTw9E6iIfI1Ki8rLfKdztZFLRbCvljuU2zhxiJKDXAIGO4 NeCJh8MUK7PLiYREYVxcdBEtzffdKrMA7o7y+7GdlVqTY42cSCFWyJCZrwKIQ3wqheBV whpg== X-Gm-Message-State: AOAM533dGmIih944TkV8zQByIkRYuGVC9eVvBXtYCM2TvXfx3iI8FPwY 5pyTTxnIisA0sx/1HtYpNDLG1eLW1keJBQ== X-Google-Smtp-Source: ABdhPJxd/JPsD8J4eN7+COHfNGc1bdMizyWj+ORULVWoeHB9KNulknUkiOUe481oiP3UgUW1qoauiQ== X-Received: by 2002:a1c:7313:: with SMTP id d19mr35991841wmb.14.1622712175636; Thu, 03 Jun 2021 02:22:55 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id h9sm2095167wmb.35.2021.06.03.02.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 02:22:55 -0700 (PDT) Date: Thu, 3 Jun 2021 10:22:54 +0100 From: Andrew Burgess To: George Barrett Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] guile: fix smob exports Message-ID: <20210603092254.GM2672@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:17:09 up 14 days, 23:01, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-12.1 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 03 Jun 2021 09:22:59 -0000 * George Barrett via Gdb-patches [2021-05-20 08:27:50 +1000]: > Before Guile v2.1[1], calls to `scm_make_smob_type' implicitly > added the created class to the exports list of (oop goops); v2.1+ does > not implicitly create bindings in any modules. This means that the GDB > manual subsection documenting exported types is not quite right when > GDB is linked against Guile goops)) instead of (gdb)) and incorrect when linked against Guile > v2.1+ (types are not bound to any variables at all!). > > This commit makes a small change to GDB's smob registration machinery > to make sure registered smobs get exported from the current > module. This will likely cause warnings to the user about conflicting > exports if they load both (gdb) and (oop goops) from a GDB linked > against Guile v2.0, but it shouldn't impact functionality (and seemed > preferable to trying to un-export bindings from (oop goops) if v2.0 > was detected). > > [1]: This changed with Guile commit > 28d0871b553a3959a6c59e2e4caec1c1509f8595 > > gdb/ChangeLog: > > 2021-05-20 George Barrett > > * guile/scm-gsmob.c (gdbscm_make_smob_type): Export registered > smob type from the current module. > > gdb/testsuite/ChangeLog: > > 2021-05-20 George Barrett > > * gdb.guile/scm-gsmob.exp (test exports): Add tests to make > sure the smob types currently listed in the GDB manual get > exported from the (gdb) module. > --- > gdb/guile/scm-gsmob.c | 9 ++++++++- > gdb/testsuite/gdb.guile/scm-gsmob.exp | 28 +++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/gdb/guile/scm-gsmob.c b/gdb/guile/scm-gsmob.c > index c623b07d26c..a8ab63a67b5 100644 > --- a/gdb/guile/scm-gsmob.c > +++ b/gdb/guile/scm-gsmob.c > @@ -96,7 +96,8 @@ gdbscm_is_gsmob (SCM scm) > return slot != NULL; > } > > -/* Call this to register a smob, instead of scm_make_smob_type. */ > +/* Call this to register a smob, instead of scm_make_smob_type. > + Exports the created smob type from the current module. */ > > scm_t_bits > gdbscm_make_smob_type (const char *name, size_t size) > @@ -104,6 +105,12 @@ gdbscm_make_smob_type (const char *name, size_t size) > scm_t_bits result = scm_make_smob_type (name, size); > > register_gsmob (result); > + > + SCM smob_type = scm_smob_type_class (result); I don't know if we have a defined earliest supported version of guile, but I tried building again guile 2.0.14 with this patch applied and the build failed at the above line as scm_smob_type_class was not known. Before this patch 2.0.14 would build fine. > + SCM smob_type_name = scm_class_name (smob_type); > + scm_define (smob_type_name, smob_type); There's also scm_c_define which looks like it would do the same thing without us having to lookup the type name? We could just pass name through directly. NOTE: I'm no guile expert, so if what I just said is rubbish, please do say so. > + scm_module_export (scm_current_module (), scm_list_1 (smob_type_name)); > + > return result; > } > > diff --git a/gdb/testsuite/gdb.guile/scm-gsmob.exp b/gdb/testsuite/gdb.guile/scm-gsmob.exp > index 90c32df7dda..d2a77198a23 100644 > --- a/gdb/testsuite/gdb.guile/scm-gsmob.exp > +++ b/gdb/testsuite/gdb.guile/scm-gsmob.exp > @@ -66,3 +66,31 @@ set prop_list [lsort $prop_list] > verbose -log "prop_list: $prop_list" > gdb_test "gu (print (sort (map car (object-properties arch)) (lambda (a b) (stringstring a) (symbol->string b)))))" \ > "= \\($prop_list\\)" "object-properties" > + > +# Check that smob classes are exported properly Missing '.' at the end here. > +with_test_prefix "test exports" { > + # For is-a? and Could you change this to 'Import (oop goops) for is-a? and .', this comment really puzzled me for a while. > + gdb_scm_test_silent_cmd "gu (use-modules (oop goops))" "import goops" > + gdb_test_no_output "gu (define-syntax-rule (gdb-exports-class? x) (is-a? (@ (gdb) x) ))" > + > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > + gdb_test "gu (print (gdb-exports-class? ))" "= #t" > +} > -- > 2.31.1