forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user