-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsb-graph.texinfo
120 lines (83 loc) · 3.69 KB
/
sb-graph.texinfo
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
@node ICR Graphing
@comment node-name, next, previous, up
@chapter ICR Graphing
@cindex Graph, ICR, IR1
The @code{sb-graph} module provides a graphing tool for SBCL ir1. It
outputs graphviz DOT format.
Its main features are that it can hook compilation so that SBCL can
output .dot files when compiler tracing is enabled, and, given a graph
in memory, provide the facility to interactively graph and interact with
it.
@menu
* Overview::
* User Manual::
* API Description::
@end menu
@node Overview
@section Overview
@node User Manual
@section User Manual
If all you want to do is output .dot files during compiler tracing, you
shouldn’t actually have to do anything after loading it except turning
on SBCL’s trace output. This can be done by calling (compile-file "file"
:trace-file t). After compilation is done, alongside the normal trace
file, SBCL is transparently hooked into writing a series of .dot files,
which contain the graphviz DOT representation of all the components
compiled. If you set sb-c::*compile-progress* to T, it will print out
progress information, and will tell you when and where it writes out the
graphviz files.
To use it interactively, call interactively-graph with a graph object
and output filename. After this is done, output, expand, and get-node
can be used to interact with said graph. As you call expand, the graph
will be output to the filename you specified. In the root of the
repository is a shell script render-on-change.sh which can be run with
two arguments: the input DOT file (the one passed to
interactively-graph), as well as an output SVG file that graphviz will
render to every time the file is changed on disk. This uses
inotify-wait, and so inotify-utils must be installed. As far as I know
this only works on Linux. A similar thing could be written for other
operating systems, though. All-in-all, this allows for a very short
expand-render-display loop.
@node API Description
@section API Description
@itemize
@item
* (make-and-dfs object distance)
This function takes an ir1 object object, and integer distance, and
returns a graph object with every node up to distance hops away from
object in its dfs-table. Each object is tagged with a “codename”,
visible as a hex digit in braces at the start of each graph node.
@item
* (interactively-graph graph &optional filename)
This function takes a graph and a filename, and sets the current working
graph to it, and the current output file to the filename. When calling
output and expand, the graph will be written to filename.
@item
* (output)
This function outputs the current working graph to a string, and if
interactively-graph was called with a filename, writes it to that file.
@item
* (expand codename)
After you’ve rendered the graph, if you want to add
a node to the dfs-table (thus expanding the amount of the in-memory
objects rendered), call this function with the codename of the new
object you’d like to add. Example: (expand "A").
If you passed a filename to interactively-graph, this function will then
write the render to file automatically.
@item
* (get-node codename)
Returns the object tied to codename from the current interactive graph.
@item
* (render-graph graph)
Given a graph with objects in its dfs-table, returns a string of the
rendering of the graph in DOT.
Does the same thing as output, but without using interactively-graph.
@item
* (expand-graph-codename graph codename)
Given a graph and codename, put the node tied to codename into the
dfs-table of the graph.
Does the same thing as expand, but without using interactively-graph.
@item
* (get-node-from-codename graph codename)
Return the node tied to codename in graph.
Does the same thing as node, but without using interactively-graph.