Exemple #1
0
 def close_connection(self, connection_id):
     try:
         self.connection_id_sink.close_connection(time_now(), connection_id)
     except Exception as e:
         if not self.catch: raise
         self.out.error(
             repr(e) + ' raised closing connection ' + str(connection_id))
Exemple #2
0
 def open_connection(self, connection_id, is_server):
     try:
         self.connection_threads[connection_id] = gdb.selected_thread(
         ).global_num
         self.connection_id_sink.open_connection(time_now(), connection_id,
                                                 is_server)
     except Exception as e:
         if not self.catch: raise
         self.out.error(
             repr(e) + ' raised closing connection ' + str(connection_id))
Exemple #3
0
def extract_message(closure, object, is_sending, new_id_is_actually_an_object):
    '''Returns a tuple containing…
    Message Name: str, the message being called
    Arguments: list of wl.Arg
    '''
    closure_message = _fast_access(closure, 'wl_closure.message')
    message_name = _fast_access(closure_message, 'wl_message.name').string()
    # The signiture is that stupid '2uufo?i' thing that has the type info
    signiture = _fast_access(closure_message, 'wl_message.signature').string()
    message_types = _fast_access(closure_message, 'wl_message.types')
    closure_args = _fast_access(closure, 'wl_closure.args')
    args = []
    i = 0
    for c in signiture:
        # If its not a version number or '?' optional indicator
        if c in type_codes:
            # Pull out the right union member at the right index
            value = closure_args[i][c]
            if c == 'i' or c == 'u':
                args.append(wl.Arg.Int(int(value)))
            elif c == 'f':
                # Math is ripped out of wl_fixed_to_double() in libwayland
                f = float(
                    gdb.parse_and_eval(
                        '(double)(void*)(((1023LL + 44LL) << 52) + (1LL << 51) + '
                        + str(value) + ') - (3LL << 43)'))
                args.append(wl.Arg.Float(f))
            elif c == 's':
                if _is_null(value):
                    str_val = '[null string]'
                else:
                    str_val = value.string()
                args.append(wl.Arg.String(str_val))
            elif c == 'a':
                size = int(value['size'])
                elems = []
                int_type = gdb.lookup_type('int')
                for i in range(size // int_type.sizeof):
                    elem = value['data'].cast(int_type.pointer())[i]
                    elems.append(wl.Arg.Int(int(elem)))
                args.append(wl.Arg.Array(elems))
            elif c == 'h':
                args.append(wl.Arg.Fd(int(value)))
            elif c == 'o':
                arg_type = message_types[i]
                if _is_null(arg_type):
                    arg_type_name = None
                else:
                    arg_type_name = arg_type['name'].string()
                if _is_null(value):
                    args.append(wl.Arg.Null(arg_type_name))
                else:
                    arg_id = int(_fast_access(value, 'wl_object.id'))
                    args.append(
                        wl.Arg.Object(
                            wl.Object.Unresolved(arg_id, arg_type_name),
                            False))
            elif c == 'n':
                arg_type = message_types[i]
                if _is_null(arg_type):
                    arg_type_name = None
                else:
                    arg_type_name = arg_type['name'].string()
                if new_id_is_actually_an_object:
                    arg_id = int(
                        _fast_access(closure_args[i]['o'], 'wl_object.id'))
                else:
                    arg_id = int(value)
                args.append(
                    wl.Arg.Object(wl.Object.Unresolved(arg_id, arg_type_name),
                                  True))
            else:
                raise RuntimeError('Invalid type code ' + c)
            i += 1
    return wl.Message(time_now(), object, is_sending, message_name, args)
Exemple #4
0
 def close_connection(self, connection_id: str) -> None:
     del self.connection_threads[connection_id]
     self.connection_id_sink.close_connection(time_now(), connection_id)
Exemple #5
0
 def open_connection(self, connection_id: str,
                     is_server: Optional[bool]) -> None:
     self.connection_threads[connection_id] = gdb.selected_thread(
     ).global_num
     self.connection_id_sink.open_connection(time_now(), connection_id,
                                             is_server)
Exemple #6
0
 def open_connection(self, connection_id, is_server):
     self.connection_threads[connection_id] = gdb.selected_thread(
     ).global_num
     self.connection_id_sink.open_connection(time_now(), connection_id,
                                             is_server)