From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6LOBMgJI+2W6XQ8AWB0awg (envelope-from ) for ; Wed, 20 Mar 2024 16:33:06 -0400 Received: by simark.ca (Postfix, from userid 112) id C9C4B1E0C0; Wed, 20 Mar 2024 16:33:06 -0400 (EDT) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B39451E08C for ; Wed, 20 Mar 2024 16:33:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73A2D38582A3 for ; Wed, 20 Mar 2024 20:33:04 +0000 (GMT) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by sourceware.org (Postfix) with ESMTPS id 8933A3858D28 for ; Wed, 20 Mar 2024 20:32:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8933A3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8933A3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710966762; cv=none; b=F/nPkDQhwcEcr1LWng7YrZtfYnfZ9lKJL2DJzioNhp1k8yy35guR2Ggf6hM6Y7jG4+7rhqn+AFef7SmRXki1GRQKUThHEHxJu/dCZkj4PSZU7FB+N6XyqaG+dwilUbnp3t+CuB692Kn4SZHU7n2BeCjFL+54SBm8gF91aHQebVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710966762; c=relaxed/simple; bh=1HZGAaCzjNSqR6xMvMpXaKmviL44uEJk0V8OUs/4QlU=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=NZyhCCK0LV0UBV3SN1LZWsukmnuObf7mID6X+5oBCR5vozOhRoO7Dd36zoN6io3RPfQqXwVhmcRG2WSMsqTFDfCFm9xwlge+gU71YiC8KkK/a8gsZrK6G5HWK1YENVfgKFatDU2L3X7EKqEOMVcgaQz8jEwdyIV4HpIqaRFWiq4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-414006a0115so2160395e9.3 for ; Wed, 20 Mar 2024 13:32:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710966751; x=1711571551; h=content-transfer-encoding:in-reply-to:from:references: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=8XhifPqGLwvZi4RjSAS4syOsR1r10dq1vIOUxTyAXL8=; b=EKcqEZ0eaVwhzl4XnpniQnBHyVP2pHF7HoxAFiyhHpCkjKbhW+kOxVAC0vDr9HorEC cf1uD7zZsc+tGaAQcJs5euy8CrdAj58SfHTi515ZXX+40cFogdSnIoUZkAgGlf/jMhzU QvespqCA6TQMBwxrWAI1VUzwRDXP1iATlLo9U0DJc7Km3SksQ0rCFHKbNL3ekUeaZn+h U2Omfj+3IObjxh9hCr7UAZZkGAOqqZt27c7f1DTGRAq6wah5SmS4/DuEsmSV5pr9XOhS rkkyt/TaM8z9+7K09GA/hff6k5RvPJETOiXivAblY1GJevsuAabUYp5nDlLJzzl1apPg rhhA== X-Forwarded-Encrypted: i=1; AJvYcCXR98RUrj8ISIaLy+WOMyMR1YAsWYd4fGDY4cmRcxH72XPcmlu0dYZd4l5jBucnSDr/9rZJt1Rv6fLHhDXa+4jCRDRegBVRA8yf3Q== X-Gm-Message-State: AOJu0YxFswQ1OzLThs4Cj28iw2HNwAMrLuqtOfUHHY4XFMLUq7Wfz5CZ d8To+xe7A4kAKI5TWoDvy3ER1jcInWZZ5d/Dt0uz9SmUzO/Rr2KEIqrJYdxv X-Google-Smtp-Source: AGHT+IG7Vi0oamVrIOijiO+NC6XYURPvweSQXeidsPJXy0jlWA3EDdelGG5LFu3RUDXoq6BwqeK/5Q== X-Received: by 2002:a05:600c:1987:b0:413:ee55:8bba with SMTP id t7-20020a05600c198700b00413ee558bbamr12626017wmq.4.1710966751071; Wed, 20 Mar 2024 13:32:31 -0700 (PDT) Received: from ?IPV6:2001:8a0:f918:ab00:3eb8:f98b:5269:3bd? ([2001:8a0:f918:ab00:3eb8:f98b:5269:3bd]) by smtp.gmail.com with ESMTPSA id p1-20020a05600c1d8100b004146bda6c32sm3241929wms.9.2024.03.20.13.32.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Mar 2024 13:32:30 -0700 (PDT) Message-ID: <2da78531-8a3a-4ac9-a87c-f4962d573fce@palves.net> Date: Wed, 20 Mar 2024 20:32:29 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] gdb, gdbserver, gdbsupport: include config.h files with -include Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org References: <20240318200257.131199-1-simon.marchi@efficios.com> <20240318200257.131199-2-simon.marchi@efficios.com> From: Pedro Alves In-Reply-To: <20240318200257.131199-2-simon.marchi@efficios.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 2024-03-18 20:01, Simon Marchi wrote: > The motivation for this change is for analysis tools and IDEs to be > better at analyzing header files on their own. > > There are some definitions and includes we want to occur at the very > beginning of all translation units. The way we currently do that is by > requiring all source files (.c and .cc files) to include one of defs.h > (for gdb), server.h (for gdbserver) of common-defs.h (for gdbsupport and > shared source files). These special header files define and include > everything that needs to be included at the very beginning. Other > header files are written in a way that assume that these special > "prologue" header files have already been included. > > My problem with that is that my editor (clangd-based) provides a very > bad experience when editing source files. I think you meant "when editing header files." > Since clangd doesn't know > that one of defs.h/server.h/common-defs.h was included already, a lot of > things are flagged as errors. For instance, CORE_ADDR is not known. > It's possible to edit the files in this state, but a lot of the power of > the editor is unavailable. > > My proposal to help with this is to include those things we always want > to be there using the compilers' `-include` option. Tom Tromey said > that the current approach might exist because not all compilers used to > have an option like this. But I believe that it's safe to assume they > do today. > > With this change, clangd picks up the -include option from the compile > command, and is able to analyze the header file correctly, as it sees > all that stuff included or defined but that -include option. That works > because when editing a header file, clangd tries to get the compilation > flags from a source file that includes said header file. > > This change is a bit, because it addresses one of my frustrations when This change is a bit ______? (fill in missing word). > editing header files, but it might help others too. I'd be curious to > know if others encounter the same kinds of problems when editing header > files. Also, even if the change is not necessary by any means, I think > the solution of using -include for stuff we always want to be there is > more elegant than the current solution. > > Even with this -include flag, many header files currently don't include > what they use, but rather depend on files included before them. This > will still cause errors when editing them, but it should be easily > fixable by adding the appropriate include. There's no rush to do so, as > long as the code still copiles, it's just a convenience thing. copiles -> compiles Note there is a make rule to check whether gdb headers are standalone. "make check-headers". Unfortunately, nobody ever runs that ( me included, after adding it a decade ago :-P ). Ideally, we'd fix all it flags and run it (or something like it) once in a while in a CI. (And same for gdbserver/gdbsupport, of course.) > > This patch does the small step of moving the inclusion of the various > config.h files to that new method. The changes are: > > - Add three files meant to be included with -include: gdb/gdb.inc.h, > gdbserver/gdbserver.inc.h and gdbsupport/gdbsupport.inc.h. > - Move the inclusion of the various config.h files there > - Modify the compilation flags of all three subdirectories to add the > appropriate -include option. I'm surprised by the actual patch. Why isn't this including defs.h/common-defs.h? There are surely things defined in those files that need to be defined in headers too. Why create this divergence? I'd think that we would include defs.h/common-defs.h in headers too, and then work on moving things out of defs.h/common-defs.h over time. Pedro Alves