summaryrefslogtreecommitdiff
path: root/usr.bin/vi/docs/internals/cscope.NOTES
blob: e0e3483d26edfde9e525675aa3a8bcb6081c9c33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Cscope Notes:

The nvi tags structure has been reworked to handle the notion of multiple
locations per tag.  This supports cscope, which returns multiple locations
per query.  It will hopefully support ctags programs that create databases
with multiple locations per tag as well.

There is now a list of "tag queues" chained from each screen.  Each tag
queue has one or more "tag locations".

   +----+    +----+	+----+     +----+
   | EP | -> | Q1 | <-- | T1 | <-- | T2 |
   +----+    +----+ --> +----+ --> +----+
  	     |
  	     +----+     +----+
  	     | Q2 | <-- | T1 |
  	     +----+ --> +----+
  	     |
  	     +----+	+----+
  	     | Q3 | <-- | T1 |
  	     +----+ --> +----+
  
In the above diagram, each "Q" is a "tag queue", and each "T" is a
tag location.  Generally, the commands:

	:tag			create a new Q
	^[			create a new Q
	:cscope find		create a new Q
	:tagnext		move to the next T
	:tagprev		move to the previous T
	:tagpop			discard one or more Q's
	^T			discard the most recent Q
	:tagtop			discard all Q's

More specifically:

:cs[cope] a[dd] cscope-dir

	Attach to the cscope database in cscope-dir.

:cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern

	Query all attached cscopes for the pattern.  The pattern is a
	regular expression.  If the pattern is a double-quote character
	followed by a valid buffer name (e.g., "t), then the contents
	of the named buffer are used as the pattern.

	c: find callers of name
	d: find all function calls made from name
	e: find pattern
	f: find files with name as substring
	g: find definition of name
	i: find files #including name
	s: find all uses of name
	t: find assignments to name

	The find command pushes the current location onto the tags stack,
	and switches to the first location resulting from the query, if
	the query returned at least one result.

:cs[cope] h[elp] [command]
	
	List the cscope commands, or usage help on one command.

:display c[onnections]

	Display the list of cscope connections

:display t[ags]

	The tags display has been enhanced to display multiple tag
	locations per tag query.

:cs[cope] k[ill] #

	Kill cscope connection number #.

:cs[cope] r[eset]
	Kill all attached cscopes.  Useful if one got hung but you don't
	know which one.

:tagn[ext][!]

	Move to the next tag resulting from a query.

:tagpr[ev][!]

	Return to the previous tag resulting from a query.

:tagp[op], ^T

	Return to the previous tag group (no change).

:tagt[op]

	Discard all tag groups (no change).

Suggested maps:

	" ^N: move to the next tag
	map ^N :tagnext^M
	" ^P: move to the previous tag
	map ^P :tagprev^M

	" Tab+letter performs a C-Scope query on the current word.
	" C-Scope 12.9 has a text-string query (type t).
	" C-Scope 13.3 replaces it with an assignment query; hence a==t.
	map <tab>a "tye:csc find t"t
	map <tab>c "tye:csc find c"t
	map <tab>d "tye:csc find d"t
	map <tab>e "tye:csc find e"t
	map <tab>f "tye:csc find f"t
	map <tab>g "tye:csc find g"t
	map <tab>i "tye:csc find i"t
	map <tab>s "tye:csc find s"t
	map <tab>t "tye:csc find t"t

To start nvi with an initial set of cscope directories, use the environment
variable CSCOPE_DIRS.  This variable should contain a <blank>-separated
list of directories containing cscope databases.  (This MAY be changed to
be an edit option, I haven't really decided, yet.)

Each cscope directory must contain a file named "cscope.out" which is the
main cscope database, or nvi will not attempt to connect to a cscope to
handle requests for that database.

The file "cscope.tpath" may contain a colon-separated directory search
path which will be used to find the files reported by cscope.  If this
cscope.tpath does not exist, then the paths are assumed to be relative to
the cscope directory itself.  This is an extension to the standard cscope,
but seems important enough to keep.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Cscope Availability:

UNIXWare System V Release 4.0 variants such as Sun Solaris 2.x
(/opt/SUNWspro/bin) have version 11.5, and UNIXWare System V
Release 4.1 has version 12.10 with an option for much faster
searching.

You can buy version 13.3 source with an unrestricted license
for $400 from AT&T Software Solutions by calling +1-800-462-8146.