prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Feature request: RVA-based breakpoints
  **Is your feature request related to a problem? Please describe.**
  I am missing a command that would allow creating a breakpoint relative to some image - either main program or a library - for example at offset 0x1337 from libc base.
  
  **Describe the solution you'd like**
  A new command that would enable this, for example
  
  ````
  bp libc.so+0x1337
  ````
  
  
  **Describe alternatives you've considered**
  The alternative is to manually find the image bases which is tedious.
  
  
  </issue>
  <code>
  [start of pwndbg/gdblib/functions.py]
  1 """
  2 Put all functions defined for gdb in here.
  3 
  4 This file might be changed into a module in the future.
  5 """
  6 
  7 from __future__ import annotations
  8 
  9 import functools
  10 from typing import Any
  11 from typing import Callable
  12 from typing import List
  13 
  14 import gdb
  15 
  16 import pwndbg.gdblib.elf
  17 import pwndbg.gdblib.proc
  18 
  19 functions: List[_GdbFunction] = []
  20 
  21 
  22 def GdbFunction(only_when_running: bool = False) -> Callable[..., Any]:
  23     return functools.partial(_GdbFunction, only_when_running=only_when_running)
  24 
  25 
  26 class _GdbFunction(gdb.Function):
  27     def __init__(self, func: Callable[..., Any], only_when_running: bool) -> None:
  28         self.name = func.__name__
  29         self.func = func
  30         self.only_when_running = only_when_running
  31 
  32         functions.append(self)
  33 
  34         super().__init__(self.name)
  35 
  36         functools.update_wrapper(self, func)
  37         self.__doc__ = func.__doc__
  38 
  39     def invoke(self, *args: gdb.Value) -> Any:
  40         if self.only_when_running and not pwndbg.gdblib.proc.alive:
  41             # Returning empty string is a workaround that we can't stop e.g. `break *$rebase(offset)`
  42             # Thx to that, gdb will print out 'evaluation of this expression requires the target program to be active'
  43             return ""
  44 
  45         return self.func(*args)
  46 
  47     def __call__(self, *args: gdb.Value) -> Any:
  48         return self.invoke(*args)
  49 
  50 
  51 @GdbFunction(only_when_running=True)
  52 def rebase(addr: gdb.Value | int) -> int:
  53     """Return rebased address."""
  54     base = pwndbg.gdblib.elf.exe().address
  55     return base + int(addr)
  56
  [end of pwndbg/gdblib/functions.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/gdblib/functions.py b/pwndbg/gdblib/functions.py
  --- a/pwndbg/gdblib/functions.py
  +++ b/pwndbg/gdblib/functions.py
  @@ -53,3 +53,16 @@
       """Return rebased address."""
       base = pwndbg.gdblib.elf.exe().address
       return base + int(addr)
  +
  +
  +@GdbFunction(only_when_running=True)
  +def base(name_pattern: gdb.Value | str) -> int:
  +    if isinstance(name_pattern, gdb.Value):
  +        name = name_pattern.string()
  +    else:
  +        name = name_pattern
  +
  +    for p in pwndbg.gdblib.vmmap.get():
  +        if name in p.objfile:
  +            return p.vaddr
  +    raise ValueError(f"No mapping named {name}")
  
verification_info: {"golden_diff": "diff --git a/pwndbg/gdblib/functions.py b/pwndbg/gdblib/functions.py\n--- a/pwndbg/gdblib/functions.py\n+++ b/pwndbg/gdblib/functions.py\n@@ -53,3 +53,16 @@\n     \"\"\"Return rebased address.\"\"\"\n     base = pwndbg.gdblib.elf.exe().address\n     return base + int(addr)\n+\n+\n+@GdbFunction(only_when_running=True)\n+def base(name_pattern: gdb.Value | str) -> int:\n+    if isinstance(name_pattern, gdb.Value):\n+        name = name_pattern.string()\n+    else:\n+        name = name_pattern\n+\n+    for p in pwndbg.gdblib.vmmap.get():\n+        if name in p.objfile:\n+            return p.vaddr\n+    raise ValueError(f\"No mapping named {name}\")\n", "issue": "Feature request: RVA-based breakpoints\n**Is your feature request related to a problem? Please describe.**\r\nI am missing a command that would allow creating a breakpoint relative to some image - either main program or a library - for example at offset 0x1337 from libc base.\r\n\r\n**Describe the solution you'd like**\r\nA new command that would enable this, for example\r\n\r\n````\r\nbp libc.so+0x1337\r\n````\r\n\r\n\r\n**Describe alternatives you've considered**\r\nThe alternative is to manually find the image bases which is tedious.\r\n\n", "before_files": [{"content": "\"\"\"\nPut all functions defined for gdb in here.\n\nThis file might be changed into a module in the future.\n\"\"\"\n\nfrom __future__ import annotations\n\nimport functools\nfrom typing import Any\nfrom typing import Callable\nfrom typing import List\n\nimport gdb\n\nimport pwndbg.gdblib.elf\nimport pwndbg.gdblib.proc\n\nfunctions: List[_GdbFunction] = []\n\n\ndef GdbFunction(only_when_running: bool = False) -> Callable[..., Any]:\n    return functools.partial(_GdbFunction, only_when_running=only_when_running)\n\n\nclass _GdbFunction(gdb.Function):\n    def __init__(self, func: Callable[..., Any], only_when_running: bool) -> None:\n        self.name = func.__name__\n        self.func = func\n        self.only_when_running = only_when_running\n\n        functions.append(self)\n\n        super().__init__(self.name)\n\n        functools.update_wrapper(self, func)\n        self.__doc__ = func.__doc__\n\n    def invoke(self, *args: gdb.Value) -> Any:\n        if self.only_when_running and not pwndbg.gdblib.proc.alive:\n            # Returning empty string is a workaround that we can't stop e.g. `break *$rebase(offset)`\n            # Thx to that, gdb will print out 'evaluation of this expression requires the target program to be active'\n            return \"\"\n\n        return self.func(*args)\n\n    def __call__(self, *args: gdb.Value) -> Any:\n        return self.invoke(*args)\n\n\n@GdbFunction(only_when_running=True)\ndef rebase(addr: gdb.Value | int) -> int:\n    \"\"\"Return rebased address.\"\"\"\n    base = pwndbg.gdblib.elf.exe().address\n    return base + int(addr)\n", "path": "pwndbg/gdblib/functions.py"}]}