This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 06/13] script language API for GDB
- From: Doug Evans <xdje42 at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 05 Dec 2013 09:18:00 -0800
- Subject: [PATCH 06/13] script language API for GDB
- Authentication-results: sourceware.org; auth=none
This patch updates the calls to the script-based pretty-printers.
I want to have something in the name of each scripting API entry point
that says "this is a scripting 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.
As a minimalist-based alternative I've gone with adding "script"
to the name.
Plus for implementations of script_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.
2013-12-05 Doug Evans <xdje42@gmail.com>
* valprint.c (val_print, value_print): Update to call
apply_val_script_pretty_printer.
* cp-valprint.c (cp_print_value): Update call to
apply_val_script_pretty_printer.
* python/py-prettyprint.c: Remove #ifdef HAVE_PYTHON.
(gdbpy_apply_val_pretty_printer): Renamed from
apply_val_pretty_printer. New arg slang.
(!HAVE_PYTHON, apply_val_pretty_printer): Delete.
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0124934..6dd1c91 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_val_script_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_val_script_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..6a4082f 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -584,17 +584,16 @@ 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 the scripting language pretty-printers 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_val_script_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..dbf6204 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 script_language_defn *slang,
+ 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 */