1GTAGS-CSCOPE(1)             General Commands Manual            GTAGS-CSCOPE(1)
2
3
4

NAME

6       gtags-cscope - interactively examine a C program
7

SYNOPSIS

9       gtags-cscope [-bCdehLlVv][-F file ][-012345678 pattern][-p n]
10

DESCRIPTION

12       gtags-cscope  is  an  interactive, screen-oriented tool that allows the
13       user to browse through source files for specified elements of code.
14
15       gtags-cscope builds the symbol cross-reference the  first  time  it  is
16       used on the source files for the program being browsed. On a subsequent
17       invocation, gtags-cscope rebuilds the cross-reference only if a  source
18       file  has  changed  or  the list of source files is different. When the
19       cross-reference is rebuilt, it is updated  incrementally,  which  makes
20       rebuilding faster than the initial build.
21
22       gtags-cscope  is a tool which just borrows user interface of cscope; it
23       is GLOBAL itself for the substance.
24

OPTIONS

26       Some command line arguments can only occur as the only argument in  the
27       execution  of  gtags-cscope.   They cause the program to just print out
28       some output and exit immediately:
29
30       -h     View the long usage help display.
31
32       -V     Print the version number of gtags-cscope.
33
34       --help Same as -h
35
36       --version
37              Same as -V
38
39       The following options can appear in any combination:
40
41       -a     Print absolute path names.
42
43       -b     Build the cross-reference only.
44
45       -C     Ignore letter case when searching.
46
47       -d     Do not update the cross-reference.
48
49       -e     Suppress the ´^e´ command prompt between files.
50
51       -F file
52              Read symbol reference lines from file.  (A symbol reference file
53              is  created  by  > and >>, and can also be read using the < com‐
54              mand, described under ``Issuing Subsequent Requests'', below.)
55
56       -i     Ignore SIGINT signal in line-oriented mode.
57
58       -L     Do a single search with line-oriented output when used with  the
59              -num pattern option.
60
61       -l     Line-oriented interface.  This option implies the -d option.
62
63       -[0-9] pattern
64              Go to input field num (counting from 0) and find pattern.
65
66       -p n   Display  the  last n file path components instead of the default
67              (1). Use ´0´ to not display the file name at all.
68
69       -v     Be more verbose in line-oriented mode.
70
72       After the cross-reference is  ready,  gtags-cscope  will  display  this
73       menu:
74
75       Find this symbol:
76       Find this global definition:
77       Find functions called by this function (N/A):
78       Find references of this function:
79       Find this text string:
80       Change this text string:
81       Find this egrep pattern:
82       Find this file:
83       Find files #including this file:
84       Find assignments to this symbol:
85
86       Press  the  <Up> or <Down> keys repeatedly to move to the desired input
87       field, type the text to search for, and then press the <Return> key.
88

Issuing subsequent requests

90       If the search is successful, any of these single-character commands can
91       be used:
92
93       0-9a-zA-Z
94              Edit the file referenced by the given line number.
95
96       <Space>
97              Display next set of matching lines.
98
99       <Tab>  Alternate between the menu and the list of matching lines
100
101       <Up>   Move to the previous menu item (if the cursor is in the menu) or
102              move to the previous matching line (if  the  cursor  is  in  the
103              matching line list).
104
105       <Down> Move  to  the  next  menu item (if the cursor is in the menu) or
106              move to the next matching line (if the cursor is in the matching
107              line list).
108
109       +      Display next set of matching lines.
110
111       -      Display previous set of matching lines.
112
113       ^e     Edit displayed files in order.
114
115       >      Write the displayed list of lines to a file.
116
117       >>     Append the displayed list of lines to a file.
118
119       <      Read  lines from a file that is in symbol reference format (cre‐
120              ated by ´>´ or ´>>´), just like the -F option.
121
122       ^      Filter all lines through a shell command and display the result‐
123              ing lines, replacing the lines that were already there.
124
125       |      Pipe  all  lines  to  a  shell  command and display them without
126              changing them.
127
128       ^g     Read lines from the result of the execution of global(1).
129
130       At any time these single-character commands can also be used:
131
132       <Return>
133              Move to next input field.
134
135       ^n     Move to next input field.
136
137       ^p     Move to previous input field.
138
139       ^y     Search with the last text typed.
140
141       ^b     Move to previous input field and search pattern.
142
143       ^f     Move to next input field and search pattern.
144
145       ^c     Toggle ignore/use letter case  when  searching.  (When  ignoring
146              letter case, a search for ´FILE´ will match ´File´ and ´file´.)
147
148       ^r     Rebuild the cross-reference.
149
150       !      Start  an  interactive  shell  (type  ´^d´  to  return to gtags-
151              cscope).
152
153       ^l     Redraw the screen.
154
155       ?      Give help information about gtags-cscope commands.
156
157       ^d     Exit gtags-cscope.
158
159       NOTE: If the first character of the text to be searched for matches one
160       of the above commands, escape it by typing a ´\' (backslash) first.
161
162       Substituting new text for old text
163
164       After  the  text to be changed has been typed, gtags-cscope will prompt
165       for the new text, and then it will display the lines containing the old
166       text.  Select  the lines to be changed with these single-character com‐
167       mands:
168
169       0-9a-zA-Z
170              Mark or unmark the line to be changed.
171
172       *      Mark or unmark all displayed lines to be changed.
173
174       <Space>
175              Display next set of lines.
176
177       +      Display next set of lines.
178
179       -      Display previous set of lines.
180
181       ^a     Mark or unmark all lines to be changed.
182
183       ^d     Change the marked lines and exit.
184
185       <Esc>  Exit without changing the marked lines.
186
187       !      Start an interactive  shell  (type  ´^d´  to  return  to  gtags-
188              cscope).
189
190       ^l     Redraw the screen.
191
192       ?      Give help information about gtags-cscope commands.
193
194       Special keys
195              If  your  terminal  has  arrow keys that work in vi, you can use
196              them to move around the input fields. The up-arrow key is useful
197              to  move  to the previous input field instead of using the <Tab>
198              key repeatedly. If you have <CLEAR>, <NEXT>, or <PREV> keys they
199              will act as the ´^l´, ´+´, and ´-´ commands, respectively.
200

Line-Oriented interface

202       The  -l option lets you use gtags-cscope where a screen-oriented inter‐
203       face would not be useful, for  example,  from  another  screen-oriented
204       program.
205
206       gtags-cscope  will prompt with ´>>´ when it is ready for an input line,
207       which starts with the field number (counting from 0), immediately  fol‐
208       lowed  by the search pattern. For example, ´1main´ finds the definition
209       of the ´main´ function.
210
211       If you just want a single search, instead of the -l option use  the  -L
212       and -num pattern options, and you won't get the ´>>´ prompt.
213
214       For -l, gtags-cscope outputs the number of reference lines:
215       cscope: 2 lines
216
217       For each reference found, gtags-cscope outputs a line consisting of the
218       file name, function name, line number, and line text, separated by spa‐
219       ces.  For example:
220       main.c main 161 main(argc, argv)
221
222       Note  that  the  editor  is  not  called to display a single reference,
223       unlike the screen-oriented interface.
224
225       You can use the ´c´ command  to  toggle  ignore/use  letter  case  when
226       searching.  (When  ignoring letter case, a search for ´FILE´ will match
227       ´File´ and ´file´.)
228
229       You can use the ´r´ command to rebuild the database.
230
231       gtags-cscope will quit when it detects end-of-file, or when  the  first
232       character of an input line is ´^d´ or ´q´.
233

ENVIRONMENT VARIABLES

235       The following environment variables are of cscope origin.
236
237       CSCOPE_EDITOR
238              Overrides the EDITOR and VIEWER variables.  Use this if you wish
239              to use a different editor with cscope  than  that  specified  by
240              your EDITOR/VIEWER variables.
241
242       CSCOPE_LINEFLAG
243              Format  of  the  line  number flag for your editor.  By default,
244              cscope invokes your editor via  the  equivalent  of  ´editor  +N
245              file´,  where  N  is the line number that the editor should jump
246              to.  This format is used by both emacs and vi.  If  your  editor
247              needs  something  different,  specify  it in this variable, with
248              ´%s´ as a placeholder for the line number.  Eg: if  your  editor
249              needs  to  be  invoked as ´editor -#103 file´ to go to line 103,
250              set this variable to ´-#%s´.
251
252       CSCOPE_LINEFLAG_AFTER_FILE
253              Set this variable to ´yes´ if your editor needs  to  be  invoked
254              with  the line number option after the filename to be edited. To
255              continue the example from CSCOPE_LINEFLAG, above: if your editor
256              needs  to see ´editor file -#number´, set this environment vari‐
257              able.  Users of most standard editors (vi, emacs) do not need to
258              set this variable.
259
260       EDITOR Preferred editor, which defaults to vi.
261
262       HOME   Home directory, which is automatically set at login.
263
264       SHELL  Preferred shell, which defaults to sh.
265
266       TERM   Terminal type, which must be a screen terminal.
267
268       TERMINFO
269              Terminal  information directory full path name. If your terminal
270              is not in the standard terminfo directory, see curses  and  ter‐
271              minfo for how to make your own terminal description.
272
273       TMPDIR Temporary file directory, which defaults to ´/tmp´.
274
275       VIEWER Preferred  file  display program (such as less), which overrides
276              EDITOR (see above).
277
278       The following environment variables are of GLOBAL origin.
279
280       GTAGSCONF
281              Configuration file.
282
283       GTAGSGLOBAL
284              If this variable is set, ´$GTAGSGLOBAL´ is used as the  name  of
285              global(1). The default is global.
286
287       GTAGSGTAGS
288              If  this  variable  is set, ´$GTAGSGTAGS´ is used as the name of
289              gtags(1). The default is gtags.
290
291       GTAGSDBPATH
292              The directory in which the  tag  files  exist.   This  value  is
293              ignored when GTAGSROOT is not defined.
294
295       GTAGSLABEL
296              Configuration label. The default is ´default´.
297
298       GTAGSLIBPATH
299              If  this  variable  is set, it is used as the path to search for
300              library functions. If the specified tags is  not  found  in  the
301              project,  global  also  searches  in  these  paths.   Since only
302              ´GTAGS´ is targeted in the retrieval, this variable  is  ignored
303              when -r or -s is specified.
304
305       GTAGSROOT
306              The root directory of the project.
307
308       MAKEOBJDIR
309              If  this  variable  is set, ´$MAKEOBJDIR´ is used as the name of
310              BSD-style objdir. The default is ´obj´.
311
312       MAKEOBJDIRPREFIX
313              If this variable is set, ´$MAKEOBJDIRPREFIX´ is used as the pre‐
314              fix of BSD-style objdir. The default is ´/usr/obj´.
315

FILES

317       ´GTAGS´
318              Tag file for definitions.
319
320       ´GRTAGS´
321              Tag file for references.
322
323       ´GPATH´
324              Tag file for source files.
325
326       ´GTAGSROOT´
327              If  environment  variable  GTAGSROOT is not set and file ´GTAGS‐
328              ROOT´ exists in the same directory as ´GTAGS´ then  global  sets
329              GTAGSROOT to the contents of the file.
330
331       ´gtags.conf´, ´$HOME/.globalrc´
332              Configuration data for GNU GLOBAL.  See gtags.conf(5).
333

SEE ALSO

335       gtags(1), global(1), htags(1).
336
337       GNU GLOBAL source code tag system
338       (http://www.gnu.org/software/global/).
339

BUG

341       The  function  field  of  the  display is almost <unknown> since GLOBAL
342       doesn't recognize it.
343
344       ´Find functions called by this function´ is not implemented.
345

AUTHOR

347       Joe Steffen (original author) and others.
348

HISTORY

350       Cscope was originally developed at Bell Labs in the  early  1980s,  and
351       was  released  as  free  software  under the BSD license in April 2000.
352       Gtags-cscope is a derivative of cscope to use GLOBAL as  the  back-end.
353       Its line-oriented interface was originally written in 2006, and was re-
354       implemented in 2011 using cscope itself.
355
356
357
358GNU Project                       March 2011                   GTAGS-CSCOPE(1)
Impressum