MCPcopy
hub / github.com/google/gvisor / Main

Function Main

tools/nvidia_driver_differ/run_differ.go:65–242  ·  view source on GitHub ↗

Main is the main function for the NVIDIA driver differ.

()

Source from the content-addressed store, hash-verified

63
64// Main is the main function for the NVIDIA driver differ.
65func Main() error {
66 // Read driver version from command line
67 baseVersion, err := nvconf.DriverVersionFrom(*baseVersionString)
68 if err != nil {
69 return fmt.Errorf("failed to parse driver version %s: %w", *baseVersionString, err)
70 }
71 nextVersion, err := nvconf.DriverVersionFrom(*nextVersionString)
72 if err != nil {
73 return fmt.Errorf("failed to parse driver version %s: %w", *nextVersionString, err)
74 }
75
76 // Unpack embedded driver_ast_parser
77 parserFile, err := createParserBinary()
78 if err != nil {
79 return fmt.Errorf("failed to unpack driver_ast_parser binary: %w", err)
80 }
81 defer func() {
82 if err := os.Remove(parserFile); err != nil {
83 log.Warningf("failed to close driver_ast_parser binary: %w", err)
84 }
85 }()
86
87 // Parse through nvproxy to find the list of structs used
88 nvproxy.Init()
89 nvproxyInfo, ok := nvproxy.SupportedIoctls(baseVersion)
90 if !ok {
91 return fmt.Errorf("failed to get struct names for version %v", baseVersion)
92 }
93
94 // Create runner for driver_ast_parser
95 runner, err := parser.NewRunner(parserFile)
96 if err != nil {
97 return fmt.Errorf("failed to create runner for driver_ast_parser: %w", err)
98 }
99 defer func() {
100 if err := runner.Cleanup(); err != nil {
101 log.Warningf("failed to clean up runner: %w", err)
102 }
103 }()
104
105 // Write list of structs to file
106 if err := runner.CreateInputFile(nvproxyInfo); err != nil {
107 return fmt.Errorf("failed to create temporary structs list: %w", err)
108 }
109
110 // Run driver_ast_parser on .cc files for both versions
111 log.Infof("Parsing driver version %s", baseVersion)
112 baseDefs, err := runner.ParseDriver(baseVersion)
113 if err != nil {
114 return fmt.Errorf("failed to run driver_ast_parser on base version: %w", err)
115 }
116 log.Infof("Parsing driver version %s", nextVersion)
117 nextDefs, err := runner.ParseDriver(nextVersion)
118 if err != nil {
119 return fmt.Errorf("failed to run driver_ast_parser on next version: %w", err)
120 }
121
122 // Create set of all records found in both versions. This will be a superset of the list of

Callers 1

mainFunction · 0.70

Calls 14

CleanupMethod · 0.95
CreateInputFileMethod · 0.95
ParseDriverMethod · 0.95
DriverVersionFromFunction · 0.92
WarningfFunction · 0.92
InitFunction · 0.92
SupportedIoctlsFunction · 0.92
NewRunnerFunction · 0.92
InfofFunction · 0.92
GetRecordDiffFunction · 0.92
createParserBinaryFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…