We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
QEMU uses binfmt root instead of pwndbg.qemu.root()
This bit here  should probably use pwndbg.qemu.root() instead of using the module variable directly: 

https://github.com/pwndbg/pwndbg/blob/609284cee279de345dcb0706e11a0b56abe349f4/pwndbg/file.py#L35

--- 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/file.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """
4 Retrieve files from the debuggee's filesystem.  Useful when
5 debugging a remote process over SSH or similar, where e.g.
6 /proc/FOO/maps is needed from the remote system.
7 """
8 from __future__ import absolute_import
9 from __future__ import division
10 from __future__ import print_function
11 from __future__ import unicode_literals
12 
13 import binascii
14 import os
15 import tempfile
16 
17 import gdb
18 
19 import pwndbg.qemu
20 import pwndbg.remote
21 import pwndbg.symbol
22 
23 
24 def get_file(path):
25     """
26     Downloads the specified file from the system where the current process is
27     being debugged.
28 
29     Returns:
30         The local path to the file
31     """
32     local_path = path
33 
34     if pwndbg.qemu.root():
35         return os.path.join(pwndbg.qemu.binfmt_root, path)
36     elif pwndbg.remote.is_remote() and not pwndbg.qemu.is_qemu():
37         local_path = tempfile.mktemp(dir=pwndbg.symbol.remote_files_dir)
38         error      = None
39         try:
40             error = gdb.execute('remote get "%s" "%s"' % (path, local_path),
41                                  to_string=True)
42         except gdb.error as e:
43             error = e
44 
45         if error:
46             raise OSError("Could not download remote file %r:\n" \
47                             "Error: %s" % (path, error))
48 
49     return local_path
50 
51 def get(path):
52     """
53     Retrieves the contents of the specified file on the system
54     where the current process is being debugged.
55 
56     Returns:
57         A byte array, or None.
58     """
59     local_path = get_file(path)
60 
61     try:
62         with open(local_path,'rb') as f:
63             return f.read()
64     except:
65         return b''
66 
67 def readlink(path):
68     """readlink(path) -> str
69 
70     Read the link specified by 'path' on the system being debugged.
71 
72     Handles local, qemu-usermode, and remote debugging cases.
73     """
74     is_qemu = pwndbg.qemu.is_qemu_usermode()
75 
76     if is_qemu:
77         if not os.path.exists(path):
78             path = os.path.join(pwndbg.qemu.root(), path)
79 
80     if is_qemu or not pwndbg.remote.is_remote():
81         try:
82             return os.readlink(path)
83         except Exception:
84             return ''
85 
86     #
87     # Hurray unexposed packets!
88     #
89     # The 'vFile:readlink:' packet does exactly what it sounds like,
90     # but there is no API exposed to do this and there is also no
91     # command exposed... so we have to send the packet manually.
92     #
93     cmd = 'maintenance packet vFile:readlink:%s'
94 
95     # The path must be uppercase hex-encoded and NULL-terminated.
96     path += '\x00'
97     path = binascii.hexlify(path.encode())
98     path = path.upper()
99     path = path.decode()
100 
101     result = gdb.execute(cmd % path, from_tty=False, to_string=True)
102 
103     """
104     sending: "vFile:readlink:2F70726F632F3130303839302F66642F3000"
105     received: "Fc;pipe:[98420]"
106 
107     sending: "vFile:readlink:2F70726F632F3130303839302F66642F333300"
108     received: "F-1,2"
109     """
110 
111     _, data = result.split('\n', 1)
112 
113     # Sanity check
114     expected = 'received: "F'
115     if not data.startswith(expected):
116         return ''
117 
118     # Negative values are errors
119     data = data[len(expected):]
120     if data[0] == '-':
121         return ''
122 
123     # If non-negative, there will be a hex-encoded length followed
124     # by a semicolon.
125     n, data = data.split(';', 1)
126 
127     n = int(n, 16)
128     if n < 0:
129         return ''
130 
131     # The result is quoted by GDB, strip the quote and newline.
132     # I have no idea how well it handles other crazy stuff.
133     ending = '"\n'
134     data = data[:-len(ending)]
135 
136     return data
137
```
--- 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/file.py b/pwndbg/file.py
--- a/pwndbg/file.py
+++ b/pwndbg/file.py
@@ -30,9 +30,9 @@
         The local path to the file
     """
     local_path = path
-
-    if pwndbg.qemu.root():
-        return os.path.join(pwndbg.qemu.binfmt_root, path)
+    qemu_root = pwndbg.qemu.root()
+    if qemu_root:
+        return os.path.join(qemu_root, path)
     elif pwndbg.remote.is_remote() and not pwndbg.qemu.is_qemu():
         local_path = tempfile.mktemp(dir=pwndbg.symbol.remote_files_dir)
         error      = None

{"golden_diff": "diff --git a/pwndbg/file.py b/pwndbg/file.py\n--- a/pwndbg/file.py\n+++ b/pwndbg/file.py\n@@ -30,9 +30,9 @@\n         The local path to the file\n     \"\"\"\n     local_path = path\n-\n-    if pwndbg.qemu.root():\n-        return os.path.join(pwndbg.qemu.binfmt_root, path)\n+    qemu_root = pwndbg.qemu.root()\n+    if qemu_root:\n+        return os.path.join(qemu_root, path)\n     elif pwndbg.remote.is_remote() and not pwndbg.qemu.is_qemu():\n         local_path = tempfile.mktemp(dir=pwndbg.symbol.remote_files_dir)\n         error      = None\n", "issue": "QEMU uses binfmt root instead of pwndbg.qemu.root()\nThis bit here  should probably use pwndbg.qemu.root() instead of using the module variable directly: \r\n\r\nhttps://github.com/pwndbg/pwndbg/blob/609284cee279de345dcb0706e11a0b56abe349f4/pwndbg/file.py#L35\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nRetrieve files from the debuggee's filesystem.  Useful when\ndebugging a remote process over SSH or similar, where e.g.\n/proc/FOO/maps is needed from the remote system.\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport binascii\nimport os\nimport tempfile\n\nimport gdb\n\nimport pwndbg.qemu\nimport pwndbg.remote\nimport pwndbg.symbol\n\n\ndef get_file(path):\n    \"\"\"\n    Downloads the specified file from the system where the current process is\n    being debugged.\n\n    Returns:\n        The local path to the file\n    \"\"\"\n    local_path = path\n\n    if pwndbg.qemu.root():\n        return os.path.join(pwndbg.qemu.binfmt_root, path)\n    elif pwndbg.remote.is_remote() and not pwndbg.qemu.is_qemu():\n        local_path = tempfile.mktemp(dir=pwndbg.symbol.remote_files_dir)\n        error      = None\n        try:\n            error = gdb.execute('remote get \"%s\" \"%s\"' % (path, local_path),\n                                 to_string=True)\n        except gdb.error as e:\n            error = e\n\n        if error:\n            raise OSError(\"Could not download remote file %r:\\n\" \\\n                            \"Error: %s\" % (path, error))\n\n    return local_path\n\ndef get(path):\n    \"\"\"\n    Retrieves the contents of the specified file on the system\n    where the current process is being debugged.\n\n    Returns:\n        A byte array, or None.\n    \"\"\"\n    local_path = get_file(path)\n\n    try:\n        with open(local_path,'rb') as f:\n            return f.read()\n    except:\n        return b''\n\ndef readlink(path):\n    \"\"\"readlink(path) -> str\n\n    Read the link specified by 'path' on the system being debugged.\n\n    Handles local, qemu-usermode, and remote debugging cases.\n    \"\"\"\n    is_qemu = pwndbg.qemu.is_qemu_usermode()\n\n    if is_qemu:\n        if not os.path.exists(path):\n            path = os.path.join(pwndbg.qemu.root(), path)\n\n    if is_qemu or not pwndbg.remote.is_remote():\n        try:\n            return os.readlink(path)\n        except Exception:\n            return ''\n\n    #\n    # Hurray unexposed packets!\n    #\n    # The 'vFile:readlink:' packet does exactly what it sounds like,\n    # but there is no API exposed to do this and there is also no\n    # command exposed... so we have to send the packet manually.\n    #\n    cmd = 'maintenance packet vFile:readlink:%s'\n\n    # The path must be uppercase hex-encoded and NULL-terminated.\n    path += '\\x00'\n    path = binascii.hexlify(path.encode())\n    path = path.upper()\n    path = path.decode()\n\n    result = gdb.execute(cmd % path, from_tty=False, to_string=True)\n\n    \"\"\"\n    sending: \"vFile:readlink:2F70726F632F3130303839302F66642F3000\"\n    received: \"Fc;pipe:[98420]\"\n\n    sending: \"vFile:readlink:2F70726F632F3130303839302F66642F333300\"\n    received: \"F-1,2\"\n    \"\"\"\n\n    _, data = result.split('\\n', 1)\n\n    # Sanity check\n    expected = 'received: \"F'\n    if not data.startswith(expected):\n        return ''\n\n    # Negative values are errors\n    data = data[len(expected):]\n    if data[0] == '-':\n        return ''\n\n    # If non-negative, there will be a hex-encoded length followed\n    # by a semicolon.\n    n, data = data.split(';', 1)\n\n    n = int(n, 16)\n    if n < 0:\n        return ''\n\n    # The result is quoted by GDB, strip the quote and newline.\n    # I have no idea how well it handles other crazy stuff.\n    ending = '\"\\n'\n    data = data[:-len(ending)]\n\n    return data\n", "path": "pwndbg/file.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\nRetrieve files from the debuggee's filesystem.  Useful when\ndebugging a remote process over SSH or similar, where e.g.\n/proc/FOO/maps is needed from the remote system.\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport binascii\nimport os\nimport tempfile\n\nimport gdb\n\nimport pwndbg.qemu\nimport pwndbg.remote\nimport pwndbg.symbol\n\n\ndef get_file(path):\n    \"\"\"\n    Downloads the specified file from the system where the current process is\n    being debugged.\n\n    Returns:\n        The local path to the file\n    \"\"\"\n    local_path = path\n    qemu_root = pwndbg.qemu.root()\n    if qemu_root:\n        return os.path.join(qemu_root, path)\n    elif pwndbg.remote.is_remote() and not pwndbg.qemu.is_qemu():\n        local_path = tempfile.mktemp(dir=pwndbg.symbol.remote_files_dir)\n        error      = None\n        try:\n            error = gdb.execute('remote get \"%s\" \"%s\"' % (path, local_path),\n                                 to_string=True)\n        except gdb.error as e:\n            error = e\n\n        if error:\n            raise OSError(\"Could not download remote file %r:\\n\" \\\n                            \"Error: %s\" % (path, error))\n\n    return local_path\n\ndef get(path):\n    \"\"\"\n    Retrieves the contents of the specified file on the system\n    where the current process is being debugged.\n\n    Returns:\n        A byte array, or None.\n    \"\"\"\n    local_path = get_file(path)\n\n    try:\n        with open(local_path,'rb') as f:\n            return f.read()\n    except:\n        return b''\n\ndef readlink(path):\n    \"\"\"readlink(path) -> str\n\n    Read the link specified by 'path' on the system being debugged.\n\n    Handles local, qemu-usermode, and remote debugging cases.\n    \"\"\"\n    is_qemu = pwndbg.qemu.is_qemu_usermode()\n\n    if is_qemu:\n        if not os.path.exists(path):\n            path = os.path.join(pwndbg.qemu.root(), path)\n\n    if is_qemu or not pwndbg.remote.is_remote():\n        try:\n            return os.readlink(path)\n        except Exception:\n            return ''\n\n    #\n    # Hurray unexposed packets!\n    #\n    # The 'vFile:readlink:' packet does exactly what it sounds like,\n    # but there is no API exposed to do this and there is also no\n    # command exposed... so we have to send the packet manually.\n    #\n    cmd = 'maintenance packet vFile:readlink:%s'\n\n    # The path must be uppercase hex-encoded and NULL-terminated.\n    path += '\\x00'\n    path = binascii.hexlify(path.encode())\n    path = path.upper()\n    path = path.decode()\n\n    result = gdb.execute(cmd % path, from_tty=False, to_string=True)\n\n    \"\"\"\n    sending: \"vFile:readlink:2F70726F632F3130303839302F66642F3000\"\n    received: \"Fc;pipe:[98420]\"\n\n    sending: \"vFile:readlink:2F70726F632F3130303839302F66642F333300\"\n    received: \"F-1,2\"\n    \"\"\"\n\n    _, data = result.split('\\n', 1)\n\n    # Sanity check\n    expected = 'received: \"F'\n    if not data.startswith(expected):\n        return ''\n\n    # Negative values are errors\n    data = data[len(expected):]\n    if data[0] == '-':\n        return ''\n\n    # If non-negative, there will be a hex-encoded length followed\n    # by a semicolon.\n    n, data = data.split(';', 1)\n\n    n = int(n, 16)\n    if n < 0:\n        return ''\n\n    # The result is quoted by GDB, strip the quote and newline.\n    # I have no idea how well it handles other crazy stuff.\n    ending = '\"\\n'\n    data = data[:-len(ending)]\n\n    return data\n", "path": "pwndbg/file.py"}]}