From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id B066F385828D; Fri, 20 Jan 2023 20:39:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B066F385828D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x32c.google.com with SMTP id g10so4959489wmo.1; Fri, 20 Jan 2023 12:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vYEtvsHOr11pCweLLxyPry228qlBYzqjT+8W6nN6EzI=; b=hHeUbBH5BTDr/chDeLGz5qNJYx8YqiNdkrF1ihjvLRZs/oznFWhI/ChDQPyKrvZURM W2OHtWn6qFaCG58NHP/8BzF+eDhk+ID9UbG6/UBXkUQ3e+QbmYEiaKX88SI63hkxfwAb h79pOf124at+CsPOagFQ+vwp3zLBeSa5SdkzWrOBQyl8gRAMdTKUKW7sWQa//S0x2jt0 V4iozZdF8mVsNBk+zPQk2+ArfVDD67QU0bXfxyPOFXg82Ugj8ZAZUasFEmvzs7yqzrw/ hwC1xsoh5sj04ho0Ok0BoYMfjq6kMYfUMOxH6ptnSUDTZChOJAt7AywApTNUoMC8aJAy oaeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vYEtvsHOr11pCweLLxyPry228qlBYzqjT+8W6nN6EzI=; b=LnAnkAsSDy1yykDG/i3XWQZbMcl7MFHri9UYToXVSl323etFh0NXuZmy3cmvAmgj/6 lRR+zckF8ZamJ7zJFSubmevJ1LHZrrpFNrnfuGE4bUrnos4tW87kMl8ZKIu21XOvB2jG oOL6kWpEDnB3SrorsK9+liW9MBSIyE+7cCMl36XHTNgXjTIPCcj57vdwb5IJDxeLxGwp hzBqxuBNJRGrPQIGoStA9MvLp1VF7naIgks0KJLxSa5fy/SJCKCJP4cujtTgpkFHWMdz 7qREUJHKJk4r5U8oMNuyDuVqzGFSoH3LmTposENPzjiBdiBc1p04Y+UeyK0WZTG5q9mz GsoA== X-Gm-Message-State: AFqh2krVt63fqRb6D1KMshlBxSAydftdVfyadHtk2jEFxU5L/gHmmqbf yyfYRtG2Ngk7xJxNky8PzPh0ZZ5THGLjdJxD1A4= X-Google-Smtp-Source: AMrXdXsDgrzI+3axll4yfMGcB8JZVv+7N9FhFwrUaR8/0LlZCScZiYFn3zHsKCBj/NXSiHnVIoomdg== X-Received: by 2002:a05:600c:2056:b0:3db:ce8:6662 with SMTP id p22-20020a05600c205600b003db0ce86662mr13366538wmg.31.1674247197347; Fri, 20 Jan 2023 12:39:57 -0800 (PST) Received: from [10.21.0.4] ([185.246.211.91]) by smtp.gmail.com with ESMTPSA id he11-20020a05600c540b00b003d9b89a39b2sm3203077wmb.10.2023.01.20.12.39.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Jan 2023 12:39:56 -0800 (PST) Message-ID: <64148e01-15a1-0331-ad52-bf131403ed76@gmail.com> Date: Fri, 20 Jan 2023 21:39:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 3/4] libbacktrace: work with aslr on windows Content-Language: en-US To: Eli Zaretskii Cc: gcc@hazardy.de, gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org References: <20230120105409.54949-1-gcc@hazardy.de> <20230120105409.54949-3-gcc@hazardy.de> <83zgadmik1.fsf@gnu.org> <83k01hm2sm.fsf@gnu.org> From: Gabriel Ravier In-Reply-To: <83k01hm2sm.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/20/23 20:19, Eli Zaretskii wrote: >> Date: Fri, 20 Jan 2023 17:46:59 +0100 >> Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org >> From: Gabriel Ravier >> >> On 1/20/23 14:39, Eli Zaretskii via Gcc wrote: >>>> From: Björn Schäpers >>>> Date: Fri, 20 Jan 2023 11:54:08 +0100 >>>> >>>> @@ -856,7 +870,12 @@ coff_add (struct backtrace_state *state, int descriptor, >>>> + (sections[i].offset - min_offset)); >>>> } >>>> >>>> - if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections, >>>> +#ifdef HAVE_WINDOWS_H >>>> + module_handle = (uintptr_t) GetModuleHandleW (NULL); >>>> + base_address = module_handle - image_base; >>>> +#endif >>>> + >>>> + if (!backtrace_dwarf_add (state, base_address, &dwarf_sections, >>>> 0, /* FIXME: is_bigendian */ >>>> NULL, /* altlink */ >>>> error_callback, data, fileline_fn, >>> Why do you force using the "wide" APIs here? Won't GetModuleHandle do >>> the job, whether it resolves to GetModuleHandleA or GetModuleHandleW? >> I would expect the reason to be either that: >> >> - using wide APIs with Windows is generally considered to be a best >> practice, even when not strictly needed (and in this case I can't see >> any problem with doing so, unless maybe we want to code to work with >> Windows 95 or something like that...) > There's no reason to forcibly break GDB on platforms where wide APIs > are not available. Are there even any platforms that have GetModuleHandleA but not GetModuleHandleW ? MSDN states that Windows XP and Windows Server 2003 are the first versions to support both of the APIs, so if this is supposed to work on Windows 98, for instance, whether we're using GetModuleHandleA or GetModuleHandleW won't matter. > >> - using the narrow API somehow has an actual drawback, for example maybe >> it might not work if the name of the exe file the NULL will tell it to >> get a handle to contains wide characters > Native Windows port of GDB doesn't support Unicode file names anyway, > which is why you used the *A APIs elsewhere in the patch, and > rightfully so. So there's no reason to use "wide" APIs in this one > place, and every reason not to. (just as a clarification, I did not write this patch)