We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
errno command is throwing errors
```
pwndbg> errno
Traceback (most recent call last):
  File "/home/gsgx/code/pwndbg/pwndbg/commands/__init__.py", line 145, in __call__
    return self.function(*args, **kwargs)
  File "/home/gsgx/code/pwndbg/pwndbg/commands/__init__.py", line 239, in _OnlyWhenRunning
    return function(*a, **kw)
  File "/home/gsgx/code/pwndbg/pwndbg/commands/misc.py", line 32, in errno
    errno_location = pwndbg.symbol.get("__errno_location")
AttributeError: '_ArgparsedCommand' object has no attribute 'symbol'
```

I don't know why the issue is occurring, but it can be fixed with this:
```diff
-        errno_location = pwndbg.symbol.get("__errno_location")
-        err = pwndbg.memory.int(errno_location)
+        errno_location = _pwndbg.symbol.address("__errno_location")
+        print(errno_location)
+        err = _pwndbg.memory.s32(errno_location)
```

But even after fixing that, there's an issue with the following lines:
```python
err = _pwndbg.memory.s32(errno_location)
#err = int(gdb.parse_and_eval('*((int *(*) (void)) __errno_location) ()'))
```

The commented out line is what actually works for me, while the existing code doesn't. I wonder if this was originally due to a change in glibc? If so, we should figure out what version and make this work on both versions.



