Documentation ¶
Overview ¶
Package parser contains functions for interfacing with driver_ast_parser.
Index ¶
- Constants
- func CreateCompileCommandsFile(dir string, config []ClangASTConfig) error
- func GetRecordDiff(name nvproxy.DriverStructName, a, b RecordDef) string
- func WriteIncludeFile(sources []string, w io.Writer) error
- type ClangASTConfig
- type DriverSourceDir
- func (d *DriverSourceDir) GetNonUVMIncludePaths() []string
- func (d *DriverSourceDir) GetNonUVMSourcePaths() ([]string, error)
- func (d *DriverSourceDir) GetUVMIncludePaths() []string
- func (d *DriverSourceDir) GetUVMSourcePaths() []string
- func (d *DriverSourceDir) GlobDriverFiles(pattern string) ([]string, error)
- func (d DriverSourceDir) Name() string
- type InputJSON
- type OutputJSON
- type ParserFile
- type RecordDef
- type RecordDefs
- type RecordField
- type Runner
- type StructsFile
- type TypeAliases
- type TypeDef
Constants ¶
const GitRepoURL = "https://github.com/NVIDIA/open-gpu-kernel-modules.git"
GitRepoURL is the URL for the NVIDIA open-gpu-kernel-modules repo.
Variables ¶
This section is empty.
Functions ¶
func CreateCompileCommandsFile ¶
func CreateCompileCommandsFile(dir string, config []ClangASTConfig) error
CreateCompileCommandsFile creates a new compile_commands.json file in the given directory, and writes config to it.
func GetRecordDiff ¶
func GetRecordDiff(name nvproxy.DriverStructName, a, b RecordDef) string
GetRecordDiff prints a diff between two records.
Types ¶
type ClangASTConfig ¶
type ClangASTConfig struct { Directory string `json:"directory"` Arguments []string `json:"arguments"` Filename string `json:"file"` }
ClangASTConfig is the format for compilation_commands.json.
func CreateIncludeFiles ¶
func CreateIncludeFiles(dir string, driverSource DriverSourceDir) ([]ClangASTConfig, error)
CreateIncludeFiles creates the necessary include files for the given driver version, and returns the config options for the files.
func NewParserConfig ¶
func NewParserConfig(directory, filename string, includes []string) ClangASTConfig
NewParserConfig creates a ClangASTConfig for the given file using the list of includes.
type DriverSourceDir ¶
type DriverSourceDir struct { ParentDirectory string Version nvproxy.DriverVersion }
DriverSourceDir represents a directory containing the source code for a given driver version.
func CloneDriverSource ¶
func CloneDriverSource(dir string, version nvproxy.DriverVersion) (*DriverSourceDir, error)
CloneDriverSource clones the given driver version into the given directory.
func (*DriverSourceDir) GetNonUVMIncludePaths ¶
func (d *DriverSourceDir) GetNonUVMIncludePaths() []string
GetNonUVMIncludePaths returns the list of paths for non-uvm include files.
func (*DriverSourceDir) GetNonUVMSourcePaths ¶
func (d *DriverSourceDir) GetNonUVMSourcePaths() ([]string, error)
GetNonUVMSourcePaths returns the list of paths for non-uvm source files.
func (*DriverSourceDir) GetUVMIncludePaths ¶
func (d *DriverSourceDir) GetUVMIncludePaths() []string
GetUVMIncludePaths returns the list of paths for uvm include files.
func (*DriverSourceDir) GetUVMSourcePaths ¶
func (d *DriverSourceDir) GetUVMSourcePaths() []string
GetUVMSourcePaths returns the list of paths for uvm source files.
func (*DriverSourceDir) GlobDriverFiles ¶
func (d *DriverSourceDir) GlobDriverFiles(pattern string) ([]string, error)
GlobDriverFiles returns all files in the given driver directory that match the given pattern.
func (DriverSourceDir) Name ¶
func (d DriverSourceDir) Name() string
Name returns the name of the driver source directory.
type InputJSON ¶
type InputJSON struct {
Structs []string `json:"structs"`
}
InputJSON is the format for the structs.json file that driver_ast_parser takes as input.
type OutputJSON ¶
type OutputJSON struct { Records RecordDefs Aliases TypeAliases }
OutputJSON is the format for the output of driver_ast_parser.
func (*OutputJSON) Merge ¶
func (a *OutputJSON) Merge(b OutputJSON)
Merge merges the struct definitions from b into this OutputJSON.
type ParserFile ¶
ParserFile is a wrapper around the driver_ast_parser binary.
type RecordDef ¶
type RecordDef struct { Fields []RecordField Size uint64 IsUnion bool `json:"is_union"` Source string }
RecordDef represents the definition of a record (struct or union).
type RecordDefs ¶
RecordDefs is a map of type names to definitions.
type RecordField ¶
RecordField represents a field in a record (struct or union).
func (RecordField) String ¶
func (s RecordField) String() string
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is a helper for running the driver_ast_parser on a given set of structs.
func NewRunner ¶
func NewRunner(parserFile *ParserFile) (*Runner, error)
NewRunner creates a new Runner around a given parser file and a temporary working directory.
func (*Runner) CreateStructsFile ¶
func (r *Runner) CreateStructsFile(structs []nvproxy.DriverStructName) error
CreateStructsFile saves a list of structs for the runner to parse.
func (*Runner) ParseDriver ¶
func (r *Runner) ParseDriver(version nvproxy.DriverVersion) (*OutputJSON, error)
ParseDriver checks out the git repo for the given version, and runs the driver_ast_parser on the source code.
type TypeAliases ¶
TypeAliases is a map of type aliases to their underlying type.