From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WBF8ON+vhV/vCAAAWB0awg (envelope-from ) for ; Tue, 13 Oct 2020 09:47:11 -0400 Received: by simark.ca (Postfix, from userid 112) id E4BDD1EF6F; Tue, 13 Oct 2020 09:47:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 97BF01E58D for ; Tue, 13 Oct 2020 09:47:11 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 188F9388A02B; Tue, 13 Oct 2020 13:47:11 +0000 (GMT) Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200]) by sourceware.org (Postfix) with ESMTPS id 329623887027 for ; Tue, 13 Oct 2020 13:47:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 329623887027 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=netbsd.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kamil@netbsd.org Received: from [IPv6:::1] (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 65DEA84CDA; Tue, 13 Oct 2020 13:47:02 +0000 (UTC) Subject: Re: [PATCH] gdb::handle_eintr, remove need to specify return type (Re: [PATCH v2 01/10] Add handle_eintr to wrap EINTR handling in syscalls) To: Pedro Alves , Kamil Rytarowski , Simon Marchi , gdb-patches@sourceware.org References: <20200904002905.13616-1-n54@gmx.com> <20200904002905.13616-2-n54@gmx.com> <75070000-03a2-eeed-4f72-e29f199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F3p0I4SVHvR7dHbIC5IHibssmk7bQgH0K1aGUX/QC18v3VY7wYYaotYH RnTiGbBGz+XxPhZYiXKQuyFu6dY3qOw/VjbsV6KVNn49z2Zg4RQV8QARAQABiQIfBBgBCAAJ BQJVcFBfAhsMAAoJEEuzCOmwLnZs9rIP/2MTyZ0252u51LFsMHa9/ylTyvl+UKq8iR852lkZ X9bH9nH4cUcen5vZo0EZI3IVOemHUq71u+DTq8PSj5vtJ0DW+sGBEbjW3Q4IjJ+96PPrlemK fYS0KWVwEzzNQLEejjduU43x83DvQ/URzSWgGnhMBqXUyJdsHyTFFNFwQ9U71gX00+wXHJyh aXRlK+7gRKtCWuNFtW/5bQXL9epxDAS0POIVAdBc1FtPLwg08Pj0KwHsGQpEr5/W8ybDtLF+ zISHIKCj1lZ8dv/7D1PmH5SEXzsv+bbzvPtb6zhoIA8HONshaG2eAYknAiCJZ0gj0npgktwc u9VkvDvHMD9+VyNzRV/M6Ak4nDeEG6QecTPv8IqCcAHDI27nY/49BvFVOJOMwqbTp5Xvfa71 ksP1mARrN+bIYMfOy7OhfCxGeZydvBhgCLKdL698aXmgy0xrmrOw+GXO69GVcebOvxWMXxz1 FOG/JnLIe1ZgCo2YF5wy8zTCGKCMx6gAwnku2nJmDGNsePVedV00FmB8mQ7Oxz+3B9+LtFim FHHR33PlRnViXlG+XTm9NontiGE0LvG4TzIY5CYNSw8PBao795dQMSsmMI4FHlvTIgupE9g1 PQWP+2H2C0RtnLUanRNUGRkze1+MNG7jc+fqJIo5s7+PSs26rUvA38QzEOJ95k7hdJty Message-ID: Date: Tue, 13 Oct 2020 15:43:42 +0200 User-Agent: Mozilla/5.0 (X11; NetBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <75070000-03a2-eeed-4f72-e29f199291af@palves.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yO0Qu7qmpUFaSCTBiAR8Oq3KYRvaXiAeo" X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tom@tromey.com Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --yO0Qu7qmpUFaSCTBiAR8Oq3KYRvaXiAeo Content-Type: multipart/mixed; boundary="nJfONEHlQFXtnalVmRiQ7LSIpMul17KBL"; protected-headers="v1" From: Kamil Rytarowski To: Pedro Alves , Kamil Rytarowski , Simon Marchi , gdb-patches@sourceware.org Cc: tom@tromey.com Message-ID: Subject: Re: [PATCH] gdb::handle_eintr, remove need to specify return type (Re: [PATCH v2 01/10] Add handle_eintr to wrap EINTR handling in syscalls) References: <20200904002905.13616-1-n54@gmx.com> <20200904002905.13616-2-n54@gmx.com> <75070000-03a2-eeed-4f72-e29f199291af@palves.net> In-Reply-To: <75070000-03a2-eeed-4f72-e29f199291af@palves.net> --nJfONEHlQFXtnalVmRiQ7LSIpMul17KBL Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 12.10.2020 19:56, Pedro Alves wrote: > Hi! >=20 Hi Pedro, > On 9/7/20 3:59 PM, Kamil Rytarowski wrote: >> On 07.09.2020 16:06, Simon Marchi wrote: >>> On 2020-09-03 8:28 p.m., Kamil Rytarowski wrote: >=20 >>>> +#ifndef GDBSUPPORT_EINTR_H >>>> +#define GDBSUPPORT_EINTR_H >>>> + >>>> +#include >>>> + >>>> +namespace gdb >>>> +{ >>>> +template >>>> +inline Ret handle_eintr (const Ret &R, const Fun &F, const Args &..= =2E A) >>>> +{ >>>> + Ret ret; >>>> + do >>>> + { >>>> + errno =3D 0; >>>> + ret =3D F (A...); >>>> + } >>>> + while (ret =3D=3D R && errno =3D=3D EINTR); >>>> + return ret; >>>> +} >>>> +} >>> >>> Can you document this function a little bit, including a usage exampl= e? I tried >>> to apply it in gdb/linux-nat.c, function async_file_mark, but I'm not= sure I'm >>> doing it correctly. In particular, what should I pass as the `R` par= ameter? Does >>> that make sense? >>> >> >> I'm going to add an example and some documentation. >> >>> gdb::handle_eintr (-1, ::write, linux_nat_event_pipe[1], "+", 1); >>> >> >> gdb::handle_eintr (-1, ::write, linux_nat_event_pipe[1], "+",= 1); >=20 > Going through my email backlog I noticed this. >=20 > This requirement to explicitly specify the return type at each caller > seems unnecessary. We can make the compiler deduce it for us based on > the return type of the wrapped function. I gave it a shot -- do you se= e > an issue with the change below? >=20 This patch applied on trunk gives me: gmake[2]: Wej=C5=9Bcie do katalogu '/public/binutils-gdb-netbsd/build/gdb= server' CXX netbsd-low.o =2E./../gdbserver/netbsd-low.cc: In function =E2=80=98bool elf_64_file_p(= const char*)=E2=80=99: =2E./../gdbserver/netbsd-low.cc:1152:57: error: no matching function for call to =E2=80=98handle_eintr(int, int (&)(const char*, int, ...), const = char*&, int)=E2=80=99 1152 | int fd =3D gdb::handle_eintr (-1, ::open, file, O_RDONLY); | ^ In file included from ../../gdbserver/netbsd-low.cc:37: =2E./../gdbserver/../gdbsupport/eintr.h:58:1: note: candidate: =E2=80=98template typename= gdb::return_type::type gdb::handle_eintr(ErrorValType, const Fun&, const Args& ...)=E2=80=99 58 | handle_eintr (ErrorValType errval, const Fun &f, const Args &... args) | ^~~~~~~~~~~~ =2E./../gdbserver/../gdbsupport/eintr.h:58:1: note: template argument deduction/substitution failed: =2E./../gdbserver/../gdbsupport/eintr.h: In substitution of =E2=80=98template typename= gdb::return_type::type gdb::handle_eintr(ErrorValType, const Fun&, const Args& ...) [with ErrorValType =3D int; Fun =3D int(const char*, int= , =2E..); Args =3D {const char*, int}]=E2=80=99: =2E./../gdbserver/netbsd-low.cc:1152:57: required from here =2E./../gdbserver/../gdbsupport/eintr.h:58:1: error: invalid use of incomplete type =E2=80=98struct gdb::return_type=E2=80=99 In file included from ../../gdbserver/../gdbsupport/poison.h:23, from ../../gdbserver/../gdbsupport/common-utils.h:26, from ../../gdbserver/../gdbsupport/common-defs.h:125, from ../../gdbserver/server.h:22, from ../../gdbserver/netbsd-low.cc:18: =2E./../gdbserver/../gdbsupport/traits.h:49:8: note: declaration of =E2=80=98struct gdb::return_type=E2=80=99 49 | struct return_type; | ^~~~~~~~~~~ gmake[2]: *** [Makefile:551: netbsd-low.o] B=C5=82=C4=85d 1 --nJfONEHlQFXtnalVmRiQ7LSIpMul17KBL-- --yO0Qu7qmpUFaSCTBiAR8Oq3KYRvaXiAeo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEELaxVpweEzw+lMDwuS7MI6bAudmwFAl+Frw4ACgkQS7MI6bAu dmzuZBAAhvG22hE1e4kzmlrVZPC/4idLJZQS/NaWYa6ZkofjUPbhfbatZs1Fgk41 EdJu0PKMinjjaWHDD2JHHXExpCsiPK2pF5kOwEukdEbAWR5eCONFgSJcJqZ34nQ8 L63XAA2cU1E6NqK4i8yltjPVFvqmyaZSOqVsZS7EVniPUemWZlI3ps9SUcUaoqwI f+41FUW092y6WQmah6yjuqFTjh88gjqSo4wKRe68lBzoTYpTMF9Owl2rGSzBLr6n 02fXGGLNDh7wr4LORiUSFEeme2oW3pm6H92gpJJqX9Jro4Y0BQy07a+NG5rHtSkW dbg5EGTPKAwtry1WucSKdZVb1Jzkrc09AzHVj9Sh7sQ/TtdVU0qlRAMl6CQVN9Py jRbH+MlIfetj2GYw5HDVDVVUcfTHa5wJKymxhninvPSTUgp2UPUYxYbaQp1dNWJ+ Aqou8B+mvGWy5Hh8owLeHloM3g79ifPd0KowrX6obX6XfPrduQX7obckutMQQc2+ n5wVjgtydNvHla8bSkBb01OkfqjSADRrSO/jvVzVcYJIIB93g6tGNCZriEmLIMbR KOAm6XLwZAYrMAg9OFM/W3BXPC9AKT0zZ3XSSeJSxlMtP8LBHH/1/gfEibWDgjXO tQiRGzh6+ug/7ltrxsilanQ+tEKQM0oLUUeyQp6LAcMfg8DPFyg= =2Pt8 -----END PGP SIGNATURE----- --yO0Qu7qmpUFaSCTBiAR8Oq3KYRvaXiAeo--