GTAGS-CSCOPE(1)
๐ gtags-cscope ๐
General Commands Manual โจ ok bestie sit down because we're about to read a whole manual together and it's gonna be cute
๐ธ NAME ๐ธ
gtags-cscope โ the interactive way to poke around a C program like it's your own group chat history ๐
โจ SYNOPSIS โจ
gtags-cscope [-abCdehilLvV][-F file ][-012345678 pattern][-p n]
๐ฆ DESCRIPTION ๐ฆ
So like, gtags-cscope is this interactive, screen-oriented tool that lets you browse through source files looking for specific elements of code. Very main character energy, honestly. ๐
The first time you run it on the source files of whatever program you're browsing, gtags-cscope builds the symbol cross-reference. Then, on a subsequent invocation, it only rebuilds that cross-reference if a source file has changed or if the list of source files is different. And when it does rebuild? It updates incrementally, which makes rebuilding way faster than that first initial build. No cap, that's the whole point. ๐ฅ
Also, real talk: gtags-cscope is a tool which just borrows the user interface of cscope โ it is Global itself for the substance. Like, the outfit is cscope's but the personality is Global's. iykyk. ๐ซถ
๐ OPTIONS ๐
Okay so some command line arguments can only show up as the only argument when you execute gtags-cscope. These ones just print some output and dip immediately:
-hโ View the long usage help display. ๐-Vโ Print the version number ofgtags-cscope. ๐ท๏ธ--helpโ Same as-h.--versionโ Same as-V.
Now the following options can appear in any combination. Slay, mix and match:
-aโ Print absolute path names. ๐-bโ Build the cross-reference only.-Cโ Ignore letter case when searching. ๐ค-dโ Do not update the cross-reference.-eโ Suppress the^ecommand prompt between files.-F fileโ Read symbol reference lines from file. (A symbol reference file is created by>and>>, and can also be read using the<command, described under ``Issuing Subsequent Requests'', below.) ๐-iโ IgnoreSIGINTsignal in line-oriented mode. ๐-Lโ Do a single search with line-oriented output when used with the-num patternoption.-lโ Line-oriented interface. This option implies the-doption.-[0-9] patternโ Go to input field num (counting from 0) and find pattern. ๐-p nโ Display the last n file path components instead of the default (1). Use0to not display the file name at all. ๐-vโ Be more verbose in line-oriented mode. ๐ฃ๏ธ
๐ซ Requesting the initial search ๐ซ
Once the cross-reference is ready, gtags-cscope will display this menu:
Find this symbol:
Find this global definition:
Find functions called by this function (N/A):
Find references of this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
Find assignments to this symbol:
Press the <Up> or <Down> keys repeatedly to move to the desired input field, type the text to search for, and then press the <Return> key. That's it. That's the move. โจ
๐ฎ Issuing subsequent requests ๐ฎ
If the search is successful, any of these single-character commands can be used:
0-9a-zA-Zโ Edit the file referenced by the given line number. โ๏ธ<Space>โ Display next set of matching lines.<Tab>โ Alternate between the menu and the list of matching lines.<Up>โ Move to the previous menu item (if the cursor is in the menu) or move to the previous matching line (if the cursor is in the matching line list).<Down>โ Move to the next menu item (if the cursor is in the menu) or move to the next matching line (if the cursor is in the matching line list).+โ Display next set of matching lines.-โ Display previous set of matching lines.^eโ Edit displayed files in order.>โ Write the displayed list of lines to a file. ๐>>โ Append the displayed list of lines to a file.<โ Read lines from a file that is in symbol reference format (created by>or>>), just like the-Foption.^โ Filter all lines through a shell command and display the resulting lines, replacing the lines that were already there.|โ Pipe all lines to a shell command and display them without changing them.^gโ Read lines from the result of the execution ofglobal(1).
At any time these single-character commands can also be used:
<Return>โ Move to next input field.^nโ Move to next input field.^pโ Move to previous input field.^yโ Search with the last text typed.^bโ Move to previous input field and search pattern.^fโ Move to next input field and search pattern.^cโ Toggle ignore/use letter case when searching. (When ignoring letter case, a search forFILEwill matchFileandfile.)^rโ Rebuild the cross-reference. ๐!โ Start an interactive shell (type^dto return togtags-cscope).^lโ Redraw the screen.?โ Give help information aboutgtags-cscopecommands.^dโ Exitgtags-cscope. ๐
NOTE: If the first character of the text to be searched for matches one of the above commands, escape it by typing a \ (backslash) first. Do not skip this, bestie, it WILL eat your search. ๐
๐ Substituting new text for old text ๐
After the text to be changed has been typed, gtags-cscope will prompt for the new text, and then it will display the lines containing the old text. Select the lines to be changed with these single-character commands:
0-9a-zA-Zโ Mark or unmark the line to be changed.*โ Mark or unmark all displayed lines to be changed.<Space>โ Display next set of lines.+โ Display next set of lines.-โ Display previous set of lines.^aโ Mark or unmark all lines to be changed.^dโ Change the marked lines and exit.<Esc>โ Exit without changing the marked lines.!โ Start an interactive shell (type^dto return togtags-cscope).^lโ Redraw the screen.?โ Give help information aboutgtags-cscopecommands.
๐ Special keys ๐
If your terminal has arrow keys that work in vi, you can use them to move around the input fields. The up-arrow key is useful to move to the previous input field instead of using the <Tab> key repeatedly. If you have <CLEAR>, <NEXT>, or <PREV> keys they will act as the ^l, +, and - commands, respectively. Iconic, honestly. ๐
๐ Line-Oriented interface ๐
The -l option lets you use gtags-cscope where a screen-oriented interface would not be useful, for example, from another screen-oriented program.
gtags-cscope will prompt with >> when it is ready for an input line, which starts with the field number (counting from 0), immediately followed by the search pattern. For example, 1main finds the definition of the main function. ๐ง
If you just want a single search, instead of the -l option use the -L and -num pattern options, and you won't get the >> prompt. Nice, right?
For -l, gtags-cscope outputs the number of reference lines:
cscope: 2 lines
For each reference found, gtags-cscope outputs a line consisting of the file name, function name, line number, and line text, separated by spaces. For example:
main.c main 161 main(argc, argv)
Note that the editor is not called to display a single reference, unlike the screen-oriented interface. Just so you know. ๐
You can use the c command to toggle ignore/use letter case when searching. (When ignoring letter case, a search for FILE will match File and file.)
You can use the r command to rebuild the database. ๐จ
gtags-cscope will quit when it detects end-of-file, or when the first character of an input line is ^d or q. Bye bestie! ๐
๐ ENVIRONMENT ๐
The following environment variables are of cscope origin.
CSCOPE_EDITORโ Overrides theEDITORandVIEWERvariables. Use this if you wish to use a different editor withcscopethan that specified by yourEDITOR/VIEWERvariables.CSCOPE_LINEFLAGโ Format of the line number flag for your editor. By default,cscopeinvokes your editor via the equivalent ofeditor +N file, where N is the line number that the editor should jump to. This format is used by bothemacsandvi. If your editor needs something different, specify it in this variable, with%sas a placeholder for the line number. Eg: if your editor needs to be invoked aseditor -#103 fileto go to line 103, set this variable to-#%s.CSCOPE_LINEFLAG_AFTER_FILEโ Set this variable toyesif your editor needs to be invoked with the line number option after the filename to be edited. To continue the example fromCSCOPE_LINEFLAG, above: if your editor needs to seeeditor file -#number, set this environment variable. Users of most standard editors (vi,emacs) do not need to set this variable.EDITORโ Preferred editor, which defaults tovi.HOMEโ Home directory, which is automatically set at login. ๐SHELLโ Preferred shell, which defaults tosh.TERMโ Terminal type, which must be a screen terminal.TERMINFOโ Terminal information directory full path name. If your terminal is not in the standard terminfo directory, seecursesandterminfofor how to make your own terminal description.TMPDIRโ Temporary file directory, which defaults to/tmp.VIEWERโ Preferred file display program (such asless), which overridesEDITOR(see above).
The following environment variables are of Global origin.
GTAGSCONFโ Configuration file.GTAGSGLOBALโ If this variable is set,$GTAGSGLOBALis used as the name ofglobal(1). The default isglobal.GTAGSGTAGSโ If this variable is set,$GTAGSGTAGSis used as the name ofgtags(1). The default isgtags.GTAGSDBPATHโ The directory in which the tag files exist. This value is ignored whenGTAGSROOTis not defined.GTAGSLABELโ Configuration label. The default isdefault.GTAGSLIBPATHโ If this variable is set, it is used as the path to search for library functions. If the specified tags is not found in the project,globalalso searches in these paths. Since onlyGTAGSis targeted in the retrieval, this variable is ignored when-ror-sis specified.GTAGSROOTโ The root directory of the project.MAKEOBJDIRโ If this variable is set,$MAKEOBJDIRis used as the name of BSD-style objdir. The default isobj.MAKEOBJDIRPREFIXโ If this variable is set,$MAKEOBJDIRPREFIXis used as the prefix of BSD-style objdir. The default is/usr/obj.
๐ FILES ๐
ok so these are the files this whole situation depends on, bestie, no cap:
GTAGSโ the tag file for definitions ๐GRTAGSโ the tag file for references โจGPATHโ the tag file for source files ๐GTAGSROOTโ okay so this one's the sneaky one: if the environment variableGTAGSROOTis not set, and a file literally namedGTAGSROOTexists in the same directory asGTAGS, then global setsGTAGSROOTto whatever's inside that file. it's giving "the file is the variable" and honestly? iconic ๐ฆgtags.conf,$HOME/.globalrcโ configuration data for GNU Global. go readgtags.conf(5)for the tea ๐ธ
๐ SEE ALSO ๐
GNU Global source code tag system (http://www.gnu.org/software/global/)
๐ BUG ๐
ok so this is the part where we're honest:
- the function field of the display is almost always
<unknown>because Global justโฆ does not recognize it. not me being dramatic, that's just how it is ๐ญ Find functions called by this functionis not implemented. like, at all. it's giving unfinished business fr fr ๐
๐ AUTHOR ๐
Joe Steffen (original author) and others. ๐ซถ
๐ HISTORY ๐
Cscope was originally developed at Bell Labs in the early 1980s, and was released as free software under the BSD license in April 2000. Gtags-cscope is a derivative of cscope to use Global as the back-end. Its line-oriented interface was originally written in 2006, and was re-implemented in 2011 using cscope itself. likeโฆ a full glow-up, twice ๐ โจ
and that's the whole page, bestie ๐ this one came from the GNU Project, dated March 2011, and it's GTAGS-CSCOPE(1) โ go forth and navigate your codebase like the main character you are ๐๐
๐ฆ 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
- debian trixie: global 6.6.13-1
- epel 10: global 6.6.15-1.el10_3 ยท 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
- fedora 43: global 6.6.15-1.fc43 ยท 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
- fedora 44: global 6.6.14-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
- fedora 44: global 6.6.15-1.fc44
- 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
- nixos 26.05: global 6.6.14
- nixpkgs unstable: global 6.6.14
- opensuse-leap 16.0: global 6.6.13-bp160.1.13 ยท GPL-3.0-only
- opensuse-leap 16.0: global 6.6.13-bp160.1.13 ยท GPL-3.0-only
- opensuse-leap 16.0: global 6.6.13-bp160.1.13 ยท GPL-3.0-only
- opensuse-leap 16.0: global 6.6.13-bp160.1.13 ยท GPL-3.0-only
- ubuntu questing: global 6.6.14-1.1
- ubuntu resolute: global 6.6.14-1.1build1
- ubuntu stonking: global 6.6.14-1.1build1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms