prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ipi doesn't work with multiline inputs
  TL;DR:
  <img width="550" alt="image" src="https://user-images.githubusercontent.com/10009354/193942063-af410d4d-3cdd-4bcb-a102-9bb87d101656.png">
  
  ```
  pwndbg> ipi
  
  In [1]: from ctypes import *
  
  In [2]: class A(LittleEndianStructure):
     ...:     a = LittleEndianStructure
     ...:
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  <ipython-input-2-814bd2a1d7ec> in <module>
  ----> 1 class A(LittleEndianStructure):
        2     a = LittleEndianStructure
        3
  
  <ipython-input-2-814bd2a1d7ec> in A()
        1 class A(LittleEndianStructure):
  ----> 2     a = LittleEndianStructure
        3
  
  NameError: name 'LittleEndianStructure' is not defined
  
  In [3]: ctypes
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  <ipython-input-3-8c9cdb26e3f3> in <module>
  ----> 1 ctypes
  
  NameError: name 'ctypes' is not defined
  
  In [4]: LittleEndianStructure
  Out[4]: _ctypes.Structure
  
  In [5]: def foo():
     ...:     return LittleEndianStructure
     ...:
  
  In [6]: foo()
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  <ipython-input-6-c19b6d9633cf> in <module>
  ----> 1 foo()
  
  <ipython-input-5-0b19aa36e370> in foo()
        1 def foo():
  ----> 2     return LittleEndianStructure
        3
  
  NameError: name 'LittleEndianStructure' is not defined
  
  In [7]:
  ```
  
  </issue>
  <code>
  [start of pwndbg/commands/ipython_interactive.py]
  1 """
  2 Command to start an interactive IPython prompt.
  3 """
  4 import sys
  5 from contextlib import contextmanager
  6 
  7 import gdb
  8 
  9 import pwndbg.color.message as M
  10 import pwndbg.commands
  11 import pwndbg.lib.stdio
  12 
  13 
  14 @contextmanager
  15 def switch_to_ipython_env():
  16     """We need to change stdout/stderr to the default ones, otherwise we can't use tab or autocomplete"""
  17     # Save GDB's excepthook
  18     saved_excepthook = sys.excepthook
  19     # Switch to default stdout/stderr
  20     with pwndbg.lib.stdio.stdio:
  21         yield
  22     # Restore Python's default ps1, ps2, and excepthook for GDB's `pi` command
  23     sys.ps1 = ">>> "
  24     sys.ps2 = "... "
  25     sys.excepthook = saved_excepthook
  26 
  27 
  28 @pwndbg.commands.ArgparsedCommand("Start an interactive IPython prompt.")
  29 def ipi():
  30     with switch_to_ipython_env():
  31         # Use `gdb.execute` to embed IPython into GDB's variable scope
  32         try:
  33             gdb.execute("pi import IPython")
  34         except gdb.error:
  35             print(
  36                 M.warn(
  37                     "Cannot import IPython.\n"
  38                     "You need to install IPython if you want to use this command.\n"
  39                     "Maybe you can try `pip install ipython` first."
  40                 )
  41             )
  42             return
  43         code4ipython = """import jedi
  44 import pwn
  45 jedi.Interpreter._allow_descriptor_getattr_default = False
  46 IPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False)
  47 """
  48         gdb.execute(f"py\n{code4ipython}")
  49
  [end of pwndbg/commands/ipython_interactive.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pwndbg/commands/ipython_interactive.py b/pwndbg/commands/ipython_interactive.py
  --- a/pwndbg/commands/ipython_interactive.py
  +++ b/pwndbg/commands/ipython_interactive.py
  @@ -43,6 +43,6 @@
           code4ipython = """import jedi
   import pwn
   jedi.Interpreter._allow_descriptor_getattr_default = False
  -IPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False)
  +IPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False, user_ns=globals())
   """
           gdb.execute(f"py\n{code4ipython}")
  
verification_info: {"golden_diff": "diff --git a/pwndbg/commands/ipython_interactive.py b/pwndbg/commands/ipython_interactive.py\n--- a/pwndbg/commands/ipython_interactive.py\n+++ b/pwndbg/commands/ipython_interactive.py\n@@ -43,6 +43,6 @@\n         code4ipython = \"\"\"import jedi\n import pwn\n jedi.Interpreter._allow_descriptor_getattr_default = False\n-IPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False)\n+IPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False, user_ns=globals())\n \"\"\"\n         gdb.execute(f\"py\\n{code4ipython}\")\n", "issue": "ipi doesn't work with multiline inputs\nTL;DR:\r\n<img width=\"550\" alt=\"image\" src=\"https://user-images.githubusercontent.com/10009354/193942063-af410d4d-3cdd-4bcb-a102-9bb87d101656.png\">\r\n\r\n```\r\npwndbg> ipi\r\n\r\nIn [1]: from ctypes import *\r\n\r\nIn [2]: class A(LittleEndianStructure):\r\n   ...:     a = LittleEndianStructure\r\n   ...:\r\n---------------------------------------------------------------------------\r\nNameError                                 Traceback (most recent call last)\r\n<ipython-input-2-814bd2a1d7ec> in <module>\r\n----> 1 class A(LittleEndianStructure):\r\n      2     a = LittleEndianStructure\r\n      3\r\n\r\n<ipython-input-2-814bd2a1d7ec> in A()\r\n      1 class A(LittleEndianStructure):\r\n----> 2     a = LittleEndianStructure\r\n      3\r\n\r\nNameError: name 'LittleEndianStructure' is not defined\r\n\r\nIn [3]: ctypes\r\n---------------------------------------------------------------------------\r\nNameError                                 Traceback (most recent call last)\r\n<ipython-input-3-8c9cdb26e3f3> in <module>\r\n----> 1 ctypes\r\n\r\nNameError: name 'ctypes' is not defined\r\n\r\nIn [4]: LittleEndianStructure\r\nOut[4]: _ctypes.Structure\r\n\r\nIn [5]: def foo():\r\n   ...:     return LittleEndianStructure\r\n   ...:\r\n\r\nIn [6]: foo()\r\n---------------------------------------------------------------------------\r\nNameError                                 Traceback (most recent call last)\r\n<ipython-input-6-c19b6d9633cf> in <module>\r\n----> 1 foo()\r\n\r\n<ipython-input-5-0b19aa36e370> in foo()\r\n      1 def foo():\r\n----> 2     return LittleEndianStructure\r\n      3\r\n\r\nNameError: name 'LittleEndianStructure' is not defined\r\n\r\nIn [7]:\r\n```\n", "before_files": [{"content": "\"\"\"\nCommand to start an interactive IPython prompt.\n\"\"\"\nimport sys\nfrom contextlib import contextmanager\n\nimport gdb\n\nimport pwndbg.color.message as M\nimport pwndbg.commands\nimport pwndbg.lib.stdio\n\n\n@contextmanager\ndef switch_to_ipython_env():\n    \"\"\"We need to change stdout/stderr to the default ones, otherwise we can't use tab or autocomplete\"\"\"\n    # Save GDB's excepthook\n    saved_excepthook = sys.excepthook\n    # Switch to default stdout/stderr\n    with pwndbg.lib.stdio.stdio:\n        yield\n    # Restore Python's default ps1, ps2, and excepthook for GDB's `pi` command\n    sys.ps1 = \">>> \"\n    sys.ps2 = \"... \"\n    sys.excepthook = saved_excepthook\n\n\n@pwndbg.commands.ArgparsedCommand(\"Start an interactive IPython prompt.\")\ndef ipi():\n    with switch_to_ipython_env():\n        # Use `gdb.execute` to embed IPython into GDB's variable scope\n        try:\n            gdb.execute(\"pi import IPython\")\n        except gdb.error:\n            print(\n                M.warn(\n                    \"Cannot import IPython.\\n\"\n                    \"You need to install IPython if you want to use this command.\\n\"\n                    \"Maybe you can try `pip install ipython` first.\"\n                )\n            )\n            return\n        code4ipython = \"\"\"import jedi\nimport pwn\njedi.Interpreter._allow_descriptor_getattr_default = False\nIPython.embed(colors='neutral',banner1='',confirm_exit=False,simple_prompt=False)\n\"\"\"\n        gdb.execute(f\"py\\n{code4ipython}\")\n", "path": "pwndbg/commands/ipython_interactive.py"}]}