From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10929 invoked by alias); 22 Sep 2017 20:47:29 -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 10198 invoked by uid 89); 22 Sep 2017 20:47:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Sep 2017 20:47:28 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE2F5C04B93A; Fri, 22 Sep 2017 20:47:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE2F5C04B93A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj@redhat.com Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B43C05D9CB; Fri, 22 Sep 2017 20:47:26 +0000 (UTC) From: Sergio Durigan Junior To: Eli Zaretskii Cc: gdb-patches@sourceware.org, palves@redhat.com Subject: Re: [PATCH v3 5/5] Extend "set cwd" to work on gdbserver References: <20170912042325.14927-1-sergiodj@redhat.com> <20170921225926.23132-1-sergiodj@redhat.com> <20170921225926.23132-6-sergiodj@redhat.com> <83o9q3cftp.fsf@gnu.org> <87bmm21sig.fsf@redhat.com> <837ewqczzs.fsf@gnu.org> Date: Fri, 22 Sep 2017 20:47:00 -0000 In-Reply-To: <837ewqczzs.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 22 Sep 2017 22:08:55 +0300") Message-ID: <87o9q2zcip.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00700.txt.bz2 On Friday, September 22 2017, Eli Zaretskii wrote: >> From: Sergio Durigan Junior >> Cc: gdb-patches@sourceware.org, palves@redhat.com >> Date: Fri, 22 Sep 2017 14:45:59 -0400 >> >> >> + if (inferior_cwd != NULL) >> >> + { >> >> + size_t cwdlen = strlen (inferior_cwd); >> >> + >> >> + wcwd = alloca ((cwdlen + 1) * sizeof (wchar_t)); >> >> + mbstowcs (wcwd, inferior_cwd, cwdlen + 1); >> >> + } >> > >> > no error checking of the mbstowcs conversion? >> >> Sorry, I am not a Windows programmer. Other places in the code also >> don't check for errors. > > Not checking for errors in these conversions can be worse on Windows > than on other platforms, because the Windows' wchar_t supports only > the BMP, so the chances of getting a conversion error are higher than > on Unix. > >> I'd be happy to improve this code, but I refuse to touch a Windows >> machine so I'm doing this all this without any testing. But please, >> feel absolutely free to point out how this code should look like. > > mbstowcs returns NULL if it fails, so I suggest to throw an error in > that case. I see no reason for anything fancier. OK, that I can do :-). >> >> +static void >> >> +extended_remote_set_inferior_cwd (struct remote_state *rs) >> >> +{ >> >> + if (packet_support (PACKET_QSetWorkingDir) != PACKET_DISABLE) >> >> + { >> >> + const char *inferior_cwd = get_inferior_cwd (); >> >> + >> >> + if (inferior_cwd != NULL) >> >> + { >> >> + std::string hexpath = bin2hex ((const gdb_byte *) inferior_cwd, >> >> + strlen (inferior_cwd)); >> >> + >> > >> > Shouldn't this do some encoding conversion, from the GDB charset to >> > the target charset, before encoding in hex? >> >> I don't know. There's nothing related to charset on gdb/gdbserver/, but >> then again I don't know if we've ever encountered a case that demanded >> conversions. I can investigate this a bit more. > > GDB does know about target-charset and host-charset. I'd expect file > names that are sent to the target be in the target charset, but since > what get_inferior_cwd returns is in host charset (it was typed by the > user), I think a conversion might be in order. I don't know. We never seem to do that in other cases. For example, when we are starting the inferior remotely: static int extended_remote_run (const std::string &args) { ... if (strlen (remote_exec_file) * 2 + len >= get_remote_packet_size ()) error (_("Remote file name too long for run packet")); len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->buf + len, strlen (remote_exec_file)); The "remote_exec_file" variable is also something that the user inputs through the "set remote exec-file" command. It doesn't seem like we need to worry about charset conversion here. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/