@@ -20,14 +20,12 @@ package main // import "golang.org/x/tools/cmd/callgraph"
20
20
// callee file/line/col
21
21
22
22
import (
23
- "bufio"
24
23
"bytes"
25
24
"flag"
26
25
"fmt"
27
26
"go/build"
28
27
"go/token"
29
28
"io"
30
- "log"
31
29
"os"
32
30
"runtime"
33
31
"text/template"
@@ -39,25 +37,21 @@ import (
39
37
"golang.org/x/tools/go/callgraph/static"
40
38
"golang.org/x/tools/go/callgraph/vta"
41
39
"golang.org/x/tools/go/packages"
42
- "golang.org/x/tools/go/pointer"
43
40
"golang.org/x/tools/go/ssa"
44
41
"golang.org/x/tools/go/ssa/ssautil"
45
42
)
46
43
47
44
// flags
48
45
var (
49
46
algoFlag = flag .String ("algo" , "rta" ,
50
- `Call graph construction algorithm (static, cha, rta, vta, pta )` )
47
+ `Call graph construction algorithm (static, cha, rta, vta)` )
51
48
52
49
testFlag = flag .Bool ("test" , false ,
53
50
"Loads test code (*_test.go) for imported packages" )
54
51
55
52
formatFlag = flag .String ("format" ,
56
53
"{{.Caller}}\t --{{.Dynamic}}-{{.Line}}:{{.Column}}-->\t {{.Callee}}" ,
57
54
"A template expression specifying how to format an edge" )
58
-
59
- ptalogFlag = flag .String ("ptalog" , "" ,
60
- "Location of the points-to analysis log file, or empty to disable logging." )
61
55
)
62
56
63
57
func init () {
@@ -68,7 +62,7 @@ const Usage = `callgraph: display the call graph of a Go program.
68
62
69
63
Usage:
70
64
71
- callgraph [-algo=static|cha|rta|vta|pta ] [-test] [-format=...] package...
65
+ callgraph [-algo=static|cha|rta|vta] [-test] [-format=...] package...
72
66
73
67
Flags:
74
68
@@ -78,11 +72,10 @@ Flags:
78
72
cha Class Hierarchy Analysis
79
73
rta Rapid Type Analysis
80
74
vta Variable Type Analysis
81
- pta inclusion-based Points-To Analysis
82
75
83
76
The algorithms are ordered by increasing precision in their
84
77
treatment of dynamic calls (and thus also computational cost).
85
- RTA and PTA require a whole program (main or test), and
78
+ RTA requires a whole program (main or test), and
86
79
include only functions reachable from main.
87
80
88
81
-test Include the package's tests in the analysis.
@@ -132,9 +125,9 @@ Examples:
132
125
$GOROOT/src/net/http/triv.go | sort | uniq
133
126
134
127
Show functions that make dynamic calls into the 'fmt' test package,
135
- using the pointer analysis algorithm:
128
+ using the Rapid Type Analysis algorithm:
136
129
137
- callgraph -format='{{.Caller}} -{{.Dynamic}}-> {{.Callee}}' -test -algo=pta fmt |
130
+ callgraph -format='{{.Caller}} -{{.Dynamic}}-> {{.Callee}}' -test -algo=rta fmt |
138
131
sed -ne 's/-dynamic-/--/p' |
139
132
sed -ne 's/-->.*fmt_test.*$//p' | sort | uniq
140
133
@@ -205,39 +198,7 @@ func doCallgraph(dir, gopath, algo, format string, tests bool, args []string) er
205
198
cg = cha .CallGraph (prog )
206
199
207
200
case "pta" :
208
- // Set up points-to analysis log file.
209
- var ptalog io.Writer
210
- if * ptalogFlag != "" {
211
- if f , err := os .Create (* ptalogFlag ); err != nil {
212
- log .Fatalf ("Failed to create PTA log file: %s" , err )
213
- } else {
214
- buf := bufio .NewWriter (f )
215
- ptalog = buf
216
- defer func () {
217
- if err := buf .Flush (); err != nil {
218
- log .Printf ("flush: %s" , err )
219
- }
220
- if err := f .Close (); err != nil {
221
- log .Printf ("close: %s" , err )
222
- }
223
- }()
224
- }
225
- }
226
-
227
- mains , err := mainPackages (pkgs )
228
- if err != nil {
229
- return err
230
- }
231
- config := & pointer.Config {
232
- Mains : mains ,
233
- BuildCallGraph : true ,
234
- Log : ptalog ,
235
- }
236
- ptares , err := pointer .Analyze (config )
237
- if err != nil {
238
- return err // internal error in pointer analysis
239
- }
240
- cg = ptares .CallGraph
201
+ return fmt .Errorf ("pointer analysis is no longer supported (see Go issue #59676)" )
241
202
242
203
case "rta" :
243
204
mains , err := mainPackages (pkgs )
0 commit comments