def _collect_scopes(self, frame):
        loc = self._image.loc_at(frame["pc"])
        func_name, cu_name, cu_line, source_dir = loc

        scopes = []
        if len(self._image._compile_units[cu_name]["variables"]) > 0:
            global_scope = ScopeModel("global variables")
            global_scope.children = self._collect_vars(self._image._compile_units[cu_name]["variables"], global_scope, frame)
            global_scope.accessor = lambda x: x.evaluator()

            scopes += [global_scope]

        if func_name:
            if len(self._image._compile_units[cu_name]["functions"][func_name]["args"]) > 0:
                argument_scope = ScopeModel("function arguments")
                argument_scope.children = self._collect_vars(self._image._compile_units[cu_name]["functions"][func_name]["args"], argument_scope, frame)
                argument_scope.accessor = lambda x: x.evaluator()

                scopes += [argument_scope]

            if len(self._image._compile_units[cu_name]["functions"][func_name]["vars"]) > 0:
                local_scope = ScopeModel("local variables")
                local_scope.children = self._collect_vars(self._image._compile_units[cu_name]["functions"][func_name]["vars"], local_scope, frame)
                local_scope.accessor = lambda x: x.evaluator()

                scopes += [local_scope]

        return scopes