|
12 | 12 | ARCH,
|
13 | 13 | debug_target,
|
14 | 14 | gdbserver_session,
|
| 15 | + get_random_port, |
15 | 16 | qemuuser_session,
|
16 | 17 | GDBSERVER_DEFAULT_HOST,
|
17 | 18 | )
|
@@ -121,48 +122,35 @@ def test_func_parse_maps_local_procfs(self):
|
121 | 122 | @pytest.mark.slow
|
122 | 123 | def test_func_parse_maps_remote_gdbserver(self):
|
123 | 124 | gef, gdb = self._gef, self._gdb
|
124 |
| - # When in a gef-remote session `parse_gdb_info_proc_maps` should work to |
| 125 | + # When in a remote session `parse_gdb_info_proc_maps` should work to |
125 | 126 | # query the memory maps
|
126 |
| - while True: |
127 |
| - port = random.randint(1025, 65535) |
128 |
| - if port != self._port: |
129 |
| - break |
| 127 | + port = get_random_port() |
130 | 128 |
|
131 | 129 | with pytest.raises(Exception):
|
132 |
| - gdb.execute(f"gef-remote {GDBSERVER_DEFAULT_HOST} {port}") |
| 130 | + gdb.execute(f"target remote :{port}") |
133 | 131 |
|
134 | 132 | with gdbserver_session(port=port) as _:
|
135 |
| - gdb.execute(f"gef-remote {GDBSERVER_DEFAULT_HOST} {port}") |
| 133 | + gdb.execute(f"target remote :{port}") |
136 | 134 | sections = gef.memory.maps
|
137 | 135 | assert len(sections) > 0
|
138 | 136 |
|
139 | 137 | @pytest.mark.skipif(ARCH not in ("x86_64",), reason=f"Skipped for {ARCH}")
|
140 | 138 | def test_func_parse_maps_remote_qemu(self):
|
141 | 139 | gdb, gef = self._gdb, self._gef
|
142 |
| - # When in a gef-remote qemu-user session `parse_gdb_info_proc_maps` |
143 |
| - # should work to query the memory maps |
144 |
| - while True: |
145 |
| - port = random.randint(1025, 65535) |
146 |
| - if port != self._port: |
147 |
| - break |
| 140 | + port = get_random_port() |
148 | 141 |
|
149 | 142 | with qemuuser_session(port=port) as _:
|
150 |
| - cmd = f"gef-remote --qemu-user --qemu-binary {self._target} {GDBSERVER_DEFAULT_HOST} {port}" |
| 143 | + cmd = f"target remote :{port}" |
151 | 144 | gdb.execute(cmd)
|
152 | 145 | sections = gef.memory.maps
|
153 | 146 | assert len(sections) > 0
|
154 | 147 |
|
155 | 148 | def test_func_parse_maps_realpath(self):
|
156 | 149 | gef, gdb = self._gef, self._gdb
|
157 |
| - # When in a gef-remote session `parse_gdb_info_proc_maps` should work to |
158 |
| - # query the memory maps |
159 |
| - while True: |
160 |
| - port = random.randint(1025, 65535) |
161 |
| - if port != self._port: |
162 |
| - break |
| 150 | + port = get_random_port() |
163 | 151 |
|
164 | 152 | with gdbserver_session(port=port) as _:
|
165 |
| - gdb.execute(f"gef-remote {GDBSERVER_DEFAULT_HOST} {port}") |
| 153 | + gdb.execute(f"target remote :{port}") |
166 | 154 | gdb.execute("b main")
|
167 | 155 | gdb.execute("continue")
|
168 | 156 | sections = gef.memory.maps
|
|
0 commit comments