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 12:16:58 -0400 [thread overview]
Message-ID: <1f5c3abf-fd40-452e-26a5-34c0809b74e1@simark.ca> (raw)
In-Reply-To: <f342e26c-2d0b-cb7a-3fc3-826f8ec02293@suse.de>
On 2021-10-07 12:15 p.m., Tom de Vries via Gdb-patches wrote:
> On 10/7/21 5:33 PM, Simon Marchi wrote:
>>> --- 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.
>>
>
> Ack, fixed.
>
>> The code LGTM, but could you write / update a test for this?
>
> The patch "[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as
> unittest" uses this. It checks the output of a command that is also
> throwing a "Error while executing Python code".
>
> Thanks,
> - Tom
>
Ok, that's fine with me.
Simon
next prev parent reply other threads:[~2021-10-07 16:17 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 ` [PATCH][gdb] " Simon Marchi
2021-10-07 16:15 ` Tom de Vries via Gdb-patches
2021-10-07 16:16 ` Simon Marchi [this message]
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=1f5c3abf-fd40-452e-26a5-34c0809b74e1@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