Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit d8885c5

Browse files
author
Sauyon Lee
committed
Add extractor diagnostic tables to the database
1 parent 25cc1b4 commit d8885c5

4 files changed

Lines changed: 169 additions & 1 deletion

File tree

extractor/dbscheme/tables.go

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,130 @@ xmllocations(
120120
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
121121
`)
122122

123+
// Compiler diagnostic tables
124+
var CompilationType = NewPrimaryKeyType("@compilation")
125+
126+
/**
127+
* An invocation of the compiler. Note that more than one file may be
128+
* compiled per invocation. For example, this command compiles three
129+
* source files:
130+
*
131+
* go build a.go b.go c.go
132+
*
133+
* The `id` simply identifies the invocation, while `cwd` is the working
134+
* directory from which the compiler was invoked.
135+
*/
136+
var CompilationsTable = NewTable("compilations",
137+
EntityColumn(CompilationType, "id").Key(),
138+
StringColumn("cwd"),
139+
)
140+
141+
/**
142+
* The arguments that were passed to the extractor for a compiler
143+
* invocation. If `id` is for the compiler invocation
144+
*
145+
* go build a.go b.go c.go
146+
*
147+
* then typically there will be rows for
148+
*
149+
* num | arg
150+
* --- | ---
151+
* 0 | *path to extractor*
152+
* 1 | `--`
153+
* 2 | a.go
154+
* 3 | b.go
155+
* 4 | c.go
156+
*/
157+
var CompilationArgsTable = NewTable("compilation_args",
158+
EntityColumn(CompilationType, "id"),
159+
IntColumn("num"),
160+
StringColumn("arg"),
161+
).KeySet("id", "num")
162+
163+
/**
164+
* The source files that are compiled by a compiler invocation.
165+
* If `id` is for the compiler invocation
166+
*
167+
* go build a.go b.go c.go
168+
*
169+
* then there will be rows for
170+
*
171+
* num | arg
172+
* --- | ---
173+
* 0 | a.go
174+
* 1 | b.go
175+
* 2 | c.go
176+
*/
177+
var CompilationCompilingFilesTable = NewTable("compilation_compiling_files",
178+
EntityColumn(CompilationType, "id"),
179+
IntColumn("num"),
180+
EntityColumn(FileType, "file"),
181+
).KeySet("id", "num")
182+
183+
type CompilationTypeKind int
184+
185+
const (
186+
FRONTEND_CPU_SECONDS = iota
187+
FRONTEND_ELAPSED_SECONDS
188+
EXTRACTOR_CPU_SECONDS
189+
EXTRACTOR_ELAPSED_SECONDS
190+
)
191+
192+
/**
193+
* The time taken by the extractor for a compiler invocation.
194+
*
195+
* For each file `num`, there will be rows for
196+
*
197+
* kind | seconds
198+
* ---- | ---
199+
* 1 | CPU seconds used by the extractor frontend
200+
* 2 | Elapsed seconds during the extractor frontend
201+
* 3 | CPU seconds used by the extractor backend
202+
* 4 | Elapsed seconds during the extractor backend
203+
*/
204+
var CompilationTimeTable = NewTable("compilation_time",
205+
EntityColumn(CompilationType, "id"),
206+
IntColumn("num"),
207+
IntColumn("kind"),
208+
FloatColumn("secs"),
209+
).KeySet("id", "num", "kind")
210+
211+
var DiagnosticType = NewPrimaryKeyType("@diagnostic")
212+
213+
/**
214+
* An error or warning generated by the extractor.
215+
* The diagnostic message `diagnostic` was generated during compiler
216+
* invocation `compilation`, and is the `file_number_diagnostic_number`th
217+
* message generated while extracting the `file_number`th file of that
218+
* invocation.
219+
*/
220+
var DiagnosticForTable = NewTable("diagnostic_for",
221+
EntityColumn(DiagnosticType, "diagnostic").Unique(),
222+
EntityColumn(CompilationType, "compilation"),
223+
IntColumn("file_number"),
224+
IntColumn("file_number_diagnostic_number"),
225+
)
226+
227+
/**
228+
* If extraction was successful, then `cpu_seconds` and
229+
* `elapsed_seconds` are the CPU time and elapsed time (respectively)
230+
* that extraction took for compiler invocation `id`.
231+
*/
232+
var CompilationFinishedTable = NewTable("compilation_finished",
233+
EntityColumn(CompilationType, "id").Unique(),
234+
FloatColumn("cpu_seconds"),
235+
FloatColumn("elapsed_seconds"),
236+
)
237+
238+
var DiagnosticsTable = NewTable("diagnostics",
239+
EntityColumn(DiagnosticType, "id").Key(),
240+
IntColumn("severity"),
241+
StringColumn("error_tag"),
242+
StringColumn("error_message"),
243+
StringColumn("full_error_message"),
244+
EntityColumn(LocationType, "location"),
245+
)
246+
123247
// ContainerType is the type of files and folders
124248
var ContainerType = NewUnionType("@container")
125249

@@ -742,6 +866,14 @@ var ErrorTypes = map[packages.ErrorKind]*BranchType{
742866
packages.TypeError: ErrorKind.NewBranch("@typeerror"),
743867
}
744868

869+
// ErrorTypes is a map from error kinds to the corresponding tag
870+
var ErrorTags = map[packages.ErrorKind]string{
871+
packages.UnknownError: "@unknownerror",
872+
packages.ListError: "@listerror",
873+
packages.ParseError: "@parseerror",
874+
packages.TypeError: "@typeerror",
875+
}
876+
745877
// LocationsDefaultTable is the table defining location objects
746878
var LocationsDefaultTable = NewTable("locations_default",
747879
EntityColumn(LocationDefaultType, "id").Key(),

ql/src/go.dbscheme

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ xmllocations(
110110

111111
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
112112

113+
compilations(unique int id: @compilation, string cwd: string ref);
114+
115+
#keyset[id, num]
116+
compilation_args(int id: @compilation ref, int num: int ref, string arg: string ref);
117+
118+
#keyset[id, num, kind]
119+
compilation_time(int id: @compilation ref, int num: int ref, int kind: int ref, float secs: float ref);
120+
121+
diagnostic_for(unique int diagnostic: @diagnostic ref, int compilation: @compilation ref, int file_number: int ref, int file_number_diagnostic_number: int ref);
122+
123+
compilation_finished(unique int id: @compilation ref, float cpu_seconds: float ref, float elapsed_seconds: float ref);
124+
125+
#keyset[id, num]
126+
compilation_compiling_files(int id: @compilation ref, int num: int ref, int file: @file ref);
127+
128+
diagnostics(unique int id: @diagnostic, int severity: int ref, string error_tag: string ref, string error_message: string ref,
129+
string full_error_message: string ref, int location: @location ref);
130+
113131
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
114132
int endLine: int ref, int endColumn: int ref);
115133

upgrades/4affa49dbe2bbab1a33f0e3ea6b045116abbcfda/go.dbscheme

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ xmllocations(
110110

111111
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
112112

113+
compilations(unique int id: @compilation, string cwd: string ref);
114+
115+
#keyset[id, num]
116+
compilation_args(int id: @compilation ref, int num: int ref, string arg: string ref);
117+
118+
#keyset[id, num, kind]
119+
compilation_time(int id: @compilation ref, int num: int ref, int kind: int ref, float secs: float ref);
120+
121+
diagnostic_for(unique int diagnostic: @diagnostic ref, int compilation: @compilation ref, int file_number: int ref, int file_number_diagnostic_number: int ref);
122+
123+
compilation_finished(unique int id: @compilation ref, float cpu_seconds: float ref, float elapsed_seconds: float ref);
124+
125+
#keyset[id, num]
126+
compilation_compiling_files(int id: @compilation ref, int num: int ref, int file: @file ref);
127+
128+
diagnostics(unique int id: @diagnostic, int severity: int ref, string error_tag: string ref, string error_message: string ref,
129+
string full_error_message: string ref, int location: @location ref);
130+
113131
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
114132
int endLine: int ref, int endColumn: int ref);
115133

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
description: Add XML tables
1+
description: Add tables for extractor diagnostics and XML
22
compatibility: backwards

0 commit comments

Comments
 (0)