From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id 64B5F3858D1E for ; Mon, 18 Apr 2022 19:24:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64B5F3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f41.google.com with SMTP id i20so19613004wrb.13 for ; Mon, 18 Apr 2022 12:24:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=5oIsExAEqRXLuEIy/x8/HAFS+IU6gyBntA4n434bXBU=; b=mXdLa/PjgJUMTO84gSp+w9O8ijXr+2U/E9mqpN9cHpAw1qEq8A6g/WyT5n8t6rbIYX 3CGLfnB7vJk2PlOc8xJfRFgTmKLsYZS8AJD0EafT75YukJSGQFoqCAq0Oe2yAmJud8Br 4a/JVaSG4TIgWcR2Zz+i/KUIxbnoE1RcbiIvVsILPXBOTaUXLN8aVuhd8793Azs05FwK bw/YKXT0rzltrOMh7ovxdd1+AkqE9AMUoFbZEWNV7UdQCPhTmARDucNpFp6WksbjnJor WK5uaaPP3nPQiRgZXaljty7OKfnl25OegYUpR4OJXQrbpUruTfLKuIfNQ8W7awD6n5mA 8UXQ== X-Gm-Message-State: AOAM533MDXB8IWebhOp8J4e2XmkNkc1jvz/1BCmMMFIV5PvOuqSV4JNe qleIBROA6keXqYWTnKmYX3s= X-Google-Smtp-Source: ABdhPJxCbL8KIKaIsPY5JH7h5/eAuq/b2ReCOSU7is80UAUVSqvq3Ilb/5mxyNBmihBzgP9VMcrZCw== X-Received: by 2002:adf:eed0:0:b0:207:9b35:62c4 with SMTP id a16-20020adfeed0000000b002079b3562c4mr9047780wrp.509.1650309857393; Mon, 18 Apr 2022 12:24:17 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id o2-20020a5d6482000000b0020a96536fcdsm3379602wri.57.2022.04.18.12.24.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 12:24:16 -0700 (PDT) Message-ID: <6c5b669b-45a1-3daf-674b-503ab950c1ff@palves.net> Date: Mon, 18 Apr 2022 20:24:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 5/5] gdbsupport: add path_join function Content-Language: en-US To: Simon Marchi , Eli Zaretskii Cc: gdb-patches@sourceware.org References: <20220414200137.3479373-1-simon.marchi@polymtl.ca> <20220414200137.3479373-5-simon.marchi@polymtl.ca> <83h76u3n04.fsf@gnu.org> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 18 Apr 2022 19:24:20 -0000 On 2022-04-18 19:11, Simon Marchi via Gdb-patches wrote: >> Suggest to add a couple of Windows-specific tests here: one which >> starts with "d:/" instead of just "/", and another with backslashes. > > Should these tests only be ran on Windows hosts? In an ideal world, > this function (and the rest of path handling in GDB) should support > cross-debugging both ways: GDB on Linux debugging a remote Windows > program, GDB on Windows debugging a remote Linux program. That means > corner cases like GDB on Linux should not recognize C:/foo as an > absolute path when debugging a native Linux program, but it should > recognize it as an absolute path when debugging a remote Windows > program. And it should recognize foo\bar\ as ending with a directory > separator when debugging remotely a Windows program, and not when > debugging natively. And vice-versa for a Windows GDB / Linux program. > > Existing code isn't written with that in mind though (macros like > IS_DIR_SEPARATOR are host-specific), and I'm not ready to tackle that > right now. So I've written path_join ignoring those cross-debugging > scenarios. > > So, if I add a test like: > > s = ::path_join ("foo\\", "bar", nullptr); > SELF_CHECK (s == "foo\\bar" || s == "foo/bar"); > > it won't pass on Linux, as s will be "foo\\/bar". So, as long as > path_join is host-dependent, I think we'll need to accept that some > tests will be host-dependent. That's not ideal, but that's how things > are at the moment. Note we have: (gdb) help set target-file-system-kind Set assumed file system kind for target reported file names. If `unix', target file names (e.g., loaded shared library file names) starting the forward slash (`/') character are considered absolute, and the directory separator character is the forward slash (`/'). If `dos-based', target file names starting with a drive letter followed by a colon (e.g., `c:'), are also considered absolute, and the backslash (`\') is also considered a directory separator. Set to `auto' (which is the default), to let GDB decide, based on its knowledge of the target operating system. (gdb) This is used in solib.c only currently. Something like "source-file-system-kind" might make sense to have too. (Not suggesting we add it now.)