aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-12-11 09:49:08 +0000
committerPedro Alves <palves@redhat.com>2013-12-12 10:15:48 +0000
commitf23981e9917c0322223aaa8941bd1ca13d1dcc58 (patch)
tree42ce159acdacc4aadf84fbbd04394e89459b70e2 /gdb/python
parent43942612f4278418e9b6c48c86e4f02798611f74 (diff)
downloadgdb-f23981e9917c0322223aaa8941bd1ca13d1dcc58.zip
gdb-f23981e9917c0322223aaa8941bd1ca13d1dcc58.tar.gz
gdb-f23981e9917c0322223aaa8941bd1ca13d1dcc58.tar.bz2
Eliminate UNSUPPORTED_ERROR.
I have a case that could use an exception for "unsupported feature". I found UNSUPPORTED_ERROR, but looking deeper, I think as is, reusing it for other things would be fragile. E.g., if the Python script sourced by source_script_from_stream triggers any other missing functionality that would result in UNSUPPORTED_ERROR being propagated out to source_script_from_stream, that would confuse the error for Python not being built into GDB. This patch thus redoes things a little. Instead of using an exception for the "No Python" scenario, check whether Python is configured in before actually trying to source the file. It adds a new function instead of using #ifdef HAVE_PYTHON directly, as that is better at avoiding bitrot, as both Python and !Python paths are visible to the compiler this way. Tested on Fedora 17, with and without Python. gdb/ 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.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/python.c5
-rw-r--r--gdb/python/python.h13
2 files changed, 16 insertions, 2 deletions
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 *);