From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::601]) by sourceware.org (Postfix) with ESMTPS id 4301C3851C1C for ; Wed, 3 Mar 2021 14:26:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4301C3851C1C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hi-angel@yandex.ru Received: from iva5-f187da138599.qloud-c.yandex.net (iva5-f187da138599.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:812a:0:640:f187:da13]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 776423C03E3A; Wed, 3 Mar 2021 17:26:51 +0300 (MSK) Received: from iva7-f62245f79210.qloud-c.yandex.net (iva7-f62245f79210.qloud-c.yandex.net [2a02:6b8:c0c:2e83:0:640:f622:45f7]) by iva5-f187da138599.qloud-c.yandex.net (mxback/Yandex) with ESMTP id ZwEzl8PfKj-QpHKi6Vn; Wed, 03 Mar 2021 17:26:51 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1614781611; bh=ywAV/zm3jchgtO/T7/Eh8E23uU1k3BSOzPRsb+GPVaw=; h=In-Reply-To:To:From:Subject:Message-ID:References:Date; b=czKDk7Zwxsp3VYtkcIfEGzbwaXjloe/WpHL5R1sW5g95yKNaIF8UdC2VVnp1gz6aA gmLCrxnhSz7LByAQQdrM57nffkOdIgRNg1rLOI5b6/owilep6HmtE2x/+3ryT0rVqH IC0gAnzk2VYeyYpeSan4kNaVleCuhsO+JljE64oA= Authentication-Results: iva5-f187da138599.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by iva7-f62245f79210.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id io9arfaXPF-QooCG0bf; Wed, 03 Mar 2021 17:26:50 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: Subject: Re: How to look up where a structure is defined? From: Konstantin Kharlamov To: Peng Yu , libc-help@sourceware.org Date: Wed, 03 Mar 2021 17:26:50 +0300 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2021 14:26:55 -0000 On Wed, 2021-03-03 at 08:12 -0600, Peng Yu via Libc-help wrote: > Hi, > > I would like to lookup types and constants in libc. It would be most > efficient to have a database lookup for this purpose instead of using > google search or code search. > > Is there such a database available? Thanks. > I assume you're referring to the usual "go to definition" functional in code editors/IDE. In that case I don't think glibc is too different from other projects. The simplest (but not very good) way is using Universal Ctags, and generating a tags file from the source tree, and then feeding that into your editor/IDE. I don't know if it's good enough for you: it should work for basic navigation, but wouldn't provide you with navigation inside functions, or for various complex constructions out of macros. Nowadays most popular way is lsp-server, should be supported by most existing modern IDEs/editors, including vim/emacs (you might need to install a plugin). For C/C++ projects I usually use `clangd` as the lsp-server. You'll stumble upon a gotcha though: Glibc is a very old project, that is still using autotools/make. So, unlike Meson-based projects, you'll need to generate `compile_commands.json` file yourself. It should be easy though: there's `bear` utility, which takes a make command as input, and parses it output while it builds the project, and stores the output into `compile_commands.json` file. So for example: if you usually build glibc with `make`, then to generate the file you have to use a `bear -- make` instead.