docstr: Record output until the gdb prompt displays.  Return recorded output.
docstr_tok: ["Record","output","until","the","gdb","prompt","displays",".","Return","recorded","output","."]
code: def wait_until_ready(self):
      """
      Record output until the gdb prompt displays.  Return recorded output.
      """
      # TODO: add timeout?
      while (
          not self.last_stdout_line.startswith(b"(gdb) ")
          and self.proc.poll() is None
      ):
          block = self.proc.stdout.read(4096)
          if self.verbose:
              sys.stdout.buffer.write(block)
              sys.stdout.buffer.flush()
          block, sep, last_line = block.rpartition(b"\n")
          if sep:
              self.last_stdout.append(self.last_stdout_line)
              self.last_stdout.append(block + sep)
              self.last_stdout_line = last_line
          else:
              assert block == b""
              self.last_stdout_line += last_line
  
      if self.proc.poll() is not None:
          raise IOError("gdb session terminated unexpectedly")
  
      out = b"".join(self.last_stdout).decode("utf-8")
      self.last_stdout = []
      self.last_stdout_line = b""
      return out
  
imports: from functools import lru_cache
  import os
  import re
  import shutil
  import subprocess
  import sys
  import pytest
  import pyarrow
label_desc: Use image node_id 2 for calling the GdbSession obj's underlying member method code with example usage: obj.wait_until_ready() and returns: out