We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
nextcall with symbol bug
### Description

after nextcall with unknown symbol/address (like nextcall lol) gdb won't run again

### Steps to reproduce
```
gdb whatever
> start
> nextcall lol
> start
> continue
Warning:
Cannot insert breakpoint -46.
Cannot access memory at address 0x7ffff7a6f916

Command aborted.
```

### My setup

GNU gdb (Debian 7.12-6) 7.12.0.20161007
nextcall with symbol bug
### Description

after nextcall with unknown symbol/address (like nextcall lol) gdb won't run again

### Steps to reproduce
```
gdb whatever
> start
> nextcall lol
> start
> continue
Warning:
Cannot insert breakpoint -46.
Cannot access memory at address 0x7ffff7a6f916

Command aborted.
```

### My setup

GNU gdb (Debian 7.12-6) 7.12.0.20161007

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pwndbg/next.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """
4 Commands for setting temporary breakpoints on the next
5 instruction of some type (call, branch, etc.)
6 """
7 from __future__ import absolute_import
8 from __future__ import division
9 from __future__ import print_function
10 from __future__ import unicode_literals
11 
12 import re
13 
14 import capstone
15 import gdb
16 
17 import pwndbg.disasm
18 import pwndbg.regs
19 from pwndbg.color import message
20 
21 jumps = set((
22     capstone.CS_GRP_CALL,
23     capstone.CS_GRP_JUMP,
24     capstone.CS_GRP_RET,
25     capstone.CS_GRP_IRET
26 ))
27 
28 interrupts = set((capstone.CS_GRP_INT,))
29 
30 
31 def next_int(address=None):
32     """
33     If there is a syscall in the current basic black,
34     return the instruction of the one closest to $PC.
35 
36     Otherwise, return None.
37     """
38     if address is None:
39         ins = pwndbg.disasm.one(pwndbg.regs.pc)
40         if not ins:
41             return None
42         address = ins.next
43 
44     ins = pwndbg.disasm.one(address)
45     while ins:
46         if set(ins.groups) & jumps:
47             return None
48         if set(ins.groups) & interrupts:
49             return ins
50         ins = pwndbg.disasm.one(ins.next)
51 
52     return None
53 
54 
55 def next_branch(address=None):
56     if address is None:
57         ins = pwndbg.disasm.one(pwndbg.regs.pc)
58         if not ins:
59             return None
60         address = ins.next
61 
62     ins = pwndbg.disasm.one(address)
63     while ins:
64         if set(ins.groups) & jumps:
65             return ins
66         ins = pwndbg.disasm.one(ins.next)
67 
68     return None
69 
70 
71 def break_next_branch(address=None):
72     ins = next_branch(address)
73 
74     if ins:
75         gdb.Breakpoint("*%#x" % ins.address, internal=True, temporary=True)
76         gdb.execute('continue', from_tty=False, to_string=True)
77         return ins
78 
79 
80 def break_next_interrupt(address=None):
81     ins = next_int(address)
82 
83     if ins:
84         gdb.Breakpoint("*%#x" % ins.address, internal=True, temporary=True)
85         gdb.execute('continue', from_tty=False, to_string=True)
86         return ins
87 
88 
89 def break_next_call(symbol_regex=None):
90     while pwndbg.proc.alive:
91         ins = break_next_branch()
92 
93         if not ins:
94             break
95 
96         # continue if not a call
97         if capstone.CS_GRP_CALL not in ins.groups:
98             continue
99 
100         # return call if we don't search for a symbol
101         if not symbol_regex:
102             return ins
103 
104         # return call if we match target address
105         if ins.target_const and re.match('%s$' % symbol_regex, hex(ins.target)):
106             return ins
107 
108         # return call if we match symbol name
109         if ins.symbol and re.match('%s$' % symbol_regex, ins.symbol):
110             return ins
111 
112 
113 def break_next_ret(address=None):
114     while pwndbg.proc.alive:
115         ins = break_next_branch(address)
116 
117         if not ins:
118             break
119 
120         if capstone.CS_GRP_RET in ins.groups:
121             return ins
122 
123 
124 def break_on_program_code():
125     """
126     Breaks on next instruction that belongs to process' objfile code.
127     :return: True for success, False when process ended or when pc is at the code.
128     """
129     mp = pwndbg.proc.mem_page
130     start = mp.start
131     end = mp.end
132 
133     if start <= pwndbg.regs.pc < end:
134         print(message.error('The pc is already at the binary objfile code. Not stepping.'))
135         return False
136 
137     while pwndbg.proc.alive:
138         gdb.execute('si', from_tty=False, to_string=False)
139 
140         addr = pwndbg.regs.pc
141         if start <= addr < end:
142             return True
143 
144     return False
145 
146 
147 def break_on_next(address=None):
148     address = address or pwndbg.regs.pc
149     ins = pwndbg.disasm.one(address)
150 
151     gdb.Breakpoint("*%#x" % (ins.address + ins.size), temporary=True)
152     gdb.execute('continue', from_tty=False, to_string=True)
153
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pwndbg/next.py b/pwndbg/next.py
--- a/pwndbg/next.py
+++ b/pwndbg/next.py
@@ -27,6 +27,14 @@
 
 interrupts = set((capstone.CS_GRP_INT,))
 
