def _buffer_incomplete_responses(raw_output, buf):
if raw_output:<EOL><INDENT>if buf:<EOL><INDENT>raw_output = b"<STR_LIT>".join([buf, raw_output])<EOL>buf = None<EOL><DEDENT>if b"<STR_LIT:\n>" not in raw_output:<EOL><INDENT>buf = raw_output<EOL>raw_output = None<EOL><DEDENT>elif not raw_output.endswith(b"<STR_LIT:\n>"):<EOL><INDENT>remainder_offset = raw_output.rindex(b"<STR_LIT:\n>") + <NUM_LIT:1><EOL>buf = raw_output[remainder_offset:]<EOL>raw_output = raw_output[:remainder_offset]<EOL><DEDENT><DEDENT>return (raw_output, buf)<EOL>
It is possible for some of gdb's output to be read before it completely finished its response.
    In that case, a partial mi response was read, which cannot be parsed into structured data.
    We want to ALWAYS parse complete mi records. To do this, we store a buffer of gdb's
    output if the output did not end in a newline.

    Args:
        raw_output: Contents of the gdb mi output
        buf (str): Buffered gdb response from the past. This is incomplete and needs to be prepended to
        gdb's next output.

    Returns:
        (raw_output, buf)