|
21 | 21 | from contextlib import contextmanager |
22 | 22 | from importlib import reload |
23 | 23 |
|
24 | | -import _gdb |
25 | | - |
| 24 | +# The star import imports _gdb names. When the names are used locally, they |
| 25 | +# trigger F405 warnings unless added to the explicit import list. |
26 | 26 | # Note that two indicators are needed here to silence flake8. |
27 | 27 | from _gdb import * # noqa: F401,F403 |
| 28 | +from _gdb import ( |
| 29 | + STDERR, |
| 30 | + STDOUT, |
| 31 | + Command, |
| 32 | + execute, |
| 33 | + flush, |
| 34 | + parameter, |
| 35 | + selected_inferior, |
| 36 | + write, |
| 37 | +) |
28 | 38 |
|
29 | 39 | # isort: split |
30 | 40 |
|
@@ -55,14 +65,14 @@ def writelines(self, iterable): |
55 | 65 | self.write(line) |
56 | 66 |
|
57 | 67 | def flush(self): |
58 | | - _gdb.flush(stream=self.stream) |
| 68 | + flush(stream=self.stream) |
59 | 69 |
|
60 | 70 | def write(self, s): |
61 | | - _gdb.write(s, stream=self.stream) |
| 71 | + write(s, stream=self.stream) |
62 | 72 |
|
63 | 73 |
|
64 | | -sys.stdout = _GdbFile(_gdb.STDOUT) |
65 | | -sys.stderr = _GdbFile(_gdb.STDERR) |
| 74 | +sys.stdout = _GdbFile(STDOUT) |
| 75 | +sys.stderr = _GdbFile(STDERR) |
66 | 76 |
|
67 | 77 | # Default prompt hook does nothing. |
68 | 78 | prompt_hook = None |
@@ -184,7 +194,7 @@ def GdbSetPythonDirectory(dir): |
184 | 194 |
|
185 | 195 | def current_progspace(): |
186 | 196 | "Return the current Progspace." |
187 | | - return _gdb.selected_inferior().progspace |
| 197 | + return selected_inferior().progspace |
188 | 198 |
|
189 | 199 |
|
190 | 200 | def objfiles(): |
@@ -221,14 +231,14 @@ def set_parameter(name, value): |
221 | 231 | value = "on" |
222 | 232 | else: |
223 | 233 | value = "off" |
224 | | - _gdb.execute("set " + name + " " + str(value), to_string=True) |
| 234 | + execute("set " + name + " " + str(value), to_string=True) |
225 | 235 |
|
226 | 236 |
|
227 | 237 | @contextmanager |
228 | 238 | def with_parameter(name, value): |
229 | 239 | """Temporarily set the GDB parameter NAME to VALUE. |
230 | 240 | Note that this is a context manager.""" |
231 | | - old_value = _gdb.parameter(name) |
| 241 | + old_value = parameter(name) |
232 | 242 | set_parameter(name, value) |
233 | 243 | try: |
234 | 244 | # Nothing that useful to return. |
@@ -406,7 +416,7 @@ class ParameterPrefix: |
406 | 416 | # __doc__ string of its own, then sub-classes will inherit that __doc__ |
407 | 417 | # string, and GDB will not understand that it needs to generate one. |
408 | 418 |
|
409 | | - class _PrefixCommand(_gdb.Command): |
| 419 | + class _PrefixCommand(Command): |
410 | 420 | """A gdb.Command used to implement both the set and show prefixes. |
411 | 421 |
|
412 | 422 | This documentation string is not used as the prefix command |
|
0 commit comments