+2016-11-08 Pedro Alves <palves@redhat.com>
+
+ * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
+ ui_file_as_string and adjust to use std::string.
+ * guile/scm-disasm.c (gdbscm_arch_disassemble): Likewise.
+ * guile/scm-frame.c (frscm_print_frame_smob): Likewise.
+ * guile/scm-type.c (tyscm_type_name): Use ui_file_as_string and
+ adjust to use std::string. Throw exception directly instead of
+ returning it in EXCP output parameter.
+ (tyscm_print_type_smob, gdbscm_type_print_name): Adjust to
+ tyscm_type_name interface change.
+ * guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
+ Use ui_file_as_string and std::string.
+
2016-11-08 Pedro Alves <palves@redhat.com>
* arm-tdep.c (_initialize_arm_tdep): Use ui_file_as_string and
struct ui_file *string_file;
struct cleanup *chain;
SCM result;
- char *cmdstr;
bp = bp_smob->bp;
}
END_CATCH
- cmdstr = ui_file_xstrdup (string_file, &length);
- make_cleanup (xfree, cmdstr);
- result = gdbscm_scm_from_c_string (cmdstr);
+ std::string cmdstr = ui_file_as_string (string_file);
+ result = gdbscm_scm_from_c_string (cmdstr.c_str ());
do_cleanups (chain);
return result;
for (pc = start, i = 0; pc <= end && i < count; )
{
int insn_len = 0;
- char *as = NULL;
struct ui_file *memfile = mem_fileopen ();
struct cleanup *cleanups = make_cleanup_ui_file_delete (memfile);
}
END_CATCH
- as = ui_file_xstrdup (memfile, NULL);
+ std::string as = ui_file_as_string (memfile);
- result = scm_cons (dascm_make_insn (pc, as, insn_len),
+ result = scm_cons (dascm_make_insn (pc, as.c_str (), insn_len),
result);
pc += insn_len;
i++;
do_cleanups (cleanups);
- xfree (as);
}
return scm_reverse_x (result, SCM_EOL);
{
frame_smob *f_smob = (frame_smob *) SCM_SMOB_DATA (self);
struct ui_file *strfile;
- char *s;
gdbscm_printf (port, "#<%s ", frame_smob_name);
strfile = mem_fileopen ();
fprint_frame_id (strfile, f_smob->frame_id);
- s = ui_file_xstrdup (strfile, NULL);
- gdbscm_printf (port, "%s", s);
+ std::string s = ui_file_as_string (strfile);
+ gdbscm_printf (port, "%s", s.c_str ());
ui_file_delete (strfile);
- xfree (s);
scm_puts (">", port);
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. */
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);
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;
}
vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
{
value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self);
- char *s = NULL;
struct value_print_options opts;
if (pstate->writingp)
struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
common_val_print (v_smob->value, stb, 0, &opts, current_language);
- s = ui_file_xstrdup (stb, NULL);
+
+ std::string s = ui_file_as_string (stb);
+ scm_puts (s.c_str (), port);
do_cleanups (old_chain);
}
}
END_CATCH
- if (s != NULL)
- {
- scm_puts (s, port);
- xfree (s);
- }
-
if (pstate->writingp)
scm_puts (">", port);
= vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct value *value = v_smob->value;
struct value_print_options opts;
- char *s = NULL;
+ std::string s;
SCM result;
get_user_print_options (&opts);
struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
common_val_print (value, stb, 0, &opts, current_language);
- s = ui_file_xstrdup (stb, NULL);
+ s = ui_file_as_string (stb);
do_cleanups (old_chain);
}
IWBN to use scm_take_locale_string here, but we'd have to temporarily
override the default port conversion handler because contrary to
documentation it doesn't necessarily free the input string. */
- result = scm_from_stringn (s, strlen (s), host_charset (),
+ result = scm_from_stringn (s.c_str (), s.size (), host_charset (),
SCM_FAILED_CONVERSION_QUESTION_MARK);
- xfree (s);
return result;
}