コード例 #1
0
ファイル: gnatfuzz.py プロジェクト: AdaCore/gps
    def gnatfuzz_fuzz_start_stop(self):
        """Action to start/stop the 'gnatfuzz fuzz' workflow"""

        # Check whether we have a "gnatfuzz fuzz" process running: if so,
        # interrupt it, and the workflow should terminate.
        if self.is_fuzz_running():
            self.stop_fuzz()
        else:
            workflows.task_workflow(FUZZ_TASK_NAME,
                                    self.gnatfuzz_fuzz_workflow)
コード例 #2
0
ファイル: gnatfuzz_view.py プロジェクト: AdaCore/gps
    def _on_view_button_press(self, _, event):
        """React to a click on a row in the list"""

        if event.get_click_count() == (True, 2):
            # On a double click, start debugging

            row = self._selected_row()
            if not row or not row[COL_TEST_FILENAME]:
                return False
            filename = row[COL_TEST_FILENAME]
            if not os.path.exists(filename):
                return False

            self.target_candidate = filename
            workflows.task_workflow("debug fuzzing crash", self.debug_candidate)
コード例 #3
0
    def __init__(self):
#        GPS.Menu.create("/Build/Run/Run All")
        gps_utils.make_interactive(callback=lambda: task_workflow("Run all", self.__do_run_all), 
                    category= "Run", 
                    name="Run All", 
                    toolbar='main',
                    menu='/Build/Run/Run All', 
                    description='Run all executables in project')
コード例 #4
0
ファイル: editor_sync.py プロジェクト: spanners/GNATstudio
def driver():
    buf = GPS.EditorBuffer.get()
    g = buf.gtk_text_buffer()

    def wf(task):
        """The task that does random edits on the buffer"""
        choices = [insert_random, delete_random]

        for j in range(N_OPERATIONS):
            # Do a random operation
            fun = random.choice(choices)
            fun(g)
            # timeout from time to time so the display and progress bar can
            # refresh
            if j % 10 == 0:
                yield timeout(50)
                task.set_progress(j, N_OPERATIONS)

    task_workflow("gremlins", wf)
    yield wait_tasks()
コード例 #5
0
ファイル: gnatfuzz_view.py プロジェクト: AdaCore/gps
    def refresh(self):
        """Refresh the view"""
        self.project_dir = os.path.dirname(GPS.Project.root().file().name())
        self.candidate_crash_files = []

        # Get a list of all candidate crash and hang files
        for issue_type in ("crashes", "hangs"):
            self.candidate_crash_files.extend(
                glob.glob(
                    os.path.join(
                        self.project_dir,
                        "session",
                        "fuzzer_output",
                        "gnatfuzz_*",
                        issue_type,
                        "id*",
                    )
                )
            )
        # Process the candidate crash files
        workflows.task_workflow("processing crashes", self.process_crashes)
コード例 #6
0
ファイル: zumo.ide.py プロジェクト: yannickmoy/SPARKZumo
    def __init__(self):
        """
        This is the entry point to the plugin.

        workflow_registry is the list that contains the workflows of the project.

        each workflow gets its own button and menu item.

        There is a build all which will run all workflows in the order specified in the list
        """

        if not self.__install_plugin_deps():
            raise Exception("Failed to install plugin dependencies.")

        GPS.Menu.create("/Build/Arduino")
        self.__workflow_registry = [{
            'name': "Build & Flash",
            'description':
            'Run ccg, Build Arduino Project, and Flash to Board',
            'func': self.__do_build_all_wf,
            'tasks': 0,
            'all-flag': False
        }, {
            'name': "Generate C Code",
            'description': 'Generate C code and Arduino lib',
            'func': self.__do_ccg_wf,
            'tasks': 3,
            'all-flag': True
        }, {
            'name': "Build Arduino Project",
            'description': 'Build Arduino Project',
            'func': self.__do_arduino_build_wf,
            'tasks': 2,
            'all-flag': True
        }, {
            'name': "Flash Arduino",
            'description': 'Flash Arduino Project to Board',
            'func': self.__do_arduino_flash_wf,
            'tasks': 2,
            'all-flag': True
        }]

        for value in self.__workflow_registry:
            value['action'] = gps_utils.make_interactive(
                callback=lambda x=value: task_workflow(x['name'], x['func']),
                category="Build",
                name=value['name'],
                toolbar='main',
                menu='/Build/Arduino/' + value['name'],
                description=value['description'])

        self.__console_msg("Plugin successfully initialized...")
