+2015-03-06 Gary Benson <gbenson@redhat.com>
+
+ * common/common-utils.h (startswith): New inline function.
+ All places where this logic was used updated to use the above.
+
2015-03-05 Pedro Alves <palves@redhat.com>
PR gdb/18002
return
(strncmp (field_name, target, len) == 0
&& (field_name[len] == '\0'
- || (strncmp (field_name + len, "___", 3) == 0
+ || (startswith (field_name + len, "___")
&& strcmp (field_name + strlen (field_name) - 6,
"___XVN") != 0)));
}
for (mapping = ada_opname_table;
mapping->encoded != NULL
- && strncmp (mapping->decoded, p,
- strlen (mapping->decoded)) != 0; mapping += 1)
+ && !startswith (p, mapping->decoded); mapping += 1)
;
if (mapping->encoded == NULL)
error (_("invalid Ada operator name: %s"), p);
*len = i;
else if (i >= 0 && encoded[i] == '$')
*len = i;
- else if (i >= 2 && strncmp (encoded + i - 2, "___", 3) == 0)
+ else if (i >= 2 && startswith (encoded + i - 2, "___"))
*len = i - 2;
- else if (i >= 1 && strncmp (encoded + i - 1, "__", 2) == 0)
+ else if (i >= 1 && startswith (encoded + i - 1, "__"))
*len = i - 1;
}
}
/* The name of the Ada main procedure starts with "_ada_".
This prefix is not part of the decoded name, so skip this part
if we see this prefix. */
- if (strncmp (encoded, "_ada_", 5) == 0)
+ if (startswith (encoded, "_ada_"))
encoded += 5;
/* If the name starts with '_', then it is not a properly encoded
is for the body of a task, but that information does not actually
appear in the decoded name. */
- if (len0 > 3 && strncmp (encoded + len0 - 3, "TKB", 3) == 0)
+ if (len0 > 3 && startswith (encoded + len0 - 3, "TKB"))
len0 -= 3;
/* Remove any trailing TB suffix. The TB suffix is slightly different
from the TKB suffix because it is used for non-anonymous task
bodies. */
- if (len0 > 2 && strncmp (encoded + len0 - 2, "TB", 2) == 0)
+ if (len0 > 2 && startswith (encoded + len0 - 2, "TB"))
len0 -= 2;
/* Remove trailing "B" suffixes. */
/* FIXME: brobecker/2006-04-19: Not sure what this are used for... */
- if (len0 > 1 && strncmp (encoded + len0 - 1, "B", 1) == 0)
+ if (len0 > 1 && startswith (encoded + len0 - 1, "B"))
len0 -= 1;
/* Make decoded big enough for possible expansion by operator name. */
/* Replace "TK__" with "__", which will eventually be translated
into "." (just below). */
- if (i < len0 - 4 && strncmp (encoded + i, "TK__", 4) == 0)
+ if (i < len0 - 4 && startswith (encoded + i, "TK__"))
i += 2;
/* Replace "__B_{DIGITS}+__" sequences by "__", which will eventually
return (strncmp (sym_name, name, len_name) == 0
&& is_name_suffix (sym_name + len_name))
- || (strncmp (sym_name, "_ada_", 5) == 0
+ || (startswith (sym_name, "_ada_")
&& strncmp (sym_name + 5, name, len_name) == 0
&& is_name_suffix (sym_name + len_name + 5));
}
TYPE_CODE (type0) == TYPE_CODE (type1)
&& (equiv_types (type0, type1)
|| (len0 < strlen (name1) && strncmp (name0, name1, len0) == 0
- && strncmp (name1 + len0, "___XV", 5) == 0));
+ && startswith (name1 + len0, "___XV")));
}
case LOC_CONST:
return SYMBOL_VALUE (sym0) == SYMBOL_VALUE (sym1)
using, for instance, Standard.Constraint_Error when Constraint_Error
is ambiguous (due to the user defining its own Constraint_Error
entity inside its program). */
- if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0)
+ if (startswith (name, "standard__"))
name += sizeof ("standard__") - 1;
ALL_MSYMBOLS (objfile, msymbol)
a library-level function. Strip this prefix before doing the
comparison, as the encoding for the renaming does not contain
this prefix. */
- if (strncmp (function_name, "_ada_", 5) == 0)
+ if (startswith (function_name, "_ada_"))
function_name += 5;
{
- int is_invisible = strncmp (function_name, scope, strlen (scope)) != 0;
+ int is_invisible = !startswith (function_name, scope);
do_cleanups (old_chain);
return is_invisible;
using, for instance, Standard.Constraint_Error when Constraint_Error
is ambiguous (due to the user defining its own Constraint_Error
entity inside its program). */
- if (strncmp (name0, "standard__", sizeof ("standard__") - 1) == 0)
+ if (startswith (name0, "standard__"))
{
block = NULL;
name = name0 + sizeof ("standard__") - 1;
if ((t1 >= 'a' && t1 <= 'z') || (t1 >= '0' && t1 <= '9'))
{
name += 1;
- if (name == name0 + 5 && strncmp (name0, "_ada", 4) == 0)
+ if (name == name0 + 5 && startswith (name0, "_ada"))
break;
else
name += 1;
cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (sym)[0];
if (cmp == 0)
{
- cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (sym), 5);
+ cmp = !startswith (SYMBOL_LINKAGE_NAME (sym), "_ada_");
if (cmp == 0)
cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym) + 5,
name_len);
for tagged types, and it contains the components inherited from
the parent type. This field should not be printed as is, but
should not be ignored either. */
- if (name[0] == '_' && strncmp (name, "_parent", 7) != 0)
+ if (name[0] == '_' && !startswith (name, "_parent"))
return 1;
}
const char *name = TYPE_FIELD_NAME (ada_check_typedef (type), field_num);
return (name != NULL
- && (strncmp (name, "PARENT", 6) == 0
- || strncmp (name, "_parent", 7) == 0));
+ && (startswith (name, "PARENT")
+ || startswith (name, "_parent")));
}
/* True iff field number FIELD_NUM of structure type TYPE is a
const char *name = TYPE_FIELD_NAME (type, field_num);
return (name != NULL
- && (strncmp (name, "PARENT", 6) == 0
+ && (startswith (name, "PARENT")
|| strcmp (name, "REP") == 0
- || strncmp (name, "_parent", 7) == 0
+ || startswith (name, "_parent")
|| name[0] == 'S' || name[0] == 'R' || name[0] == 'O'));
}
for (discrim_end = name + strlen (name) - 6; discrim_end != name;
discrim_end -= 1)
{
- if (strncmp (discrim_end, "___XVN", 6) == 0)
+ if (startswith (discrim_end, "___XVN"))
break;
}
if (discrim_end == name)
if (discrim_start == name + 1)
return "";
if ((discrim_start > name + 3
- && strncmp (discrim_start - 3, "___", 3) == 0)
+ && startswith (discrim_start - 3, "___"))
|| discrim_start[-1] == '.')
break;
}
else
align_offset = len - 1;
- if (align_offset < 7 || strncmp ("___XV", name + align_offset - 6, 5) != 0)
+ if (align_offset < 7 || !startswith (name + align_offset - 6, "___XV"))
return TARGET_CHAR_BIT;
return atoi (name + align_offset) * TARGET_CHAR_BIT;
/* Check to see if we have a condition. */
args = skip_spaces (args);
- if (strncmp (args, "if", 2) == 0
+ if (startswith (args, "if")
&& (isspace (args[2]) || args[2] == '\0'))
{
args += 2;
args = skip_spaces (args);
/* Check whether a condition was provided. */
- if (strncmp (args, "if", 2) == 0
+ if (startswith (args, "if")
&& (isspace (args[2]) || args[2] == '\0'))
{
args += 2;
if (post_prologue_pc
&& (cust != NULL
&& COMPUNIT_PRODUCER (cust) != NULL
- && strncmp (COMPUNIT_PRODUCER (cust), "clang ",
- sizeof ("clang ") - 1) == 0))
+ && startswith (COMPUNIT_PRODUCER (cust), "clang ")))
return max (start_pc, post_prologue_pc);
}
if (symname)
{
- if (strncmp (symname, "__imp_", 6) == 0
- || strncmp (symname, "_imp_", 5) == 0)
+ if (startswith (symname, "__imp_")
+ || startswith (symname, "_imp_"))
destination
= read_memory_unsigned_integer (indirect_addr, 8, byte_order);
}
sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
find_pc_partial_function (func, &name, NULL, NULL);
- if (name && strncmp (name, "Xintr", 5) == 0)
+ if (name && startswith (name, "Xintr"))
addr = sp + 8; /* It's an interrupt frame. */
else
addr = sp;
return (name && ((strcmp (name, "calltrap") == 0)
|| (strcmp (name, "osyscall1") == 0)
|| (strcmp (name, "Xsyscall") == 0)
- || (strncmp (name, "Xintr", 5) == 0)));
+ || (startswith (name, "Xintr"))));
}
static const struct frame_unwind amd64obsd_trapframe_unwind = {
chp = strchr (target_name, '-');
if (chp != NULL
&& chp - 2 >= target_name
- && strncmp (chp - 2, "el", 2) == 0)
+ && startswith (chp - 2, "el"))
default_byte_order = BFD_ENDIAN_LITTLE;
}
if (default_byte_order == BFD_ENDIAN_UNKNOWN)
/* On soft-float targets, __truncdfsf2 is called to convert promoted
arguments to their argument types in non-prototyped
functions. */
- if (strncmp (name, "__truncdfsf2", strlen ("__truncdfsf2")) == 0)
+ if (startswith (name, "__truncdfsf2"))
return 1;
- if (strncmp (name, "__aeabi_d2f", strlen ("__aeabi_d2f")) == 0)
+ if (startswith (name, "__aeabi_d2f"))
return 1;
/* Internal functions related to thread-local storage. */
- if (strncmp (name, "__tls_get_addr", strlen ("__tls_get_addr")) == 0)
+ if (startswith (name, "__tls_get_addr"))
return 1;
- if (strncmp (name, "__aeabi_read_tp", strlen ("__aeabi_read_tp")) == 0)
+ if (startswith (name, "__aeabi_read_tp"))
return 1;
}
else
/* ADDR must correspond to a symbol whose name is __stack_chk_guard.
Otherwise, this sequence cannot be for stack protector. */
if (stack_chk_guard.minsym == NULL
- || strncmp (MSYMBOL_LINKAGE_NAME (stack_chk_guard.minsym),
- "__stack_chk_guard",
- strlen ("__stack_chk_guard")) != 0)
+ || !startswith (MSYMBOL_LINKAGE_NAME (stack_chk_guard.minsym), "__stack_chk_guard"))
return pc;
if (is_thumb)
if (post_prologue_pc
&& (cust == NULL
|| COMPUNIT_PRODUCER (cust) == NULL
- || strncmp (COMPUNIT_PRODUCER (cust), "GNU ",
- sizeof ("GNU ") - 1) == 0
- || strncmp (COMPUNIT_PRODUCER (cust), "clang ",
- sizeof ("clang ") - 1) == 0))
+ || startswith (COMPUNIT_PRODUCER (cust), "GNU ")
+ || startswith (COMPUNIT_PRODUCER (cust), "clang ")))
return post_prologue_pc;
if (post_prologue_pc != 0)
_call_via_xx, where x is the register name. The possible names
are r0-r9, sl, fp, ip, sp, and lr. ARM RealView has similar
functions, named __ARM_call_via_r[0-7]. */
- if (strncmp (name, "_call_via_", 10) == 0
- || strncmp (name, "__ARM_call_via_", strlen ("__ARM_call_via_")) == 0)
+ if (startswith (name, "_call_via_")
+ || startswith (name, "__ARM_call_via_"))
{
/* Use the name suffix to determine which register contains the
target PC. */
namelen = strlen (name);
if (name[0] == '_' && name[1] == '_'
&& ((namelen > 2 + strlen ("_from_thumb")
- && strncmp (name + namelen - strlen ("_from_thumb"), "_from_thumb",
- strlen ("_from_thumb")) == 0)
+ && startswith (name + namelen - strlen ("_from_thumb"), "_from_thumb"))
|| (namelen > 2 + strlen ("_from_arm")
- && strncmp (name + namelen - strlen ("_from_arm"), "_from_arm",
- strlen ("_from_arm")) == 0)))
+ && startswith (name + namelen - strlen ("_from_arm"), "_from_arm"))))
{
char *target_name;
int target_len = namelen - 2;
return 0;
symname = MSYMBOL_LINKAGE_NAME (indsym.minsym);
- if (symname == NULL || strncmp (symname, "__imp_", 6) != 0)
+ if (symname == NULL || !startswith (symname, "__imp_"))
return 0;
next_pc = read_memory_unsigned_integer (indirect, 4, byte_order);
/* If no arg given, or if first arg is 'if ', use the default
breakpoint. */
if ((*address) == NULL
- || (strncmp ((*address), "if", 2) == 0 && isspace ((*address)[2])))
+ || (startswith ((*address), "if") && isspace ((*address)[2])))
{
/* The last displayed codepoint, if it's valid, is our default breakpoint
address. */
tok++;
toklen = end_tok - tok + 1;
- if (toklen == 6 && !strncmp (tok, "thread", 6))
+ if (toklen == 6 && startswith (tok, "thread"))
{
/* At this point we've found a "thread" token, which means
the user is trying to set a watchpoint that triggers
if (!valid_thread_id (thread))
invalid_thread_id_error (thread);
}
- else if (toklen == 4 && !strncmp (tok, "mask", 4))
+ else if (toklen == 4 && startswith (tok, "mask"))
{
/* We've found a "mask" token, which means the user wants to
create a hardware watchpoint that is going to have the mask
/* Decide if we are dealing with a static tracepoint marker (`-m'),
or with a normal static tracepoint. */
- if (arg && strncmp (arg, "-m", 2) == 0 && isspace (arg[2]))
+ if (arg && startswith (arg, "-m") && isspace (arg[2]))
ops = &strace_marker_breakpoint_ops;
else
ops = &tracepoint_breakpoint_ops;
for (names = bsd_uthread_solib_names; *names; names++)
{
- if (strncmp (so->so_original_name, *names, strlen (*names)) == 0)
+ if (startswith (so->so_original_name, *names))
{
solib_read_symbols (so, 0);
some other way, feel free to rewrite this function. */
const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
- if (strncmp (name, "operator", 8) != 0)
+ if (!startswith (name, "operator"))
return 0;
name += 8;
/* If this doesn't look like the start of an identifier, then it
isn't a type conversion operator. */
return 0;
- else if (strncmp (name, "new", 3) == 0)
+ else if (startswith (name, "new"))
name += 3;
- else if (strncmp (name, "delete", 6) == 0)
+ else if (startswith (name, "delete"))
name += 6;
else
/* If it doesn't look like new or delete, it's a type conversion
enum}" tag for unnamed struct/union/enum's, which we don't
want to print. */
if (TYPE_TAG_NAME (type) != NULL
- && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+ && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
{
/* When printing the tag name, we are still effectively
printing in the outer context, hence the use of FLAGS
tag for unnamed struct/union/enum's, which we don't
want to print. */
if (TYPE_TAG_NAME (type) != NULL
- && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+ && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
{
print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
if (show > 0)
char *binary_string = "binary";
/* Look for optional "binary" flag. */
- if (strncmp (args, binary_string, strlen (binary_string)) == 0)
+ if (startswith (args, binary_string))
{
binary_flag = 1;
args += strlen (binary_string);
{
while ((p = strchr (p, '$')))
{
- if (strncmp (p, "$arg", 4) == 0
+ if (startswith (p, "$arg")
&& (isdigit (p[4]) || p[4] == 'c'))
return p;
p++;
/* 'end' is always recognized, regardless of parse_commands value.
We also permit whitespace before end and after. */
- if (p_end - p_start == 3 && !strncmp (p_start, "end", 3))
+ if (p_end - p_start == 3 && startswith (p_start, "end"))
return end_command;
if (parse_commands)
return nop_command;
/* Is the else clause of an if control structure? */
- if (p_end - p == 4 && !strncmp (p, "else", 4))
+ if (p_end - p == 4 && startswith (p, "else"))
return else_command;
/* Check for while, if, break, continue, etc and build a new
command line structure for them. */
- if ((p_end - p >= 14 && !strncmp (p, "while-stepping", 14))
- || (p_end - p >= 8 && !strncmp (p, "stepping", 8))
- || (p_end - p >= 2 && !strncmp (p, "ws", 2)))
+ if ((p_end - p >= 14 && startswith (p, "while-stepping"))
+ || (p_end - p >= 8 && startswith (p, "stepping"))
+ || (p_end - p >= 2 && startswith (p, "ws")))
{
/* Because validate_actionline and encode_action lookup
command's line as command, we need the line to
not. */
*command = build_command_line (while_stepping_control, p);
}
- else if (p_end - p > 5 && !strncmp (p, "while", 5))
+ else if (p_end - p > 5 && startswith (p, "while"))
{
char *first_arg;
first_arg++;
*command = build_command_line (while_control, first_arg);
}
- else if (p_end - p > 2 && !strncmp (p, "if", 2))
+ else if (p_end - p > 2 && startswith (p, "if"))
{
char *first_arg;
first_arg++;
*command = build_command_line (if_control, first_arg);
}
- else if (p_end - p >= 8 && !strncmp (p, "commands", 8))
+ else if (p_end - p >= 8 && startswith (p, "commands"))
{
char *first_arg;
first_arg++;
*command = build_command_line (commands_control, first_arg);
}
- else if (p_end - p == 6 && !strncmp (p, "python", 6))
+ else if (p_end - p == 6 && startswith (p, "python"))
{
/* Note that we ignore the inline "python command" form
here. */
*command = build_command_line (python_control, "");
}
- else if (p_end - p == 6 && !strncmp (p, "compile", 7))
+ else if (p_end - p == 6 && startswith (p, "compile"))
{
/* Note that we ignore the inline "compile command" form
here. */
(*command)->control_u.compile.scope = COMPILE_I_INVALID_SCOPE;
}
- else if (p_end - p == 5 && !strncmp (p, "guile", 5))
+ else if (p_end - p == 5 && startswith (p, "guile"))
{
/* Note that we ignore the inline "guile command" form here. */
*command = build_command_line (guile_control, "");
}
- else if (p_end - p == 10 && !strncmp (p, "loop_break", 10))
+ else if (p_end - p == 10 && startswith (p, "loop_break"))
{
*command = (struct command_line *)
xmalloc (sizeof (struct command_line));
(*command)->body_count = 0;
(*command)->body_list = NULL;
}
- else if (p_end - p == 13 && !strncmp (p, "loop_continue", 13))
+ else if (p_end - p == 13 && startswith (p, "loop_continue"))
{
*command = (struct command_line *)
xmalloc (sizeof (struct command_line));
csi->textaddr = bfd_section_vma (abfd, sectp);
csi->textsize += bfd_section_size (abfd, sectp);
}
- else if (strncmp (name, ".text", sizeof ".text" - 1) == 0)
+ else if (startswith (name, ".text"))
{
csi->textsize += bfd_section_size (abfd, sectp);
}
{
csi->stabstrsect = sectp;
}
- else if (strncmp (name, ".stab", sizeof ".stab" - 1) == 0)
+ else if (startswith (name, ".stab"))
{
const char *s;
return 0;
/* The name must start with "__fu<digits>__". */
- if (strncmp (cs->c_name, "__fu", 4) != 0)
+ if (!startswith (cs->c_name, "__fu"))
return 0;
if (! isdigit (cs->c_name[4]))
return 0;
FIXME: We should use BFD to read the symbol table, and thus avoid
this problem. */
pe_file =
- strncmp (bfd_get_target (objfile->obfd), "pe", 2) == 0
- || strncmp (bfd_get_target (objfile->obfd), "epoc-pe", 7) == 0;
+ startswith (bfd_get_target (objfile->obfd), "pe")
+ || startswith (bfd_get_target (objfile->obfd), "epoc-pe");
/* End of warning. */
symbol in OBJFILE. Note that 'maintenance print msymbols'
shows that type of these "_imp_XXXX" symbols is mst_data. */
if (MSYMBOL_TYPE (msym) == mst_data
- && (strncmp (name, "__imp_", 6) == 0
- || strncmp (name, "_imp_", 5) == 0))
+ && (startswith (name, "__imp_")
+ || startswith (name, "_imp_")))
{
const char *name1 = (name[1] == '_' ? &name[7] : &name[6]);
struct bound_minimal_symbol found;
}
else if (!SDB_TYPE (cs->c_type)
&& cs->c_name[0] == 'L'
- && (strncmp (cs->c_name, "LI%", 3) == 0
- || strncmp (cs->c_name, "LF%", 3) == 0
- || strncmp (cs->c_name, "LC%", 3) == 0
- || strncmp (cs->c_name, "LP%", 3) == 0
- || strncmp (cs->c_name, "LPB%", 4) == 0
- || strncmp (cs->c_name, "LBB%", 4) == 0
- || strncmp (cs->c_name, "LBE%", 4) == 0
- || strncmp (cs->c_name, "LPBX%", 5) == 0))
+ && (startswith (cs->c_name, "LI%")
+ || startswith (cs->c_name, "LF%")
+ || startswith (cs->c_name, "LC%")
+ || startswith (cs->c_name, "LP%")
+ || startswith (cs->c_name, "LPB%")
+ || startswith (cs->c_name, "LBB%")
+ || startswith (cs->c_name, "LBE%")
+ || startswith (cs->c_name, "LPBX%")))
/* At least on a 3b1, gcc generates swbeg and string labels
that look like this. Ignore them. */
break;
extern char *safe_strerror (int);
+/* Return non-zero if the start of STRING matches PATTERN, zero
+ otherwise. */
+
+static inline int
+startswith (const char *string, const char *pattern)
+{
+ return strncmp (string, pattern, strlen (pattern)) == 0;
+}
+
#endif
char *zap;
int wstat;
- gdb_assert (strncmp (dir, TMP_PREFIX, strlen (TMP_PREFIX)) == 0);
+ gdb_assert (startswith (dir, TMP_PREFIX));
zap = concat ("rm -rf ", dir, (char *) NULL);
wstat = system (zap);
if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
const char *cs;
if (symtab == NULL || symtab->producer == NULL
- || strncmp (symtab->producer, "GNU ", strlen ("GNU ")) != 0)
+ || !startswith (symtab->producer, "GNU "))
return NULL;
cs = symtab->producer;
int fake_pid_p = 0;
struct inferior *inf;
- if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
+ if (!startswith (bfd_section_name (abfd, asect), ".reg/"))
return;
core_tid = atoi (bfd_section_name (abfd, asect) + 5);
len = strlen (current->import_dest);
directive_match = (search_parents
- ? (strncmp (scope, current->import_dest,
- strlen (current->import_dest)) == 0
+ ? (startswith (scope, current->import_dest)
&& (len == 0
|| scope[len] == ':'
|| scope[len] == '\0'))
differently from Solaris), and false for SunOS4 and other a.out
file formats. */
block_address_function_relative =
- ((0 == strncmp (bfd_get_target (sym_bfd), "elf", 3))
- || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3))
- || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4))
- || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2))
- || (0 == strncmp (bfd_get_target (sym_bfd), "epoc-pe", 7))
- || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3)));
+ ((startswith (bfd_get_target (sym_bfd), "elf"))
+ || (startswith (bfd_get_target (sym_bfd), "som"))
+ || (startswith (bfd_get_target (sym_bfd), "coff"))
+ || (startswith (bfd_get_target (sym_bfd), "pe"))
+ || (startswith (bfd_get_target (sym_bfd), "epoc-pe"))
+ || (startswith (bfd_get_target (sym_bfd), "nlm")));
val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);
if (val < 0)
processing_gcc_compilation = 2;
if (tempstring[0] == bfd_get_symbol_leading_char (symfile_bfd))
++tempstring;
- if (strncmp (tempstring, "__gnu_compiled", 14) == 0)
+ if (startswith (tempstring, "__gnu_compiled"))
processing_gcc_compilation = 2;
}
}
string = string0;
if (*string == '_')
{
- if (strncmp (string, "_ada_", 5) == 0)
+ if (startswith (string, "_ada_"))
string += 5;
else
return msymbol_hash_iw (string0);
this problem is fixed (no quirk needed). If the armcc
augmentation is missing, the quirk is needed. */
if (fde->cie->version == 3
- && (strncmp (fde->cie->augmentation, "armcc", 5) != 0
+ && (!startswith (fde->cie->augmentation, "armcc")
|| strchr (fde->cie->augmentation + 5, '+') == NULL))
fs->armcc_cfa_offsets_reversed = 1;
/* Ignore armcc augmentations. We only use them for quirks,
and that doesn't happen until later. */
- if (strncmp (augmentation, "armcc", 5) == 0)
+ if (startswith (augmentation, "armcc"))
augmentation += strlen (augmentation);
/* The GCC 2.x "eh" augmentation has a pointer immediately
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
{
/* 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;
}
}
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
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:
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,
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
for that section is ".plt". So, if there is a ".plt"
section, and yet the section name of our symbol does not
start with ".plt", we ignore that symbol. */
- if (strncmp (sect->name, ".plt", 4) != 0
+ if (!startswith (sect->name, ".plt")
&& bfd_get_section_by_name (abfd, ".plt") != NULL)
continue;
int p_type = 0;
/* FIXME: these constants may only be applicable for ELF. */
- if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
+ if (startswith (bfd_section_name (obfd, osec), "load"))
p_type = PT_LOAD;
- else if (strncmp (bfd_section_name (obfd, osec), "note", 4) == 0)
+ else if (startswith (bfd_section_name (obfd, osec), "note"))
p_type = PT_NOTE;
else
p_type = PT_NULL;
return;
/* Only interested in "load" sections. */
- if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
+ if (!startswith (bfd_section_name (obfd, osec), "load"))
return;
size = min (total_size, MAX_COPY_BYTES);
int
handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
{
- if (strncmp (own_buf, "vFile:open:", 11) == 0)
+ if (startswith (own_buf, "vFile:open:"))
handle_open (own_buf);
- else if (strncmp (own_buf, "vFile:pread:", 12) == 0)
+ else if (startswith (own_buf, "vFile:pread:"))
handle_pread (own_buf, new_packet_len);
- else if (strncmp (own_buf, "vFile:pwrite:", 13) == 0)
+ else if (startswith (own_buf, "vFile:pwrite:"))
handle_pwrite (own_buf, packet_len);
- else if (strncmp (own_buf, "vFile:close:", 12) == 0)
+ else if (startswith (own_buf, "vFile:close:"))
handle_close (own_buf);
- else if (strncmp (own_buf, "vFile:unlink:", 13) == 0)
+ else if (startswith (own_buf, "vFile:unlink:"))
handle_unlink (own_buf);
- else if (strncmp (own_buf, "vFile:readlink:", 15) == 0)
+ else if (startswith (own_buf, "vFile:readlink:"))
handle_readlink (own_buf, new_packet_len);
else
return 0;
break;
len = sep - annex;
- if (len == 5 && strncmp (annex, "start", 5) == 0)
+ if (len == 5 && startswith (annex, "start"))
addrp = &lm_addr;
- else if (len == 4 && strncmp (annex, "prev", 4) == 0)
+ else if (len == 4 && startswith (annex, "prev"))
addrp = &lm_prev;
else
{
with "i386" in qSupported query, it supports x86 XML target
descriptions. */
use_xml = 0;
- if (query != NULL && strncmp (query, "xmlRegisters=", 13) == 0)
+ if (query != NULL && startswith (query, "xmlRegisters="))
{
char *copy = xstrdup (query + 13);
char *p;
{
const char *ack_name = notifs[i]->ack_name;
- if (strncmp (own_buf, ack_name, strlen (ack_name)) == 0
+ if (startswith (own_buf, ack_name)
&& packet_len == strlen (ack_name))
break;
}
{
ULONGEST ret;
- if (strncmp (buf, "-1", 2) == 0)
+ if (startswith (buf, "-1"))
{
ret = (ULONGEST) -1;
buf += 2;
return -1;
}
- if (strncmp (own_buf, "qSymbol:", strlen ("qSymbol:")) != 0)
+ if (!startswith (own_buf, "qSymbol:"))
{
warning ("Malformed response to qSymbol, ignoring: %s\n", own_buf);
return -1;
return -1;
}
- if (strncmp (own_buf, "qRelocInsn:", strlen ("qRelocInsn:")) != 0)
+ if (!startswith (own_buf, "qRelocInsn:"))
{
warning ("Malformed response to qRelocInsn, ignoring: %s\n",
own_buf);
const char *err;
char *op;
- if (strncmp ("Qbtrace:", own_buf, strlen ("Qbtrace:")) != 0)
+ if (!startswith (own_buf, "Qbtrace:"))
return 0;
op = own_buf + strlen ("Qbtrace:");
struct thread_info *thread;
char *op;
- if (strncmp ("Qbtrace-conf:", own_buf, strlen ("Qbtrace-conf:")) != 0)
+ if (!startswith (own_buf, "Qbtrace-conf:"))
return 0;
op = own_buf + strlen ("Qbtrace-conf:");
return -1;
}
- if (strncmp (op, "bts:size=", strlen ("bts:size=")) == 0)
+ if (startswith (op, "bts:size="))
{
unsigned long size;
char *endp = NULL;
static void
handle_general_set (char *own_buf)
{
- if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0)
+ if (startswith (own_buf, "QPassSignals:"))
{
int numsigs = (int) GDB_SIGNAL_LAST, i;
const char *p = own_buf + strlen ("QPassSignals:");
return;
}
- if (strncmp ("QProgramSignals:", own_buf, strlen ("QProgramSignals:")) == 0)
+ if (startswith (own_buf, "QProgramSignals:"))
{
int numsigs = (int) GDB_SIGNAL_LAST, i;
const char *p = own_buf + strlen ("QProgramSignals:");
return;
}
- if (strncmp (own_buf, "QNonStop:", 9) == 0)
+ if (startswith (own_buf, "QNonStop:"))
{
char *mode = own_buf + 9;
int req = -1;
return;
}
- if (strncmp ("QDisableRandomization:", own_buf,
- strlen ("QDisableRandomization:")) == 0)
+ if (startswith (own_buf, "QDisableRandomization:"))
{
char *packet = own_buf + strlen ("QDisableRandomization:");
ULONGEST setting;
&& handle_tracepoint_general_set (own_buf))
return;
- if (strncmp ("QAgent:", own_buf, strlen ("QAgent:")) == 0)
+ if (startswith (own_buf, "QAgent:"))
{
char *mode = own_buf + strlen ("QAgent:");
int req = 0;
remote_debug = 0;
monitor_output ("Protocol debug output disabled.\n");
}
- else if (strncmp (mon, "set debug-format ",
- sizeof ("set debug-format ") - 1) == 0)
+ else if (startswith (mon, "set debug-format "))
{
char *error_msg
= parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
char *annex;
char *offset;
- if (strncmp (own_buf, "qXfer:", 6) != 0)
+ if (!startswith (own_buf, "qXfer:"))
return 0;
/* Grab the object, r/w and annex. */
}
/* Protocol features query. */
- if (strncmp ("qSupported", own_buf, 10) == 0
+ if (startswith (own_buf, "qSupported")
&& (own_buf[10] == ':' || own_buf[10] == '\0'))
{
char *p = &own_buf[10];
/* Thread-local storage support. */
if (the_target->get_tls_address != NULL
- && strncmp ("qGetTLSAddr:", own_buf, 12) == 0)
+ && startswith (own_buf, "qGetTLSAddr:"))
{
char *p = own_buf + 12;
CORE_ADDR parts[2], address = 0;
/* Windows OS Thread Information Block address support. */
if (the_target->get_tib_address != NULL
- && strncmp ("qGetTIBAddr:", own_buf, 12) == 0)
+ && startswith (own_buf, "qGetTIBAddr:"))
{
char *annex;
int n;
}
/* Handle "monitor" commands. */
- if (strncmp ("qRcmd,", own_buf, 6) == 0)
+ if (startswith (own_buf, "qRcmd,"))
{
char *mon = malloc (PBUFSIZ);
int len = strlen (own_buf + 6);
return;
}
- if (strncmp ("qSearch:memory:", own_buf,
- sizeof ("qSearch:memory:") - 1) == 0)
+ if (startswith (own_buf, "qSearch:memory:"))
{
require_running (own_buf);
handle_search_memory (own_buf, packet_len);
}
if (strcmp (own_buf, "qAttached") == 0
- || strncmp (own_buf, "qAttached:", sizeof ("qAttached:") - 1) == 0)
+ || startswith (own_buf, "qAttached:"))
{
struct process_info *process;
return;
}
- if (strncmp ("qCRC:", own_buf, 5) == 0)
+ if (startswith (own_buf, "qCRC:"))
{
/* CRC check (compare-section). */
char *comma;
{
if (!disable_packet_vCont)
{
- if (strncmp (own_buf, "vCont;", 6) == 0)
+ if (startswith (own_buf, "vCont;"))
{
require_running (own_buf);
handle_v_cont (own_buf);
return;
}
- if (strncmp (own_buf, "vCont?", 6) == 0)
+ if (startswith (own_buf, "vCont?"))
{
strcpy (own_buf, "vCont;c;C;s;S;t");
if (target_supports_range_stepping ())
}
}
- if (strncmp (own_buf, "vFile:", 6) == 0
+ if (startswith (own_buf, "vFile:")
&& handle_vFile (own_buf, packet_len, new_packet_len))
return;
- if (strncmp (own_buf, "vAttach;", 8) == 0)
+ if (startswith (own_buf, "vAttach;"))
{
if ((!extended_protocol || !multi_process) && target_running ())
{
return;
}
- if (strncmp (own_buf, "vRun;", 5) == 0)
+ if (startswith (own_buf, "vRun;"))
{
if ((!extended_protocol || !multi_process) && target_running ())
{
return;
}
- if (strncmp (own_buf, "vKill;", 6) == 0)
+ if (startswith (own_buf, "vKill;"))
{
if (!target_running ())
{
}
else if (strcmp (*next_arg, "--debug") == 0)
debug_threads = 1;
- else if (strncmp (*next_arg,
- "--debug-format=",
- sizeof ("--debug-format=") - 1) == 0)
+ else if (startswith (*next_arg, "--debug-format="))
{
char *error_msg
= parse_debug_format_options ((*next_arg)
gdbserver_show_disableable (stdout);
exit (0);
}
- else if (strncmp (*next_arg,
- "--disable-packet=",
- sizeof ("--disable-packet=") - 1) == 0)
+ else if (startswith (*next_arg, "--disable-packet="))
{
char *packets, *tok;
if (!add_breakpoint_condition (bp, &dataptr))
skip_to_semicolon (&dataptr);
}
- else if (strncmp (dataptr, "cmds:", strlen ("cmds:")) == 0)
+ else if (startswith (dataptr, "cmds:"))
{
dataptr += strlen ("cmds:");
if (debug_threads)
packet += strlen ("QTFrame:");
- if (strncmp (packet, "pc:", strlen ("pc:")) == 0)
+ if (startswith (packet, "pc:"))
{
packet += strlen ("pc:");
unpack_varlen_hex (packet, &pc);
trace_debug ("Want to find next traceframe at pc=0x%s", paddress (pc));
tframe = find_next_traceframe_in_range (pc, pc, 1, &tfnum);
}
- else if (strncmp (packet, "range:", strlen ("range:")) == 0)
+ else if (startswith (packet, "range:"))
{
packet += strlen ("range:");
packet = unpack_varlen_hex (packet, &lo);
paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 1, &tfnum);
}
- else if (strncmp (packet, "outside:", strlen ("outside:")) == 0)
+ else if (startswith (packet, "outside:"))
{
packet += strlen ("outside:");
packet = unpack_varlen_hex (packet, &lo);
paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 0, &tfnum);
}
- else if (strncmp (packet, "tdp:", strlen ("tdp:")) == 0)
+ else if (startswith (packet, "tdp:"))
{
packet += strlen ("tdp:");
unpack_varlen_hex (packet, &num);
/* The user visible error string in terror needs to be hex encoded.
We leave it as plain string in `tracing_stop_reason' to ease
debugging. */
- if (strncmp (stop_reason_rsp, "terror:", strlen ("terror:")) == 0)
+ if (startswith (stop_reason_rsp, "terror:"))
{
const char *result_name;
int hexstr_len;
while (*packet)
{
- if (strncmp ("user:", packet, strlen ("user:")) == 0)
+ if (startswith (packet, "user:"))
{
packet += strlen ("user:");
saved = packet;
xfree (tracing_user_name);
tracing_user_name = user;
}
- else if (strncmp ("notes:", packet, strlen ("notes:")) == 0)
+ else if (startswith (packet, "notes:"))
{
packet += strlen ("notes:");
saved = packet;
xfree (tracing_notes);
tracing_notes = notes;
}
- else if (strncmp ("tstop:", packet, strlen ("tstop:")) == 0)
+ else if (startswith (packet, "tstop:"))
{
packet += strlen ("tstop:");
saved = packet;
cmd_qtinit (packet);
return 1;
}
- else if (strncmp ("QTDP:", packet, strlen ("QTDP:")) == 0)
+ else if (startswith (packet, "QTDP:"))
{
cmd_qtdp (packet);
return 1;
}
- else if (strncmp ("QTDPsrc:", packet, strlen ("QTDPsrc:")) == 0)
+ else if (startswith (packet, "QTDPsrc:"))
{
cmd_qtdpsrc (packet);
return 1;
}
- else if (strncmp ("QTEnable:", packet, strlen ("QTEnable:")) == 0)
+ else if (startswith (packet, "QTEnable:"))
{
cmd_qtenable_disable (packet, 1);
return 1;
}
- else if (strncmp ("QTDisable:", packet, strlen ("QTDisable:")) == 0)
+ else if (startswith (packet, "QTDisable:"))
{
cmd_qtenable_disable (packet, 0);
return 1;
}
- else if (strncmp ("QTDV:", packet, strlen ("QTDV:")) == 0)
+ else if (startswith (packet, "QTDV:"))
{
cmd_qtdv (packet);
return 1;
}
- else if (strncmp ("QTro:", packet, strlen ("QTro:")) == 0)
+ else if (startswith (packet, "QTro:"))
{
cmd_qtro (packet);
return 1;
cmd_qtstop (packet);
return 1;
}
- else if (strncmp ("QTDisconnected:", packet,
- strlen ("QTDisconnected:")) == 0)
+ else if (startswith (packet, "QTDisconnected:"))
{
cmd_qtdisconnected (packet);
return 1;
}
- else if (strncmp ("QTFrame:", packet, strlen ("QTFrame:")) == 0)
+ else if (startswith (packet, "QTFrame:"))
{
cmd_qtframe (packet);
return 1;
}
- else if (strncmp ("QTBuffer:circular:", packet, strlen ("QTBuffer:circular:")) == 0)
+ else if (startswith (packet, "QTBuffer:circular:"))
{
cmd_bigqtbuffer_circular (packet);
return 1;
}
- else if (strncmp ("QTBuffer:size:", packet, strlen ("QTBuffer:size:")) == 0)
+ else if (startswith (packet, "QTBuffer:size:"))
{
cmd_bigqtbuffer_size (packet);
return 1;
}
- else if (strncmp ("QTNotes:", packet, strlen ("QTNotes:")) == 0)
+ else if (startswith (packet, "QTNotes:"))
{
cmd_qtnotes (packet);
return 1;
cmd_qtstatus (packet);
return 1;
}
- else if (strncmp ("qTP:", packet, strlen ("qTP:")) == 0)
+ else if (startswith (packet, "qTP:"))
{
cmd_qtp (packet);
return 1;
cmd_qtsv (packet);
return 1;
}
- else if (strncmp ("qTV:", packet, strlen ("qTV:")) == 0)
+ else if (startswith (packet, "qTV:"))
{
cmd_qtv (packet);
return 1;
}
- else if (strncmp ("qTBuffer:", packet, strlen ("qTBuffer:")) == 0)
+ else if (startswith (packet, "qTBuffer:"))
{
cmd_qtbuffer (packet);
return 1;
cmd_qtsstm (packet);
return 1;
}
- else if (strncmp ("qTSTMat:", packet, strlen ("qTSTMat:")) == 0)
+ else if (startswith (packet, "qTSTMat:"))
{
cmd_qtstmat (packet);
return 1;
if (ret)
return ret;
- if (strncmp (buf, "OK", 2) != 0)
+ if (!startswith (buf, "OK"))
return 1;
/* The value of tracepoint's target address is stored in BUF. */
if (cmd_buf[0])
{
- if (strncmp ("close", cmd_buf, 5) == 0)
+ if (startswith (cmd_buf, "close"))
{
stop_loop = 1;
}
{
cmd_qtsstm (cmd_buf);
}
- else if (strncmp ("unprobe_marker_at:",
- cmd_buf,
- sizeof ("unprobe_marker_at:") - 1) == 0)
+ else if (startswith (cmd_buf, "unprobe_marker_at:"))
{
unprobe_marker_at (cmd_buf);
}
- else if (strncmp ("probe_marker_at:",
- cmd_buf,
- sizeof ("probe_marker_at:") - 1) == 0)
+ else if (startswith (cmd_buf, "probe_marker_at:"))
{
probe_marker_at (cmd_buf);
}
- else if (strncmp ("qTSTMat:",
- cmd_buf,
- sizeof ("qTSTMat:") - 1) == 0)
+ else if (startswith (cmd_buf, "qTSTMat:"))
{
cmd_qtstmat (cmd_buf);
}
return;
}
- if (strncmp (s, "cYg", 3) != 0)
+ if (!startswith (s, "cYg"))
{
if (!server_waiting)
{
}
/* If we read one argument and it was ``void'', don't count it. */
- if (strncmp (argtypetext, "(void)", 6) == 0)
+ if (startswith (argtypetext, "(void)"))
argcount -= 1;
/* We need one extra slot, for the THIS pointer. */
Therefore the only thing we need to handle here are v2 operator
names. */
- if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z", 2) != 0)
+ if (found_stub && !startswith (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z"))
{
int ret;
char dem_opname[256];
gnuv2_is_destructor_name (const char *name)
{
if ((name[0] == '_' && is_cplus_marker (name[1]) && name[2] == '_')
- || strncmp (name, "__dt__", 6) == 0)
+ || startswith (name, "__dt__"))
return complete_object_dtor;
else
return 0;
{
if ((name[0] == '_' && name[1] == '_'
&& (isdigit (name[2]) || strchr ("Qt", name[2])))
- || strncmp (name, "__ct__", 6) == 0)
+ || startswith (name, "__ct__"))
return complete_object_ctor;
else
return 0;
static int
gnuv2_is_operator_name (const char *name)
{
- return strncmp (name, "operator", 8) == 0;
+ return startswith (name, "operator");
}
\f
static int
gnuv3_is_vtable_name (const char *name)
{
- return strncmp (name, "_ZTV", 4) == 0;
+ return startswith (name, "_ZTV");
}
static int
gnuv3_is_operator_name (const char *name)
{
- return strncmp (name, "operator", 8) == 0;
+ return startswith (name, "operator");
}
should work just as well, and doesn't read target memory. */
vtable_symbol_name = MSYMBOL_DEMANGLED_NAME (vtable_symbol);
if (vtable_symbol_name == NULL
- || strncmp (vtable_symbol_name, "vtable for ", 11))
+ || !startswith (vtable_symbol_name, "vtable for "))
{
warning (_("can't find linker symbol for virtual table for `%s' value"),
TYPE_SAFE_NAME (values_type));
libgo_.*: used by gccgo's runtime
Thus we don't support -fgo-prefix (except as used by the runtime). */
- if (strncmp (mangled_name, "go.", 3) != 0
- && strncmp (mangled_name, "libgo_", 6) != 0)
+ if (!startswith (mangled_name, "go.")
+ && !startswith (mangled_name, "libgo_"))
return NULL;
/* Quick check for whether a search may be fruitful. */
TRY_CATCH (except, RETURN_MASK_ALL)
{
- if (!strncmp (type_name, "struct ", 7))
+ if (startswith (type_name, "struct "))
type = lookup_struct (type_name + 7, NULL);
- else if (!strncmp (type_name, "union ", 6))
+ else if (startswith (type_name, "union "))
type = lookup_union (type_name + 6, NULL);
- else if (!strncmp (type_name, "enum ", 5))
+ else if (startswith (type_name, "enum "))
type = lookup_enum (type_name + 5, NULL);
else
type = lookup_typename (current_language, get_current_arch (),
gdb_byte *buf = NULL;
- if (strncmp (sect->name, ".module", 7) != 0)
+ if (!startswith (sect->name, ".module"))
return;
buf = xmalloc (bfd_get_section_size (sect) + 1);
if (post_prologue_pc
&& (cust != NULL
&& COMPUNIT_PRODUCER (cust) != NULL
- && strncmp (COMPUNIT_PRODUCER (cust), "clang ",
- sizeof ("clang ") - 1) == 0))
+ && startswith (COMPUNIT_PRODUCER (cust), "clang ")))
return max (start_pc, post_prologue_pc);
}
if (symname)
{
- if (strncmp (symname, "__imp_", 6) == 0
- || strncmp (symname, "_imp_", 5) == 0)
+ if (startswith (symname, "__imp_")
+ || startswith (symname, "_imp_"))
return name ? 1 :
read_memory_unsigned_integer (indirect, 4, byte_order);
}
sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
find_pc_partial_function (func, &name, NULL, NULL);
- if (name && strncmp (name, "Xintr", 5) == 0)
+ if (name && startswith (name, "Xintr"))
addr = sp + 8; /* It's an interrupt frame. */
else
addr = sp;
find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL);
return (name && (strcmp (name, "calltrap") == 0
|| strcmp (name, "syscall1") == 0
- || strncmp (name, "Xintr", 5) == 0
- || strncmp (name, "Xsoft", 5) == 0));
+ || startswith (name, "Xintr")
+ || startswith (name, "Xsoft")));
}
static const struct frame_unwind i386obsd_trapframe_unwind = {
if (args != NULL)
{
- if (strncmp (args, "-a", sizeof ("-a") - 1) == 0)
+ if (startswith (args, "-a"))
{
all_threads = 1;
args += sizeof ("-a") - 1;
dont_repeat (); /* Not for the faint of heart. */
if (args != NULL
- && strncmp (args, "-a", sizeof ("-a") - 1) == 0)
+ && startswith (args, "-a"))
all_threads = 1;
if (!non_stop && all_threads)
{
QUIT;
/* Don't print out virtual function table. */
- if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
+ if (startswith (TYPE_FIELD_NAME (type, i), "_vptr")
&& is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
continue;
/* Don't print the dummy field "class". */
- if (strncmp (TYPE_FIELD_NAME (type, i), "class", 5) == 0)
+ if (startswith (TYPE_FIELD_NAME (type, i), "class"))
continue;
print_spaces_filtered (level + 4, stream);
for (mapping = ada_opname_table;
mapping->encoded != NULL
- && strncmp (mapping->decoded, string,
- strlen (mapping->decoded)) != 0; ++mapping)
+ && !startswith (string, mapping->decoded); ++mapping)
;
return mapping->decoded == NULL ? 0 : strlen (mapping->decoded);
const char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter);
char dem_opname[64];
- if (strncmp (method_name, "__", 2) == 0 ||
- strncmp (method_name, "op", 2) == 0 ||
- strncmp (method_name, "type", 4) == 0)
+ if (startswith (method_name, "__") ||
+ startswith (method_name, "op") ||
+ startswith (method_name, "type"))
{
if (cplus_demangle_opname (method_name, dem_opname, DMGL_ANSI))
method_name = dem_opname;
if (s != NULL)
{
/* Found first char in HAYSTACK; check rest of string. */
- if (strncmp (s, needle, strlen (needle)) == 0)
+ if (startswith (s, needle))
return s;
/* Didn't find it; loop over HAYSTACK, looking for the next
Unfortunately some Red Hat kernels include the shared pending
queue but not the ShdPnd status field. */
- if (strncmp (buffer, "SigPnd:\t", 8) == 0)
+ if (startswith (buffer, "SigPnd:\t"))
add_line_to_sigset (buffer + 8, pending);
- else if (strncmp (buffer, "ShdPnd:\t", 8) == 0)
+ else if (startswith (buffer, "ShdPnd:\t"))
add_line_to_sigset (buffer + 8, pending);
- else if (strncmp (buffer, "SigBlk:\t", 8) == 0)
+ else if (startswith (buffer, "SigBlk:\t"))
add_line_to_sigset (buffer + 8, blocked);
- else if (strncmp (buffer, "SigIgn:\t", 8) == 0)
+ else if (startswith (buffer, "SigIgn:\t"))
add_line_to_sigset (buffer + 8, ignored);
}
/* Print the tag if it exists. */
if (TYPE_TAG_NAME (type) != NULL)
{
- if (strncmp (TYPE_TAG_NAME (type), "$$", 2) != 0)
+ if (!startswith (TYPE_TAG_NAME (type), "$$"))
{
fputs_filtered (TYPE_TAG_NAME (type), stream);
if (show > 0)
myIPaddress = skip_spaces (myIPaddress);
- if (!strncmp (myIPaddress, "0.0.", 4)) /* empty */
+ if (startswith (myIPaddress, "0.0.")) /* empty */
error (_("Please use 'set board-address' to "
"set the M32R-EVA board's IP address."));
if (strchr (myIPaddress, '('))
const char *bfd_sect_name = osect->the_bfd_section->name;
int sect_index = osect - objfile->sections;;
- if (strncmp (bfd_sect_name, "LC_SEGMENT.", 11) == 0)
+ if (startswith (bfd_sect_name, "LC_SEGMENT."))
bfd_sect_name += 11;
if (strcmp (bfd_sect_name, "__TEXT") == 0
|| strcmp (bfd_sect_name, "__TEXT.__text") == 0)
char *p = *expp;
unsigned int len;
- if (is_parameter && !strncmp (p, "...", 3))
+ if (is_parameter && startswith (p, "..."))
{
/* Ok. */
}
;
}
- if (is_parameter && !strncmp (p, "...", 3))
+ if (is_parameter && startswith (p, "..."))
p += 3;
len = p - *expp;
if (strchr (p, '-'))
{
/* Got a range. Either r0-r7, r8-r15 or ss0-ss4. */
- if (strncmp (p, "r0", 2) == 0 || strncmp (p, "r8", 2) == 0)
+ if (startswith (p, "r0") || startswith (p, "r8"))
{
int rn = (p[1] == '0' ? 0 : 8);
int i = 0;
i++;
}
}
- else if (strncmp (p, "ss", 2) == 0)
+ else if (startswith (p, "ss"))
{
/* Get the next five values, ignoring the first. */
int rn;
--name_len;
}
- if (ms_type == mst_file_text && strncmp (name, "__gnu_compiled", 14) == 0)
+ if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
return (NULL);
if (msym_bunch_index == BUNCH_SIZE)
/* The presence of a section with a ".sde" prefix is indicative
of an SDE binary. */
- if (strncmp (name, ".sde", 4) == 0)
+ if (startswith (name, ".sde"))
*os_ident_ptr = GDB_OSABI_SDE;
}
return 0;
/* If the PC is in __mips16_call_stub_*, this is a call/return stub. */
- if (strncmp (name, mips_str_mips16_call_stub,
- strlen (mips_str_mips16_call_stub)) == 0)
+ if (startswith (name, mips_str_mips16_call_stub))
return 1;
/* If the PC is in __call_stub_*, this is a call/return or a call stub. */
- if (strncmp (name, mips_str_call_stub, strlen (mips_str_call_stub)) == 0)
+ if (startswith (name, mips_str_call_stub))
return 1;
/* If the PC is in __fn_stub_*, this is a call stub. */
- if (strncmp (name, mips_str_fn_stub, strlen (mips_str_fn_stub)) == 0)
+ if (startswith (name, mips_str_fn_stub))
return 1;
return 0; /* Not a stub. */
msym = lookup_minimal_symbol_by_pc (pc);
if (msym.minsym != NULL
&& MSYMBOL_LINKAGE_NAME (msym.minsym) != NULL
- && strncmp (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.", 5) == 0)
+ && startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic."))
return 1;
return 0;
/* If the PC is in __call_stub_* or __fn_stub*, this is one of the
compiler-generated call or call/return stubs. */
- if (strncmp (name, mips_str_fn_stub, strlen (mips_str_fn_stub)) == 0
- || strncmp (name, mips_str_call_stub, strlen (mips_str_call_stub)) == 0)
+ if (startswith (name, mips_str_fn_stub)
+ || startswith (name, mips_str_call_stub))
{
if (pc == start_addr)
/* This is the 'call' part of a call stub. Call this helper
if (msym.minsym == NULL
|| BMSYMBOL_VALUE_ADDRESS (msym) != pc
|| MSYMBOL_LINKAGE_NAME (msym.minsym) == NULL
- || strncmp (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.", 5) != 0)
+ || !startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic."))
return 0;
/* A two-instruction header. */
if (*abip != MIPS_ABI_UNKNOWN)
return;
- if (strncmp (name, ".mdebug.", 8) != 0)
+ if (!startswith (name, ".mdebug."))
return;
if (strcmp (name, ".mdebug.abi32") == 0)
int *lbp = (int *) obj;
const char *name = bfd_get_section_name (abfd, sect);
- if (strncmp (name, ".gcc_compiled_long32", 20) == 0)
+ if (startswith (name, ".gcc_compiled_long32"))
*lbp = 32;
- else if (strncmp (name, ".gcc_compiled_long64", 20) == 0)
+ else if (startswith (name, ".gcc_compiled_long64"))
*lbp = 64;
- else if (strncmp (name, ".gcc_compiled_long", 18) == 0)
+ else if (startswith (name, ".gcc_compiled_long"))
warning (_("unrecognized .gcc_compiled_longXX"));
}
const char *name)
{
return (name != NULL
- && strncmp (msp430_epilog_name_prefix, name,
- strlen (msp430_epilog_name_prefix)) == 0);
+ && startswith (name, msp430_epilog_name_prefix));
}
/* Implement the "skip_trampoline_code" gdbarch method. */
have_state = 0;
while (fgets (buffer, buffer_size, procfile) != NULL)
- if (strncmp (buffer, "State:", 6) == 0)
+ if (startswith (buffer, "State:"))
{
have_state = 1;
break;
have function names which begin with "__sigtramp". */
return (func_name != NULL
- && strncmp (func_name, "__sigtramp", 10) == 0);
+ && startswith (func_name, "__sigtramp"));
}
pascal_type_print_method_args (const char *physname, const char *methodname,
struct ui_file *stream)
{
- int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
- int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
+ int is_constructor = (startswith (physname, "__ct__"));
+ int is_destructor = (startswith (physname, "__dt__"));
if (is_constructor || is_destructor)
{
{
QUIT;
/* Don't print out virtual function table. */
- if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0)
+ if ((startswith (TYPE_FIELD_NAME (type, i), "_vptr"))
&& is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
continue;
{
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
- int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
- int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
+ int is_constructor = (startswith (physname, "__ct__"));
+ int is_destructor = (startswith (physname, "__dt__"));
QUIT;
if (TYPE_FN_FIELD_PROTECTED (f, j))
static int
ppc_linux_spu_section (bfd *abfd, asection *asect, void *user_data)
{
- return strncmp (bfd_section_name (abfd, asect), "SPU/", 4) == 0;
+ return startswith (bfd_section_name (abfd, asect), "SPU/");
}
static const struct target_desc *
TRY_CATCH (except, RETURN_MASK_ALL)
{
- if (!strncmp (type_name, "struct ", 7))
+ if (startswith (type_name, "struct "))
type = lookup_struct (type_name + 7, NULL);
- else if (!strncmp (type_name, "union ", 6))
+ else if (startswith (type_name, "union "))
type = lookup_union (type_name + 6, NULL);
- else if (!strncmp (type_name, "enum ", 5))
+ else if (startswith (type_name, "enum "))
type = lookup_enum (type_name + 5, NULL);
else
type = lookup_typename (python_language, python_gdbarch,
t = n;
}
/* Chop a leading builtin_type. */
- if (strncmp (t, blt, strlen (blt)) == 0)
+ if (startswith (t, blt))
t += strlen (blt);
}
fprintf_unfiltered (file, " %-15s", t);
if (*arg != '-')
filename = arg;
- else if (strncmp (arg, "-quiet", strlen (arg)) == 0)
+ else if (startswith ("-quiet", arg))
quiet = 1;
- else if (strncmp (arg, "-nostart", strlen (arg)) == 0)
+ else if (startswith ("-nostart", arg))
nostart = 1;
else
error (_("Unknown option `%s'"), arg);
{
const char *name = notifs[i]->name;
- if (strncmp (buf, name, strlen (name)) == 0
+ if (startswith (buf, name)
&& buf[strlen (name)] == ':')
break;
}
buf = *buf_p;
if (buf[0] == 'E')
trace_error (buf);
- else if (strncmp (buf, "qRelocInsn:", strlen ("qRelocInsn:")) == 0)
+ else if (startswith (buf, "qRelocInsn:"))
{
ULONGEST ul;
CORE_ADDR from, to, org_to;
ptr = buf;
lose = 0;
- if (strncmp (ptr, "Text=", 5) == 0)
+ if (startswith (ptr, "Text="))
{
ptr += 5;
/* Don't use strtol, could lose on big values. */
while (*ptr && *ptr != ';')
text_addr = (text_addr << 4) + fromhex (*ptr++);
- if (strncmp (ptr, ";Data=", 6) == 0)
+ if (startswith (ptr, ";Data="))
{
ptr += 6;
while (*ptr && *ptr != ';')
else
lose = 1;
- if (!lose && strncmp (ptr, ";Bss=", 5) == 0)
+ if (!lose && startswith (ptr, ";Bss="))
{
ptr += 5;
while (*ptr && *ptr != ';')
else
lose = 1;
}
- else if (strncmp (ptr, "TextSeg=", 8) == 0)
+ else if (startswith (ptr, "TextSeg="))
{
ptr += 8;
/* Don't use strtol, could lose on big values. */
text_addr = (text_addr << 4) + fromhex (*ptr++);
num_segments = 1;
- if (strncmp (ptr, ";DataSeg=", 9) == 0)
+ if (startswith (ptr, ";DataSeg="))
{
ptr += 9;
while (*ptr && *ptr != ';')
packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSymbol]);
reply = rs->buf;
- while (strncmp (reply, "qSymbol:", 8) == 0)
+ while (startswith (reply, "qSymbol:"))
{
struct bound_minimal_symbol sym;
of in ser-tcp.c, because it is the remote protocol assuming that the
serial connection is reliable and not the serial connection promising
to be. */
- if (!udp_warning && strncmp (name, "udp:", 4) == 0)
+ if (!udp_warning && startswith (name, "udp:"))
{
warning (_("The remote protocol may be unreliable over UDP.\n"
"Some events may be lost, rendering further debugging "
buf = rs->buf;
/* Make sure that the features we assume are supported. */
- if (strncmp (buf, "vCont", 5) == 0)
+ if (startswith (buf, "vCont"))
{
char *p = &buf[5];
int support_s, support_S, support_c, support_C;
if (*p == '\0')
;
- else if (strncmp (p,
- "process:", sizeof ("process:") - 1) == 0)
+ else if (startswith (p, "process:"))
{
ULONGEST upid;
int
remote_filename_p (const char *filename)
{
- return strncmp (filename,
- REMOTE_SYSROOT_PREFIX,
- sizeof (REMOTE_SYSROOT_PREFIX) - 1) == 0;
+ return startswith (filename, REMOTE_SYSROOT_PREFIX);
}
bfd *
if (args == NULL || args[0] == '\0')
error (_("Command requires an argument."));
- if (strncmp (args, "start", strlen ("start")) == 0
- || strncmp (args, "begin", strlen ("begin")) == 0
- || strncmp (args, "end", strlen ("end")) == 0)
+ if (startswith (args, "start")
+ || startswith (args, "begin")
+ || startswith (args, "end"))
{
/* Special case. Give target opportunity to handle. */
target_goto_bookmark ((gdb_byte *) args, from_tty);
rs6000_in_solib_return_trampoline (struct gdbarch *gdbarch,
CORE_ADDR pc, const char *name)
{
- return name && !strncmp (name, "@FIX", 4);
+ return name && startswith (name, "@FIX");
}
/* Skip code that the user doesn't want to see when stepping:
unsigned int polls = 0;
use_udp = 0;
- if (strncmp (name, "udp:", 4) == 0)
+ if (startswith (name, "udp:"))
{
use_udp = 1;
name = name + 4;
}
- else if (strncmp (name, "tcp:", 4) == 0)
+ else if (startswith (name, "tcp:"))
name = name + 4;
port_str = strchr (name, ':');
if (strcmp (name, "pc") == 0)
ops = serial_interface_lookup ("pc");
- else if (strncmp (name, "lpt", 3) == 0)
+ else if (startswith (name, "lpt"))
ops = serial_interface_lookup ("parallel");
- else if (strncmp (name, "|", 1) == 0)
+ else if (startswith (name, "|"))
{
ops = serial_interface_lookup ("pipe");
/* Discard ``|'' and any space before the command itself. */
if ((symname[0] == 'L' && symname[1] == '$')
|| (symname[0] == '$' && symname[strlen (symname) - 1] == '$')
|| (symname[0] == 'D' && symname[1] == '$')
- || (strncmp (symname, "L0\001", 3) == 0)
- || (strncmp (symname, "$PIC", 4) == 0))
+ || (startswith (symname, "L0\001"))
+ || (startswith (symname, "$PIC")))
continue;
break;
find_pc_partial_function (pc, &name, NULL, NULL);
if (sparc64nbsd_pc_in_sigtramp (pc, name))
{
- if (name == NULL || strncmp (name, "__sigtramp_sigcontext", 21))
+ if (name == NULL || !startswith (name, "__sigtramp_sigcontext"))
return 1;
}
find_pc_partial_function (pc, &name, NULL, NULL);
if (sparc32nbsd_pc_in_sigtramp (pc, name))
{
- if (name == NULL || strncmp (name, "__sigtramp_sigcontext", 21))
+ if (name == NULL || !startswith (name, "__sigtramp_sigcontext"))
return 1;
}
|| (newname && strcmp (field_name, newname) == 0);
if (!is_destructor)
- is_destructor = (strncmp (physname, "__dt", 4) == 0);
+ is_destructor = (startswith (physname, "__dt"));
if (is_destructor || is_full_physname_constructor)
{
operator_chars (const char *p, const char **end)
{
*end = "";
- if (strncmp (p, "operator", 8))
+ if (!startswith (p, "operator"))
return *end;
p += 8;
return 0;
for (i = 0; i < ARRAY_SIZE (arm_idents); i++)
- if (strncmp (producer, arm_idents[i], strlen (arm_idents[i])) == 0)
+ if (startswith (producer, arm_idents[i]))
return 1;
return 0;
bytes += TRACE_HEADER_SIZE;
if (!(header[0] == 0x7f
- && (strncmp (header + 1, "TRACE0\n", 7) == 0)))
+ && (startswith (header + 1, "TRACE0\n"))))
error (_("File is not a valid trace file."));
push_target (&tfile_ops);
{
char *p = line;
- if (strncmp (p, "R ", strlen ("R ")) == 0)
+ if (startswith (p, "R "))
{
p += strlen ("R ");
trace_regblock_size = strtol (p, &p, 16);
}
- else if (strncmp (p, "status ", strlen ("status ")) == 0)
+ else if (startswith (p, "status "))
{
p += strlen ("status ");
parse_trace_status (p, current_trace_status ());
}
- else if (strncmp (p, "tp ", strlen ("tp ")) == 0)
+ else if (startswith (p, "tp "))
{
p += strlen ("tp ");
parse_tracepoint_definition (p, utpp);
}
- else if (strncmp (p, "tsv ", strlen ("tsv ")) == 0)
+ else if (startswith (p, "tsv "))
{
p += strlen ("tsv ");
parse_tsv_definition (p, utsvp);
end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2);
buf[end] = '\0';
- if (strncmp (srctype, "at:", strlen ("at:")) == 0)
+ if (startswith (srctype, "at:"))
utp->at_string = xstrdup (buf);
- else if (strncmp (srctype, "cond:", strlen ("cond:")) == 0)
+ else if (startswith (srctype, "cond:"))
utp->cond_string = xstrdup (buf);
- else if (strncmp (srctype, "cmd:", strlen ("cmd:")) == 0)
+ else if (startswith (srctype, "cmd:"))
VEC_safe_push (char_ptr, utp->cmd_strings, xstrdup (buf));
}
else if (piece == 'V')
char *cur_name = tui_win_name (&tui_win_list[i]->generic);
if (strlen (name) <= strlen (cur_name)
- && strncmp (name, cur_name, strlen (name)) == 0)
+ && startswith (cur_name, name))
win_info = tui_win_list[i];
}
i++;
if (template_string != (char *) NULL && string_to_compare != (char *) NULL
&& strlen (string_to_compare) <= strlen (template_string))
match =
- (strncmp
- (template_string, string_to_compare, strlen (string_to_compare)) == 0);
+ (startswith (template_string, string_to_compare));
else
match = 0;
return match;
{
const char *cs;
- if (producer != NULL && strncmp (producer, "GNU ", strlen ("GNU ")) == 0)
+ if (producer != NULL && startswith (producer, "GNU "))
{
int maj, min;
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
/* FIXME! May need to check for ARM demangling here. */
- if (strncmp (t_field_name, "__", 2) == 0 ||
- strncmp (t_field_name, "op", 2) == 0 ||
- strncmp (t_field_name, "type", 4) == 0)
+ if (startswith (t_field_name, "__") ||
+ startswith (t_field_name, "op") ||
+ startswith (t_field_name, "type"))
{
if (cplus_demangle_opname (t_field_name, dem_opname, DMGL_ANSI))
t_field_name = dem_opname;
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
char dem_opname[64];
- if (strncmp (t_field_name, "__", 2) == 0
- || strncmp (t_field_name, "op", 2) == 0
- || strncmp (t_field_name, "type", 4) == 0)
+ if (startswith (t_field_name, "__")
+ || startswith (t_field_name, "op")
+ || startswith (t_field_name, "type"))
{
if (cplus_demangle_opname (t_field_name,
dem_opname, DMGL_ANSI))
&s, 1024, 0)
|| !s || !*s)
/* nothing to do */;
- else if (strncmp (s, _CYGWIN_SIGNAL_STRING,
- sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0)
+ else if (!startswith (s, _CYGWIN_SIGNAL_STRING))
{
#ifdef __CYGWIN__
- if (strncmp (s, "cYg", 3) != 0)
+ if (!startswith (s, "cYg"))
#endif
warning (("%s"), s);
}
if ((!cygwin_exceptions && (addr >= cygwin_load_start
&& addr < cygwin_load_end))
|| (find_pc_partial_function (addr, &fn, NULL, NULL)
- && strncmp (fn, "KERNEL32!IsBad",
- strlen ("KERNEL32!IsBad")) == 0))
+ && startswith (fn, "KERNEL32!IsBad")))
return 0;
}
#endif
loader-generated definitions. Keeping the global
symbols leads to "in psymbols but not in symbols"
errors. */
- if (strncmp (namestring, "@FIX", 4) == 0)
+ if (startswith (namestring, "@FIX"))
continue;
symbol.n_value += ANOFFSET (objfile->section_offsets,