Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb] Make execute_command_to_string return string on throw
Date: Thu, 7 Oct 2021 11:33:28 -0400	[thread overview]
Message-ID: <2f2ce317-ae71-88b8-4b84-5eead84c376d@simark.ca> (raw)
In-Reply-To: <20210911120202.GA16898@delia.home>

> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -728,13 +728,22 @@ execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn)
>
>  /* See gdbcmd.h.  */
>
> -std::string
> -execute_fn_to_string (std::function<void(void)> fn, bool term_out)
> +void
> +execute_fn_to_string (std::string &res, std::function<void(void)> fn,
> +		      bool term_out)
>  {
>    string_file str_file (term_out);
>
> -  execute_fn_to_ui_file (&str_file, fn);
> -  return std::move (str_file.string ());
> +  try {
> +    execute_fn_to_ui_file (&str_file, fn);
> +  } catch (...) {
> +    /* Finally.  */
> +    res = std::move (str_file.string ());
> +    throw;
> +  }

Formatting.

The code LGTM, but could you write / update a test for this?

Simon

  parent reply	other threads:[~2021-10-07 15:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 12:02 Tom de Vries via Gdb-patches
2021-10-07 14:37 ` [PING][PATCH][gdb] " Tom de Vries via Gdb-patches
2021-10-07 15:33 ` Simon Marchi [this message]
2021-10-07 16:15   ` [PATCH][gdb] " Tom de Vries via Gdb-patches
2021-10-07 16:16     ` Simon Marchi
2021-10-20 18:53     ` Tom Tromey
2021-10-20 20:43       ` Tom de Vries via Gdb-patches
2021-10-20 22:14         ` Tom Tromey
2021-10-21 18:28           ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f2ce317-ae71-88b8-4b84-5eead84c376d@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox