|
1 | 1 | # Architecture |
2 | 2 |
|
3 | | -This document describes the overall architecture of the proof |
4 | | -debugger. It describes the major components of the implementation and |
5 | | -the organization of the source code. A lot of the presentation here |
6 | | -comes from comments embedded in the source code. For more detail, see |
7 | | -the source code itself. |
| 3 | +This is a description of the debugger architecture in Visual Studio Code. |
8 | 4 |
|
9 | | -## Visual Studio Code |
10 | | - |
11 | | -The [user documentation](https://code.visualstudio.com/docs) |
12 | | -is the place to start if you are unfamiliar with Visual Studio Code. The |
13 | | -[user guide](https://code.visualstudio.com/docs/editor/codebasics) |
14 | | -introduces the basic concepts like |
15 | | -[editing](https://code.visualstudio.com/docs/editor/codebasics) |
16 | | -and |
17 | | -[debugging](https://code.visualstudio.com/docs/editor/debugging). |
18 | | -Most important are |
19 | | -* The |
20 | | - [debug actions](https://code.visualstudio.com/docs/editor/debugging#_debug-actions) |
21 | | - that a software developer uses to interact with a debugger. |
22 | | -* The [debug configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) |
23 | | - that a software developer uses to select a debugger. |
24 | | - |
25 | | - |
26 | | -The [developer documentation](https://code.visualstudio.com/api) is the place |
27 | | -for extension developers to start. |
28 | | -Most important is |
29 | | -* The |
30 | | - [debugger extension](https://code.visualstudio.com/api/extension-guides/debugger-extension) |
31 | | - overview gives a fairly complete example of how to write and package a debugger |
32 | | - extension. |
33 | | - The code repository used in that example was the starting point for this debugger. |
34 | | - |
35 | | - |
36 | | -You should now be able to read the code implementing this debugger, |
37 | | -but you will eventually want to skim |
38 | | -* The |
39 | | - [Extension Guides](https://code.visualstudio.com/api/extension-guides/overview) |
40 | | - that describe the Visual Studio Code Extension APIs. |
41 | | - This debugger uses |
42 | | - * [Tree Views](https://code.visualstudio.com/api/extension-guides/tree-view) |
43 | | - to display the code issues having traces available for debugging. |
44 | | -* The [UX Guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) |
45 | | - that describe the Visual Studio Code user interface. This debugger uses |
46 | | - |
47 | | - * [Views](https://code.visualstudio.com/api/ux-guidelines/views) |
48 | | - as containers of the content that appears in sidebars and panels, |
49 | | - * [Sidebars](https://code.visualstudio.com/api/ux-guidelines/sidebars) |
50 | | - and |
51 | | - [Panels](https://code.visualstudio.com/api/ux-guidelines/panel) |
52 | | - to display views, and |
53 | | - * [Notifications](https://code.visualstudio.com/api/ux-guidelines/notifications) |
54 | | - to display progress and error messages. |
55 | | - |
56 | | -## Architecture overview |
| 5 | +## Debugger overview |
57 | 6 |
|
58 | 7 | Visual Studio Code implements a generic user interface to debuggers. |
59 | 8 | A developer needs to learn only one user interface to use any debugger |
@@ -99,85 +48,49 @@ for gdb: |
99 | 48 | <img src="https://microsoft.github.io/debug-adapter-protocol/img/init-launch.png"> |
100 | 49 | </center> |
101 | 50 |
|
102 | | -## Implementation overview |
103 | | - |
104 | | -### Values |
105 | | - |
106 | | -A value can be a string, a number, a struct, or an array. A value can appear in a trace or be stored in memory. |
107 | | -A value is represented in CBMC output as a string that must be parsed. |
108 | | -* value.ts: Defines the Value class and subclasses for strings, number, structs, and arrays. |
109 | | -* valueLexer.ts: A lexer for values in CBMC output. |
110 | | -* valueParser.ts: A parser for values in CBMC output. |
111 | | - |
112 | | -### Variables |
113 | | - |
114 | | -A variable in a trace is a string like 'foo.bar[0]` consisting of a base name 'foo' |
115 | | -followed by a list of selectors like field member selection '.bar' or array |
116 | | -indexing '[0]'. |
117 | | -We model memory as a single struct, so 'foo.bar[0]' is modeled as 'MEMORY.foo.bar[0]'. |
118 | | -We think of '.foo.bar[0]' as a path through memory, where path elements |
119 | | -denote field selection and array indexing. |
120 | | -A variable is represented in CBMC output as a string that must be parsed. |
121 | | -* variable.ts: Defines the Element class and subclasses for field selection and array indexing. |
122 | | -* variableLexer.ts: A lexer for variables in CBMC output. |
123 | | -* variableParser.ts: A parser for variables in CBMC output. |
124 | | - |
125 | | -### Failures |
126 | | - |
127 | | -A panel at the bottom of the screen displays the set of failures that can be debugged. |
128 | | -The failures are organized into a tree and displayed as |
129 | | -nested lists of files, functions within a file, lines within a |
130 | | -function, and failures at a line. |
131 | | -The debug extension describes this tree to Visual Studio Code using the Tree View API. |
132 | | -The key to the Tree View is the TreeDataProvider interface that includes |
133 | | -functions like getChildren(node) returning a node's children and getTreeItem(node) |
134 | | -returning a node's contents. |
135 | | -So the debug extension must load the failures available for debugging, |
136 | | -organize them into a tree, |
137 | | -and use the tree to implement the TreeDataProvider interface. |
138 | | -* traceData.ts: |
139 | | - The method create(result, property, loop) loads the summaries produced |
140 | | - by cbmc-viewer and returns a mapping file_name -> function_name -> line_number -> failure. |
141 | | -* traceTree.ts: |
142 | | - The method create(mapping) transforms a failure mapping into a failure tree. |
143 | | -* traceView.ts: |
144 | | - The class TraceProvider implements the TreeDataProvider. |
145 | | - |
146 | | -### Debug adapter |
147 | | - |
148 | | -The debug adapter sits between Visual Studio Code and the debugger. |
149 | | -The job of the debug adapter is to accept requests from Visual Studio |
150 | | -Code like "set breakpoint" and "run" and to generate responses after |
151 | | -driving the debugger and inspecting its state. |
152 | | - |
153 | | -Visual Studio Code and the debug adapter communicate via requests and responses |
154 | | -defined by the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol). |
155 | | -Visual Studio Code sends the |
156 | | -[SetBreakpointsRequest](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetBreakpoints) |
157 | | -to the debug adapter which sends a SetBreakpointsResponse back to Visual Studio Code. |
158 | | - |
159 | | -The class ProofDebuggerSession implements the DebugSession interface. It maintains the state of the |
160 | | -debug adapter for one debugging session, and it implements methods like setBreakPointsRequest that |
161 | | -Visual Studio Code can use to send the SetBreakpointsRequest and receive the SetBreapointsRepsonse. |
162 | | - |
163 | | -How the debug adapter and the debugger communicate is of no concern to Visual Studio Code. In our case, |
164 | | -the debugger is really just a trace simulator. The debug adaptor uses methods in the simulator interface |
165 | | -to move the simulator forwards and backwards in the trace, and to examine the current state of the trace. |
166 | | - |
167 | | -* adapter.ts: Defines ProofDebuggerSession implementing the DebugSession interface. |
168 | | - |
169 | | -### Debugger |
170 | | - |
171 | | -* simulator.ts: Simulator is the debugger being managed by the debug adpater |
172 | | -* simulatorState.ts: A state of a trace being simulated by the simulator |
173 | | -* simulatorTrace.ts: A trace being simulated by the simulator (and methods to load the trace) |
174 | | - |
175 | | -### Extension activation |
176 | | - |
177 | | -* extension.ts: Methods to activate and deactive the debugger extension. |
178 | | - |
179 | | -### Extension utilities |
180 | | - |
181 | | -* constants.ts: Defines string constants used in the extension |
182 | | -* exceptions.ts: Defines an exception raised by the extension |
183 | | -* storage.ts: Defines methods to access the persistent storage available to the extension |
| 51 | +## Debugger documentation |
| 52 | + |
| 53 | +The [user documentation](https://code.visualstudio.com/docs) |
| 54 | +is the place to start if you are unfamiliar with Visual Studio Code. The |
| 55 | +[user guide](https://code.visualstudio.com/docs/editor/codebasics) |
| 56 | +introduces the basic concepts like |
| 57 | +[editing](https://code.visualstudio.com/docs/editor/codebasics) |
| 58 | +and |
| 59 | +[debugging](https://code.visualstudio.com/docs/editor/debugging). |
| 60 | +Most important are |
| 61 | +* The |
| 62 | + [debug actions](https://code.visualstudio.com/docs/editor/debugging#_debug-actions) |
| 63 | + that a software developer uses to interact with a debugger. |
| 64 | +* The [debug configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) |
| 65 | + that a software developer uses to select a debugger. |
| 66 | + |
| 67 | + |
| 68 | +The [developer documentation](https://code.visualstudio.com/api) is the place |
| 69 | +for extension developers to start. |
| 70 | +Most important is |
| 71 | +* The |
| 72 | + [debugger extension](https://code.visualstudio.com/api/extension-guides/debugger-extension) |
| 73 | + overview gives a fairly complete example of how to write and package a debugger |
| 74 | + extension. |
| 75 | + The code repository used in that example was the starting point for this debugger. |
| 76 | + |
| 77 | + |
| 78 | +You should now be able to read the code implementing this debugger, |
| 79 | +but you will eventually want to skim |
| 80 | +* The |
| 81 | + [Extension Guides](https://code.visualstudio.com/api/extension-guides/overview) |
| 82 | + that describe the Visual Studio Code Extension APIs. |
| 83 | + This debugger uses |
| 84 | + * [Tree Views](https://code.visualstudio.com/api/extension-guides/tree-view) |
| 85 | + to display the code issues having traces available for debugging. |
| 86 | +* The [UX Guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) |
| 87 | + that describe the Visual Studio Code user interface. This debugger uses |
| 88 | + |
| 89 | + * [Views](https://code.visualstudio.com/api/ux-guidelines/views) |
| 90 | + as containers of the content that appears in sidebars and panels, |
| 91 | + * [Sidebars](https://code.visualstudio.com/api/ux-guidelines/sidebars) |
| 92 | + and |
| 93 | + [Panels](https://code.visualstudio.com/api/ux-guidelines/panel) |
| 94 | + to display views, and |
| 95 | + * [Notifications](https://code.visualstudio.com/api/ux-guidelines/notifications) |
| 96 | + to display progress and error messages. |
0 commit comments