This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 2/9] Define and export Guile classes for all GDB object types
- From: Andy Wingo <wingo at igalia dot com>
- To: gdb-patches at sourceware dot org
- Cc: Andy Wingo <wingo at igalia dot com>
- Date: Thu, 17 Apr 2014 12:46:21 +0200
- Subject: [PATCH v2 2/9] Define and export Guile classes for all GDB object types
- Authentication-results: sourceware.org; auth=none
- References: <1397731588-23750-1-git-send-email-wingo at igalia dot com>
gdb/ChangeLog:
* guile/scm-gsmob.c (gdbscm_make_smob_type): Define a binding
for a GOOPS class corresponding to the SMOB type.
(gdbscm_initialize_smobs): Load GOOPS.
* guile/lib/gdb.scm: Export the GOOPS classes.
---
gdb/ChangeLog | 8 ++++++++
gdb/guile/lib/gdb.scm | 17 +++++++++++++++++
gdb/guile/scm-gsmob.c | 20 +++++++++++++++++++-
gdb/testsuite/gdb.guile/scm-generics.exp | 2 +-
4 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ec8f7b2..36dbce0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2014-04-17 Andy Wingo <wingo@igalia.com>
+ * guile/scm-gsmob.c (gdbscm_make_smob_type): Define a binding
+ for a GOOPS class corresponding to the SMOB type.
+ (gdbscm_initialize_smobs): Load GOOPS.
+
+ * guile/lib/gdb.scm: Export the GOOPS classes.
+
+2014-04-17 Andy Wingo <wingo@igalia.com>
+
* configure.ac (try_guile_versions): Allow building with Guile
2.2.
* configure: Regenerate.
diff --git a/gdb/guile/lib/gdb.scm b/gdb/guile/lib/gdb.scm
index f12769e..98eb388 100644
--- a/gdb/guile/lib/gdb.scm
+++ b/gdb/guile/lib/gdb.scm
@@ -50,6 +50,7 @@
;; scm-arch.c
+ <gdb:arch>
arch?
current-arch
arch-name
@@ -85,6 +86,7 @@
;; scm-block.c
+ <gdb:block>
block?
block-valid?
block-start
@@ -96,6 +98,7 @@
block-global?
block-static?
block-symbols
+ <gdb:block-symbols-iterator>
make-block-symbols-iterator
block-symbols-progress?
lookup-block
@@ -113,6 +116,7 @@
WP_WRITE
WP_ACCESS
+ <gdb:breakpoint>
make-breakpoint
breakpoint-delete!
breakpoints
@@ -147,6 +151,7 @@
;; scm-exception.c
+ <gdb:exception>
make-exception
exception?
exception-key
@@ -170,6 +175,7 @@
FRAME_UNWIND_SAME_ID
FRAME_UNWIND_NO_SAVED_PC
+ <gdb:frame>
frame?
frame-valid?
frame-name
@@ -190,6 +196,7 @@
;; scm-iterator.c
+ <gdb:iterator>
make-iterator
iterator?
iterator-object
@@ -202,6 +209,7 @@
;; scm-lazy-string.c
;; FIXME: Where's the constructor?
+ <gdb:lazy-string>
lazy-string?
lazy-string-address
lazy-string-length
@@ -238,6 +246,7 @@
;; scm-objfile.c
+ <gdb:objfile>
objfile?
objfile-valid?
objfile-filename
@@ -263,10 +272,12 @@
;; scm-pretty-print.c
+ <gdb:pretty-printer>
make-pretty-printer
pretty-printer?
pretty-printer-enabled?
set-pretty-printer-enabled!
+ <gdb:pretty-printer-worker>
make-pretty-printer-worker
pretty-printer-worker?
@@ -308,6 +319,7 @@
SYMBOL_FUNCTIONS_DOMAIN
SYMBOL_TYPES_DOMAIN
+ <gdb:symbol>
symbol?
symbol-valid?
symbol-type
@@ -328,6 +340,7 @@
;; scm-symtab.c
+ <gdb:symtab>
symtab?
symtab-valid?
symtab-filename
@@ -335,6 +348,7 @@
symtab-objfile
symtab-global-block
symtab-static-block
+ <gdb:sal>
sal?
sal-valid?
sal-symtab
@@ -372,6 +386,7 @@
TYPE_CODE_DECFLOAT
TYPE_CODE_INTERNAL_FUNCTION
+ <gdb:type>
type?
lookup-type
type-code
@@ -394,6 +409,7 @@
make-field-iterator
type-field
type-has-field?
+ <gdb:field>
field?
field-name
field-type
@@ -405,6 +421,7 @@
;; scm-value.c
+ <gdb:value>
value?
make-value
value-optimized-out?
diff --git a/gdb/guile/scm-gsmob.c b/gdb/guile/scm-gsmob.c
index b0f9e19..1fbd193 100644
--- a/gdb/guile/scm-gsmob.c
+++ b/gdb/guile/scm-gsmob.c
@@ -120,7 +120,22 @@ gdbscm_is_gsmob (SCM scm)
scm_t_bits
gdbscm_make_smob_type (const char *name, size_t size)
{
- scm_t_bits result = scm_make_smob_type (name, size);
+ scm_t_bits result;
+ SCM klass;
+ char *class_name;
+
+ /* In Guile 2.0, defining a new SMOB type causes the binding to also be
+ exported by (oop goops), but this is deprecated behavior and is no longer
+ the case in Guile 2.2. Here we arrange to export the class names from
+ (gdb). */
+
+ result = scm_make_smob_type (name, size);
+
+ klass = scm_smob_class[SCM_TC2SMOBNUM (result)];
+ gdb_assert (SCM_UNPACK (klass) != 0);
+ class_name = xstrprintf ("<%s>", name);
+ scm_c_define (class_name, klass);
+ xfree (class_name);
register_gsmob (result);
return result;
@@ -475,6 +490,9 @@ Return an unsorted list of names of properties." },
void
gdbscm_initialize_smobs (void)
{
+ /* Load GOOPS, so that scm_make_smob_type defines GOOPS classes eagerly. */
+ scm_c_use_module ("oop goops");
+
registered_gsmobs = htab_create_alloc (10,
hash_scm_t_bits, eq_scm_t_bits,
NULL, xcalloc, xfree);
diff --git a/gdb/testsuite/gdb.guile/scm-generics.exp b/gdb/testsuite/gdb.guile/scm-generics.exp
index 664affc..b64ea11 100644
--- a/gdb/testsuite/gdb.guile/scm-generics.exp
+++ b/gdb/testsuite/gdb.guile/scm-generics.exp
@@ -30,7 +30,7 @@ gdb_reinitialize_dir $srcdir/$subdir
gdb_install_guile_utils
gdb_install_guile_module
-gdb_test_no_output "guile (use-modules ((oop goops)))"
+gdb_test_no_output "guile (use-modules (oop goops))"
gdb_test_no_output "guile (define-generic +)"
gdb_test_no_output "guile (define-method (+ (x <gdb:value>) (y <gdb:value>)) (value-add x y))"
--
1.9.1