Esempio n. 1
0
    def evaluate(self, params):
        # Cast to string from possible unicode.
        command = str(params["expression"])

        # `objectGroups` are used by the client to designate remote objects on
        # the server that should stick around (for potential future queries),
        # and eventually released with a `releaseObjectGroup` call.
        #
        # Incidentally, they have names denoting which part of the client made
        # the request. We use these names to disambiguate LLDB commands from
        # C-style expressions.
        if params["objectGroup"] == "console":
            result = lldb.SBCommandReturnObject()
            self.debugger.GetCommandInterpreter().HandleCommand(command, result)

            return {"result": {"value": result.GetOutput() + result.GetError()}, "wasThrown": False}
        elif params["objectGroup"] == "watch-group":
            frame = self.debugger.GetSelectedTarget().process.GetSelectedThread().GetSelectedFrame()
            value = frame.EvaluateExpression(command)
            # `value.error` is an `SBError` instance which captures whether the
            # result had an error. `SBError.success` denotes no error.
            if value.error.success:
                return {
                    "result": value_serializer.serialize_value(
                        value, self._remote_object_manager.get_add_object_func(params["objectGroup"])
                    ),
                    "wasThrown": False,
                }
            else:
                return {
                    "result": {"type": "undefined"},
                    "wasThrown": True,
                    "exceptionDetails": {"text": value.error.description},
                }
        return {"result": {}, "wasThrown": False}
Esempio n. 2
0
    def evaluate(self, params):
        # Cast to string from possible unicode.
        expression = str(params['expression'])

        # `objectGroups` are used by the client to designate remote objects on
        # the server that should stick around (for potential future queries),
        # and eventually released with a `releaseObjectGroup` call.
        #
        # Incidentally, they have names denoting which part of the client made
        # the request. We use these names to disambiguate LLDB commands from
        # C-style expressions.
        if params['objectGroup'] == 'console':
            result = lldb.SBCommandReturnObject()
            self.debugger_store.debugger.GetCommandInterpreter().HandleCommand(
                expression, result)

            return {
                'result': {
                    'value': result.GetOutput() + result.GetError(),
                    'type': 'text',
                },
                'wasThrown': False,
            }
        elif params['objectGroup'] == 'watch-group':
            frame = self.debugger_store.debugger.GetSelectedTarget(). \
                process.GetSelectedThread().GetSelectedFrame()
            # TODO: investigate why "EvaluateExpression"
            # is not working for some scenarios on Linux.
            if sys.platform.startswith('linux'):
                value = frame.GetValueForVariablePath(expression)
            else:
                value = frame.EvaluateExpression(expression)
            # `value.error` is an `SBError` instance which captures whether the
            # result had an error. `SBError.success` denotes no error.
            if value.error.success:
                return {
                    'result':
                    value_serializer.serialize_value(
                        value,
                        self.debugger_store.remote_object_manager.
                        get_add_object_func(params['objectGroup'])),
                    'wasThrown':
                    False,
                }
            else:
                return {
                    'result': {
                        'type': 'text',
                    },
                    'wasThrown': True,
                    'exceptionDetails': {
                        'text': value.error.description,
                    }
                }
        return {
            'result': {},
            'wasThrown': False,
        }
Esempio n. 3
0
    def evaluate(self, params):
        # Cast to string from possible unicode.
        expression = str(params['expression'])

        # `objectGroups` are used by the client to designate remote objects on
        # the server that should stick around (for potential future queries),
        # and eventually released with a `releaseObjectGroup` call.
        #
        # Incidentally, they have names denoting which part of the client made
        # the request. We use these names to disambiguate LLDB commands from
        # C-style expressions.
        if params['objectGroup'] == 'console':
            result = get_lldb().SBCommandReturnObject()
            self.debugger_store.debugger.GetCommandInterpreter().HandleCommand(expression, result)

            return {
                'result': {
                    'value': result.GetOutput() + result.GetError(),
                    'type': 'text',
                },
                'wasThrown': False,
            }
        elif params['objectGroup'] == 'watch-group':
            frame = self.debugger_store.debugger.GetSelectedTarget(). \
                process.GetSelectedThread().GetSelectedFrame()
            # TODO: investigate why "EvaluateExpression"
            # is not working for some scenarios on Linux.
            if sys.platform.startswith('linux'):
                value = frame.GetValueForVariablePath(expression)
            else:
                value = frame.EvaluateExpression(expression)
            # `value.error` is an `SBError` instance which captures whether the
            # result had an error. `SBError.success` denotes no error.
            if value.error.success:
                return {
                    'result': value_serializer.serialize_value(
                        value,
                        self.debugger_store.remote_object_manager.
                        get_add_object_func(params['objectGroup'])),
                    'wasThrown': False,
                }
            else:
                return {
                    'result': {
                        'type': 'text',
                    },
                    'wasThrown': True,
                    'exceptionDetails': {
                        'text': value.error.description,
                    }
                }
        return {
            'result': {},
            'wasThrown': False,
        }
    def properties(self):
        import value_serializer  # delayed import to break circular dependency

        property_descriptors = []
        for value in self._values:
            property_descriptors.append({
                'name':
                value.name,
                'value':
                value_serializer.serialize_value(value, self._add_object_func),
            })
        return {
            'result': property_descriptors,
        }