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 v2 06/13] script language API for GDB: pretty-printer changes


This patch updates the calls to the script-based pretty-printers.

I want to have something in the name of each extension language API entry point
that says "this is a extension languages API entry point".  It makes the code
easier to understand.  My first attempt had "slang_" as a prefix but that
was thought to cause too much confusion with the slang scripting language.
With the renaming to "extension" instead of "scripting" I've gone with
adding "ext_lang" to the name.

Plus for implementations of extension_language_ops methods I've made them
all have a consistent name: ${lang}_${method_name}.
And to follow convention for "ops" methods, they all take a "this"
parameter as the first argument.

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

2013-12-10  Doug Evans  <xdje42@gmail.com>

	* valprint.c (val_print, value_print): Update to call
	apply_ext_lang_val_pretty_printer.
	* cp-valprint.c (cp_print_value): Update call to
	apply_ext_lang_val_pretty_printer.
	* python/py-prettyprint.c: Remove #ifdef HAVE_PYTHON.
	(gdbpy_apply_val_pretty_printer): Renamed from
	apply_val_pretty_printer.  New arg extlang.
	(!HAVE_PYTHON, apply_val_pretty_printer): Delete.

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0124934..786ef35 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -764,9 +764,9 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
   if (!options->raw)
     {
-      ret = apply_val_pretty_printer (type, valaddr, embedded_offset,
-				      address, stream, recurse,
-				      val, options, language);
+      ret = apply_ext_lang_val_pretty_printer (type, valaddr, embedded_offset,
+					       address, stream, recurse,
+					       val, options, language);
       if (ret)
 	return;
     }
@@ -870,12 +870,13 @@ value_print (struct value *val, struct ui_file *stream,
 
   if (!options->raw)
     {
-      int r = apply_val_pretty_printer (value_type (val),
-					value_contents_for_printing (val),
-					value_embedded_offset (val),
-					value_address (val),
-					stream, 0,
-					val, options, current_language);
+      int r
+	= apply_ext_lang_val_pretty_printer (value_type (val),
+					     value_contents_for_printing (val),
+					     value_embedded_offset (val),
+					     value_address (val),
+					     stream, 0,
+					     val, options, current_language);
 
       if (r)
 	return;
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index bcf54ff..4b02ecf 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -584,17 +584,17 @@ cp_print_value (struct type *type, struct type *real_type,
 	{
 	  int result = 0;
 
-	  /* Attempt to run the Python pretty-printers on the
+	  /* Attempt to run an extension language pretty-printer on the
 	     baseclass if possible.  */
 	  if (!options->raw)
-	    result = apply_val_pretty_printer (baseclass, base_valaddr,
-					       thisoffset + boffset,
-					       value_address (base_val),
-					       stream, recurse, base_val,
-					       options, current_language);
+	    result
+	      = apply_ext_lang_val_pretty_printer (baseclass, base_valaddr,
+						   thisoffset + boffset,
+						   value_address (base_val),
+						   stream, recurse,
+						   base_val, options,
+						   current_language);
 
-
-	  	  
 	  if (!result)
 	    cp_print_value_fields (baseclass, thistype, base_valaddr,
 				   thisoffset + boffset,
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index a09a09b..0588120 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -25,8 +25,6 @@
 #include "valprint.h"
 
 #include "python.h"
-
-#ifdef HAVE_PYTHON
 #include "python-internal.h"
 
 /* Return type of print_string_repr.  */
@@ -300,7 +298,7 @@ print_stack_unless_memory_error (struct ui_file *stream)
     gdbpy_print_stack ();
 }
 
-/* Helper for apply_val_pretty_printer which calls to_string and
+/* Helper for gdbpy_apply_val_pretty_printer which calls to_string and
    formats the result.  */
 
 static enum string_repr_result
@@ -467,7 +465,7 @@ push_dummy_python_frame (void)
 }
 #endif
 
-/* Helper for apply_val_pretty_printer that formats children of the
+/* Helper for gdbpy_apply_val_pretty_printer that formats children of the
    printer, if any exist.  If is_py_none is true, then nothing has
    been printed by to_string, and format output accordingly. */
 static void
@@ -687,12 +685,13 @@ print_children (PyObject *printer, const char *hint,
 }
 
 int
-apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int recurse,
-			  const struct value *val,
-			  const struct value_print_options *options,
-			  const struct language_defn *language)
+gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
+				struct type *type, const gdb_byte *valaddr,
+				int embedded_offset, CORE_ADDR address,
+				struct ui_file *stream, int recurse,
+				const struct value *val,
+				const struct value_print_options *options,
+				const struct language_defn *language)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
   PyObject *printer = NULL;
@@ -838,18 +837,3 @@ gdbpy_default_visualizer (PyObject *self, PyObject *args)
   cons = find_pretty_printer (val_obj);
   return cons;
 }
-
-#else /* HAVE_PYTHON */
-
-int
-apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int recurse,
-			  const struct value *val,
-			  const struct value_print_options *options,
-			  const struct language_defn *language)
-{
-  return 0;
-}
-
-#endif /* HAVE_PYTHON */


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