This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v4 07/16] extension language API for GDB: cli changes


This patch contains the changes to CLI.
They're pretty simple and straightforward.

Changes will be needed here and/or in extension.c if UNSUPPORTED_ERROR is
removed for this bit of code, but that'll be straightforward.

Changes from v2:
- in cli-cmds.c, cli-scripts.c, replace #include "python/python.h" with
  "extension.h"

Changes from v1:
- updates for scripting -> extension renaming

2014-01-15  Doug Evans  <xdje42@gmail.com>

	* cli/cli-cmds.c (source_script_from_stream): Rewrite to use
	extension language API.
	* cli/cli-script.c (execute_control_command): Update to call
	eval_ext_lang_from_control_command.

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index bc18169..9374c1d 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -50,7 +50,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-utils.h"
 
-#include "python/python.h"
+#include "extension.h"
 
 #ifdef TUI
 #include "tui/tui.h"	/* For tui_active et.al.  */
@@ -522,21 +522,33 @@ find_and_open_script (const char *script_file, int search_path,
 static void
 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"))
+  if (script_ext_mode != script_ext_off)
     {
-      if (have_python ())
-	source_python_script (stream, file);
-      else if (script_ext_mode == script_ext_soft)
+      const struct extension_language_defn *extlang
+	= get_ext_lang_of_file (file);
+
+      if (extlang != NULL)
 	{
-	  /* Fallback to GDB script mode.  */
-	  script_from_file (stream, file);
+	  if (ext_lang_present_p (extlang))
+	    {
+	      script_sourcer_func *sourcer
+		= ext_lang_script_sourcer (extlang);
+
+	      gdb_assert (sourcer != NULL);
+	      sourcer (extlang, stream, file);
+	      return;
+	    }
+	  else if (script_ext_mode == script_ext_soft)
+	    {
+	      /* Assume the file is a gdb script.
+		 This is handled below.  */
+	    }
+	  else
+	    throw_ext_lang_unsupported (extlang);
 	}
-      else
-	error (_("Python scripting is not supported in this copy of GDB."));
     }
-  else
-    script_from_file (stream, file);
+
+  script_from_file (stream, file);
 }
 
 /* Worker to perform the "source" command.
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index afedc92..47cad75 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -32,7 +32,7 @@
 #include "cli/cli-script.h"
 #include "gdb_assert.h"
 
-#include "python/python.h"
+#include "extension.h"
 #include "interps.h"
 
 /* Prototypes for local functions.  */
@@ -590,7 +590,7 @@ execute_control_command (struct command_line *cmd)
 
     case python_control:
       {
-	eval_python_from_control_command (cmd);
+	eval_ext_lang_from_control_command (cmd);
 	ret = simple_control;
 	break;
       }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]