def stop_reply(packet):
    """ Parses Stop Reply Packet
        See: https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html

        :returns: tuple (kind, signal, data), signal and data can be None
    """
    kind = packet[:1]
    if kind == b'T':
        signal, data = int(packet[1:3], 16), packet[3:]
    elif kind == b'S':
        signal, data = int(packet[1:3], 16), None
    elif kind == b'N':
        signal, data = None, None
    elif kind in (b'O', b'F'):
        signal, data = None, packet[1:]
    elif kind in (b'W', b'X', b'w'):
        if len(packet) > 3:
            kind_signal, data = packet.split(b';', 1)
            signal = int(kind_signal[1:], 16)
        else:
            signal, data = int(packet[1:3], 16), None
    return kind, signal, data
