How to look up where a structure is defined?

Konstantin Kharlamov hi-angel@yandex.ru
Wed Mar 3 20:09:47 GMT 2021


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 <hi-angel@yandex.ru> 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.
> 




More information about the Libc-help mailing list