コード例 #7
0
def driver():
    # interrupt the action if it's being run again
    global IN_PROGRESS
    if IN_PROGRESS:
        IN_PROGRESS = False
        return

    IN_PROGRESS = True
    buf = GPS.EditorBuffer.get()
    lang = buf.file().language()
    als = GPS.LanguageServer.get_by_file(buf.file())
    ada_sources = [
        f for f in GPS.Project.root().sources(True) if f.language() == lang
    ]

    def random_ada_source():
        return random.choice(ada_sources)

    def random_query(buf):
        unit = buf.get_analysis_unit()
        identifiers = unit.root.findall(lambda x: x.is_a(lal.Identifier))
        identifier = random.choice(identifiers)
        line = identifier.sloc_range.start.line
        column = identifier.sloc_range.start.column

        method = "textDocument/definition"
        params = {
            "textDocument": {
                "uri": "file://{}".format(buf.file().name())
            },
            "position": {
                "line": line - 1,
                "character": column - 1
            }
        }

        return (method, params)

    def wf(task):
        """The task that does random edits on the buffer"""
        choices = [insert_random]

        good_queries = []
        # contains (method, params, result)

        # Start
        counter = 0
        while counter != N_OPERATIONS:
            counter += 1

            # allow breaking the workflow
            global IN_PROGRESS
            if not IN_PROGRESS:
                break

            # Select a source at random and open a buffer for it
            f = random_ada_source()

            buf = GPS.EditorBuffer.get(f)
            g = buf.gtk_text_buffer()

            # Generate a random query on the buffer
            method, params = random_query(buf)

            # Execute this random query and get the result
            result = yield als.request_promise(method, params)
            orig_result = str(result)

            # Store the result in the "good queries" that we've done
            good_queries.append((method, params, orig_result))

            # Now do a random edit
            fun = random.choice(choices)
            fun(g)

            # Generate another random query on the buffer, this time
            # when the buffer is (most probably) invalid, just to throw LAL off
            bad_method, bad_params = random_query(buf)
            yield als.request_promise(bad_method, bad_params)

            # now undo the operation
            buf.undo()

            # Verify that the initial request still works!
            result = yield als.request_promise(method, params)
            new_result = str(result)

            if new_result != orig_result:
                GPS.MDI.dialog("{}\n  /=  \n{}".format(new_result,
                                                       orig_result))
                break

            # TODO: execute a past random request

    task_workflow("gremlins", wf)
    yield wait_tasks()
コード例 #8
0
ファイル: gnatfuzz.py プロジェクト: AdaCore/gps
 def gnatfuzz_generate(self):
     """Action to launch the 'gnatfuzz generate' workflow"""
     workflows.task_workflow("gnatfuzz generate",
                             self.gnatfuzz_generate_workflow)
コード例 #9
0
ファイル: gnatfuzz.py プロジェクト: AdaCore/gps
 def gnatfuzz_analyze_file(self):
     self.clear_analyze_messages()
     """Action to launch the 'gnatfuzz analyze' workflow on a file"""
     workflows.task_workflow("gnatfuzz analyze",
                             self.gnatfuzz_analyze_file_workflow)
コード例 #10
0
ファイル: gnatfuzz.py プロジェクト: AdaCore/gps
 def gnatfuzz_analyze_project(self):
     """Action to launch the 'gnatfuzz analyze' workflow"""
     self.clear_analyze_messages()
     workflows.task_workflow("gnatfuzz analyze",
                             self.gnatfuzz_analyze_project_workflow)