diff options
author | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
commit | 61012eef8463764ccd9117dc1c9bc43cc452b7cc (patch) | |
tree | f576a77bcb77e71cc60e6592b56d2aa915b50c36 /gdb/dwarf2read.c | |
parent | e80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff) | |
download | gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.zip gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.gz gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.bz2 |
New common function "startswith"
This commit introduces a new inline common function "startswith"
which takes two string arguments and returns nonzero if the first
string starts with the second. It also updates the 295 places
where this logic was written out longhand to use the new function.
gdb/ChangeLog:
* common/common-utils.h (startswith): New inline function.
All places where this logic was used updated to use the above.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 071f97b..a283cba 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -12306,7 +12306,7 @@ check_producer (struct dwarf2_cu *cu) cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6); cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3); } - else if (strncmp (cu->producer, "Intel(R) C", strlen ("Intel(R) C")) == 0) + else if (startswith (cu->producer, "Intel(R) C")) cu->producer_is_icc = 1; else { @@ -12987,8 +12987,8 @@ is_vtable_name (const char *name, struct dwarf2_cu *cu) /* Look for the C++ and Java forms of the vtable. */ if ((cu->language == language_java - && strncmp (name, vtable, sizeof (vtable) - 1) == 0) - || (strncmp (name, vptr, sizeof (vptr) - 1) == 0 + && startswith (name, vtable)) + || (startswith (name, vptr) && is_cplus_marker (name[sizeof (vptr) - 1]))) return 1; @@ -13296,8 +13296,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) } } else if (cu->producer - && strncmp (cu->producer, - "IBM(R) XL C/C++ Advanced Edition", 32) == 0) + && startswith (cu->producer, "IBM(R) XL C/C++ Advanced Edition")) { /* The IBM XLC compiler does not provide direct indication of the containing type, but the vtable pointer is @@ -14695,7 +14694,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type_flags |= TYPE_FLAG_UNSIGNED; if (cu->language == language_fortran && name - && strncmp (name, "character(", sizeof ("character(") - 1) == 0) + && startswith (name, "character(")) code = TYPE_CODE_CHAR; break; case DW_ATE_signed_char: @@ -18262,7 +18261,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, if (cu->language == language_fortran && die->parent && die->parent->tag == DW_TAG_module && cu->producer - && strncmp (cu->producer, "GNU Fortran ", 12) == 0) + && startswith (cu->producer, "GNU Fortran ")) SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED; /* A variable with DW_AT_external is never static, @@ -19339,8 +19338,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) or simply "<anonymous struct>" or "<anonymous union>" in GCC 4.3 and GCC 4.4. We work around this problem by ignoring these. */ if (attr && DW_STRING (attr) - && (strncmp (DW_STRING (attr), "._", 2) == 0 - || strncmp (DW_STRING (attr), "<anonymous", 10) == 0)) + && (startswith (DW_STRING (attr), "._") + || startswith (DW_STRING (attr), "<anonymous"))) return NULL; /* GCC might emit a nameless typedef that has a linkage name. See |