From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [IPv6:2a02:6b8:0:801:2::109]) by sourceware.org (Postfix) with ESMTPS id 410B33987C0D for ; Wed, 3 Mar 2021 20:09:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 410B33987C0D 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 myt5-a2a79abff87c.qloud-c.yandex.net (myt5-a2a79abff87c.qloud-c.yandex.net [IPv6:2a02:6b8:c12:1f87:0:640:a2a7:9abf]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 11DCF11A03B7; Wed, 3 Mar 2021 23:09:48 +0300 (MSK) Received: from myt6-016ca1315a73.qloud-c.yandex.net (myt6-016ca1315a73.qloud-c.yandex.net [2a02:6b8:c12:4e0e:0:640:16c:a131]) by myt5-a2a79abff87c.qloud-c.yandex.net (mxback/Yandex) with ESMTP id pke0Tx8vbq-9lIWhA4D; Wed, 03 Mar 2021 23:09:48 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1614802188; bh=1QPj8y+3T7VqwQDDQ4dL1T/APYJYFyTvpM891yh770w=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=jh0WZqkLJc92B4QyjYzpkJmkww4t6LExUJlPi33YySBHsUETJ0mCVlsUOjXfK63EE pqnfEE1hy7DEyoqSFpK0cH31ru8mlvPLYKqZnF88IRP9od9N+Qarui4Yh/Qd98o7BM rzZUWj5IdVOsJypVN7cKpDgHDD3DnCYMUzcLevfo= Authentication-Results: myt5-a2a79abff87c.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by myt6-016ca1315a73.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id a7nEpOauwX-9loqNYKu; Wed, 03 Mar 2021 23:09:47 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <998ef50db5faec782f174bd05394155a54830e11.camel@yandex.ru> Subject: Re: How to look up where a structure is defined? From: Konstantin Kharlamov To: Peng Yu Cc: libc-help Date: Wed, 03 Mar 2021 23:09:47 +0300 In-Reply-To: References: <9f1dbafc6d1184d9ca07bdea98f696e0ca65b9e2.camel@yandex.ru> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 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 20:09:53 -0000 On Wed, 2021-03-03 at 13:51 -0600, Peng Yu wrote: > This seems to be a complicated solution. I just want to get a database > (a TSV file should be fine) of types and the header they appear. I > don't want to build the project just to get this info. I see, well, the Universal Ctags I mentioned should work for you. It doesn't require building the project: you just run `ctags -R` or `ctags -Re` (first for vim-style tags file, second one for emacs-style) over the repository, and you get a `tags` or `TAGS` file with a list of definitions. Possible drawbacks on ctags I mentioned in the other email. Basically it's that it doesn't take context into consideration. Regarding usage: the tags file it generates, although can be read for human, supposed to be read by text editors/IDEs. Since you mention a CSV file, I assume you might want something human-readable. Please see option --output-format= in `man ctags` for details: I think you might want the `xref` format. (I never tried it myself, just reading the man it seems like it what you're after). > It seems that this database could be made and hosted online for easy > download or lookup. Yeah, something like a https://elixir.bootlin.com/linux/v5.12-rc1/source site (which allows to navigate Linux kernel sources online), but for glibc — I agree, would be nice! > On Wed, Mar 3, 2021 at 8:55 AM Konstantin Kharlamov wrote: > > > > On Wed, 2021-03-03 at 17:26 +0300, Konstantin Kharlamov wrote: > > > 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. > > > > To clarify: if you already built the project you'll need somehow to re-build > > it > > with bear. So, for example, you can call a `find -type f -exec touch {} \;` in > > the source tree to cause timestamps of all files to get bumped, and then > > running > > a make command will trigger a full rebuild. >