diff options
author | Pedro Alves <palves@redhat.com> | 2018-07-18 23:41:06 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-07-18 23:41:06 +0100 |
commit | 3a5f2a48ffe3941396d7a19d9398c9a4945b4e5d (patch) | |
tree | cf7d7656953a1109c0f8e8d12eda3ed3280c519f /gdb | |
parent | 557e56be2648db13cd5d9876f702ba119ee9e7fd (diff) | |
download | gdb-3a5f2a48ffe3941396d7a19d9398c9a4945b4e5d.zip gdb-3a5f2a48ffe3941396d7a19d9398c9a4945b4e5d.tar.gz gdb-3a5f2a48ffe3941396d7a19d9398c9a4945b4e5d.tar.bz2 |
Eliminate cleanup in gdbscm_execute_gdb_command
Note: the "may be modified" comment is no longer true nowadays.
gdb/ChangeLog:
2018-07-18 Pedro Alves <palves@redhat.com>
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
gdbscm_wrap. Use gdb::unique_xmalloc_ptr<char> instead of a
cleanup.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/guile/guile.c | 29 |
2 files changed, 14 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6d1a1c6..92c93f4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2018-07-18 Pedro Alves <palves@redhat.com> + * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use + gdbscm_wrap. Use gdb::unique_xmalloc_ptr<char> instead of a + cleanup. + +2018-07-18 Pedro Alves <palves@redhat.com> + * guile/guile-internal.h: Add comment about mixing GDB and Scheme exceptions. (GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS): Delete. diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 6b5faa3..6353b35 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -289,22 +289,17 @@ 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; - struct cleanup *cleanups; - struct gdb_exception except = exception_none; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt", command_scm, &command, rest, &from_tty_arg_pos, &from_tty, &to_string_arg_pos, &to_string); - /* Note: The contents of "command" may get modified while it is - executed. */ - cleanups = make_cleanup (xfree, command); - - std::string to_string_res; - - TRY + return gdbscm_wrap ([=] { + gdb::unique_xmalloc_ptr<char> command_holder (command); + std::string to_string_res; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, 0); @@ -316,19 +311,11 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); - } - CATCH (ex, RETURN_MASK_ALL) - { - except = ex; - } - END_CATCH - - do_cleanups (cleanups); - GDBSCM_HANDLE_GDB_EXCEPTION (except); - if (to_string) - return gdbscm_scm_from_c_string (to_string_res.c_str ()); - return SCM_UNSPECIFIED; + if (to_string) + return gdbscm_scm_from_c_string (to_string_res.c_str ()); + return SCM_UNSPECIFIED; + }); } /* (data-directory) -> string */ |