mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-24 02:37:23 +08:00
Allow "source" to load python scripts.
* exceptions.h (enum errors): Add UNSUPPORTED_ERROR. * python/python.c (source_python_script): New function. * python/python.h (source_python_script): Add declaration. * cli/cli-cmds.c: #include exceptions.h and python/python.h. (script_ext_off, script_ext_soft, script_ext_strict) (script_ext_enums, script_ext_mode): New static constants. (show_script_ext_mode, find_and_open_script): New functions. (source_script): Enhance to handle Python scripts. (init_cli_cmds): Add set/show script-extension commands.
This commit is contained in:
@ -343,6 +343,22 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args)
|
||||
return value_to_value_object (result);
|
||||
}
|
||||
|
||||
/* Read a file as Python code. STREAM is the input file; FILE is the
|
||||
name of the file. */
|
||||
|
||||
void
|
||||
source_python_script (FILE *stream, char *file)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
|
||||
state = PyGILState_Ensure ();
|
||||
|
||||
PyRun_SimpleFile (stream, file);
|
||||
|
||||
fclose (stream);
|
||||
PyGILState_Release (state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Printing. */
|
||||
@ -525,6 +541,14 @@ eval_python_from_control_command (struct command_line *cmd)
|
||||
error (_("Python scripting is not supported in this copy of GDB."));
|
||||
}
|
||||
|
||||
void
|
||||
source_python_script (FILE *stream, char *file)
|
||||
{
|
||||
fclose (stream);
|
||||
throw_error (UNSUPPORTED_ERROR,
|
||||
_("Python scripting is not supported in this copy of GDB."));
|
||||
}
|
||||
|
||||
#endif /* HAVE_PYTHON */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user