GTAGS(1)
π GTAGS(1) π
okay bestie, sit down, hydrate, because this is the general commands manual page for gtags and it's a LOT (which is why we're doing it in parts π
).
β¨ NAME β¨
gtags β create tag files for global π
πΈ SYNOPSIS πΈ
gtags [-ciIOqvw][-C dir][-d tag-file][-f file][dbpath]
π¦ DESCRIPTION π¦
So. gtags is the girl who makes tag files for global(1). That's her whole job. She's very good at it. π«Ά
gtags recursively collects source files under the current directory, picks up symbols, and writes all that cross-reference data into the tag files β those are GTAGS, GRTAGS and GPATH. Three files, one icon. π
By default, gtags picks up C, Yacc, assembly language, Java, C++ and PHP source files. Here's the full vibe check on suffixes, no cap:
- Files whose names end in
.c,.hare assumed to be C source files. - Files whose names end in
.yare assumed to be Yacc source files. - Files whose names end in
.s,.Sare assumed to be assembly language source files. - Files whose names end in
.javaare assumed to be Java source files. - Files whose names end in
.c++,.cc,.hh,.cpp,.cxx,.hxx,.hpp,.C,.Hare assumed to be C++ source files. - Files whose names end in
.php,.php3,.phtmlare assumed to be PHP source files.
Other files are assumed to be text files. And gtags does not treat binary files. periodt. π
ββοΈ
If gtags.files exists in the current directory, or a file is specified by the -f option, target files are limited by it. Lines starting with . are comments. π¬
β¨ OPTIONS β¨
The following options are available:
--accept-dotfilesβ Accept files and directories whose names begin with a dot. By default,gtagsignores them. π-c,--compactβ MakeGTAGSin compact format. This option does not influenceGRTAGS, because that is always made in compact format. (she's born compact, she stays compact π )-C,--directorydir β Change the directory before doing all the work including parameter analysis. This option is ignored in GTAGS_OPTIONS. Please specify it on the command line directly. like, directly directly. π«΅--config[=name]β Print the value of config variable name. If name is not specified then print all names and values. Additionally, you can refer to the directory name where the system is installed as read only variables:bindir,libdir,datadir,localstatedirandsysconfdir. peek behind the curtain, bestie β¨-d,--dumptag-file β Dump a tag file as text to the standard output. Output format is'key<tab>data'. This is for debugging. π--explainβ Explain handling files. she'll tell you exactly what she's doing with each one, very transparent, we love that π-f,--filefile β Give a list of candidates of target files. Files which are not on the list are ignored. The argument file can be set to-to accept a list of files from the standard input. File names must be separated by newline. To make the list you may use find(1), which has rich options for selecting files. π§Ί--gtagsconffile β Set environment variableGTAGSCONFto file.--gtagslabellabel β Set environment variableGTAGSLABELto label. π·οΈ--helpβ Print a usage message.-I,--idutilsβ In addition to tag files, make ID database for idutils(1). overachiever behavior π₯-i,--incrementalβ Update tag files incrementally. It's better to use global(1) with the-ucommand.-O,--objdirβ Use BSD-style obj directory as the location of tag files. IfGTAGSOBJDIRPREFIXis set and$GTAGSOBJDIRPREFIXdirectory exists,gtagscreates$GTAGSOBJDIRPREFIX/<current directory>directory and makes tag files in it. Though you can useMAKEOBJDIRPREFIXinstead ofGTAGSOBJDIRPREFIX, it is deprecated. If dbpath is specified, this option is ignored. π¦--single-updatefile β Update tag files for a single file. It is considered that file was added, updated or deleted, and there is no change in other files. This option implies the-ioption. just one file, one little file, main character energy π--skip-unreadableβ Skip unreadable files. This option was deprecated. Any file that cannot be read is skipped with a warning message, regardless of whether this option is used. so like. it does nothing now. we still list her though π--skip-symlink[=type]β Skip symbolic links. If type is'f'then skip only symbolic links for file, else if'd'then skip only symbolic links for directory. The default value of type is'a'(all symbolic links). If you configure this program with--with-fts, the type value is ignored, and always treated as if'a'were specified. π--sqlite3β Use Sqlite 3 API to make tag files. By default, BSD/DB 1.85 API is used. To use this option, you need to invoke configure script with--with-sqlite3in the build phase. ποΈ--statisticsβ Print statistics information. numbers!! give me the numbers π-q,--quietβ Quiet mode. π€«-v,--verboseβ Verbose mode. π£οΈ--versionβ Show version number.-w,--warningβ Print warning messages. β οΈ- dbpath β The directory in which tag files are generated. The default is the current directory. π
π« EXAMPLES π«
$ ls -F
Makefile src/ lib/
$ gtags -v
$ global -x main
main 10 src/main.c main (argc, argv) {
see how easy that was? ate. π
πΈ FILES πΈ
GTAGSβ Tag file for definitions.GRTAGSβ Tag file for references.GPATHβ Tag file for source files.gtags.conf,$HOME/.globalrcβ Configuration data for GNU Global. See gtags.conf(5).gtags.filesβ The list of candidates of target files..notfunctionβ The list of symbols which is not a definition. If this file exists in the project root directory,gtagsdoes not regard the symbols listed in this file as definitions. Lines starting with';'are comment lines.
π ENVIRONMENT π
The following environment variables affect the execution of gtags:
GTAGSCACHEβ The size of the B-tree cache. The default is50000000(bytes). π§GTAGSCONFβ Configuration file.GTAGSFORCECPPβ If this variable is set, each file whose suffix is.his forcibly parsed by the built-in C++ parser. Do not set this variable if you are using plug-in parsers. This variable and the built-in C++ parser are deprecated. π«GTAGSFORCEENDBLOCKβ If this variable is set, each}at the first column brings end of block of 0 level.GTAGSLABELβ Configuration label. The default is'default'.GTAGSLOGGINGβ If this variable is set,$GTAGSLOGGINGis used as the path name of a log file. There is no default value. πGTAGS_COMMANDLINEβ This variable can only be referenced from the hook (seegtags_hook).gtagssets its own effective command line to this variable before calling the hook. Each argument is separated by whitespace, and real whitespace is represented as'%20'. This is read only. πGTAGS_OPTIONSβ The value of this variable is inserted in the head of arguments.GTAGSOBJDIRβ If this variable is set, it is used as the name of BSD-style objdir. The default is'obj'. Though you can useMAKEOBJDIRinstead ofGTAGSOBJDIR, it is deprecated.GTAGSOBJDIRPREFIXβ If this variable is set, it is used as the prefix of BSD-style objdir. The default is'/usr/obj'. Though you can useMAKEOBJDIRPREFIXinstead ofGTAGSOBJDIRPREFIX, it is deprecated.TMPDIRβ The location used to stored temporary files. The default is'/tmp'.
y'all the deprecated ones are deprecated for a reason, please stop using them, i'm begging π
β¨ CONFIGURATION β¨
The following configuration variables affect the execution of gtags. You can see the default value for each variable with the --config option. ποΈ
gtags_parser(comma separated list) β Specify the mapping of language names and plug-in parsers. Each part delimited by the comma consists of a language name, a colon, the shared object path, an optional colon followed by a function name. If the function name is not specified,'parser'is assumed. As a special exception,gtagscollects values from multiplegtags_parservariables. For these mappings, the first match is adopted.gtags_hook(command line) β Specify a command line which should be executed at the beginning ofgtagsafter loading configuration file. You can use this hook to updategtags.filesdynamically."./"in it always means the project root directory, sincegtagsis always invoked there.
This hook is ignored when the following options are specified: --version, --help, --config, --dump.
icase_path(boolean) β Ignore case distinctions in the path. Suffixes check is affected by this capability.langmap(comma separated list) β Language mapping. Each comma-separated map consists of a language name, a colon, and a list of file extensions. You can specify a glob pattern surrounded by parentheses instead of an extension for the files without extensions (e.g.Make:([Mm]akefile).mak.mk). As a special exception,gtagscollects values from multiplelangmapvariables. For these mappings, the first match is adopted. Default mapping is:'c:.c.h,yacc:.y,asm:.s.S,java:.java,cpp:.c++.cc.hh.cpp.cxx.hxx.hpp.C.H,php:.php.php3.phtml'. πΊοΈskip(comma separated list) βgtagsskips files and directories which are given in this list. As a special exception,gtagscollects values from multipleskipvariables. If the value ends with'/', it is assumed as a directory andgtagsskips all files under it. The value may include glob patterns (*,?,[...],[!...],[^...]).
If the value starts with '/', it is assumed a relative path name from the root directory of the project. You cannot use glob patterns for a path name. However, this direction is out-of-date, and is not recommended. Instead, you can use -f option which can be combined with find(1). Since find(1) has rich options to select files, you can do everything. Additionally, this technique can also be applied to any other tagging systems like ctags(1), cscope(1), etc.
Skip list is also effective when you use the -f or gtags.files.
π« EXAMPLES π«
#
# There are several ways to use Universal Ctags plug-in parser.
#
$ gtags --gtagsconf=/usr/local/share/gtags/gtags.conf --gtagslabel=universal-ctags
$ gtags --explain
or
$ export GTAGSCONF=/usr/local/share/gtags/gtags.conf
$ export GTAGSLABEL=universal-ctags
$ gtags --explain
or
# In your project
$ cp /usr/local/share/gtags/gtags.conf .
$ vi gtags.conf # default:tc=native => default:tc=universal-ctags
$ gtags --explain
three ways to serve the same look, we love options π
π DIAGNOSTICS π
okay so here's the tea on whether it worked or not, bestie:
gtagsexits with a non-0 value if an error occurred, and0if everything was chill. no in-between, no vibes-based ambiguity.- heads up tho: any files that
gtagscreated while it had a non-zero exit code? consider those corrupted. fr fr. don't trust them, don't build on them, just yeet them and re-run. π«Ά
π SEE ALSO π
your little friend group of manpages, go say hi:
global(1)β the main character of querying, lowkey iconichtags(1)β makes the pretty HTML version, serving looksgtags.conf(5)β where all the config drama lives
and if you wanna go deeper down the rabbit hole: GNU Global source code tag system at http://www.gnu.org/software/global/. that's the source, bestie. πβ¨
π¨ BUG π¨
real talk, no filter:
GTAGSandGRTAGSare very large. like, alarming. before you run this command, please please please check the space on your disk. do the vibe check on yourdffirst, i'm begging π- Assembly language support is far from complete. it only extracts
ENTRY()andALTENTRY()from the source file β that's it, that's the whole bag. and honestly it's probably only valid for FreeBSD and Linux kernel source anyway. π€·ββοΈ - C++ support is deprecated. letting you know gently but firmly. π
- there is no concurrency control about tag files. nope. none. so don't have two things writing to them at once unless you enjoy chaos. π
π AUTHOR π
Shigio YAMAGUCHI, Hideki IWAMOTO and others. absolute legends, we stan. π«Άβ¨
π HISTORY π
the gtags command appeared in FreeBSD 2.2.2. it's been serving cunt since the 90s, periodt. π
π
and that's a wrap on the GTAGS(1) page, bestie!! π¦ this was the GNU Project's very own manpage, dated February 2021, and you now know it inside out. go tag some code, hydrate, and remember: no concurrency control, no cap. ππΈβ
π¦ where this page comes from
- arch rolling: global 6.7-1 Β· BSD-3-Clause AND GPL-2.0-only AND GPL-3.0-or-later AND LGPL-2.0-or-later AND LicenseRef-CALDERA AND LicenseRef-PD AND MIT
- fedora 44: global 6.7-1.fc44 Β· GPL-3.0-or-later and LGPL-2.0-or-later and LGPL-2.1-or-later and BSD-3-Clause and MIT and LicenseRef-Fedora-Public-Domain and blessing and GFDL-1.2-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms