aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile/scm-string.c
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-06-03 01:58:15 -0700
committerDoug Evans <xdje42@gmail.com>2014-06-03 01:58:15 -0700
commit06eb158633faa8746dd39f19ce784448bb7ece00 (patch)
treeaf106d0dafb2da97a959d2008a02abe3b0e61e4d /gdb/guile/scm-string.c
parentaef392c4aee243fe0fe2897d8847aebbbff6abdb (diff)
downloadgdb-06eb158633faa8746dd39f19ce784448bb7ece00.zip
gdb-06eb158633faa8746dd39f19ce784448bb7ece00.tar.gz
gdb-06eb158633faa8746dd39f19ce784448bb7ece00.tar.bz2
Add parameter support for Guile.
* Makefile.in (SUBDIR_GUILE_OBS): Add scm-param.o. (SUBDIR_GUILE_SRCS): Add scm-param.c. (scm-param.o): New rule. * guile/guile-internal.h (gdbscm_gc_dup_argv): Declare. (gdbscm_misc_error): Declare. (gdbscm_canonicalize_command_name): Declare. (gdbscm_scm_to_host_string): Declare. (gdbscm_scm_from_host_string): Declare. (gdbscm_initialize_parameters): Declare. * guile/guile.c (initialize_gdb_module): Call gdbscm_initialize_parameters. * guile/lib/gdb.scm: Export parameter symbols. * guile/scm-cmd.c (gdbscm_canonicalize_command_name): Renamed from cmdscm_canonicalize_name and made public. All callers updated. * guile/scm-exception.c (gdbscm_misc_error): New function. * guile/scm-param.c: New file. * guile/scm-string.c (gdbscm_scm_to_string): Add comments. (gdbscm_scm_to_host_string): New function. (gdbscm_scm_from_host_string): New function. * scm-utils.c (gdbscm_gc_dup_argv): New function. testsuite/ * gdb.guile/scm-parameter.exp: New file. doc/ * guile.texi (Guile API): Add entry for Parameters In Guile. (GDB Scheme Data Types): Mention <gdb:parameter> object. (Parameters In Guile): New node.
Diffstat (limited to 'gdb/guile/scm-string.c')
-rw-r--r--gdb/guile/scm-string.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/guile/scm-string.c b/gdb/guile/scm-string.c
index c8d81c4..25f1d67 100644
--- a/gdb/guile/scm-string.c
+++ b/gdb/guile/scm-string.c
@@ -90,10 +90,17 @@ gdbscm_call_scm_to_stringn (void *datap)
/* Convert an SCM string to a string in charset CHARSET.
This function is guaranteed to not throw an exception.
+
+ If LENP is NULL then the returned string is NUL-terminated,
+ and an exception is thrown if the string contains embedded NULs.
+ Otherwise the string is not guaranteed to be NUL-terminated, but worse
+ there's no space to put a NUL if we wanted to (scm_to_stringn limitation).
+
If STRICT is non-zero, and there's a conversion error, then a
<gdb:exception> object is stored in *EXCEPT_SCMP, and NULL is returned.
If STRICT is zero, then escape sequences are used for characters that
can't be converted, and EXCEPT_SCMP may be passed as NULL.
+
Space for the result is allocated with malloc, caller must free.
It is an error to call this if STRING is not a string. */
@@ -151,6 +158,7 @@ gdbscm_call_scm_from_stringn (void *datap)
/* Convert STRING to a Scheme string in charset CHARSET.
This function is guaranteed to not throw an exception.
+
If STRICT is non-zero, and there's a conversion error, then a
<gdb:exception> object is returned.
If STRICT is zero, then question marks are used for characters that
@@ -183,6 +191,36 @@ gdbscm_scm_from_string (const char *string, size_t len,
return scm_result;
}
+/* Convert an SCM string to a host string.
+ This function is guaranteed to not throw an exception.
+
+ If LENP is NULL then the returned string is NUL-terminated,
+ and if the string contains embedded NULs then NULL is returned with
+ an exception object stored in *EXCEPT_SCMP.
+ Otherwise the string is not guaranteed to be NUL-terminated, but worse
+ there's no space to put a NUL if we wanted to (scm_to_stringn limitation).
+
+ Returns NULL if there is a conversion error, with the exception object
+ stored in *EXCEPT_SCMP.
+ Space for the result is allocated with malloc, caller must free.
+ It is an error to call this if STRING is not a string. */
+
+char *
+gdbscm_scm_to_host_string (SCM string, size_t *lenp, SCM *except_scmp)
+{
+ return gdbscm_scm_to_string (string, lenp, host_charset (), 1, except_scmp);
+}
+
+/* Convert a host string to an SCM string.
+ This function is guaranteed to not throw an exception.
+ Returns a <gdb:exception> object if there's a conversion error. */
+
+SCM
+gdbscm_scm_from_host_string (const char *string, size_t len)
+{
+ return gdbscm_scm_from_string (string, len, host_charset (), 1);
+}
+
/* (string->argv string) -> list
Return list of strings split up according to GDB's argv parsing rules.
This is useful when writing GDB commands in Scheme. */