diff options
author | Doug Evans <xdje42@gmail.com> | 2014-06-06 15:57:03 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2014-06-06 15:57:03 -0700 |
commit | d2929fdcf05bb14dc2484ee6918dbf67c5b46d75 (patch) | |
tree | 031eb52397389646d26efdefa250bc0aa1157334 /gdb/guile/guile.c | |
parent | 6da01dbef2535e333e2b26547d61e4684b8e4da7 (diff) | |
download | gdb-d2929fdcf05bb14dc2484ee6918dbf67c5b46d75.zip gdb-d2929fdcf05bb14dc2484ee6918dbf67c5b46d75.tar.gz gdb-d2929fdcf05bb14dc2484ee6918dbf67c5b46d75.tar.bz2 |
Add support for guile 2.0.5.
* guile/guile-internal.h (gdbscm_guile_major_version): Declare.
(gdbscm_guile_minor_version, gdbscm_guile_micro_version): Declare.
(gdbscm_guile_version_is_at_least): Declare.
(gdbscm_scm_string_to_int): Declare.
* guile/guile.c (gdbscm_guile_major_version): New global.
(gdbscm_guile_minor_version, gdbscm_guile_micro_version): New globals.
(guile_datadir): New static global.
(gdbscm_guile_data_directory): New function.
(initialize_scheme_side): Update.
(misc_guile_functions): Add guile-data-directory.
(initialize_gdb_module): Fetch guile version number.
* guile/lib/gdb.scm: Remove call to add-to-load-path.
* guile/lib/gdb/init.scm (%initialize!): Ditto.
* guile/lib/gdb/boot.scm: Use guile-data-directory.
* guile/scm-exception.c (gdbscm_print_exception_with_stack): Fix
comments.
* guile/scm-string.c (gdbscm_scm_string_to_int): New function.
* guile/scm-utils.c (gdbscm_guile_version_is_at_least): New function.
* guile/scm-value.c (gdbscm_value_to_string): Only call
scm_port_conversion_strategy if Guile version >= 2.0.6.
doc/
* guile.texi (Guile Configuration): Document guile-data-directory.
Diffstat (limited to 'gdb/guile/guile.c')
-rw-r--r-- | gdb/guile/guile.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 00d7b06..167e717 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -37,6 +37,18 @@ #include "guile-internal.h" #endif +/* The Guile version we're using. + We *could* use the macros in libguile/version.h but that would preclude + handling the user switching in a different version with, e.g., + LD_LIBRARY_PATH (using a different version than what gdb was compiled with + is not something to be done lightly, but can be useful). */ +int gdbscm_guile_major_version; +int gdbscm_guile_minor_version; +int gdbscm_guile_micro_version; + +/* The guile subdirectory within gdb's data-directory. */ +static const char *guile_datadir; + /* Declared constants and enum for guile exception printing. */ const char gdbscm_print_excp_none[] = "none"; const char gdbscm_print_excp_full[] = "full"; @@ -353,6 +365,14 @@ gdbscm_data_directory (void) return gdbscm_scm_from_c_string (gdb_datadir); } +/* (guile-data-directory) -> string */ + +static SCM +gdbscm_guile_data_directory (void) +{ + return gdbscm_scm_from_c_string (guile_datadir); +} + /* (gdb-version) -> string */ static SCM @@ -468,6 +488,10 @@ Execute the given GDB command.\n\ "\ Return the name of GDB's data directory." }, + { "guile-data-directory", 0, 0, 0, gdbscm_guile_data_directory, + "\ +Return the name of the Guile directory within GDB's data directory." }, + { "gdb-version", 0, 0, 0, gdbscm_gdb_version, "\ Return GDB's version string." }, @@ -489,11 +513,13 @@ Return the name of the target configuration." }, static void initialize_scheme_side (void) { - char *gdb_guile_dir = concat (gdb_datadir, SLASH_STRING, "guile", NULL); - char *boot_scm_path = concat (gdb_guile_dir, SLASH_STRING, "gdb", - SLASH_STRING, boot_scm_filename, NULL); + char *boot_scm_path; char *msg; + guile_datadir = concat (gdb_datadir, SLASH_STRING, "guile", NULL); + boot_scm_path = concat (guile_datadir, SLASH_STRING, "gdb", + SLASH_STRING, boot_scm_filename, NULL); + /* While scm_c_primitive_load works, the loaded code is not compiled, instead it is left to be interpreted. Eh? Anyways, this causes a ~100x slowdown, so we only use it to load @@ -512,7 +538,6 @@ initialize_scheme_side (void) boot_scm_path); } - xfree (gdb_guile_dir); xfree (boot_scm_path); } @@ -524,6 +549,13 @@ initialize_scheme_side (void) static void initialize_gdb_module (void *data) { + /* Computing these is a pain, so only do it once. + Also, do it here and save the result so that obtaining the values + is thread-safe. */ + gdbscm_guile_major_version = gdbscm_scm_string_to_int (scm_major_version ()); + gdbscm_guile_minor_version = gdbscm_scm_string_to_int (scm_minor_version ()); + gdbscm_guile_micro_version = gdbscm_scm_string_to_int (scm_micro_version ()); + /* The documentation symbol needs to be defined before any calls to gdbscm_define_{variables,functions}. */ gdbscm_documentation_symbol = scm_from_latin1_symbol ("documentation"); |