def run_analysis()

in memory_analyzer/analysis_utils.py [0:0]


    def run_analysis(self, debug=False):
        self.create_pipe()
        frontend_utils.echo_info(f"Analyzing pid {self.pid}")
        command_file = f"{self.current_path}/gdb_commands.py"
        command = [
            "gdb",
            "-q",
            # Activates python for GDB.
            self.executable,
            "-p",
            f"{self.pid}",
            "-ex",
            "set trace-commands on",
            f"{'-batch' if debug else '-batch-silent'}",
            # This shouldn't be required since we specify absolute path, but
            # TODO this gives us a way to inject a path with objgraph on it.
            "-ex",
            # Lets gdb find the correct gdb_commands script.
            f"set directories {self.current_path}",
            "-ex",
            # Sets the correct path for gdb_commands, else C-API commands fail.
            f'py sys.path.append("{self.current_path}")',
            "-x",
            f"{command_file}",
        ]
        frontend_utils.echo_info(f"Setting up GDB for pid {self.pid}")
        proc = subprocess.Popen(
            command, stderr=sys.stderr if debug else subprocess.DEVNULL
        )
        with self.drain_pipe(proc) as data:
            retrieved_objs = RetrievedObjects(
                pid=self.pid,
                title=f"Analysis for {self.pid}",
                data=self.unpickle_pipe(data),
            )

        self._end_subprocess(proc)
        return retrieved_objs