From db1ec11fff1a46f7046bcbd971a42632d2ea795c Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 8 Nov 2016 15:26:45 +0000 Subject: Use ui_file_as_string in execute_command_to_string ... and then return std::string and adjust all callers. gdb/ChangeLog: 2016-11-08 Pedro Alves * gdbcmd.h (execute_command_to_string): Now returns std::string. (lookup_struct_elt_type): Adjust to use std::string. * top.c (execute_command_to_string): Use ui_file_as_string and return std::string. * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use std::string. * python/python.c (execute_gdb_command): Adjust to use std::string. --- gdb/guile/guile.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'gdb/guile') diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 3a19eec..9a126a1 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -311,7 +311,6 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) int from_tty = 0, to_string = 0; const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F }; char *command; - char *result = NULL; struct cleanup *cleanups; struct gdb_exception except = exception_none; @@ -324,6 +323,8 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) executed. */ cleanups = make_cleanup (xfree, command); + std::string to_string_res; + TRY { struct cleanup *inner_cleanups; @@ -333,12 +334,9 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) prevent_dont_repeat (); if (to_string) - result = execute_command_to_string (command, from_tty); + to_string_res = execute_command_to_string (command, from_tty); else - { - execute_command (command, from_tty); - result = NULL; - } + execute_command (command, from_tty); /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); @@ -354,12 +352,8 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); - if (result) - { - SCM r = gdbscm_scm_from_c_string (result); - xfree (result); - return r; - } + if (to_string) + return gdbscm_scm_from_c_string (to_string_res.c_str ()); return SCM_UNSPECIFIED; } -- cgit v1.1