From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100257 invoked by alias); 9 Jul 2018 15:22:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100248 invoked by uid 89); 9 Jul 2018 15:22:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=restrict X-HELO: a2-111.smtp-out.eu-west-1.amazonses.com Received: from a2-111.smtp-out.eu-west-1.amazonses.com (HELO a2-111.smtp-out.eu-west-1.amazonses.com) (54.240.2.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 15:22:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=jl7vyxitgsfircfdhxflkj2c3tgxidze; d=farjump.io; t=1531149760; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id; bh=76ia/tN0nSQamg63tSk9WbRGsSizGgkbFdKr4kqR940=; b=dkQhvhDns6PJ5suW2O3oE2X3DkkQtJt9ioFicRtSmLXSvVWf4TgsoRGE+f5wlAjo 85ierWvuxuU9lKztHb5WtCmyuC4TLGm1Ra1Z5MvU79umFIacUD1AfITUR0oNjRfiiTn ExBUWuP4N6sqDL785qgka6QAyXBbTl+RNrtWeVUs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1531149760; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id:Feedback-ID; bh=76ia/tN0nSQamg63tSk9WbRGsSizGgkbFdKr4kqR940=; b=KP14ZhZEmdHHrFY9cv8QV/NWJLl8s49Yx9oCPQBHkeUSbq2d475XJKzpNRdobebI 9cQ4Yf4YOUJoBF0zQFrBr6Pq4WlofpHwHkF7KDFa2lyf+QKXmcO6Ln5wujgFJmFD5q7 Fi5cxnJGKbxlYH54GdIWDrRNBRIk30L7wfQZiGoQ= Subject: Re: [PATCH v4] Allow using special files with File I/O functions From: =?UTF-8?Q?Julio_Guerra?= To: =?UTF-8?Q?Pedro_Alves?= , =?UTF-8?Q?gdb-patches=40s?= =?UTF-8?Q?ourceware=2Eorg?= Date: Mon, 09 Jul 2018 15:22:00 -0000 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In-Reply-To: <263942fb-504c-7eeb-7840-fc4b70a76ed1@redhat.com> References: <20180705091618.33743-1-julio@farjump.io> <0102016469ba9beb-e8338b53-74bd-46ea-91c7-eea909052532-000000@eu-west-1.amazonses.com> <50cbe319-5b79-24dd-c615-25209d6dd390@redhat.com> <010201647f2fec5a-727b623a-1c7f-4d7e-a9e2-e8076d9e3cc2-000000@eu-west-1.amazonses.com> <263942fb-504c-7eeb-7840-fc4b70a76ed1@redhat.com> <28e7d8d4-7a1a-8fe0-a868-bed711cdb417@farjump.io> Message-ID: <010201647fa337da-17606848-2754-4441-9fed-999f7c238536-000000@eu-west-1.amazonses.com> X-SW-Source: 2018-07/txt/msg00216.txt.bz2 =0D >>>> Signed-off-by: Julio Guerra =0D >>> I'm not sure whether I asked this before, but, just in case,=0D >>> do you have a copyright assignment on file with the FSF?=0D >>> I looked for one now and couldn't find it.=0D >>>=0D >> No, I don't.=0D > See:=0D >=0D > https://sourceware.org/gdb/wiki/ContributionChecklist#FSF_copyright_Assi= gnment=0D >=0D > The request-assign.future one is most common one. Please follow the=0D > instructions at the top of the file.=0D =0D Done.=0D =0D >=0D >>>> diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c=0D >>>> index 313da642ea..168590245e 100644=0D >>>> --- a/gdb/remote-fileio.c=0D >>>> +++ b/gdb/remote-fileio.c=0D >>>> @@ -885,16 +885,9 @@ remote_fileio_func_stat (remote_target *remote, c= har *buf)=0D >>>> remote_fileio_return_errno (remote, -1);=0D >>>> return;=0D >>>> }=0D >>>> - /* Only operate on regular files and directories. */=0D >>>> - if (!ret && !S_ISREG (st.st_mode) && !S_ISDIR (st.st_mode))=0D >>>> - {=0D >>>> - remote_fileio_reply (remote, -1, FILEIO_EACCES);=0D >>>> - return;=0D >>>> - }=0D >>> What happens if we stat/open some kind of unsupported file type?=0D >>> Do we end up with st_mode =3D=3D 0 and report success anyway, or is=0D >>> something else catching it and returning FILEIO_EACCES or some such?=0D >>>=0D >> Yes, bits SFMT of st_mode end up with everything 0 and it doesn't fail.= =0D >> It's like not knowing what kind of file it exactly is, but still get=0D >> other values.=0D > Hmm, OK. I mildly worry whether that that might cause trouble.=0D > I wonder what other filesystem network protocols do here. Like,=0D > e.g., nfs, sshfs, etc.=0D >=0D =0D The 3 options I see:=0D 1 - No restrinction: this one.=0D 2 - Warning: test SFMT bits and when "unsupported", set File IO SFMT=0D bits to some specific FILEIO_S_UNKNOWN value.=0D 3 - Restrict: strictly restrict to those SFMT types I added.=0D =0D I would go for 1 or 2, to avoid another similar restriction like there=0D was in open before this patch.=0D =0D >>>> /* Nonexistant file */=0D >>>> errno =3D 0;=0D >>>> ret =3D stat (NONEXISTANT, &st);=0D >>>> - printf ("stat 4: ret =3D %d, errno =3D %d %s\n", ret, errno,=0D >>>> - strerrno (errno));=0D >>>> + if (!ret)=0D >>>> + printf ("stat 4: ret =3D %d, errno =3D %d %s\n", ret, errno,=0D >>>> + strerrno (errno));=0D >>>> + else=0D >>>> + printf ("stat 1: ret =3D %d, errno =3D %d\n", ret, errno);=0D >>> Do we want to print errno in the !ret case? That indicates the=0D >>> stat call succeeded (even though we expect it to fail).=0D >>> Might be that helps simplify the .exp, I haven't checked.=0D >>>=0D >>> But at least the strerrno call should be on the else=0D >>> branch, as that's the branch where errno is meaninful, and=0D >>> the .exp expects it:=0D >>>=0D >>> FAIL: gdb.base/fileio.exp: Stat a nonexistant file returns ENOENT=0D >>>=0D >>> Did this pass against your stub?=0D >> Yes, here are logs of GDB's execution on this case:=0D >>=0D >>> Continuing.=0D >>> stat 4: ret =3D -1, errno =3D 2 ENOENT=0D > I don't see how that could have been logs for the patch you sent,=0D > because if ret really was -1, then that would have said "stat 1",=0D > and would not have printed ENOENT. Maybe you tested a=0D > different patch?=0D =0D I guess I didn't=C2=A0 run the tests again after this last 'if ... else'=0D modification, sorry...=0D =0D =0D >>>> diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.bas= e/fileio.exp=0D >>>> index bc409c26aa..234f304ac7 100644=0D >>>> --- a/gdb/testsuite/gdb.base/fileio.exp=0D >>>> +++ b/gdb/testsuite/gdb.base/fileio.exp=0D >>>> @@ -31,7 +31,7 @@ if {[is_remote host]} {=0D >>>> =0D >>>> if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \=0D >>>> executable \=0D >>>> - [list debug "additional_flags=3D-DOUTDIR=3D\"$outdir/\""]] !=3D "= " } {=0D >>>> + [list debug "additional_flags=3D-DOUTDIR=3D\"$outdir/\" [target= _info fileio,cflags]" "ldflags=3D[target_info fileio,ldflags]"]] !=3D "" } = {=0D >>> I couldn't tell what's this change for? Why did you need it?=0D >> I couldn't find any other way of adding some CFLAGS and LDFLAGS to the=0D >> call to the cross-compiler to link against the libc using File IOs, to=0D >> add target-specific compilation flags, etc. For example, in my case:=0D >>=0D >>> set_board_info fileio,cflags "--specs=3D$sdk/Alpha.specs=0D >> -mfloat-abi=3Dhard -mfpu=3Dvfp -march=3Darmv6zk -mtune=3Darm1176jzf-s"=0D >>> set_board_info fileio,ldflags "-Wl,-T$sdk/link.ld"=0D > Is this something really specific to this testcase? Don't you=0D > need to do the same for all other testcases?=0D =0D Yes, every other tests involving cross-compilation and the C library=0D need the same.=0D =0D > Did you try CC_FOR_TARGET/LD_FOR_TARGET?=0D =0D I just tried and couldn't make it work. Common use cases are indeed=0D adding extra flags but also extra files to be linked (such as the fileio=0D open, read, write, ... stubs).=0D =0D -- =0D Julio Guerra=0D =0D