aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-07-26 14:58:58 -0700
committerDoug Evans <xdje42@gmail.com>2014-07-26 14:58:58 -0700
commitee7333ae06f46f3a6909a0059c2f0bd441a54bfe (patch)
treee1c478aacb968406633bb216ccf56be62a25ca60 /gdb/guile
parent74edf51613b507d1f27d66360cd8fdd8a253e88a (diff)
downloadgdb-ee7333ae06f46f3a6909a0059c2f0bd441a54bfe.zip
gdb-ee7333ae06f46f3a6909a0059c2f0bd441a54bfe.tar.gz
gdb-ee7333ae06f46f3a6909a0059c2f0bd441a54bfe.tar.bz2
PR guile/17177
* guile/lib/gdb.scm (pretty-printers): Export. (set-pretty-printers!): Export. * guile/lib/gdb/printing.scm (gdb module): Update. (prepend-pretty-printer!, append-pretty-printer!): Update. * guile/scm-pretty-print.c (pretty_printer_list_name): Delete. (pretty_printer_list_var): Delete. (pretty_printer_list): New static global. (gdbscm_pretty_printers): New function. (gdbscm_set_pretty_printers_x): New function. (ppscm_find_pretty_printer_from_gdb): Update. (pretty_printer_functions): Add pretty-printers, set-pretty-printers!. (gdbscm_initialize_pretty_printers): Update. doc/ * guile.texi (Guile Pretty Printing API): Fix typo. Document set-pretty-printers!, pretty-printers. (Selecting Guile Pretty-Printers): Update. Mention program-space based pretty-printers.
Diffstat (limited to 'gdb/guile')
-rw-r--r--gdb/guile/lib/gdb.scm2
-rw-r--r--gdb/guile/lib/gdb/printing.scm7
-rw-r--r--gdb/guile/scm-pretty-print.c51
3 files changed, 42 insertions, 18 deletions
diff --git a/gdb/guile/lib/gdb.scm b/gdb/guile/lib/gdb.scm
index 120fcc6..4fd4699 100644
--- a/gdb/guile/lib/gdb.scm
+++ b/gdb/guile/lib/gdb.scm
@@ -319,6 +319,8 @@
set-pretty-printer-enabled!
make-pretty-printer-worker
pretty-printer-worker?
+ pretty-printers
+ set-pretty-printers!
;; scm-progspace.c
diff --git a/gdb/guile/lib/gdb/printing.scm b/gdb/guile/lib/gdb/printing.scm
index eac9417..2d1274f 100644
--- a/gdb/guile/lib/gdb/printing.scm
+++ b/gdb/guile/lib/gdb/printing.scm
@@ -19,7 +19,8 @@
(define-module (gdb printing)
#:use-module ((gdb) #:select
- (*pretty-printers* pretty-printer? objfile? progspace?
+ (pretty-printer? objfile? progspace?
+ pretty-printers set-pretty-printers!
objfile-pretty-printers set-objfile-pretty-printers!
progspace-pretty-printers set-progspace-pretty-printers!))
#:use-module (gdb init))
@@ -30,7 +31,7 @@ If OBJ is #f, add MATCHER to the global list."
(%assert-type (pretty-printer? matcher) matcher SCM_ARG1
'prepend-pretty-printer!)
(cond ((eq? obj #f)
- (set! *pretty-printers* (cons matcher *pretty-printers*)))
+ (set-pretty-printers! (cons matcher (pretty-printers))))
((objfile? obj)
(set-objfile-pretty-printers!
obj (cons matcher (objfile-pretty-printers obj))))
@@ -46,7 +47,7 @@ If OBJ is #f, add MATCHER to the global list."
(%assert-type (pretty-printer? matcher) matcher SCM_ARG1
'append-pretty-printer!)
(cond ((eq? obj #f)
- (set! *pretty-printers* (append! *pretty-printers* (list matcher))))
+ (set-pretty-printers! (append! (pretty-printers) (list matcher))))
((objfile? obj)
(set-objfile-pretty-printers!
obj (append! (objfile-pretty-printers obj) (list matcher))))
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index e20da68..79b9e64 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -111,11 +111,8 @@ static const char pretty_printer_worker_smob_name[] =
static scm_t_bits pretty_printer_smob_tag;
static scm_t_bits pretty_printer_worker_smob_tag;
-/* Global list of pretty-printers. */
-static const char pretty_printer_list_name[] = "*pretty-printers*";
-
-/* The *pretty-printer* variable. */
-static SCM pretty_printer_list_var;
+/* The global pretty-printer list. */
+static SCM pretty_printer_list;
/* gdb:pp-type-error. */
static SCM pp_type_error_symbol;
@@ -239,6 +236,29 @@ gdbscm_set_pretty_printer_enabled_x (SCM self, SCM enabled)
return SCM_UNSPECIFIED;
}
+
+/* (pretty-printers) -> list
+ Returns the list of global pretty-printers. */
+
+static SCM
+gdbscm_pretty_printers (void)
+{
+ return pretty_printer_list;
+}
+
+/* (set-pretty-printers! list) -> unspecified
+ Set the global pretty-printers list. */
+
+static SCM
+gdbscm_set_pretty_printers_x (SCM printers)
+{
+ SCM_ASSERT_TYPE (gdbscm_is_true (scm_list_p (printers)), printers,
+ SCM_ARG1, FUNC_NAME, _("list"));
+
+ pretty_printer_list = printers;
+
+ return SCM_UNSPECIFIED;
+}
/* Administrivia for pretty-printer-worker smobs.
These are created when a matcher recognizes a value. */
@@ -457,11 +477,8 @@ ppscm_find_pretty_printer_from_progspace (SCM value)
static SCM
ppscm_find_pretty_printer_from_gdb (SCM value)
{
- SCM pp_list, pp;
+ SCM pp = ppscm_search_pp_list (pretty_printer_list, value);
- /* Fetch the global pretty printer list. */
- pp_list = scm_variable_ref (pretty_printer_list_var);
- pp = ppscm_search_pp_list (pp_list, value);
return pp;
}
@@ -1074,6 +1091,15 @@ Create a <gdb:pretty-printer-worker> object.\n\
"\
Return #t if the object is a <gdb:pretty-printer-worker> object." },
+ { "pretty-printers", 0, 0, 0, gdbscm_pretty_printers,
+ "\
+Return the list of global pretty-printers." },
+
+ { "set-pretty-printers!", 1, 0, 0,
+ gdbscm_set_pretty_printers_x,
+ "\
+Set the list of global pretty-printers." },
+
END_FUNCTIONS
};
@@ -1094,12 +1120,7 @@ gdbscm_initialize_pretty_printers (void)
gdbscm_define_functions (pretty_printer_functions, 1);
- scm_c_define (pretty_printer_list_name, SCM_EOL);
-
- pretty_printer_list_var
- = scm_c_private_variable (gdbscm_module_name,
- pretty_printer_list_name);
- gdb_assert (!gdbscm_is_false (pretty_printer_list_var));
+ pretty_printer_list = SCM_EOL;
pp_type_error_symbol = scm_from_latin1_symbol ("gdb:pp-type-error");