--- 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/lib/tips.py`
Content:
```
1 from random import choice
2 
3 TIPS = [
4     # GDB hints
5     "GDB's `apropos <topic>` command displays all registered commands that are related to the given <topic>",
6     "GDB's `follow-fork-mode` parameter can be used to set whether to trace parent or child after fork() calls",
7     'Use GDB\'s `dprintf` command to print all calls to given function. E.g. `dprintf malloc, "malloc(%p)\\n", (void*)$rdi` will print all malloc calls',
8     "Use GDB's `pi` command to run an interactive Python console where you can use Pwndbg APIs like `pwndbg.gdb.memory.read(addr, len)`, `pwndbg.gdb.memory.write(addr, data)`, `pwndbg.gdb.vmmap.get()` and so on!",
9     "GDB's `set directories <path>` parameter can be used to debug e.g. glibc sources like the malloc/free functions!",
10     # Pwndbg hints
11     "GDB and Pwndbg parameters can be shown or set with `show <param>` and `set <param> <value>` GDB commands",
12     "Use Pwndbg's `config` and `theme` commands to tune its configuration and theme colors!",
13     "Pwndbg mirrors some of Windbg commands like `eq`, `ew`, `ed`, `eb`, `es`, `dq`, `dw`, `dd`, `db`, `ds` for writing and reading memory",
14     "Pwndbg resolves kernel memory maps by parsing page tables (default) or via `monitor info mem` QEMU gdbstub command (use `set kernel-vmmap-via-page-tables off` for that)",
15     "Use the `vmmap` instruction for a better & colored memory maps display (than the GDB's `info proc mappings`)",
16     "Use the `telescope` command to dereference a given address/pointer multiple times (if the dereferenced value is a valid ptr; see `config telescope` to configure its behavior)",
17     "Use the `context` (or `ctx`) command to display the context once again. You can reconfigure the context layout with `set context-section <sections>` or forward the output to a file/tty via `set context-output <file>`. See also `config context` to configure it further!",
18     "Disable Pwndbg context information display with `set context-sections ''`",
19     "Pwndbg context displays where the program branches to thanks to emulating few instructions into the future. You can disable this with `set emulate off` which may also speed up debugging",
20     "Use the `canary` command to see all stack canary/cookie values on the stack (based on the *usual* stack canary value initialized by glibc)",
21     "Use the `procinfo` command for better process introspection (than the GDB's `info proc` command)",
22     "Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context",
23     "The $heap_base GDB variable can be used to refer to the starting address of the heap after running the `heap` command",
24 ]
25 
26 
27 def get_tip_of_the_day() -> str:
28     return choice(TIPS)
29
```

Path: `pwndbg/commands/misc.py`
Content:
```
1 import argparse
2 import errno
3 
4 import gdb
5 
6 import pwndbg.auxv
7 import pwndbg.commands
8 import pwndbg.gdblib.arch as _arch
9 import pwndbg.regs
10 import pwndbg.symbol
11 
12 errno.errorcode[0] = "OK"
13 
14 parser = argparse.ArgumentParser(
15     description="""
16 Converts errno (or argument) to its string representation.
17 """
18 )
19 parser.add_argument(
20     "err",
21     type=int,
22     nargs="?",
23     default=None,
24     help="Errno; if not passed, it is retrieved from __errno_location",
25 )
26 
27 
28 @pwndbg.commands.ArgparsedCommand(parser, command_name="errno")
29 @pwndbg.commands.OnlyWhenRunning
30 def errno_(err):
31     if err is None:
32         # Try to get the `errno` variable value
33         # if it does not exist, get the errno variable from its location
34         try:
35             err = int(gdb.parse_and_eval("errno"))
36         except gdb.error:
37             try:
38                 err = int(gdb.parse_and_eval("*((int *(*) (void)) __errno_location) ()"))
39             except gdb.error:
40                 print(
41                     "Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (was libc.so loaded already?)"
42                 )
43                 return
44 
45     msg = errno.errorcode.get(int(err), "Unknown error code")
46     print("Errno %s: %s" % (err, msg))
47 
48 
49 parser = argparse.ArgumentParser(
50     description="""
51 Prints out a list of all pwndbg commands. The list can be optionally filtered if filter_pattern is passed.
52 """
53 )
54 parser.add_argument(
55     "filter_pattern",
56     type=str,
57     nargs="?",
58     default=None,
59     help="Filter to apply to commands names/docs",
60 )
61 
62 
63 @pwndbg.commands.ArgparsedCommand(parser, command_name="pwndbg")
64 def pwndbg_(filter_pattern):
65     for name, docs in list_and_filter_commands(filter_pattern):
66         print("%-20s %s" % (name, docs))
67 
68 
69 parser = argparse.ArgumentParser(description="""Print the distance between the two arguments.""")
70 parser.add_argument("a", type=int, help="The first address.")
71 parser.add_argument("b", type=int, help="The second address.")
72 
73 
74 @pwndbg.commands.ArgparsedCommand(parser)
75 def distance(a, b):
76     """Print the distance between the two arguments"""
77     a = int(a) & pwndbg.arch.ptrmask
78     b = int(b) & pwndbg.arch.ptrmask
79 
80     distance = b - a
81 
82     print("%#x->%#x is %#x bytes (%#x words)" % (a, b, distance, distance // pwndbg.arch.ptrsize))
83 
84 
85 def list_and_filter_commands(filter_str):
86     sorted_commands = list(pwndbg.commands.commands)
87     sorted_commands.sort(key=lambda x: x.__name__)
88 
89     if filter_str:
90         filter_str = filter_str.lower()
91 
92     results = []
93 
94     for c in sorted_commands:
95         name = c.__name__
96         docs = c.__doc__
97 
98         if docs:
99             docs = docs.strip()
100         if docs:
101             docs = docs.splitlines()[0]
102 
103         if not filter_str or filter_str in name.lower() or (docs and filter_str in docs.lower()):
104             results.append((name, docs))
105 
106     return results
107
```
--- 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/commands/misc.py b/pwndbg/commands/misc.py
--- a/pwndbg/commands/misc.py
+++ b/pwndbg/commands/misc.py
@@ -35,10 +35,24 @@
             err = int(gdb.parse_and_eval("errno"))
         except gdb.error:
             try:
-                err = int(gdb.parse_and_eval("*((int *(*) (void)) __errno_location) ()"))
+                # We can't simply call __errno_location because its .plt.got entry may be uninitialized
+                # (e.g. if the binary was just started with `starti` command)
+                # So we have to check the got.plt entry first before calling it
+                errno_loc_gotplt = pwndbg.symbol.address("__errno_location@got.plt")
+
+                # If the got.plt entry is not there (is None), it means the symbol is not used by the binary
+                if errno_loc_gotplt is None or pwndbg.vmmap.find(
+                    pwndbg.memory.pvoid(errno_loc_gotplt)
+                ):
+                    err = int(gdb.parse_and_eval("*((int *(*) (void)) __errno_location) ()"))
+                else:
+                    print(
+                        "Could not determine error code automatically: the __errno_location@got.plt has no valid address yet (perhaps libc.so hasn't been loaded yet?)"
+                    )
+                    return
             except gdb.error:
                 print(
-                    "Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (was libc.so loaded already?)"
+                    "Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (perhaps libc.so hasn't been not loaded yet?)"
                 )
                 return
 
diff --git a/pwndbg/lib/tips.py b/pwndbg/lib/tips.py
--- a/pwndbg/lib/tips.py
+++ b/pwndbg/lib/tips.py
@@ -21,6 +21,7 @@
     "Use the `procinfo` command for better process introspection (than the GDB's `info proc` command)",
     "Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context",
     "The $heap_base GDB variable can be used to refer to the starting address of the heap after running the `heap` command",
+    "Use the `errno` (or `errno <number>`) command to see the name of the last or provided (libc) error",
 ]

{"golden_diff": "diff --git a/pwndbg/commands/misc.py b/pwndbg/commands/misc.py\n--- a/pwndbg/commands/misc.py\n+++ b/pwndbg/commands/misc.py\n@@ -35,10 +35,24 @@\n             err = int(gdb.parse_and_eval(\"errno\"))\n         except gdb.error:\n             try:\n-                err = int(gdb.parse_and_eval(\"*((int *(*) (void)) __errno_location) ()\"))\n+                # We can't simply call __errno_location because its .plt.got entry may be uninitialized\n+                # (e.g. if the binary was just started with `starti` command)\n+                # So we have to check the got.plt entry first before calling it\n+                errno_loc_gotplt = pwndbg.symbol.address(\"__errno_location@got.plt\")\n+\n+                # If the got.plt entry is not there (is None), it means the symbol is not used by the binary\n+                if errno_loc_gotplt is None or pwndbg.vmmap.find(\n+                    pwndbg.memory.pvoid(errno_loc_gotplt)\n+                ):\n+                    err = int(gdb.parse_and_eval(\"*((int *(*) (void)) __errno_location) ()\"))\n+                else:\n+                    print(\n+                        \"Could not determine error code automatically: the __errno_location@got.plt has no valid address yet (perhaps libc.so hasn't been loaded yet?)\"\n+                    )\n+                    return\n             except gdb.error:\n                 print(\n-                    \"Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (was libc.so loaded already?)\"\n+                    \"Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (perhaps libc.so hasn't been not loaded yet?)\"\n                 )\n                 return\n \ndiff --git a/pwndbg/lib/tips.py b/pwndbg/lib/tips.py\n--- a/pwndbg/lib/tips.py\n+++ b/pwndbg/lib/tips.py\n@@ -21,6 +21,7 @@\n     \"Use the `procinfo` command for better process introspection (than the GDB's `info proc` command)\",\n     \"Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context\",\n     \"The $heap_base GDB variable can be used to refer to the starting address of the heap after running the `heap` command\",\n+    \"Use the `errno` (or `errno <number>`) command to see the name of the last or provided (libc) error\",\n ]\n", "issue": "errno command is throwing errors\n```\r\npwndbg> errno\r\nTraceback (most recent call last):\r\n  File \"/home/gsgx/code/pwndbg/pwndbg/commands/__init__.py\", line 145, in __call__\r\n    return self.function(*args, **kwargs)\r\n  File \"/home/gsgx/code/pwndbg/pwndbg/commands/__init__.py\", line 239, in _OnlyWhenRunning\r\n    return function(*a, **kw)\r\n  File \"/home/gsgx/code/pwndbg/pwndbg/commands/misc.py\", line 32, in errno\r\n    errno_location = pwndbg.symbol.get(\"__errno_location\")\r\nAttributeError: '_ArgparsedCommand' object has no attribute 'symbol'\r\n```\r\n\r\nI don't know why the issue is occurring, but it can be fixed with this:\r\n```diff\r\n-        errno_location = pwndbg.symbol.get(\"__errno_location\")\r\n-        err = pwndbg.memory.int(errno_location)\r\n+        errno_location = _pwndbg.symbol.address(\"__errno_location\")\r\n+        print(errno_location)\r\n+        err = _pwndbg.memory.s32(errno_location)\r\n```\r\n\r\nBut even after fixing that, there's an issue with the following lines:\r\n```python\r\nerr = _pwndbg.memory.s32(errno_location)\r\n#err = int(gdb.parse_and_eval('*((int *(*) (void)) __errno_location) ()'))\r\n```\r\n\r\nThe commented out line is what actually works for me, while the existing code doesn't. I wonder if this was originally due to a change in glibc? If so, we should figure out what version and make this work on both versions.\r\n\r\n\n", "before_files": [{"content": "from random import choice\n\nTIPS = [\n    # GDB hints\n    \"GDB's `apropos <topic>` command displays all registered commands that are related to the given <topic>\",\n    \"GDB's `follow-fork-mode` parameter can be used to set whether to trace parent or child after fork() calls\",\n    'Use GDB\\'s `dprintf` command to print all calls to given function. E.g. `dprintf malloc, \"malloc(%p)\\\\n\", (void*)$rdi` will print all malloc calls',\n    \"Use GDB's `pi` command to run an interactive Python console where you can use Pwndbg APIs like `pwndbg.gdb.memory.read(addr, len)`, `pwndbg.gdb.memory.write(addr, data)`, `pwndbg.gdb.vmmap.get()` and so on!\",\n    \"GDB's `set directories <path>` parameter can be used to debug e.g. glibc sources like the malloc/free functions!\",\n    # Pwndbg hints\n    \"GDB and Pwndbg parameters can be shown or set with `show <param>` and `set <param> <value>` GDB commands\",\n    \"Use Pwndbg's `config` and `theme` commands to tune its configuration and theme colors!\",\n    \"Pwndbg mirrors some of Windbg commands like `eq`, `ew`, `ed`, `eb`, `es`, `dq`, `dw`, `dd`, `db`, `ds` for writing and reading memory\",\n    \"Pwndbg resolves kernel memory maps by parsing page tables (default) or via `monitor info mem` QEMU gdbstub command (use `set kernel-vmmap-via-page-tables off` for that)\",\n    \"Use the `vmmap` instruction for a better & colored memory maps display (than the GDB's `info proc mappings`)\",\n    \"Use the `telescope` command to dereference a given address/pointer multiple times (if the dereferenced value is a valid ptr; see `config telescope` to configure its behavior)\",\n    \"Use the `context` (or `ctx`) command to display the context once again. You can reconfigure the context layout with `set context-section <sections>` or forward the output to a file/tty via `set context-output <file>`. See also `config context` to configure it further!\",\n    \"Disable Pwndbg context information display with `set context-sections ''`\",\n    \"Pwndbg context displays where the program branches to thanks to emulating few instructions into the future. You can disable this with `set emulate off` which may also speed up debugging\",\n    \"Use the `canary` command to see all stack canary/cookie values on the stack (based on the *usual* stack canary value initialized by glibc)\",\n    \"Use the `procinfo` command for better process introspection (than the GDB's `info proc` command)\",\n    \"Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context\",\n    \"The $heap_base GDB variable can be used to refer to the starting address of the heap after running the `heap` command\",\n]\n\n\ndef get_tip_of_the_day() -> str:\n    return choice(TIPS)\n", "path": "pwndbg/lib/tips.py"}, {"content": "import argparse\nimport errno\n\nimport gdb\n\nimport pwndbg.auxv\nimport pwndbg.commands\nimport pwndbg.gdblib.arch as _arch\nimport pwndbg.regs\nimport pwndbg.symbol\n\nerrno.errorcode[0] = \"OK\"\n\nparser = argparse.ArgumentParser(\n    description=\"\"\"\nConverts errno (or argument) to its string representation.\n\"\"\"\n)\nparser.add_argument(\n    \"err\",\n    type=int,\n    nargs=\"?\",\n    default=None,\n    help=\"Errno; if not passed, it is retrieved from __errno_location\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, command_name=\"errno\")\n@pwndbg.commands.OnlyWhenRunning\ndef errno_(err):\n    if err is None:\n        # Try to get the `errno` variable value\n        # if it does not exist, get the errno variable from its location\n        try:\n            err = int(gdb.parse_and_eval(\"errno\"))\n        except gdb.error:\n            try:\n                err = int(gdb.parse_and_eval(\"*((int *(*) (void)) __errno_location) ()\"))\n            except gdb.error:\n                print(\n                    \"Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (was libc.so loaded already?)\"\n                )\n                return\n\n    msg = errno.errorcode.get(int(err), \"Unknown error code\")\n    print(\"Errno %s: %s\" % (err, msg))\n\n\nparser = argparse.ArgumentParser(\n    description=\"\"\"\nPrints out a list of all pwndbg commands. The list can be optionally filtered if filter_pattern is passed.\n\"\"\"\n)\nparser.add_argument(\n    \"filter_pattern\",\n    type=str,\n    nargs=\"?\",\n    default=None,\n    help=\"Filter to apply to commands names/docs\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, command_name=\"pwndbg\")\ndef pwndbg_(filter_pattern):\n    for name, docs in list_and_filter_commands(filter_pattern):\n        print(\"%-20s %s\" % (name, docs))\n\n\nparser = argparse.ArgumentParser(description=\"\"\"Print the distance between the two arguments.\"\"\")\nparser.add_argument(\"a\", type=int, help=\"The first address.\")\nparser.add_argument(\"b\", type=int, help=\"The second address.\")\n\n\n@pwndbg.commands.ArgparsedCommand(parser)\ndef distance(a, b):\n    \"\"\"Print the distance between the two arguments\"\"\"\n    a = int(a) & pwndbg.arch.ptrmask\n    b = int(b) & pwndbg.arch.ptrmask\n\n    distance = b - a\n\n    print(\"%#x->%#x is %#x bytes (%#x words)\" % (a, b, distance, distance // pwndbg.arch.ptrsize))\n\n\ndef list_and_filter_commands(filter_str):\n    sorted_commands = list(pwndbg.commands.commands)\n    sorted_commands.sort(key=lambda x: x.__name__)\n\n    if filter_str:\n        filter_str = filter_str.lower()\n\n    results = []\n\n    for c in sorted_commands:\n        name = c.__name__\n        docs = c.__doc__\n\n        if docs:\n            docs = docs.strip()\n        if docs:\n            docs = docs.splitlines()[0]\n\n        if not filter_str or filter_str in name.lower() or (docs and filter_str in docs.lower()):\n            results.append((name, docs))\n\n    return results\n", "path": "pwndbg/commands/misc.py"}], "after_files": [{"content": "from random import choice\n\nTIPS = [\n    # GDB hints\n    \"GDB's `apropos <topic>` command displays all registered commands that are related to the given <topic>\",\n    \"GDB's `follow-fork-mode` parameter can be used to set whether to trace parent or child after fork() calls\",\n    'Use GDB\\'s `dprintf` command to print all calls to given function. E.g. `dprintf malloc, \"malloc(%p)\\\\n\", (void*)$rdi` will print all malloc calls',\n    \"Use GDB's `pi` command to run an interactive Python console where you can use Pwndbg APIs like `pwndbg.gdb.memory.read(addr, len)`, `pwndbg.gdb.memory.write(addr, data)`, `pwndbg.gdb.vmmap.get()` and so on!\",\n    \"GDB's `set directories <path>` parameter can be used to debug e.g. glibc sources like the malloc/free functions!\",\n    # Pwndbg hints\n    \"GDB and Pwndbg parameters can be shown or set with `show <param>` and `set <param> <value>` GDB commands\",\n    \"Use Pwndbg's `config` and `theme` commands to tune its configuration and theme colors!\",\n    \"Pwndbg mirrors some of Windbg commands like `eq`, `ew`, `ed`, `eb`, `es`, `dq`, `dw`, `dd`, `db`, `ds` for writing and reading memory\",\n    \"Pwndbg resolves kernel memory maps by parsing page tables (default) or via `monitor info mem` QEMU gdbstub command (use `set kernel-vmmap-via-page-tables off` for that)\",\n    \"Use the `vmmap` instruction for a better & colored memory maps display (than the GDB's `info proc mappings`)\",\n    \"Use the `telescope` command to dereference a given address/pointer multiple times (if the dereferenced value is a valid ptr; see `config telescope` to configure its behavior)\",\n    \"Use the `context` (or `ctx`) command to display the context once again. You can reconfigure the context layout with `set context-section <sections>` or forward the output to a file/tty via `set context-output <file>`. See also `config context` to configure it further!\",\n    \"Disable Pwndbg context information display with `set context-sections ''`\",\n    \"Pwndbg context displays where the program branches to thanks to emulating few instructions into the future. You can disable this with `set emulate off` which may also speed up debugging\",\n    \"Use the `canary` command to see all stack canary/cookie values on the stack (based on the *usual* stack canary value initialized by glibc)\",\n    \"Use the `procinfo` command for better process introspection (than the GDB's `info proc` command)\",\n    \"Want to display each context panel in a separate tmux window? See https://github.com/pwndbg/pwndbg/blob/dev/FEATURES.md#splitting--layouting-context\",\n    \"The $heap_base GDB variable can be used to refer to the starting address of the heap after running the `heap` command\",\n    \"Use the `errno` (or `errno <number>`) command to see the name of the last or provided (libc) error\",\n]\n\n\ndef get_tip_of_the_day() -> str:\n    return choice(TIPS)\n", "path": "pwndbg/lib/tips.py"}, {"content": "import argparse\nimport errno\n\nimport gdb\n\nimport pwndbg.auxv\nimport pwndbg.commands\nimport pwndbg.gdblib.arch as _arch\nimport pwndbg.regs\nimport pwndbg.symbol\n\nerrno.errorcode[0] = \"OK\"\n\nparser = argparse.ArgumentParser(\n    description=\"\"\"\nConverts errno (or argument) to its string representation.\n\"\"\"\n)\nparser.add_argument(\n    \"err\",\n    type=int,\n    nargs=\"?\",\n    default=None,\n    help=\"Errno; if not passed, it is retrieved from __errno_location\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, command_name=\"errno\")\n@pwndbg.commands.OnlyWhenRunning\ndef errno_(err):\n    if err is None:\n        # Try to get the `errno` variable value\n        # if it does not exist, get the errno variable from its location\n        try:\n            err = int(gdb.parse_and_eval(\"errno\"))\n        except gdb.error:\n            try:\n                # We can't simply call __errno_location because its .plt.got entry may be uninitialized\n                # (e.g. if the binary was just started with `starti` command)\n                # So we have to check the got.plt entry first before calling it\n                errno_loc_gotplt = pwndbg.symbol.address(\"__errno_location@got.plt\")\n\n                # If the got.plt entry is not there (is None), it means the symbol is not used by the binary\n                if errno_loc_gotplt is None or pwndbg.vmmap.find(\n                    pwndbg.memory.pvoid(errno_loc_gotplt)\n                ):\n                    err = int(gdb.parse_and_eval(\"*((int *(*) (void)) __errno_location) ()\"))\n                else:\n                    print(\n                        \"Could not determine error code automatically: the __errno_location@got.plt has no valid address yet (perhaps libc.so hasn't been loaded yet?)\"\n                    )\n                    return\n            except gdb.error:\n                print(\n                    \"Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (perhaps libc.so hasn't been not loaded yet?)\"\n                )\n                return\n\n    msg = errno.errorcode.get(int(err), \"Unknown error code\")\n    print(\"Errno %s: %s\" % (err, msg))\n\n\nparser = argparse.ArgumentParser(\n    description=\"\"\"\nPrints out a list of all pwndbg commands. The list can be optionally filtered if filter_pattern is passed.\n\"\"\"\n)\nparser.add_argument(\n    \"filter_pattern\",\n    type=str,\n    nargs=\"?\",\n    default=None,\n    help=\"Filter to apply to commands names/docs\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, command_name=\"pwndbg\")\ndef pwndbg_(filter_pattern):\n    for name, docs in list_and_filter_commands(filter_pattern):\n        print(\"%-20s %s\" % (name, docs))\n\n\nparser = argparse.ArgumentParser(description=\"\"\"Print the distance between the two arguments.\"\"\")\nparser.add_argument(\"a\", type=int, help=\"The first address.\")\nparser.add_argument(\"b\", type=int, help=\"The second address.\")\n\n\n@pwndbg.commands.ArgparsedCommand(parser)\ndef distance(a, b):\n    \"\"\"Print the distance between the two arguments\"\"\"\n    a = int(a) & pwndbg.arch.ptrmask\n    b = int(b) & pwndbg.arch.ptrmask\n\n    distance = b - a\n\n    print(\"%#x->%#x is %#x bytes (%#x words)\" % (a, b, distance, distance // pwndbg.arch.ptrsize))\n\n\ndef list_and_filter_commands(filter_str):\n    sorted_commands = list(pwndbg.commands.commands)\n    sorted_commands.sort(key=lambda x: x.__name__)\n\n    if filter_str:\n        filter_str = filter_str.lower()\n\n    results = []\n\n    for c in sorted_commands:\n        name = c.__name__\n        docs = c.__doc__\n\n        if docs:\n            docs = docs.strip()\n        if docs:\n            docs = docs.splitlines()[0]\n\n        if not filter_str or filter_str in name.lower() or (docs and filter_str in docs.lower()):\n            results.append((name, docs))\n\n    return results\n", "path": "pwndbg/commands/misc.py"}]}