From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:109]) by sourceware.org (Postfix) with ESMTPS id 4CD933850430 for ; Wed, 3 Mar 2021 22:57:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4CD933850430 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-36442628f0be.qloud-c.yandex.net (myt5-36442628f0be.qloud-c.yandex.net [IPv6:2a02:6b8:c12:1c0c:0:640:3644:2628]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 8516A1C80511; Thu, 4 Mar 2021 01:57:12 +0300 (MSK) Received: from myt5-ca5ec8faf378.qloud-c.yandex.net (myt5-ca5ec8faf378.qloud-c.yandex.net [2a02:6b8:c12:2514:0:640:ca5e:c8fa]) by myt5-36442628f0be.qloud-c.yandex.net (mxback/Yandex) with ESMTP id ZCMhZtSLKZ-vCImUASx; Thu, 04 Mar 2021 01:57:12 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1614812232; bh=UmAwyxqqiF6MSX9eYIc5aJecAIQbmI9v1YOtQokdycI=; h=In-Reply-To:Cc:To:From:Subject:Message-ID:References:Date; b=aHrV9dL6xxENqep7fMBOnS9JmCsE05Zj17Y7FTxroeaAboDGcZCf/KFFPw4YPOR+u HhMNOnNPJ7c+NyeaL3jJqtaDeFRGXRs/P/+u1KhIe1bXVt88qEivfmBiUZlcDvCauu mhoiLO8aCXFg0qvPPartdb16qaH+XR613Mwwfm9g= Authentication-Results: myt5-36442628f0be.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by myt5-ca5ec8faf378.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 0g3YjqXerH-vBpGMg1e; Thu, 04 Mar 2021 01:57:12 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <578771c0c477e121db3fc5f87ecec37df9068c84.camel@yandex.ru> Subject: Re: How to look up where a structure is defined? From: Konstantin Kharlamov To: Peng Yu Cc: libc-help Date: Thu, 04 Mar 2021 01:57:11 +0300 In-Reply-To: References: <9f1dbafc6d1184d9ca07bdea98f696e0ca65b9e2.camel@yandex.ru> <998ef50db5faec782f174bd05394155a54830e11.camel@yandex.ru> <61f99c80b25f584bdcf0f03c271fd005a09757c4.camel@yandex.ru> <56fda69d99a5bdb4e7aed891a4af0e0a6112f16e.camel@yandex.ru> 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=-2.4 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 22:57:16 -0000 On Wed, 2021-03-03 at 16:46 -0600, Peng Yu wrote: > On 3/3/21, Konstantin Kharlamov wrote: > > On Wed, 2021-03-03 at 16:24 -0600, Peng Yu wrote: > > > On Wed, Mar 3, 2021 at 2:23 PM Konstantin Kharlamov > > > 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.