public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb] Make execute_command_to_string return string on throw
Date: Thu, 7 Oct 2021 18:15:19 +0200	[thread overview]
Message-ID: <f342e26c-2d0b-cb7a-3fc3-826f8ec02293@suse.de> (raw)
In-Reply-To: <2f2ce317-ae71-88b8-4b84-5eead84c376d@simark.ca>

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

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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 12:02 Tom de Vries
2021-10-07 14:37 ` [PING][PATCH][gdb] " Tom de Vries
2021-10-07 15:33 ` [PATCH][gdb] " Simon Marchi
2021-10-07 16:15   ` Tom de Vries [this message]
2021-10-07 16:16     ` Simon Marchi
2021-10-20 18:53     ` Tom Tromey
2021-10-20 20:43       ` Tom de Vries
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=f342e26c-2d0b-cb7a-3fc3-826f8ec02293@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).