aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2004-09-01 04:19:22 +0000
committerJim Blandy <jimb@codesourcery.com>2004-09-01 04:19:22 +0000
commit1168df017b621644c4ecae79a6e9ff72a791fde7 (patch)
tree4bbb5f66841e6c6b6192e4a05ef0ab098f5de7c8 /gdb/dwarf2read.c
parentf14f9744c488a66b74ae8815bb5a4ea8e9f637cb (diff)
downloadfsf-binutils-gdb-1168df017b621644c4ecae79a6e9ff72a791fde7.zip
fsf-binutils-gdb-1168df017b621644c4ecae79a6e9ff72a791fde7.tar.gz
fsf-binutils-gdb-1168df017b621644c4ecae79a6e9ff72a791fde7.tar.bz2
* dwarf2read.c (is_vtable_name): New function, based on logic from
read_structure_type, but passing the correct length to strncmp, and using 'sizeof' instead of 'strlen'. (read_structure_type): Call it.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 4e9cdfa..49a003f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3265,6 +3265,23 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
}
+
+/* Returns non-zero if NAME is the name of a vtable member in CU's
+ language, zero otherwise. */
+static int
+is_vtable_name (const char *name, struct dwarf2_cu *cu)
+{
+ static const char vptr[] = "_vptr";
+
+ /* C++ and some implementations of Java use this name. */
+ if (strncmp (name, vptr, sizeof (vptr) - 1) == 0
+ && is_cplus_marker (name[sizeof (vptr) - 1]))
+ return 1;
+
+ return 0;
+}
+
+
/* Called when we find the DIE that starts a structure or union scope
(definition) to process all dies that define the members of the
structure or union.
@@ -3403,8 +3420,6 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
TYPE_VPTR_BASETYPE (type) = t;
if (type == t)
{
- static const char vptr_name[] =
- {'_', 'v', 'p', 't', 'r', '\0'};
int i;
/* Our own class provides vtbl ptr. */
@@ -3414,10 +3429,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if ((strncmp (fieldname, vptr_name,
- strlen (vptr_name) - 1)
- == 0)
- && is_cplus_marker (fieldname[strlen (vptr_name)]))
+ if (is_vtable_name (fieldname, cu))
{
TYPE_VPTR_FIELDNO (type) = i;
break;