aboutsummaryrefslogtreecommitdiff
path: root/gdb/extension.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-03-14 16:38:02 -0600
committerTom Tromey <tom@tromey.com>2018-03-27 10:09:25 -0600
commitc819b2c0b216c69a4ae5bfba0eac71ffdf1b3596 (patch)
tree01abe30f0570df89f905e782787bca0ff136692b /gdb/extension.c
parent608219fb2917d407058952adf164eb616880662b (diff)
downloadgdb-c819b2c0b216c69a4ae5bfba0eac71ffdf1b3596.zip
gdb-c819b2c0b216c69a4ae5bfba0eac71ffdf1b3596.tar.gz
gdb-c819b2c0b216c69a4ae5bfba0eac71ffdf1b3596.tar.bz2
C++-ify typedef hash
This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
Diffstat (limited to 'gdb/extension.c')
-rw-r--r--gdb/extension.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/gdb/extension.c b/gdb/extension.c
index 4e3b3e9..e5c0146 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -405,21 +405,16 @@ auto_load_ext_lang_scripts_for_objfile (struct objfile *objfile)
We don't know in advance which extension language will provide a
pretty-printer for the type, so all are initialized. */
-struct ext_lang_type_printers *
-start_ext_lang_type_printers (void)
+ext_lang_type_printers::ext_lang_type_printers ()
{
- struct ext_lang_type_printers *printers
- = XCNEW (struct ext_lang_type_printers);
int i;
const struct extension_language_defn *extlang;
ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
{
if (extlang->ops->start_type_printers != NULL)
- extlang->ops->start_type_printers (extlang, printers);
+ extlang->ops->start_type_printers (extlang, this);
}
-
- return printers;
}
/* Iteratively try the type pretty-printers specified by PRINTERS
@@ -460,11 +455,7 @@ apply_ext_lang_type_printers (struct ext_lang_type_printers *printers,
return NULL;
}
-/* Call this after pretty-printing a type to release all memory held
- by PRINTERS. */
-
-void
-free_ext_lang_type_printers (struct ext_lang_type_printers *printers)
+ext_lang_type_printers::~ext_lang_type_printers ()
{
int i;
const struct extension_language_defn *extlang;
@@ -472,10 +463,8 @@ free_ext_lang_type_printers (struct ext_lang_type_printers *printers)
ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
{
if (extlang->ops->free_type_printers != NULL)
- extlang->ops->free_type_printers (extlang, printers);
+ extlang->ops->free_type_printers (extlang, this);
}
-
- xfree (printers);
}
/* Try to pretty-print a value of type TYPE located at VAL's contents