aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-05-02 16:08:54 -0600
committerTom Tromey <tom@tromey.com>2019-05-08 16:01:56 -0600
commit4c58e3376da3fedaca81f8c9386f3ccb81261f8a (patch)
treea6c691b4ef3bd4d6342d86eebc9edd4d0ae1be52
parentd772d2abcc163142fc38655896c4704b06dae0b6 (diff)
downloadgdb-4c58e3376da3fedaca81f8c9386f3ccb81261f8a.zip
gdb-4c58e3376da3fedaca81f8c9386f3ccb81261f8a.tar.gz
gdb-4c58e3376da3fedaca81f8c9386f3ccb81261f8a.tar.bz2
Convert objc-lang.c to type-safe registry API
This changes objc-lang.c to use the type-safe registry API. gdb/ChangeLog 2019-05-08 Tom Tromey <tom@tromey.com> * objc-lang.c (objc_objfile_data): Change type. (find_methods): Update. (_initialize_objc_lang): Remove.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/objc-lang.c16
2 files changed, 9 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0d4b3ae..08489a8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2019-05-08 Tom Tromey <tom@tromey.com>
+ * objc-lang.c (objc_objfile_data): Change type.
+ (find_methods): Update.
+ (_initialize_objc_lang): Remove.
+
+2019-05-08 Tom Tromey <tom@tromey.com>
+
* stabsread.c (rs6000_builtin_type_data): Change type.
(rs6000_builtin_type, _initialize_stabsread): Update.
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index b25a981..ab40e54 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -75,7 +75,7 @@ struct objc_method {
CORE_ADDR imp;
};
-static const struct objfile_data *objc_objfile_data;
+static const struct objfile_key<unsigned int> objc_objfile_data;
/* Lookup a structure type named "struct NAME", visible in lexical
block BLOCK. If NOERR is nonzero, return zero if NAME is not
@@ -1004,7 +1004,7 @@ find_methods (char type, const char *theclass, const char *category,
unsigned int objfile_csym = 0;
- objc_csym = (unsigned int *) objfile_data (objfile, objc_objfile_data);
+ objc_csym = objc_objfile_data.get (objfile);
if (objc_csym != NULL && *objc_csym == 0)
/* There are no ObjC symbols in this objfile. Skip it entirely. */
continue;
@@ -1056,11 +1056,7 @@ find_methods (char type, const char *theclass, const char *category,
}
if (objc_csym == NULL)
- {
- objc_csym = XOBNEW (&objfile->objfile_obstack, unsigned int);
- *objc_csym = objfile_csym;
- set_objfile_data (objfile, objc_objfile_data, objc_csym);
- }
+ objc_csym = objc_objfile_data.emplace (objfile, objfile_csym);
else
/* Count of ObjC methods in this objfile should be constant. */
gdb_assert (*objc_csym == objfile_csym);
@@ -1576,9 +1572,3 @@ resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
return 1;
return 0;
}
-
-void
-_initialize_objc_lang (void)
-{
- objc_objfile_data = register_objfile_data ();
-}