aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-11-08 15:26:44 +0000
committerPedro Alves <palves@redhat.com>2016-11-08 15:26:44 +0000
commit3ab692db7f4d96022a132379614031a852de6f35 (patch)
treedcc4b2cdf8d475300d5b72633589d458820166d8 /gdb
parent09b0e4b047b44063cf4c8c00527886743619c24e (diff)
downloadfsf-binutils-gdb-3ab692db7f4d96022a132379614031a852de6f35.zip
fsf-binutils-gdb-3ab692db7f4d96022a132379614031a852de6f35.tar.gz
fsf-binutils-gdb-3ab692db7f4d96022a132379614031a852de6f35.tar.bz2
Use ui_file_as_string in gdb/guile/
gdb/ChangeLog: 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/guile/scm-breakpoint.c6
-rw-r--r--gdb/guile/scm-disasm.c6
-rw-r--r--gdb/guile/scm-frame.c6
-rw-r--r--gdb/guile/scm-type.c42
-rw-r--r--gdb/guile/scm-value.c18
6 files changed, 40 insertions, 52 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 52b471b..f88e505 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
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
std::string.
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index baecf01..61d16da 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -981,7 +981,6 @@ gdbscm_breakpoint_commands (SCM self)
struct ui_file *string_file;
struct cleanup *chain;
SCM result;
- char *cmdstr;
bp = bp_smob->bp;
@@ -1004,9 +1003,8 @@ gdbscm_breakpoint_commands (SCM self)
}
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;
diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c
index 78a7b83..a7d6b14 100644
--- a/gdb/guile/scm-disasm.c
+++ b/gdb/guile/scm-disasm.c
@@ -282,7 +282,6 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
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);
@@ -302,15 +301,14 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
}
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);
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index 8f920b2..a86ea5f 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -157,16 +157,14 @@ frscm_print_frame_smob (SCM self, SCM port, scm_print_state *pstate)
{
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);
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index 2acdfad..383e58a 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -99,16 +99,12 @@ tyscm_type_smob_type (type_smob *t_smob)
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;
@@ -119,17 +115,19 @@ tyscm_type_name (struct type *type, SCM *excp)
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");
}
/* Administrivia for type smobs. */
@@ -207,11 +205,7 @@ static int
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.
@@ -220,7 +214,7 @@ tyscm_print_type_smob (SCM self, SCM port, scm_print_state *pstate)
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);
@@ -608,16 +602,8 @@ gdbscm_type_print_name (SCM self)
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;
}
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index 416e488..fa0e2b7 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -141,7 +141,6 @@ static int
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)
@@ -162,7 +161,9 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
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);
}
@@ -172,12 +173,6 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
}
END_CATCH
- if (s != NULL)
- {
- scm_puts (s, port);
- xfree (s);
- }
-
if (pstate->writingp)
scm_puts (">", port);
@@ -1282,7 +1277,7 @@ gdbscm_value_print (SCM self)
= 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);
@@ -1294,7 +1289,7 @@ gdbscm_value_print (SCM self)
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);
}
@@ -1309,9 +1304,8 @@ gdbscm_value_print (SCM self)
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;
}