From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id 36B07385F028 for ; Wed, 3 Mar 2021 22:25:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 36B07385F028 Received: by mail-io1-xd35.google.com with SMTP id n14so27575925iog.3 for ; Wed, 03 Mar 2021 14:25:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OhmzhNiXljYq4u1uyYwwjJIgMjqtO9LaYvD5L6A/ZdY=; b=JUdt4G+Fa8quz8k3XpXegexwR7XYH/8O7Xtt+AA7/2FjfnvPWJCAp5nLyjTLY9ChMB 4HavPoCUP7t1J/DCtnDik04fvCoE2zaxl+9YoooSSHDN3ZdJZXFnJqTt3qW00l4F6gNR CgbLNgecO0+izmKogynkOpxdhP1lRis2/3ca4RhYEXCTb1iTio6+E63eL9NYcBJrkfQn EJRuq57q+Z2bYRF94dTqjn6yTh4L/PaOP1X5d2TDC55ExKMPHe5bH6Upr4jywewosqpm 3gBOBWMRxxSHGrQ9ulmK2rwbKp6TQWKFvarwuYx+l2egDwbQubO5sJVxtBhTS4DZattK dAcg== X-Gm-Message-State: AOAM5321w2qMOmlh8IrYOy9qiVKzSE8o3hilM1p/AXwpMXtNFAG7yydL odphJLtFoNFpa6zjjgXbAxMIivTrqzhV0TIs7uI= X-Google-Smtp-Source: ABdhPJzbeOg+in4/ip3xMXhBMXXuClqFIke/Ux7noHBIXHAcs+WpIMpXE0FdsidmFSHcx4dwnA5uguvD7yg7cGxohWk= X-Received: by 2002:a02:9003:: with SMTP id w3mr1122093jaf.31.1614810306742; Wed, 03 Mar 2021 14:25:06 -0800 (PST) MIME-Version: 1.0 References: <9f1dbafc6d1184d9ca07bdea98f696e0ca65b9e2.camel@yandex.ru> <998ef50db5faec782f174bd05394155a54830e11.camel@yandex.ru> <61f99c80b25f584bdcf0f03c271fd005a09757c4.camel@yandex.ru> In-Reply-To: <61f99c80b25f584bdcf0f03c271fd005a09757c4.camel@yandex.ru> From: Peng Yu Date: Wed, 3 Mar 2021 16:24:55 -0600 Message-ID: Subject: Re: How to look up where a structure is defined? To: Konstantin Kharlamov Cc: libc-help Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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:25:10 -0000 On Wed, Mar 3, 2021 at 2:23 PM Konstantin Kharlamov wr= ote: > > 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 databas= e > > > (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 do= esn't > > require building the project: you just run `ctags -R` or `ctags -Re` (f= irst > > for > > vim-style tags file, second one for emacs-style) over the repository, a= nd you > > get a `tags` or `TAGS` file with a list of definitions. > > > > Possible drawbacks on ctags I mentioned in the other email. Basically i= t's > > that > > it doesn't take context into consideration. > > > > Regarding usage: the tags file it generates, although can be read for h= uman, > > 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-for= mat=3D in > > `man ctags` for details: I think you might want the `xref` format. (I n= ever > > tried it myself, just reading the man it seems like it what you're afte= r). > > Although, I wouldn't hold my breath that reading a resulting xref file wo= uld be easy The reason being is that I expect a tags file created from glib= c repo to be some hundreds of megabytes. For reference, a TAGS file I gener= ated long ago for libreoffice project is sized at 183M. > > So yeah, you will probably want to use the file from an IDE or text edito= r, 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 ./socket/sys/socket.h 215:extern int setsockopt (int __fd, int __level, int __optname, --=20 Regards, Peng