+@pwndbg.events.exit
+def clear_temp_breaks():
+    if not pwndbg.proc.alive:
+        breakpoints = gdb.breakpoints()
+        if breakpoints:
+            for bp in breakpoints:
+                if bp.temporary and not bp.visible: #visible is used instead of internal because older gdb's don't support internal 
+                    bp.delete()
 
 def next_int(address=None):
     """

{"golden_diff": "diff --git a/pwndbg/next.py b/pwndbg/next.py\n--- a/pwndbg/next.py\n+++ b/pwndbg/next.py\n@@ -27,6 +27,14 @@\n \n interrupts = set((capstone.CS_GRP_INT,))\n \n+@pwndbg.events.exit\n+def clear_temp_breaks():\n+    if not pwndbg.proc.alive:\n+        breakpoints = gdb.breakpoints()\n+        if breakpoints:\n+            for bp in breakpoints:\n+                if bp.temporary and not bp.visible: #visible is used instead of internal because older gdb's don't support internal \n+                    bp.delete()\n \n def next_int(address=None):\n     \"\"\"\n", "issue": "nextcall with symbol bug\n### Description\r\n\r\nafter nextcall with unknown symbol/address (like nextcall lol) gdb won't run again\r\n\r\n### Steps to reproduce\r\n```\r\ngdb whatever\r\n> start\r\n> nextcall lol\r\n> start\r\n> continue\r\nWarning:\r\nCannot insert breakpoint -46.\r\nCannot access memory at address 0x7ffff7a6f916\r\n\r\nCommand aborted.\r\n```\r\n\r\n### My setup\r\n\r\nGNU gdb (Debian 7.12-6) 7.12.0.20161007\nnextcall with symbol bug\n### Description\r\n\r\nafter nextcall with unknown symbol/address (like nextcall lol) gdb won't run again\r\n\r\n### Steps to reproduce\r\n```\r\ngdb whatever\r\n> start\r\n> nextcall lol\r\n> start\r\n> continue\r\nWarning:\r\nCannot insert breakpoint -46.\r\nCannot access memory at address 0x7ffff7a6f916\r\n\r\nCommand aborted.\r\n```\r\n\r\n### My setup\r\n\r\nGNU gdb (Debian 7.12-6) 7.12.0.20161007\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nCommands for setting temporary breakpoints on the next\ninstruction of some type (call, branch, etc.)\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport re\n\nimport capstone\nimport gdb\n\nimport pwndbg.disasm\nimport pwndbg.regs\nfrom pwndbg.color import message\n\njumps = set((\n    capstone.CS_GRP_CALL,\n    capstone.CS_GRP_JUMP,\n    capstone.CS_GRP_RET,\n    capstone.CS_GRP_IRET\n))\n\ninterrupts = set((capstone.CS_GRP_INT,))\n\n\ndef next_int(address=None):\n    \"\"\"\n    If there is a syscall in the current basic black,\n    return the instruction of the one closest to $PC.\n\n    Otherwise, return None.\n    \"\"\"\n    if address is None:\n        ins = pwndbg.disasm.one(pwndbg.regs.pc)\n        if not ins:\n            return None\n        address = ins.next\n\n    ins = pwndbg.disasm.one(address)\n    while ins:\n        if set(ins.groups) & jumps:\n            return None\n        if set(ins.groups) & interrupts:\n            return ins\n        ins = pwndbg.disasm.one(ins.next)\n\n    return None\n\n\ndef next_branch(address=None):\n    if address is None:\n        ins = pwndbg.disasm.one(pwndbg.regs.pc)\n        if not ins:\n            return None\n        address = ins.next\n\n    ins = pwndbg.disasm.one(address)\n    while ins:\n        if set(ins.groups) & jumps:\n            return ins\n        ins = pwndbg.disasm.one(ins.next)\n\n    return None\n\n\ndef break_next_branch(address=None):\n    ins = next_branch(address)\n\n    if ins:\n        gdb.Breakpoint(\"*%#x\" % ins.address, internal=True, temporary=True)\n        gdb.execute('continue', from_tty=False, to_string=True)\n        return ins\n\n\ndef break_next_interrupt(address=None):\n    ins = next_int(address)\n\n    if ins:\n        gdb.Breakpoint(\"*%#x\" % ins.address, internal=True, temporary=True)\n        gdb.execute('continue', from_tty=False, to_string=True)\n        return ins\n\n\ndef break_next_call(symbol_regex=None):\n    while pwndbg.proc.alive:\n        ins = break_next_branch()\n\n        if not ins:\n            break\n\n        # continue if not a call\n        if capstone.CS_GRP_CALL not in ins.groups:\n            continue\n\n        # return call if we don't search for a symbol\n        if not symbol_regex:\n            return ins\n\n        # return call if we match target address\n        if ins.target_const and re.match('%s$' % symbol_regex, hex(ins.target)):\n            return ins\n\n        # return call if we match symbol name\n        if ins.symbol and re.match('%s$' % symbol_regex, ins.symbol):\n            return ins\n\n\ndef break_next_ret(address=None):\n    while pwndbg.proc.alive:\n        ins = break_next_branch(address)\n\n        if not ins:\n            break\n\n        if capstone.CS_GRP_RET in ins.groups:\n            return ins\n\n\ndef break_on_program_code():\n    \"\"\"\n    Breaks on next instruction that belongs to process' objfile code.\n    :return: True for success, False when process ended or when pc is at the code.\n    \"\"\"\n    mp = pwndbg.proc.mem_page\n    start = mp.start\n    end = mp.end\n\n    if start <= pwndbg.regs.pc < end:\n        print(message.error('The pc is already at the binary objfile code. Not stepping.'))\n        return False\n\n    while pwndbg.proc.alive:\n        gdb.execute('si', from_tty=False, to_string=False)\n\n        addr = pwndbg.regs.pc\n        if start <= addr < end:\n            return True\n\n    return False\n\n\ndef break_on_next(address=None):\n    address = address or pwndbg.regs.pc\n    ins = pwndbg.disasm.one(address)\n\n    gdb.Breakpoint(\"*%#x\" % (ins.address + ins.size), temporary=True)\n    gdb.execute('continue', from_tty=False, to_string=True)\n", "path": "pwndbg/next.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nCommands for setting temporary breakpoints on the next\ninstruction of some type (call, branch, etc.)\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport re\n\nimport capstone\nimport gdb\n\nimport pwndbg.disasm\nimport pwndbg.regs\nfrom pwndbg.color import message\n\njumps = set((\n    capstone.CS_GRP_CALL,\n    capstone.CS_GRP_JUMP,\n    capstone.CS_GRP_RET,\n    capstone.CS_GRP_IRET\n))\n\ninterrupts = set((capstone.CS_GRP_INT,))\n\n@pwndbg.events.exit\ndef clear_temp_breaks():\n    if not pwndbg.proc.alive:\n        breakpoints = gdb.breakpoints()\n        if breakpoints:\n            for bp in breakpoints:\n                if bp.temporary and not bp.visible: #visible is used instead of internal because older gdb's don't support internal \n                    bp.delete()\n\ndef next_int(address=None):\n    \"\"\"\n    If there is a syscall in the current basic black,\n    return the instruction of the one closest to $PC.\n\n    Otherwise, return None.\n    \"\"\"\n    if address is None:\n        ins = pwndbg.disasm.one(pwndbg.regs.pc)\n        if not ins:\n            return None\n        address = ins.next\n\n    ins = pwndbg.disasm.one(address)\n    while ins:\n        if set(ins.groups) & jumps:\n            return None\n        if set(ins.groups) & interrupts:\n            return ins\n        ins = pwndbg.disasm.one(ins.next)\n\n    return None\n\n\ndef next_branch(address=None):\n    if address is None:\n        ins = pwndbg.disasm.one(pwndbg.regs.pc)\n        if not ins:\n            return None\n        address = ins.next\n\n    ins = pwndbg.disasm.one(address)\n    while ins:\n        if set(ins.groups) & jumps:\n            return ins\n        ins = pwndbg.disasm.one(ins.next)\n\n    return None\n\n\ndef break_next_branch(address=None):\n    ins = next_branch(address)\n\n    if ins:\n        gdb.Breakpoint(\"*%#x\" % ins.address, internal=True, temporary=True)\n        gdb.execute('continue', from_tty=False, to_string=True)\n        return ins\n\n\ndef break_next_interrupt(address=None):\n    ins = next_int(address)\n\n    if ins:\n        gdb.Breakpoint(\"*%#x\" % ins.address, internal=True, temporary=True)\n        gdb.execute('continue', from_tty=False, to_string=True)\n        return ins\n\n\ndef break_next_call(symbol_regex=None):\n    while pwndbg.proc.alive:\n        ins = break_next_branch()\n\n        if not ins:\n            break\n\n        # continue if not a call\n        if capstone.CS_GRP_CALL not in ins.groups:\n            continue\n\n        # return call if we don't search for a symbol\n        if not symbol_regex:\n            return ins\n\n        # return call if we match target address\n        if ins.target_const and re.match('%s$' % symbol_regex, hex(ins.target)):\n            return ins\n\n        # return call if we match symbol name\n        if ins.symbol and re.match('%s$' % symbol_regex, ins.symbol):\n            return ins\n\n\ndef break_next_ret(address=None):\n    while pwndbg.proc.alive:\n        ins = break_next_branch(address)\n\n        if not ins:\n            break\n\n        if capstone.CS_GRP_RET in ins.groups:\n            return ins\n\n\ndef break_on_program_code():\n    \"\"\"\n    Breaks on next instruction that belongs to process' objfile code.\n    :return: True for success, False when process ended or when pc is at the code.\n    \"\"\"\n    mp = pwndbg.proc.mem_page\n    start = mp.start\n    end = mp.end\n\n    if start <= pwndbg.regs.pc < end:\n        print(message.error('The pc is already at the binary objfile code. Not stepping.'))\n        return False\n\n    while pwndbg.proc.alive:\n        gdb.execute('si', from_tty=False, to_string=False)\n\n        addr = pwndbg.regs.pc\n        if start <= addr < end:\n            return True\n\n    return False\n\n\ndef break_on_next(address=None):\n    address = address or pwndbg.regs.pc\n    ins = pwndbg.disasm.one(address)\n\n    gdb.Breakpoint(\"*%#x\" % (ins.address + ins.size), temporary=True)\n    gdb.execute('continue', from_tty=False, to_string=True)\n", "path": "pwndbg/next.py"}]}