diff options
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 26 | ||||
-rw-r--r-- | gdb/exceptions.h | 3 | ||||
-rw-r--r-- | gdb/python/python.c | 5 | ||||
-rw-r--r-- | gdb/python/python.h | 13 |
5 files changed, 32 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 40368b5..637a462 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2013-12-12 Pedro Alves <palves@redhat.com> + + * cli/cli-cmds.c (source_script_from_stream) Use have_python + instead of catching UNSUPPORTED_ERROR. + * exceptions.h (UNSUPPORTED_ERROR): Delete. + * python/python.c (source_python_script) [!HAVE_PYTHON]: Internal + error if called. + * python/python.h (have_python): New static inline function. + 2013-12-11 Doug Evans <dje@google.com> * dwarf2read.c (lookup_dwo_cutu): Include name of dwp file in diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 52a6bc9..73e03cf 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -525,27 +525,15 @@ source_script_from_stream (FILE *stream, const char *file) if (script_ext_mode != script_ext_off && strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py")) { - volatile struct gdb_exception e; - - TRY_CATCH (e, RETURN_MASK_ERROR) + if (have_python ()) + source_python_script (stream, file); + else if (script_ext_mode == script_ext_soft) { - source_python_script (stream, file); - } - if (e.reason < 0) - { - /* Should we fallback to ye olde GDB script mode? */ - if (script_ext_mode == script_ext_soft - && e.reason == RETURN_ERROR && e.error == UNSUPPORTED_ERROR) - { - fseek (stream, 0, SEEK_SET); - script_from_file (stream, (char*) file); - } - else - { - /* Nope, just punt. */ - throw_exception (e); - } + /* Fallback to GDB script mode. */ + script_from_file (stream, file); } + else + error (_("Python scripting is not supported in this copy of GDB.")); } else script_from_file (stream, file); diff --git a/gdb/exceptions.h b/gdb/exceptions.h index 705f1a1..2cb8242 100644 --- a/gdb/exceptions.h +++ b/gdb/exceptions.h @@ -79,9 +79,6 @@ enum errors { /* Error accessing memory. */ MEMORY_ERROR, - /* Feature is not supported in this copy of GDB. */ - UNSUPPORTED_ERROR, - /* Value not available. E.g., a register was not collected in a traceframe. */ NOT_AVAILABLE_ERROR, diff --git a/gdb/python/python.c b/gdb/python/python.c index 1873936..55bb6cf 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1390,8 +1390,9 @@ eval_python_from_control_command (struct command_line *cmd) void source_python_script (FILE *file, const char *filename) { - throw_error (UNSUPPORTED_ERROR, - _("Python scripting is not supported in this copy of GDB.")); + internal_error (__FILE__, __LINE__, + _("source_python_script called when Python scripting is " + "not supported.")); } int diff --git a/gdb/python/python.h b/gdb/python/python.h index c07b2aa..abbb581 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h @@ -89,6 +89,19 @@ typedef enum py_frame_args CLI_ALL_VALUES } py_frame_args; +/* Returns true if Python support is built into GDB, false + otherwise. */ + +static inline int +have_python (void) +{ +#ifdef HAVE_PYTHON + return 1; +#else + return 0; +#endif +} + extern void finish_python_initialization (void); void eval_python_from_control_command (struct command_line *); |