mirror of
https://github.com/github/codeql.git
synced 2026-07-21 03:08:25 +02:00
Add extractor diagnostic tables to the database
This commit is contained in:
@@ -120,6 +120,130 @@ xmllocations(
|
||||
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
|
||||
`)
|
||||
|
||||
// Compiler diagnostic tables
|
||||
var CompilationType = NewPrimaryKeyType("@compilation")
|
||||
|
||||
/**
|
||||
* An invocation of the compiler. Note that more than one file may be
|
||||
* compiled per invocation. For example, this command compiles three
|
||||
* source files:
|
||||
*
|
||||
* go build a.go b.go c.go
|
||||
*
|
||||
* The `id` simply identifies the invocation, while `cwd` is the working
|
||||
* directory from which the compiler was invoked.
|
||||
*/
|
||||
var CompilationsTable = NewTable("compilations",
|
||||
EntityColumn(CompilationType, "id").Key(),
|
||||
StringColumn("cwd"),
|
||||
)
|
||||
|
||||
/**
|
||||
* The arguments that were passed to the extractor for a compiler
|
||||
* invocation. If `id` is for the compiler invocation
|
||||
*
|
||||
* go build a.go b.go c.go
|
||||
*
|
||||
* then typically there will be rows for
|
||||
*
|
||||
* num | arg
|
||||
* --- | ---
|
||||
* 0 | *path to extractor*
|
||||
* 1 | `--`
|
||||
* 2 | a.go
|
||||
* 3 | b.go
|
||||
* 4 | c.go
|
||||
*/
|
||||
var CompilationArgsTable = NewTable("compilation_args",
|
||||
EntityColumn(CompilationType, "id"),
|
||||
IntColumn("num"),
|
||||
StringColumn("arg"),
|
||||
).KeySet("id", "num")
|
||||
|
||||
/**
|
||||
* The source files that are compiled by a compiler invocation.
|
||||
* If `id` is for the compiler invocation
|
||||
*
|
||||
* go build a.go b.go c.go
|
||||
*
|
||||
* then there will be rows for
|
||||
*
|
||||
* num | arg
|
||||
* --- | ---
|
||||
* 0 | a.go
|
||||
* 1 | b.go
|
||||
* 2 | c.go
|
||||
*/
|
||||
var CompilationCompilingFilesTable = NewTable("compilation_compiling_files",
|
||||
EntityColumn(CompilationType, "id"),
|
||||
IntColumn("num"),
|
||||
EntityColumn(FileType, "file"),
|
||||
).KeySet("id", "num")
|
||||
|
||||
type CompilationTypeKind int
|
||||
|
||||
const (
|
||||
FRONTEND_CPU_SECONDS = iota
|
||||
FRONTEND_ELAPSED_SECONDS
|
||||
EXTRACTOR_CPU_SECONDS
|
||||
EXTRACTOR_ELAPSED_SECONDS
|
||||
)
|
||||
|
||||
/**
|
||||
* The time taken by the extractor for a compiler invocation.
|
||||
*
|
||||
* For each file `num`, there will be rows for
|
||||
*
|
||||
* kind | seconds
|
||||
* ---- | ---
|
||||
* 1 | CPU seconds used by the extractor frontend
|
||||
* 2 | Elapsed seconds during the extractor frontend
|
||||
* 3 | CPU seconds used by the extractor backend
|
||||
* 4 | Elapsed seconds during the extractor backend
|
||||
*/
|
||||
var CompilationTimeTable = NewTable("compilation_time",
|
||||
EntityColumn(CompilationType, "id"),
|
||||
IntColumn("num"),
|
||||
IntColumn("kind"),
|
||||
FloatColumn("secs"),
|
||||
).KeySet("id", "num", "kind")
|
||||
|
||||
var DiagnosticType = NewPrimaryKeyType("@diagnostic")
|
||||
|
||||
/**
|
||||
* An error or warning generated by the extractor.
|
||||
* The diagnostic message `diagnostic` was generated during compiler
|
||||
* invocation `compilation`, and is the `file_number_diagnostic_number`th
|
||||
* message generated while extracting the `file_number`th file of that
|
||||
* invocation.
|
||||
*/
|
||||
var DiagnosticForTable = NewTable("diagnostic_for",
|
||||
EntityColumn(DiagnosticType, "diagnostic").Unique(),
|
||||
EntityColumn(CompilationType, "compilation"),
|
||||
IntColumn("file_number"),
|
||||
IntColumn("file_number_diagnostic_number"),
|
||||
)
|
||||
|
||||
/**
|
||||
* If extraction was successful, then `cpu_seconds` and
|
||||
* `elapsed_seconds` are the CPU time and elapsed time (respectively)
|
||||
* that extraction took for compiler invocation `id`.
|
||||
*/
|
||||
var CompilationFinishedTable = NewTable("compilation_finished",
|
||||
EntityColumn(CompilationType, "id").Unique(),
|
||||
FloatColumn("cpu_seconds"),
|
||||
FloatColumn("elapsed_seconds"),
|
||||
)
|
||||
|
||||
var DiagnosticsTable = NewTable("diagnostics",
|
||||
EntityColumn(DiagnosticType, "id").Key(),
|
||||
IntColumn("severity"),
|
||||
StringColumn("error_tag"),
|
||||
StringColumn("error_message"),
|
||||
StringColumn("full_error_message"),
|
||||
EntityColumn(LocationType, "location"),
|
||||
)
|
||||
|
||||
// ContainerType is the type of files and folders
|
||||
var ContainerType = NewUnionType("@container")
|
||||
|
||||
@@ -742,6 +866,14 @@ var ErrorTypes = map[packages.ErrorKind]*BranchType{
|
||||
packages.TypeError: ErrorKind.NewBranch("@typeerror"),
|
||||
}
|
||||
|
||||
// ErrorTypes is a map from error kinds to the corresponding tag
|
||||
var ErrorTags = map[packages.ErrorKind]string{
|
||||
packages.UnknownError: "@unknownerror",
|
||||
packages.ListError: "@listerror",
|
||||
packages.ParseError: "@parseerror",
|
||||
packages.TypeError: "@typeerror",
|
||||
}
|
||||
|
||||
// LocationsDefaultTable is the table defining location objects
|
||||
var LocationsDefaultTable = NewTable("locations_default",
|
||||
EntityColumn(LocationDefaultType, "id").Key(),
|
||||
|
||||
@@ -110,6 +110,24 @@ xmllocations(
|
||||
|
||||
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
|
||||
|
||||
compilations(unique int id: @compilation, string cwd: string ref);
|
||||
|
||||
#keyset[id, num]
|
||||
compilation_args(int id: @compilation ref, int num: int ref, string arg: string ref);
|
||||
|
||||
#keyset[id, num, kind]
|
||||
compilation_time(int id: @compilation ref, int num: int ref, int kind: int ref, float secs: float ref);
|
||||
|
||||
diagnostic_for(unique int diagnostic: @diagnostic ref, int compilation: @compilation ref, int file_number: int ref, int file_number_diagnostic_number: int ref);
|
||||
|
||||
compilation_finished(unique int id: @compilation ref, float cpu_seconds: float ref, float elapsed_seconds: float ref);
|
||||
|
||||
#keyset[id, num]
|
||||
compilation_compiling_files(int id: @compilation ref, int num: int ref, int file: @file ref);
|
||||
|
||||
diagnostics(unique int id: @diagnostic, int severity: int ref, string error_tag: string ref, string error_message: string ref,
|
||||
string full_error_message: string ref, int location: @location ref);
|
||||
|
||||
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
|
||||
int endLine: int ref, int endColumn: int ref);
|
||||
|
||||
|
||||
@@ -110,6 +110,24 @@ xmllocations(
|
||||
|
||||
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
|
||||
|
||||
compilations(unique int id: @compilation, string cwd: string ref);
|
||||
|
||||
#keyset[id, num]
|
||||
compilation_args(int id: @compilation ref, int num: int ref, string arg: string ref);
|
||||
|
||||
#keyset[id, num, kind]
|
||||
compilation_time(int id: @compilation ref, int num: int ref, int kind: int ref, float secs: float ref);
|
||||
|
||||
diagnostic_for(unique int diagnostic: @diagnostic ref, int compilation: @compilation ref, int file_number: int ref, int file_number_diagnostic_number: int ref);
|
||||
|
||||
compilation_finished(unique int id: @compilation ref, float cpu_seconds: float ref, float elapsed_seconds: float ref);
|
||||
|
||||
#keyset[id, num]
|
||||
compilation_compiling_files(int id: @compilation ref, int num: int ref, int file: @file ref);
|
||||
|
||||
diagnostics(unique int id: @diagnostic, int severity: int ref, string error_tag: string ref, string error_message: string ref,
|
||||
string full_error_message: string ref, int location: @location ref);
|
||||
|
||||
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
|
||||
int endLine: int ref, int endColumn: int ref);
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
description: Add XML tables
|
||||
description: Add tables for extractor diagnostics and XML
|
||||
compatibility: backwards
|
||||
|
||||
Reference in New Issue
Block a user