aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-12-14 17:16:16 +0000
committerTom Tromey <tromey@redhat.com>2012-12-14 17:16:16 +0000
commit2dc3df72a7ffca9a893ae41db8c3788c0019d59c (patch)
tree49b2ffbba40f64f238abd2d810ec8451bba266b6 /gdb/symtab.c
parent451b7c33cb3c9ec6272c36870adb4d4f5649aae2 (diff)
downloadgdb-2dc3df72a7ffca9a893ae41db8c3788c0019d59c.zip
gdb-2dc3df72a7ffca9a893ae41db8c3788c0019d59c.tar.gz
gdb-2dc3df72a7ffca9a893ae41db8c3788c0019d59c.tar.bz2
* symtab.c (check_field): Now static. Move from...
* valops.c (check_field): ... here. Remove. * value.h (check_field): Don't declare.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1b0b35b..1de3454 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1278,6 +1278,42 @@ lookup_language_this (const struct language_defn *lang,
return NULL;
}
+/* Given TYPE, a structure/union,
+ return 1 if the component named NAME from the ultimate target
+ structure/union is defined, otherwise, return 0. */
+
+static int
+check_field (struct type *type, const char *name)
+{
+ int i;
+
+ /* The type may be a stub. */
+ CHECK_TYPEDEF (type);
+
+ for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
+ {
+ const char *t_field_name = TYPE_FIELD_NAME (type, i);
+
+ if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
+ return 1;
+ }
+
+ /* C++: If it was not found as a data field, then try to return it
+ as a pointer to a method. */
+
+ for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
+ {
+ if (strcmp_iw (TYPE_FN_FIELDLIST_NAME (type, i), name) == 0)
+ return 1;
+ }
+
+ for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
+ if (check_field (TYPE_BASECLASS (type, i), name))
+ return 1;
+
+ return 0;
+}
+
/* Behave like lookup_symbol except that NAME is the natural name
(e.g., demangled name) of the symbol that we're looking for. */