From: Tom de Vries <tdevries@suse.de>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] [gdb/remote] Fix abort on REMOTE_CLOSE_ERROR
Date: Sat, 27 Apr 2024 17:49:01 +0200 [thread overview]
Message-ID: <73cb8691-ce18-41fc-8d39-bcd135e390a7@suse.de> (raw)
In-Reply-To: <a976c205-b845-4950-9c5a-6e2eaaa17afa@palves.net>
On 4/26/24 18:03, Pedro Alves wrote:
> On 2024-04-20 10:14, Tom de Vries wrote:
>
>> +
>> /* See gdb_bfd.h. */
>>
>> gdb_bfd_ref_ptr
>> @@ -938,21 +961,48 @@ gdb_bfd_openr_iovec (const char *filename, const char *target,
>> auto do_open = [] (bfd *nbfd, void *closure) -> void *
>> {
>> auto real_opener = static_cast<gdb_iovec_opener_ftype *> (closure);
>> - return (*real_opener) (nbfd);
>> + /* Prevent exceptions from escaping to C code and triggering an abort. */
>> + auto res = catch_exceptions<gdb_bfd_iovec_base *, nullptr> ([&] {
>> + return (*real_opener) (nbfd);
>> + });
>
> Please use the lambda formatting described at:
>
> https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Indentation_of_lambdas_as_parameters
>
>
>> + if (res == nullptr)
>> + {
>> + errno = EIO;
>> + bfd_set_error (bfd_error_system_call);
>> + }
>> + return res;
>> };
>>
>> auto read_trampoline = [] (bfd *nbfd, void *stream, void *buf,
>> file_ptr nbytes, file_ptr offset) -> file_ptr
>> {
>> gdb_bfd_iovec_base *obj = static_cast<gdb_bfd_iovec_base *> (stream);
>> - return obj->read (nbfd, buf, nbytes, offset);
>> + /* Prevent exceptions from escaping to C code and triggering an abort. */
>> + auto res = catch_exceptions<long int, -1> ([&] {
>> + return obj->read (nbfd, buf, nbytes, offset);
>> + });
>
> Ditto re. formatting.
>
>> + if (res == -1)
>> + {
>> + errno = EIO;
>> + bfd_set_error (bfd_error_system_call);
>> + }
>> + return res;
>> };
>>
>> auto stat_trampoline = [] (struct bfd *abfd, void *stream,
>> struct stat *sb) -> int
>> {
>> gdb_bfd_iovec_base *obj = static_cast<gdb_bfd_iovec_base *> (stream);
>> - return obj->stat (abfd, sb);
>> + /* Prevent exceptions from escaping to C code and triggering an abort. */
>> + auto res = catch_exceptions<int, -1> ([&] {
>> + return obj->stat (abfd, sb);
>> + });
>
> Ditto.
>
>> + if (res == -1)
>> + {
>> + errno = EIO;
>> + bfd_set_error (bfd_error_system_call);
>> + }
>> + return res;
>> };
>>
>> auto close_trampoline = [] (struct bfd *nbfd, void *stream) -> int
>>
>> base-commit: 20eee7540b9f2615f7661393756fec0bb62a1495
>
> Otherwise:
>
> Approved-by: Pedro Alves <pedro@palves.net>
Hi Pedro,
thanks for the review.
Pushed with those changes.
Thanks,
- Tom
>
> Thanks.
>
prev parent reply other threads:[~2024-04-27 15:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-20 9:14 Tom de Vries
2024-04-26 16:03 ` Pedro Alves
2024-04-27 15:49 ` Tom de Vries [this message]
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=73cb8691-ce18-41fc-8d39-bcd135e390a7@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
/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).