From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Peng Yu <pengyu.ut@gmail.com>
Cc: libc-help <libc-help@sourceware.org>
Subject: Re: How to look up where a structure is defined?
Date: Thu, 04 Mar 2021 01:57:11 +0300 [thread overview]
Message-ID: <578771c0c477e121db3fc5f87ecec37df9068c84.camel@yandex.ru> (raw)
In-Reply-To: <CABrM6w=qHq_mSK8Gr8wUGQjURs_JfO00kZEUO0K6H94giJ4Jow@mail.gmail.com>
On Wed, 2021-03-03 at 16:46 -0600, Peng Yu wrote:
> On 3/3/21, Konstantin Kharlamov <hi-angel@yandex.ru> wrote:
> > On Wed, 2021-03-03 at 16:24 -0600, Peng Yu wrote:
> > > On Wed, Mar 3, 2021 at 2:23 PM Konstantin Kharlamov <hi-angel@yandex.ru>
> > > wrote:
> > > >
> > > > On Wed, 2021-03-03 at 23:09 +0300, Konstantin Kharlamov wrote:
> > > > > 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).
> > > >
> > > > Although, I wouldn't hold my breath that reading a resulting xref file
> > > > would
> > > > be easy The reason being is that I expect a tags file created from
> > > > glibc
> > > > repo to be some hundreds of megabytes. For reference, a TAGS file I
> > > > generated long ago for libreoffice project is sized at 183M.
> > > >
> > > > So yeah, you will probably want to use the file from an IDE or text
> > > > editor,
> > > > rather than reading it manually.
> > >
> > > ctags can partially solve the problem. The declaration and definition
> > > of a struct are all in the header. So finding the definition is OK.
> > > But it can not return function declaration. Is there a way to show
> > > function declaration as well? (For example, ./socket/sys/socket.h for
> > > setsockopt().)
> > >
> > > $ grep '^icmphdr\>' tags
> > > icmphdr sysdeps/gnu/netinet/ip_icmp.h /^struct icmphdr$/;" s
> > > $ grep ^setsockopt tags
> > > setsockopt sysdeps/unix/sysv/linux/setsockopt.c /^setsockopt (int fd,
> > > int level, int optname, const void *optval, socklen_t len)$/;" f
>
> ctags only shows the above. The following is what I show where the
> declaration is.
Ah, I see. Okay, so, I think including declarations by default is disabled, you probably need to enable it. There're various options on what to include in the tags file, see `ctags --list-kinds-full`, and then using an option kinda like `--kinds-C=+px` (p and x are letters from the --list-kinds-full) should work.
next prev parent reply other threads:[~2021-03-03 22:57 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
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 [this message]
[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=578771c0c477e121db3fc5f87ecec37df9068c84.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).