public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Peng Yu <pengyu.ut@gmail.com>, libc-help@sourceware.org
Subject: Re: How to look up where a structure is defined?
Date: Wed, 03 Mar 2021 17:26:50 +0300	[thread overview]
Message-ID: <c5e51385df87657043423eead4b6923771a874bb.camel@yandex.ru> (raw)
In-Reply-To: <CABrM6wndrzOVgRVWqq1zeR+6mzk+PKK7cchVppO0cE_EuBqyCg@mail.gmail.com>

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.


  reply	other threads:[~2021-03-03 14:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 14:12 Peng Yu
2021-03-03 14:26 ` Konstantin Kharlamov [this message]
2021-03-03 14:55   ` Konstantin Kharlamov
2021-03-03 19:51     ` Peng Yu
2021-03-03 20:09       ` Konstantin Kharlamov
2021-03-03 20:23         ` Konstantin Kharlamov
2021-03-03 22:24           ` Peng Yu
2021-03-03 22:45             ` Konstantin Kharlamov
2021-03-03 22:46               ` Peng Yu
2021-03-03 22:57                 ` Konstantin Kharlamov
     [not found]                   ` <CABrM6wkdp_WB5_XT9-TyzjwqPTAz5eNX=NiWL2XhfXEUsm976Q@mail.gmail.com>
     [not found]                     ` <947e1677c982b59d21fc4507f5cf6b284b3c8355.camel@yandex.ru>
2021-03-03 23:21                       ` Peng Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5e51385df87657043423eead4b6923771a874bb.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=libc-help@sourceware.org \
    --cc=pengyu.ut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).