/* Scheme interface to types.
- Copyright (C) 2008-2015 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
This file is part of GDB.
return t_smob->type;
}
-/* Return the name of TYPE in expanded form.
- Space for the result is malloc'd, caller must free.
- If there's an error computing the name, the result is NULL and the
- exception is stored in *EXCP. */
+/* Return the name of TYPE in expanded form. If there's an error
+ computing the name, throws the gdb exception with scm_throw. */
-static char *
-tyscm_type_name (struct type *type, SCM *excp)
+static std::string
+tyscm_type_name (struct type *type)
{
- char *name = NULL;
-
TRY
{
struct cleanup *old_chain;
LA_PRINT_TYPE (type, "", stb, -1, 0, &type_print_raw_options);
- name = ui_file_xstrdup (stb, NULL);
+ std::string name = ui_file_as_string (stb);
do_cleanups (old_chain);
+
+ return name;
}
CATCH (except, RETURN_MASK_ALL)
{
- *excp = gdbscm_scm_from_gdb_exception (except);
- return NULL;
+ SCM excp = gdbscm_scm_from_gdb_exception (except);
+ gdbscm_throw (excp);
}
END_CATCH
- return name;
+ gdb_assert_not_reached ("no way to get here");
}
\f
/* Administrivia for type smobs. */
static hashval_t
tyscm_hash_type_smob (const void *p)
{
- const type_smob *t_smob = p;
+ const type_smob *t_smob = (const type_smob *) p;
return htab_hash_pointer (t_smob->type);
}
static int
tyscm_eq_type_smob (const void *ap, const void *bp)
{
- const type_smob *a = ap;
- const type_smob *b = bp;
+ const type_smob *a = (const type_smob *) ap;
+ const type_smob *b = (const type_smob *) bp;
return (a->type == b->type
&& a->type != NULL);
if (objfile == NULL)
return global_types_map;
- htab = objfile_data (objfile, tyscm_objfile_data_key);
+ htab = (htab_t) objfile_data (objfile, tyscm_objfile_data_key);
if (htab == NULL)
{
htab = gdbscm_create_eqable_gsmob_ptr_map (tyscm_hash_type_smob,
tyscm_print_type_smob (SCM self, SCM port, scm_print_state *pstate)
{
type_smob *t_smob = (type_smob *) SCM_SMOB_DATA (self);
- SCM exception;
- char *name = tyscm_type_name (t_smob->type, &exception);
-
- if (name == NULL)
- gdbscm_throw (exception);
+ std::string name = tyscm_type_name (t_smob->type);
/* pstate->writingp = zero if invoked by display/~A, and nonzero if
invoked by write/~S. What to do here may need to evolve.
if (pstate->writingp)
gdbscm_printf (port, "#<%s ", type_smob_name);
- scm_puts (name, port);
+ scm_puts (name.c_str (), port);
if (pstate->writingp)
scm_puts (">", port);
tyscm_copy_type_recursive (void **slot, void *info)
{
type_smob *t_smob = (type_smob *) *slot;
- htab_t copied_types = info;
+ htab_t copied_types = (htab_t) info;
struct objfile *objfile = TYPE_OBJFILE (t_smob->type);
htab_t htab;
eqable_gdb_smob **new_slot;
static void
save_objfile_types (struct objfile *objfile, void *datum)
{
- htab_t htab = datum;
+ htab_t htab = (htab_t) datum;
htab_t copied_types;
if (!gdb_scheme_initialized)
type_smob *t_smob
= tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct type *type = t_smob->type;
- char *thetype;
- SCM exception, result;
-
- thetype = tyscm_type_name (type, &exception);
-
- if (thetype == NULL)
- gdbscm_throw (exception);
-
- result = gdbscm_scm_from_c_string (thetype);
- xfree (thetype);
+ std::string thetype = tyscm_type_name (type);
+ SCM result = gdbscm_scm_from_c_string (thetype.c_str ());
return result;
}