Execute the parameter `source` as GDB command. This is done by writing `commands` to a temporary file, which is then executed via GDB `source` command. The tempfile is then deleted.
(commands: str)
| 2110 | |
| 2111 | |
| 2112 | def gef_execute_gdb_script(commands: str) -> None: |
| 2113 | """Execute the parameter `source` as GDB command. This is done by writing `commands` to |
| 2114 | a temporary file, which is then executed via GDB `source` command. The tempfile is then deleted.""" |
| 2115 | fd, fname = tempfile.mkstemp(suffix=".gdb", prefix="gef_") |
| 2116 | with os.fdopen(fd, "w") as f: |
| 2117 | f.write(commands) |
| 2118 | f.flush() |
| 2119 | |
| 2120 | fname = pathlib.Path(fname) |
| 2121 | if fname.is_file() and os.access(fname, os.R_OK): |
| 2122 | gdb.execute(f"source {fname}") |
| 2123 | fname.unlink() |
| 2124 | return |
| 2125 | |
| 2126 | |
| 2127 | @deprecated("Use Elf(fname).checksec()") |