def gnatpp(file): """ Run gnatpp on a specific file. Nothing is done if the file is not an Ada file. """ if file.language().lower() != 'ada': GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path) return sv = GPS.Project.scenario_variables() x_args = ['-X%s=%s' % (k, v) for k, v in sv.items()] if sv else [] gnat_driver = gs_utils.get_gnat_driver_cmd() # If the GNAT driver is not found (e.g: when <target_prefix>-gnat # is not found), fallback on the native GNAT driver if not locate_exec_on_path(gnat_driver): gnat_driver = "gnat" cmd = [gnat_driver, 'pretty', '-rnb', '-P%s' % GPS.Project.root().file().path] + x_args + [file.path] p = ProcessWrapper(cmd, spawn_console='') status, output = yield p.wait_until_terminate() if status != 0: GPS.Locations.parse(output, category='gnat pretty') else: GPS.EditorBuffer.get(file, force=True, open=True)
def _internal_commit_staged_files(self, visitor, args): """ Execute the command `args` and pass all staged files. :param List(str) args: the command and its arguments """ # Need to copy the list, since '_staged' will be changed below files = list(self._staged) p = ProcessWrapper(args + [f.path for f in files], directory=self.working_dir.path) (status, output) = yield p.wait_until_terminate() if status: GPS.Console().write("%s %s" % (" ".join(args), output)) else: self.stage_or_unstage_files(files, stage=False) visitor.success('Commit successful')
def process_crashes(self, task): """Workflow to read the crashes from the fuzzing session""" global counter while self.candidate_crash_files: candidate = self.candidate_crash_files.pop() if candidate not in self.crashes: executable = coverage_executable() # We're actually launching the executable to get the # parameters that were passed to the crash, along with # the actual crash message. cl = [executable, candidate] p = ProcessWrapper(cl) status, output = yield p.wait_until_terminate() c = FuzzCrash(candidate) splits = candidate.split(os.sep) issue_dir = splits[-2] if issue_dir == "crashes": issue_label = "Crash" elif issue_dir == "hangs": issue_label = "Hang" else: issue_label = "Issue" c.label = f"{str(counter)} ({issue_label})" counter += 1 c.params = [] # Replace this code when the output of harness programs # is simpler to parse. for line in output.splitlines(): if line.startswith("Parameter:"): param, value = line.split("=", 1) c.params.append((param, value)) # Very crude, need a proper parsable output for this if "raised" in line: _, msg = line.split("raised") c.message = msg self.fcl.add_crash(c)
def gnatpp(file): """ Run gnatpp on a specific file. Nothing is done if the file is not an Ada file. """ if file.language().lower() != 'ada': GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path) return p = ProcessWrapper([ gps_utils.get_gnat_driver_cmd(), 'pretty', '-rf', '-P%s' % GPS.Project.root().file().path, GPS.Project.scenario_variables_cmd_line('-X'), file.path ], spawn_console='') status, output = yield p.wait_until_terminate() if status != 0: GPS.Locations.parse(output, category='gnat pretty') else: GPS.EditorBuffer.get(file, force=True, open=True)
def gnatpp(file): """ Run gnatpp on a specific file. Nothing is done if the file is not an Ada file. """ if file.language().lower() != 'ada': GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path) return p = ProcessWrapper( [gps_utils.get_gnat_driver_cmd(), 'pretty', '-rf', '-P%s' % GPS.Project.root().file().path, GPS.Project.scenario_variables_cmd_line('-X'), file.path], spawn_console='') status, output = yield p.wait_until_terminate() if status != 0: GPS.Locations.parse(output, category='gnat pretty') else: GPS.EditorBuffer.get(file, force=True, open=True)