code: def _buffer_incomplete_responses(raw_output, buf):
      
  
      if raw_output:
          if buf:
              # concatenate buffer and new output
              raw_output = b"".join([buf, raw_output])
              buf = None
  
          if b"\n" not in raw_output:
              # newline was not found, so assume output is incomplete and store in buffer
              buf = raw_output
              raw_output = None
  
          elif not raw_output.endswith(b"\n"):
              # raw output doesn't end in a newline, so store everything after the last newline (if anything)
              # in the buffer, and parse everything before it
              remainder_offset = raw_output.rindex(b"\n") + 1
              buf = raw_output[remainder_offset:]
              raw_output = raw_output[:remainder_offset]
  
      return (raw_output, buf)
docs: 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)