mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 16:05:56 +08:00
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.
This commit is contained in:
@ -595,3 +595,32 @@ gdbscm_gc_xstrdup (const char *str)
|
||||
strcpy (result, str);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Return a duplicate of ARGV living on the GC heap. */
|
||||
|
||||
const char * const *
|
||||
gdbscm_gc_dup_argv (char **argv)
|
||||
{
|
||||
int i, len;
|
||||
size_t string_space;
|
||||
char *p, **result;
|
||||
|
||||
for (len = 0, string_space = 0; argv[len] != NULL; ++len)
|
||||
string_space += strlen (argv[len]) + 1;
|
||||
|
||||
/* Allocating "pointerless" works because the pointers are all
|
||||
self-contained within the object. */
|
||||
result = scm_gc_malloc_pointerless (((len + 1) * sizeof (char *))
|
||||
+ string_space, "parameter enum list");
|
||||
p = (char *) &result[len + 1];
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
result[i] = p;
|
||||
strcpy (p, argv[i]);
|
||||
p += strlen (p) + 1;
|
||||
}
|
||||
result[i] = NULL;
|
||||
|
||||
return (const char * const *) result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user